/* =====================================================================
   Times Tables Rockers — styles
   1. Tokens & themes        6. Lobby & tiles        11. Stats & heatmap
   2. Base                   7. Countdown            12. Shop
   3. Utilities              8. Play                 13. Settings
   4. Buttons & controls     9. Keypad & clock       14. Dialog & toast
   5. Profiles               10. Results             15. Motion
   ===================================================================== */

/* ---------- 1. Tokens & themes ---------- */
:root {
  --bg1: #2a0a4a;
  --bg2: #120620;
  --surface: rgba(255, 255, 255, 0.07);
  --surface-2: rgba(255, 255, 255, 0.13);
  --border: rgba(255, 255, 255, 0.16);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.7);
  --faint: rgba(255, 255, 255, 0.38);
  --pink: #ff007d;
  --lemon: #fef84c;
  --cyan: #2ee6ff;
  --on-pink: #ffffff;
  --on-lemon: #2a0a4a;
  --right: #22d36b;
  --wrong: #ff3b5c;
  --glow: 0 0 24px rgba(255, 0, 125, 0.45);
  --key-bg: rgba(255, 255, 255, 0.1);
  --key-bg-press: rgba(255, 255, 255, 0.28);
  --key-text: #ffffff;
  --answer-bg: rgba(0, 0, 0, 0.35);

  --heat-grey: rgba(255, 255, 255, 0.14);
  --heat-green4: #00a650;
  --heat-green3: #22c55e;
  --heat-green2: #6fdc5a;
  --heat-green1: #b6ec7e;
  --heat-yellow: #fef84c;
  --heat-amber: #ffc233;
  --heat-orange: #ff8a1f;
  --heat-red: #ff3b3b;
  --heat-red2: #b0001f;

  --font-display: 'Bungee', 'Baloo 2', system-ui, sans-serif;
  --font-body: 'Baloo 2', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 18px;
  --radius-sm: 12px;
  --gutter: 16px;
  --key-h: 62px;
  --q-size: clamp(2.6rem, 13vw, 4.6rem);
  --ans-size: clamp(2.2rem, 11vw, 3.6rem);
  color-scheme: dark;
}

[data-theme='neon'] {
  --bg1: #0a0220; --bg2: #000000;
  --pink: #ff2bd6; --lemon: #c6ff00; --cyan: #00f0ff; --on-lemon: #000;
  --glow: 0 0 28px rgba(0, 240, 255, 0.55);
  --surface: rgba(0, 240, 255, 0.06); --surface-2: rgba(0, 240, 255, 0.12); --border: rgba(0, 240, 255, 0.3);
}
[data-theme='sunset'] {
  --bg1: #ff5e3a; --bg2: #4a0f5e;
  --pink: #ff2e63; --lemon: #ffe66d; --cyan: #7af5ff;
  --surface: rgba(30, 0, 40, 0.25); --surface-2: rgba(30, 0, 40, 0.38); --border: rgba(255, 255, 255, 0.25);
  --answer-bg: rgba(30, 0, 40, 0.4);
}
[data-theme='mono'] {
  --bg1: #1b1b1b; --bg2: #000000;
  --pink: #ffffff; --on-pink: #000000; --lemon: #ffffff; --on-lemon: #000; --cyan: #d0d0d0;
  --right: #ffffff; --wrong: #8a8a8a; --glow: none;
  --heat-green4: #ffffff; --heat-green3: #e6e6e6; --heat-green2: #cccccc; --heat-green1: #b3b3b3; --heat-yellow: #999999;
  --heat-amber: #808080; --heat-orange: #666666; --heat-red: #4d4d4d; --heat-red2: #333333; --heat-grey: rgba(255,255,255,.08);
}
/* Colour-safe: no red/green anywhere. Right = blue, wrong = orange. */
[data-theme='colorblind'] {
  --bg1: #141432; --bg2: #05050f;
  --pink: #ff9f1c; --on-pink: #141432; --lemon: #ffd166; --cyan: #4cc9f0;
  --right: #3a86ff; --wrong: #ff8800; --glow: 0 0 22px rgba(58, 134, 255, 0.45);
  --heat-green4: #08306b; --heat-green3: #2171b5; --heat-green2: #4292c6; --heat-green1: #9ecae1; --heat-yellow: #fff3b0;
  --heat-amber: #fdd0a2; --heat-orange: #fd8d3c; --heat-red: #d94801; --heat-red2: #7f2704;
}

