:root {
  color-scheme: dark;
  --ink: #070a10;
  --panel: #10151f;
  --line: #1e2632;
  --text: #d5dde8;
  --muted: #8a95a6;
  --accent: #5ce1c6;
  --metric: #f2c078;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
/* No overflow:hidden — on a short viewport the page must still scroll, or the
   paddle sits below the fold with no way to reach it. */
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  display: grid;
  place-items: center;
  min-height: 100dvh;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.shell { width: min(980px, 100%); padding: 16px; display: grid; gap: 10px; }
.hud { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.hud-item strong { color: var(--text); font-size: 15px; }
.hud button {
  font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 12px; cursor: pointer;
}
/* The first button pushes itself and everything after it to the right edge. */
.hud #mute { margin-left: auto; }
.hud button:hover { border-color: var(--accent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stage { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--ink); }
canvas { display: block; width: 100%; aspect-ratio: 16 / 9; touch-action: none; outline: none; -webkit-tap-highlight-color: transparent; }
/* Keep the whole stage inside the viewport. Scoped away from shot mode, where
   the canvas must fill the captured frame: a global cap would still win over
   the pinned inline height there, and the shot gate would fail on the band. */
body:not(.shot) canvas { max-height: max(120px, calc(100dvh - 150px)); }
canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.overlay, .fallback {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px;
  text-align: center; padding: 24px;
  /* Dark enough to read the text, clear enough at the edges that the 3D scene
     still reads as an invitation to play. */
  background: radial-gradient(ellipse 70% 55% at 50% 50%,
    color-mix(in srgb, var(--ink) 88%, transparent) 0%,
    color-mix(in srgb, var(--ink) 84%, transparent) 38%,
    color-mix(in srgb, var(--ink) 26%, transparent) 100%);
}
/* The paddle tracks the pointer before the serve, so the overlay must not eat
   pointer events — only its button does. */
.overlay { pointer-events: none; }
.overlay button { pointer-events: auto; }
.overlay[hidden], .fallback[hidden] { display: none; }
.overlay h2, .fallback h2 { font-size: clamp(22px, 4vw, 34px); letter-spacing: -0.02em; }
.overlay p, .fallback p { color: var(--muted); max-width: 44ch; }
.overlay button {
  font: inherit; font-weight: 600; color: #061018; background: var(--accent);
  border: 0; border-radius: 8px; padding: 10px 18px; cursor: pointer;
}
.overlay button:hover { filter: brightness(1.08); }
.hint { font-family: var(--mono); font-size: 11.5px; color: var(--muted); text-align: center; }
.status { font-size: 13px; color: var(--metric); text-align: center; min-height: 1.2em; }
/* Floating score numbers: DOM text over the canvas, positioned from the same
   projection the scene is drawn with. */
.pop {
  position: absolute; transform: translate(-50%, -50%); pointer-events: none;
  font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--text);
  text-shadow: 0 1px 6px var(--ink); white-space: nowrap;
  animation: pop-rise 0.9s ease-out forwards;
}
.pop-combo { color: var(--metric); font-size: 19px; }
.pop-good { color: var(--accent); }
@keyframes pop-rise {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  18% { opacity: 1; transform: translate(-50%, -75%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  /* The number still reports the score; it just stops flying. */
  .pop { animation: pop-fade 0.9s linear forwards; }
  @keyframes pop-fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
}
@media (max-width: 480px) {
  .hud { gap: 9px; font-size: 11px; }
  .hud-item strong { font-size: 13px; }
  .hud button { padding: 6px 10px; }
  .hint { font-size: 10px; }
}
@media (pointer: coarse) {
  button { min-height: 44px; min-width: 44px; }
}
body.shot .hud, body.shot .hint, body.shot .status, body.shot .overlay, body.shot .sr-only { display: none; }
body.shot { display: block; overflow: hidden; }
body.shot .shell { width: 100%; padding: 0; gap: 0; }
body.shot .stage { border: 0; border-radius: 0; }
body.shot canvas { height: 100dvh; aspect-ratio: auto; max-height: none; }
@media print {
  body { display: block; }
  canvas, .hud button { display: none; }
}
