:root {
  color-scheme: dark;
  --bg: #0c1018;
  --bg-soft: #141b28;
  --panel: rgba(12, 16, 24, 0.72);
  --text: #e8edf5;
  --muted: #93a0b5;
  --line: rgba(200, 214, 232, 0.16);
  --accent: #8bb7d6;
  --btn: #e8edf5;
  --btn-text: #10151e;
  --focus: #d5e8f8;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Noto Sans SC",
    "Source Han Sans SC", "Segoe UI", sans-serif;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  min-height: 100dvh;
  overflow: hidden;
}

.app {
  width: min(560px, 100%);
  margin: 0 auto;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  padding: max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  font-weight: 650;
}

.scores {
  display: flex;
  gap: 16px;
  margin: 0;
}

.scores div {
  display: grid;
  gap: 2px;
  text-align: right;
}

.scores dt {
  font-size: 0.72rem;
  color: var(--muted);
}

.scores dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 650;
}

.stage {
  position: relative;
  width: min(100%, 72vh, 520px, calc(100dvh - 14rem));
  margin: 0 auto;
  aspect-ratio: 1;
  flex: 0 0 auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  background: #0a0e16;
  box-shadow: inset 0 0 0 1px var(--line);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  border-radius: var(--radius);
  background: rgba(8, 12, 20, 0.52);
}

.overlay.is-playing {
  display: none;
}

.panel {
  width: min(100%, 360px);
  padding: 20px 20px 18px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 1.35rem;
  font-weight: 650;
}

.lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}

.status {
  margin: 0;
  min-height: 2.6em;
  color: var(--text);
  line-height: 1.45;
  font-size: 0.92rem;
}

.controls {
  display: grid;
  gap: 8px;
  justify-items: center;
  margin-top: auto;
}

button {
  appearance: none;
  min-height: 48px;
  min-width: min(100%, 280px);
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--btn);
  color: var(--btn-text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover {
  filter: brightness(1.04);
}

button:active {
  transform: translateY(1px);
}

button:focus {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

button:focus:not(:focus-visible) {
  outline: none;
}

button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hint,
.noscript {
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.45;
  max-width: 40em;
}

.noscript {
  padding: 12px;
}

@media (max-width: 420px) {
  h1 {
    letter-spacing: 0.12em;
  }

  .panel {
    padding: 16px;
  }
}

@media (max-height: 520px) {
  .app {
    gap: 8px;
  }

  .hint {
    display: none;
  }

  .status {
    min-height: 0;
    font-size: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  button:active {
    transform: none;
  }

  .overlay {
    background: rgba(8, 12, 20, 0.72);
  }
}