[data-font='readable'] {
  --font-body: 'Atkinson Hyperlegible', 'Baloo 2', system-ui, sans-serif;
  --font-display: 'Atkinson Hyperlegible', system-ui, sans-serif;
}
[data-font='huge'] { font-size: 125%; --key-h: 72px; --q-size: clamp(3.2rem, 16vw, 6rem); --ans-size: clamp(2.8rem, 14vw, 4.6rem); }

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.4;
  color: var(--text);
  background: radial-gradient(120% 80% at 50% 0%, var(--bg1) 0%, var(--bg2) 70%) fixed, var(--bg2);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body::before { /* stage lights */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(40% 30% at 10% 0%, color-mix(in srgb, var(--pink) 22%, transparent), transparent 70%),
    radial-gradient(40% 30% at 90% 0%, color-mix(in srgb, var(--cyan) 18%, transparent), transparent 70%);
}
#app { position: relative; z-index: 1; outline: none; }
h1, h2, h3 { margin: 0; line-height: 1.1; }
p { margin: 0; }
a { color: var(--cyan); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

.screen {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: calc(var(--gutter) + env(safe-area-inset-top, 0px)) var(--gutter) calc(32px + env(safe-area-inset-bottom, 0px));
}
.boot { display: grid; place-items: center; min-height: 60vh; font-family: var(--font-display); color: var(--muted); letter-spacing: .05em; }
.screen-title, .section-title, .card-title, .logo, .tile-name, .rock-name, .play-mode, .cd-mode {
  font-family: var(--font-display); font-weight: 400; letter-spacing: 0.02em;
}
.screen-title { font-size: clamp(1.5rem, 6vw, 2.2rem); }
.section-title { font-size: 1.15rem; color: var(--lemon); margin: 28px 0 12px; text-transform: uppercase; letter-spacing: .06em; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(6px);
}
.card-title { font-size: 1.1rem; margin-bottom: 8px; color: var(--lemon); }
.screen-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.screen-head .screen-title { flex: 1; min-width: 0; }

/* ---------- 3. Utilities ---------- */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 50; background: var(--lemon); color: var(--on-lemon); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { top: 8px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.noscript { padding: 40px; text-align: center; }

/* ---------- 4. Buttons & controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px;
  border: 2px solid transparent; border-radius: 999px;
  font-weight: 700; font-size: 1.05rem; line-height: 1.1; text-decoration: none;
  background: var(--surface-2); color: var(--text);
  transition: transform .12s ease, background .15s, box-shadow .15s;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--pink); color: var(--on-pink); box-shadow: var(--glow); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--wrong) 70%, transparent); color: var(--text); }
.btn-danger:hover { background: color-mix(in srgb, var(--wrong) 25%, transparent); }
.btn-wide { width: 100%; }
.btn-big { min-height: 60px; font-size: 1.25rem; }
.btn-small { min-height: 40px; padding: 6px 14px; font-size: .95rem; }
.btn-icon { min-width: 52px; padding: 0; font-size: 1.5rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.btn-back {
  width: 48px; height: 48px; flex: none; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 1.4rem; line-height: 1;
}
.link-btn { background: none; border: 0; color: var(--cyan); text-decoration: underline; padding: 10px 6px; min-height: 44px; font-weight: 600; }
.file-btn { position: relative; cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--cyan); outline-offset: 3px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 999px; font-weight: 700; font-size: .95rem; white-space: nowrap; }
.pill-coins { background: color-mix(in srgb, var(--lemon) 20%, transparent); color: var(--lemon); border: 1px solid color-mix(in srgb, var(--lemon) 45%, transparent); }
.pill-status { background: color-mix(in srgb, var(--pink) 25%, transparent); border: 1px solid color-mix(in srgb, var(--pink) 60%, transparent); }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(0,0,0,.28); border: 1px solid var(--border); max-width: 100%; }
.seg-btn {
  min-height: 40px; padding: 4px 14px; border-radius: 999px; border: 0; background: transparent;
  font-weight: 700; color: var(--muted); touch-action: manipulation;
}
.seg-btn[aria-checked='true'] { background: var(--lemon); color: var(--on-lemon); }
.seg-wrap { border-radius: var(--radius-sm); }
.seg-wrap .seg-btn { border-radius: 9px; }

.chips { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.chip {
  min-height: 44px; border-radius: 12px; border: 1px solid var(--border); background: rgba(0,0,0,.22);
  font-weight: 800; font-size: 1.05rem; color: var(--muted); touch-action: manipulation;
}
.chip[aria-pressed='true'] { background: var(--cyan); color: #04202a; border-color: transparent; }

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; min-height: 44px; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { position: relative; flex: none; width: 50px; height: 30px; border-radius: 999px; background: rgba(0,0,0,.4); border: 1px solid var(--border); transition: background .15s; }
.switch-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .switch-ui { background: var(--pink); }
.switch input:checked + .switch-ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-ui { outline: 3px solid var(--cyan); outline-offset: 2px; }
.switch-row { display: flex; width: 100%; padding: 8px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: 0; }
.switch-text { display: flex; flex-direction: column; }
.switch-text small { color: var(--muted); font-weight: 500; font-size: .85rem; line-height: 1.25; }

.field { display: block; margin-top: 14px; }
.field-label { display: block; font-weight: 700; margin: 12px 0 6px; color: var(--muted); font-size: .95rem; }
.field-hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.input {
  width: 100%; min-height: 52px; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: rgba(0,0,0,.3); font-size: 1.15rem; font-weight: 600;
}
.input:focus { border-color: var(--cyan); outline: none; }
.input-row { display: flex; gap: 8px; }
.form-error { color: var(--lemon); font-weight: 700; margin-top: 10px; }

/* ---------- 5. Profiles ---------- */
.screen-profiles { max-width: 520px; }
.brand { text-align: center; margin: 12px 0 20px; }
.brand-mark { font-size: 3rem; filter: drop-shadow(0 0 18px var(--pink)); }
.logo { font-size: clamp(1.9rem, 9vw, 2.8rem); line-height: 1; color: var(--text); text-shadow: 3px 3px 0 var(--pink); }
.logo span { color: var(--lemon); text-shadow: 3px 3px 0 var(--pink), 0 0 30px color-mix(in srgb, var(--lemon) 40%, transparent); }
.new-rocker { padding: 20px; }
.new-avatar { display: flex; justify-content: center; margin-bottom: 4px; }
.new-rocker .btn-primary { margin-top: 18px; }
.new-rocker .btn-ghost { margin-top: 10px; }
.profile-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
.profile-card {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 10px 14px; text-align: left;
  border-radius: var(--radius); border: 2px solid var(--border); background: var(--surface); min-height: 72px;
}
.profile-card.is-active { border-color: var(--pink); }
.profile-card:hover { background: var(--surface-2); }
.profile-names { display: flex; flex-direction: column; min-width: 0; }
.profile-names strong { font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-names small { color: var(--muted); }

.avatar { display: inline-block; flex: none; border-radius: 22%; overflow: hidden; background: rgba(0,0,0,.3); aspect-ratio: 200 / 240; line-height: 0; }
.avatar svg { width: 100%; height: 100%; display: block; }
.avatar-fallback { display: grid; place-items: center; height: 100%; font-size: 2rem; line-height: 1; }
.avatar-thumb { width: 64px; }
.avatar-sm { width: 52px; }
.avatar-md { width: 78px; border: 3px solid var(--pink); box-shadow: var(--glow); }
.avatar-lg { width: 140px; border: 3px solid var(--pink); box-shadow: var(--glow); }
.avatar-xl { width: min(220px, 55vw); border: 3px solid var(--pink); box-shadow: var(--glow); }

/* ---------- 6. Lobby & tiles ---------- */
.lobby-header { display: flex; align-items: center; gap: 14px; }
.lobby-me { padding: 0; border: 0; background: none; border-radius: 22%; }
.lobby-who { min-width: 0; flex: 1; }
.rock-name { font-size: clamp(1.25rem, 6vw, 1.9rem); color: var(--lemon); overflow-wrap: anywhere; }
.real-name { color: var(--muted); font-weight: 600; }
.lobby-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.lobby-nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0 14px; }
.nav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); font-weight: 700; font-size: .85rem;
}
.nav-btn span { font-size: 1.4rem; line-height: 1; }
.nav-btn:hover { background: var(--surface-2); }
.btn-reds {
  flex-direction: column; gap: 0; border-radius: var(--radius);
  background: linear-gradient(90deg, color-mix(in srgb, var(--heat-red) 80%, transparent), color-mix(in srgb, var(--heat-orange) 80%, transparent));
  color: #fff; font-size: 1.15rem; min-height: 62px;
}
.btn-reds small { font-weight: 600; font-size: .85rem; opacity: .9; }
.btn-reds[aria-disabled='true'] { filter: saturate(.25); opacity: .8; }
[data-theme='mono'] .btn-reds { background: var(--surface-2); }

.tiles { display: grid; grid-template-columns: 1fr; gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface-2), var(--surface)); border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.tile::after { content: ''; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--tile-accent, var(--pink)); opacity: .14; pointer-events: none; }
.tile-garage { --tile-accent: var(--cyan); }
.tile-studio { --tile-accent: var(--pink); }
.tile-soundcheck { --tile-accent: var(--lemon); }
.tile-jamming { --tile-accent: #9b5de5; }
.tile-gig { --tile-accent: #ff8a1f; }
.tile-arena { --tile-accent: var(--cyan); }
.tile-festival { --tile-accent: var(--lemon); }
.tile-rockslam { --tile-accent: var(--pink); }
.tile-head { display: flex; gap: 12px; align-items: flex-start; }
.tile-icon { font-size: 2rem; width: 52px; height: 52px; flex: none; display: grid; place-items: center; border-radius: 14px; background: rgba(0,0,0,.25); }
.tile-name { font-size: 1.3rem; color: var(--text); }
.tile-desc { color: var(--muted); font-size: .95rem; line-height: 1.3; margin-top: 2px; }
.tile-opts { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.opt-label { font-weight: 700; color: var(--muted); font-size: .9rem; min-width: 64px; }
.atm-label { font-weight: 700; color: var(--cyan); }
.atm-label.big { font-size: 1.2rem; }
.tile-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: auto; }
.btn-play { background: var(--lemon); color: var(--on-lemon); min-width: 120px; min-height: 52px; font-size: 1.15rem; font-family: var(--font-display); font-weight: 400; letter-spacing: .03em; }
.tile.is-locked { filter: grayscale(.7); }
.tile-compact { display: grid; grid-template-columns: 1fr auto; align-items: center; }
.tile-compact .tile-foot { margin: 0; flex-direction: column; align-items: flex-end; gap: 0; }
.tile-compact .btn-play { min-width: 96px; }
@media (max-width: 380px) { .tile-compact { grid-template-columns: 1fr; } .tile-compact .tile-foot { flex-direction: row; justify-content: flex-end; } }
.tile.is-locked .btn-play { background: var(--surface-2); color: var(--muted); }

/* ---------- 7. Countdown ---------- */
.screen-countdown { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; }
.cd-mode { font-size: clamp(2rem, 10vw, 3.4rem); color: var(--lemon); text-shadow: 4px 4px 0 var(--pink); }
.cd-sub { color: var(--muted); font-weight: 600; }
.cd-stage { height: 46vw; max-height: 260px; min-height: 160px; display: grid; place-items: center; }
.cd-num { font-family: var(--font-display); font-size: clamp(6rem, 34vw, 13rem); line-height: 1; color: var(--text); text-shadow: 0 0 40px var(--pink), 6px 6px 0 var(--pink); }
.cd-num.is-go { color: var(--lemon); font-size: clamp(4rem, 22vw, 9rem); }
.cd-anim { animation: cd-pop .7s cubic-bezier(.2, 1.6, .4, 1) both; }
.cd-lights { display: flex; gap: 14px; }
.cd-lights i { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); transition: background .2s, box-shadow .2s; }
.cd-lights i.on { background: var(--pink); box-shadow: 0 0 18px var(--pink); }
@keyframes cd-pop { 0% { transform: scale(2.2); opacity: 0; } 60% { opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

/* ---------- 8. Play ---------- */
.screen-play {
  max-width: 560px; min-height: 100dvh; display: flex; flex-direction: column;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); position: relative;
}
.play-top { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 10px; }
.btn-quit { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); font-size: 1.1rem; }
.play-mode { font-size: 1.2rem; text-align: center; color: var(--lemon); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-coins { min-width: 48px; text-align: right; font-weight: 800; font-size: 1.15rem; color: var(--lemon); font-variant-numeric: tabular-nums; }
.play-clock-slot { margin-top: 10px; min-height: 8px; }
.play-body { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.play-main { flex: 1; display: flex; flex-direction: column; align-items: stretch; }
.q-next {
  margin-top: 10px; min-height: 1.8em; text-align: center; color: var(--faint); font-weight: 700; font-size: 1.15rem;
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.q-next span:first-child { font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; margin-right: 6px; vertical-align: middle; }
.q-next .q-blank { padding: 0 4px; border-width: 1px; }
.q-stage { flex: 1; min-height: 120px; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.q-tag { font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: .85rem; }
.q-current {
  font-size: var(--q-size); font-weight: 800; line-height: 1.05; text-align: center; white-space: nowrap;
  font-variant-numeric: tabular-nums lining-nums; text-shadow: 0 4px 0 rgba(0,0,0,.25);
}
.q-blank { display: inline-block; min-width: .9em; padding: 0 .12em; border: 3px dashed var(--lemon); border-radius: .2em; color: var(--lemon); line-height: 1; }
.q-in { animation: q-in .22s ease-out both; }
@keyframes q-in { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.answer-box {
  margin: 18px auto 0; width: min(100%, 300px); height: calc(var(--ans-size) * 1.45); display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: var(--answer-bg); border: 3px solid var(--border);
  font-size: var(--ans-size); font-weight: 800; font-variant-numeric: tabular-nums; position: relative;
  transition: border-color .15s, background .15s;
}
.ans-caret { width: 3px; height: .9em; background: var(--cyan); margin-left: 4px; animation: blink 1s steps(1) infinite; }
.answer-box.is-ghost .ans-text { color: var(--faint); }
.answer-box.is-ghost .ans-caret, .answer-box.is-right .ans-caret, .answer-box.is-wrong .ans-caret { display: none; }
.answer-box.is-right { border-color: var(--right); background: color-mix(in srgb, var(--right) 28%, transparent); }
.answer-box.is-wrong { border-color: var(--wrong); background: color-mix(in srgb, var(--wrong) 25%, transparent); }
.answer-box.shake { animation: shake .35s; }
.play-hint { min-height: 1.6em; text-align: center; color: var(--lemon); font-weight: 700; margin-top: 6px; }
.play-actions { display: flex; justify-content: center; min-height: 0; }
.play-actions:not(:empty) { margin-bottom: 8px; }
.keypad-slot { margin-top: auto; }
.sc-dots { display: flex; gap: 12px; }
.sc-dots i { width: 16px; height: 16px; border-radius: 50%; background: var(--text); opacity: .3; animation: pulse 1.2s infinite ease-in-out; }
.sc-dots i:nth-child(2) { animation-delay: .2s; }
.sc-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%, 100% { opacity: .2; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* full-screen flash */
.screen-play::before { content: ''; position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: -1; }
.screen-play.flash-right::before { background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--right) 45%, transparent), transparent 65%); animation: flash .6s ease-out; }
.screen-play.flash-wrong::before { background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--wrong) 45%, transparent), transparent 65%); animation: flash .6s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.coin-pop { position: absolute; right: 22px; top: 52px; font-weight: 800; color: var(--lemon); opacity: 0; pointer-events: none; font-size: 1.2rem; }
.coin-pop.pop { animation: coin-pop .8s ease-out; }
@keyframes coin-pop { 0% { opacity: 0; transform: translateY(14px) scale(.7); } 25% { opacity: 1; transform: translateY(0) scale(1.2); } 100% { opacity: 0; transform: translateY(-26px) scale(1); } }

.stamp {
  position: fixed; left: 50%; top: 42%; z-index: 20; transform: translate(-50%, -50%) rotate(-8deg);
  font-family: var(--font-display); font-size: clamp(2.4rem, 12vw, 4.5rem); color: var(--lemon); white-space: nowrap;
  padding: 10px 26px; border: 6px solid var(--lemon); border-radius: 16px; background: color-mix(in srgb, var(--bg2) 85%, transparent);
  text-shadow: 3px 3px 0 var(--pink); box-shadow: 0 0 0 9999px rgba(0,0,0,.45);
  animation: stamp .45s cubic-bezier(.2, 1.8, .4, 1) both;
}
@keyframes stamp { from { transform: translate(-50%, -50%) rotate(-8deg) scale(2.4); opacity: 0; } to { transform: translate(-50%, -50%) rotate(-8deg) scale(1); opacity: 1; } }

/* Opponents (Arena / Festival) */
.opponents { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; order: -1; margin-top: 8px; }
.opp-title { font-family: var(--font-display); font-weight: 400; font-size: .8rem; color: var(--cyan); letter-spacing: .1em; margin-bottom: 4px; }
.opp-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.opp { display: grid; grid-template-columns: 1.4em 1fr auto; gap: 6px; align-items: center; font-size: .88rem; padding: 1px 6px; border-radius: 8px; }
.opp-rank { color: var(--muted); font-weight: 700; }
.opp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-score { font-variant-numeric: tabular-nums; }
.opp.is-me { background: var(--pink); color: var(--on-pink); }
.opp.is-me .opp-rank { color: inherit; }
.has-opponents .q-stage { min-height: 100px; }

/* Rock Slam ghost race */
.ghost-race { margin-top: 8px; display: grid; gap: 6px; }
.race-row { display: grid; grid-template-columns: 74px 1fr 32px; align-items: center; gap: 8px; font-weight: 700; font-size: .9rem; }
.race-track { height: 12px; border-radius: 999px; background: rgba(0,0,0,.35); overflow: hidden; }
.race-fill { display: block; height: 100%; transform-origin: left; transform: scaleX(0); background: var(--pink); transition: transform .25s; }
.race-ghost .race-fill { background: color-mix(in srgb, var(--text) 55%, transparent); }
.race-score { text-align: right; font-variant-numeric: tabular-nums; }
.race-first { text-align: center; color: var(--muted); font-weight: 600; }

/* MTC mode: black and white like the real check */
.screen-play.is-mtc { color: #000; }
html:has(.is-mtc) body { background: #fff; }
html:has(.is-mtc) body::before { display: none; }
.is-mtc .play-mode, .is-mtc .q-tag { color: #000; }
.is-mtc .btn-quit { background: #fff; border-color: #000; color: #000; }
.is-mtc .q-current { text-shadow: none; }
.is-mtc .q-blank { color: #000; border-color: #000; }
.is-mtc .answer-box { background: #fff; border-color: #000; color: #000; }
.is-mtc .ans-caret { background: #000; }
.is-mtc .sc-dots i { background: #000; }
.is-mtc .clock-digits { color: #000; }
.is-mtc .clock-bar { background: #ddd; }
.is-mtc .clock-fill { background: #000; }
.is-mtc .key { background: #f1f1f1; color: #000; border: 2px solid #000; box-shadow: none; }
.is-mtc .key-enter { background: #000; color: #fff; }
.is-mtc .key.pressed { background: #ccc; }

/* Declutter */
.declutter .play-clock-slot, .declutter .q-next, .declutter .coin-pop { display: none; }
@media (pointer: fine) { .declutter .keypad-slot { display: none; } }

/* ---------- 9. Keypad & clock ---------- */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 420px; margin: 0 auto; transition: opacity .15s; }
.keypad.is-locked { opacity: .55; }
.key {
  height: var(--key-h); min-height: 56px; border-radius: 16px; border: 0;
  background: var(--key-bg); color: var(--key-text); font-size: 1.8rem; font-weight: 800;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.25); touch-action: manipulation; user-select: none; -webkit-user-select: none;
  font-variant-numeric: tabular-nums;
}
@media (hover: hover) { .key:not(.key-enter):not(.key-back):hover { background: rgba(255, 255, 255, 0.16); } .key-enter:hover { filter: brightness(1.1); } }
.key.pressed { animation: key-press .16s; }
@keyframes key-press { 0% { background: var(--key-bg-press); transform: scale(.94); } 100% { transform: none; } }
.key-enter { background: var(--pink); color: var(--on-pink); }
.key-back { font-size: 1.5rem; background: rgba(0,0,0,.28); }
.clock { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; }
.clock-digits { font-family: var(--font-display); font-size: 1.35rem; min-width: 3.2em; font-variant-numeric: tabular-nums; color: var(--cyan); }
.clock-bar { height: 12px; border-radius: 999px; background: rgba(0,0,0,.35); overflow: hidden; }
.clock-fill { display: block; height: 100%; width: 100%; transform-origin: left; background: linear-gradient(90deg, var(--cyan), var(--pink)); border-radius: inherit; }
.clock.is-low .clock-digits { color: var(--lemon); animation: pulse 1s infinite; }
.clock.is-low .clock-fill { background: var(--lemon); }
.clock-item .clock-digits { display: none; }
.clock-item { grid-template-columns: 1fr; }

/* ---------- 10. Results ---------- */
.screen-results { max-width: 640px; display: flex; flex-direction: column; gap: 14px; position: relative; }
.results-stamp {
  align-self: center; margin-top: 4px; font-family: var(--font-display); font-size: clamp(1.8rem, 9vw, 2.6rem); color: var(--lemon);
  padding: 4px 18px; border: 4px solid var(--lemon); border-radius: 12px; transform: rotate(-4deg); text-shadow: 2px 2px 0 var(--pink);
  animation: stamp-in .4s cubic-bezier(.2, 1.8, .4, 1) both;
}
@keyframes stamp-in { from { transform: rotate(-4deg) scale(2); opacity: 0; } to { transform: rotate(-4deg) scale(1); opacity: 1; } }
.screen-results .screen-title { text-align: center; font-size: 1.2rem; color: var(--muted); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8px 4px; border-radius: var(--radius-sm); background: rgba(0,0,0,.2); }
.stat-num { font-size: 1.7rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-num small { font-size: .55em; color: var(--muted); margin-left: 2px; }
.stat-label { color: var(--muted); font-weight: 600; font-size: .88rem; }
.fine-warning { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--wrong) 22%, transparent); border: 1px solid var(--wrong); font-weight: 700; }
.status-big { font-family: var(--font-display); font-size: 1.5rem; text-align: center; margin: 14px 0 4px; color: var(--lemon); }
.promo-banner { text-align: center; font-family: var(--font-display); font-size: 1.4rem; color: var(--lemon); animation: pulse 1.4s infinite; }
.is-promoted { border-color: var(--lemon); box-shadow: 0 0 30px color-mix(in srgb, var(--lemon) 35%, transparent); }
.result-studio .muted, .result-garage .muted, .result-multi .muted { text-align: center; }
.result-garage .atm-label { text-align: center; margin: 6px 0; }
.score-big { text-align: center; font-size: 1.5rem; color: var(--muted); margin-bottom: 10px; }
.score-big b { font-size: 3rem; color: var(--text); }
.sc-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.sc-item { display: grid; grid-template-columns: 1.6em 1fr auto; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 10px; background: rgba(0,0,0,.22); font-variant-numeric: tabular-nums; font-weight: 700; border-left: 4px solid var(--right); }
.sc-item.is-wrong { border-left-color: var(--wrong); }
.sc-n { color: var(--muted); font-size: .8rem; }
.sc-mark { font-size: 1.1rem; }
.is-right .sc-mark { color: var(--right); }
.is-wrong .sc-mark { color: var(--wrong); }
.sc-given { grid-column: 2 / -1; font-size: .78rem; color: var(--muted); font-weight: 600; }
.placement { margin-top: 12px; text-align: center; }
.results-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.results-actions .btn-primary { grid-column: 1 / -1; }
.new-badges .badge-list { justify-content: center; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.confetti i { position: absolute; top: -20px; left: calc(var(--i) * 4.2%); width: 10px; height: 16px; border-radius: 3px;
  background: var(--pink); animation: confetti 2.8s calc(var(--i) * -0.13s) ease-in infinite; }
.confetti i:nth-child(3n) { background: var(--lemon); }
.confetti i:nth-child(3n+1) { background: var(--cyan); }
@keyframes confetti { to { transform: translateY(110vh) rotate(720deg); } }

/* Bars (shared: results Gig, stats tables, Soundcheck history) */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 54px 1fr 58px; gap: 10px; align-items: center; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .95rem; }
.bar-label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 14px; border-radius: 999px; background: rgba(0,0,0,.35); overflow: hidden; }
.bar-fill { display: block; height: 100%; transform-origin: left; border-radius: inherit; background: var(--heat-red); }
.bar-fill.ok { background: var(--heat-amber); }
.bar-fill.good { background: var(--heat-green3); }
.bar-val { text-align: right; }

/* Badges */
.badge-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: color-mix(in srgb, var(--lemon) 16%, transparent); border: 1px solid color-mix(in srgb, var(--lemon) 50%, transparent); font-weight: 700; font-size: .92rem; }
.badge.is-locked { background: transparent; border-color: var(--border); color: var(--faint); }
.badge-icon { font-size: 1.2rem; }

/* ---------- 11. Stats & heatmap ---------- */
.stat-row-hero { margin-bottom: 14px; grid-template-columns: repeat(4, 1fr); }
.stat-row-hero .stat-num { font-size: 1.4rem; }
.stats-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.card-heatmap .muted { margin-bottom: 10px; }
.heatmap-wrap { position: relative; }
.heatmap { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px; max-width: 520px; margin: 0 auto; }
.hm-head, .hm-corner { display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: var(--muted); aspect-ratio: 1; font-variant-numeric: tabular-nums; }
.hm-corner { color: var(--lemon); }
.hm-cell { aspect-ratio: 1; border: 0; padding: 0; border-radius: 4px; min-width: 0; background: var(--heat-grey); touch-action: manipulation; }
.hm-cell.is-selected { outline: 3px solid var(--text); outline-offset: 1px; z-index: 1; }
.heat-grey { background: var(--heat-grey); }
.heat-green4 { background: var(--heat-green4); }
.heat-green3 { background: var(--heat-green3); }
.heat-green2 { background: var(--heat-green2); }
.heat-green1 { background: var(--heat-green1); }
.heat-yellow { background: var(--heat-yellow); }
.heat-amber { background: var(--heat-amber); }
.heat-orange { background: var(--heat-orange); }
.heat-red { background: var(--heat-red); }
.heat-red2 { background: var(--heat-red2); }
.hm-pop {
  position: absolute; z-index: 5; width: 240px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg2) 94%, #fff 6%); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.hm-pop-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.2rem; }
.hm-pop-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin: 6px 0 0; }
.hm-pop-stats div { display: flex; justify-content: space-between; gap: 6px; white-space: nowrap; }
.hm-pop-stats dt { color: var(--muted); }
.hm-pop-stats dd { margin: 0; font-weight: 700; }
.hm-pop-band { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.hm-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; flex: none; vertical-align: middle; }
.hm-legend { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .8rem; color: var(--muted); justify-content: center; }
.hm-legend li { display: inline-flex; align-items: center; gap: 4px; }
.sticky-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.sticky-list li { display: flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; }
.sticky-list b { flex: 1; }
.speed-chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 13px; font-family: var(--font-body); }
.chart-goal { stroke: var(--lemon); stroke-dasharray: 6 5; stroke-width: 1.5; opacity: .8; }
.chart-goal-label { fill: var(--lemon); font-size: 11px; font-family: var(--font-body); font-weight: 700; }
.chart-line { fill: none; stroke: var(--pink); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: color-mix(in srgb, var(--pink) 18%, transparent); }
.chart-dot { fill: var(--lemon); stroke: var(--bg2); stroke-width: 2; }
.certs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.cert { text-align: center; padding: 16px 12px; border-radius: var(--radius-sm); border: 3px double var(--lemon); background: linear-gradient(160deg, color-mix(in srgb, var(--lemon) 14%, transparent), transparent); }
.cert-kicker { font-size: .75rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.cert-title { font-family: var(--font-display); color: var(--lemon); font-size: 1.05rem; margin: 4px 0; }
.cert-name { font-weight: 700; }
.cert-date { color: var(--muted); font-size: .85rem; }

/* ---------- 12. Shop ---------- */
.shop-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.shop-layout > * { min-width: 0; }
.shop-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.shop-sel-name { font-weight: 800; font-size: 1.15rem; min-height: 1.4em; }
.shop-action { width: 100%; max-width: 280px; }
.shop-msg { min-height: 1.4em; color: var(--lemon); font-weight: 700; font-size: .95rem; }
.shop-coins { font-size: 1.05rem; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.tab { flex: none; min-height: 44px; padding: 6px 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; white-space: nowrap; }
.tab[aria-selected='true'] { background: var(--cyan); color: #04202a; border-color: transparent; }
.shop-items { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.shop-item {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px;
  border-radius: var(--radius-sm); border: 2px solid var(--border); background: var(--surface); text-align: center;
}
.shop-item.is-selected { border-color: var(--pink); background: var(--surface-2); }
.shop-item.is-equipped .item-price { color: var(--right); }
.item-name { font-weight: 700; font-size: .85rem; line-height: 1.15; }
.item-price { font-weight: 800; font-size: .85rem; color: var(--lemon); }
.shake { animation: shake .4s; }
.is-short { filter: saturate(.5); }

/* ---------- 13. Settings ---------- */
.settings-grid { display: grid; gap: 14px; }
.settings-grid .seg { margin-bottom: 4px; }
.manage-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.manage-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 10px; border-radius: var(--radius-sm); background: rgba(0,0,0,.2); border: 2px solid transparent; }
.manage-row.is-active { border-color: var(--pink); }
.manage-row .profile-names { flex: 1; min-width: 140px; }
.manage-actions { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.rename-form { flex: 1; display: grid; gap: 6px; min-width: 200px; }
.manage-foot { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* ---------- 14. Dialog & toast ---------- */
.dialog {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; max-width: min(92vw, 420px);
  background: var(--bg1); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog-msg { font-size: 1.1rem; font-weight: 600; margin-bottom: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 60; transform: translate(-50%, 140%);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px; background: var(--lemon); color: var(--on-lemon);
  font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: transform .25s ease; text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
.pop { animation: pop-in .3s ease; }
@keyframes pop-in { 0% { transform: scale(.94); } 60% { transform: scale(1.03); } 100% { transform: none; } }

/* ---------- Wider screens ---------- */
@media (min-width: 640px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .card-heatmap { grid-row: span 2; }
  .card-wide { grid-column: 1 / -1; }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .manage-actions { width: auto; }
  .results-actions { grid-template-columns: 2fr 1fr 1fr; }
  .results-actions .btn-primary { grid-column: auto; }
  .lobby-nav { display: flex; justify-content: flex-start; margin-top: 18px; }
  .nav-btn { flex-direction: row; min-height: 48px; padding: 0 16px; font-size: .95rem; gap: 8px; }
  .nav-btn span { font-size: 1.15rem; }
}
@media (min-width: 900px) {
  .screen-lobby { display: grid; grid-template-columns: 1fr auto; column-gap: 20px; align-items: center; }
  .screen-lobby > :not(.lobby-header):not(.lobby-nav) { grid-column: 1 / -1; }
  .lobby-nav { margin: 0; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .shop-layout { grid-template-columns: 300px 1fr; align-items: start; }
  .shop-preview { position: sticky; top: 16px; }
  .screen-play.has-opponents { max-width: 900px; }
  .has-opponents .play-body { flex-direction: row; align-items: stretch; }
  .has-opponents .play-main { flex: 1; }
  .has-opponents .opponents { order: 0; width: 260px; flex: none; margin-top: 10px; align-self: flex-start; }
  .has-opponents .opp-list { grid-template-columns: 1fr; gap: 4px; }
  .has-opponents .opp { font-size: 1rem; padding: 6px 10px; }
  .screen-play { padding-top: 24px; }
}
@media (min-width: 900px) and (min-height: 760px) { :root { --key-h: 68px; } }
@media (max-height: 700px) { :root { --key-h: 56px; --q-size: clamp(2.2rem, 11vw, 3.6rem); } .q-stage { min-height: 90px; } }

/* ---------- 15. Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important;
  }
  .confetti { display: none; }
}
[data-motion='reduced'] *, [data-motion='reduced'] *::before, [data-motion='reduced'] *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important;
}
[data-motion='reduced'] .confetti { display: none; }
