/* Digibeat — global stylesheet.
 *
 * Token layer copied verbatim from spell/DESIGN_SYSTEM.md §1 (the anti-drift rule:
 * every colour, radius, and size comes from :root; nothing re-declares or hard-codes
 * them). The Digibeat skin (ambient pulse, beat-flash) sits on top of the shared
 * tokens — see DESIGN.md §6, theme decision D.
 */

:root {
  /* Praise tiers — same meaning everywhere (gold=perfect, cyan=amazing, emerald=great,
     amethyst=good, slate=gentle try-again; never an error red). */
  --gold: #ffd23f;
  --cyan: #36f1cd;
  --emerald: #7ae582;
  --amethyst: #9d8df1;
  --slate: #6c7a89;
  /* Surfaces */
  --bg-0: #070a1c;
  --bg-1: #0e1430;
  --bg-2: #161d44;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(150, 180, 255, 0.18);
  --ink: #eaf0ff;
  --ink-dim: #9fb0d8;
  --accent: #7aa2ff;
  --danger: #ff9aa2;
  /* Sizing */
  --radius: 22px;
  --tap-min: 64px;
  /* Digibeat: one beat period drives every pulse/flash. Chunk 3's Web Audio clock
     will set this from the actual tempo; 833ms = 72 bpm ambient default. */
  --beat: 833ms;
}

@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/fonts/atkinson-hyperlegible-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/fonts/atkinson-hyperlegible-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 18px;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: 'Atkinson Hyperlegible', 'Quicksand', 'Segoe UI Rounded', 'Nunito',
    system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 800px at 50% -10%, #21306e 0%, transparent 60%),
    radial-gradient(900px 700px at 90% 110%, #2a1b54 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* The ambient Digibeat pulse: a faint glow that breathes on the beat. Purely
   decorative; stilled entirely under prefers-reduced-motion. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(900px 600px at 50% 85%, var(--accent) 0%, transparent 60%);
  opacity: 0.05;
  animation: ambient-pulse calc(var(--beat) * 2) ease-in-out infinite;
  z-index: 0;
}

@keyframes ambient-pulse {
  0%, 100% { opacity: 0.04; }
  50% { opacity: 0.09; }
}

/* The app is exactly one viewport tall and the document never scrolls: long
   surfaces (store, lesson wall, dashboard, debug) scroll inside their own
   region instead, so the header and the number pad always stay put. */
#app {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  margin: 0 0 12px;
}

/* ---------- shared components (spell conventions) ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.btn {
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  border-radius: var(--radius);
  padding: 16px 26px;
  font-size: 1.2rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  cursor: pointer;
  transition: transform 0.1s ease;
}
.btn:active {
  transform: scale(0.96);
}
.btn.primary {
  background: linear-gradient(150deg, #5f7bff, #8a5cff);
  border-color: transparent;
  box-shadow: 0 10px 30px -8px #5f7bff88;
}
.btn.ghost {
  min-height: 52px;
  padding: 10px 22px;
  font-size: 1.05rem;
  opacity: 0.92;
}
.btn[disabled] {
  opacity: 0.4;
  pointer-events: none;
}
/* Danger button — the shared --danger token, never a red fill. */
.btn.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}
.btn.danger:hover {
  background: color-mix(in srgb, var(--danger) 8%, transparent);
}

.seg {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.seg button {
  min-height: var(--tap-min);
  border-radius: 16px;
  font-weight: 800;
  font-size: 1.1rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--panel-border);
  cursor: pointer;
}
.seg button.on {
  background: linear-gradient(150deg, #5f7bff, #8a5cff);
  border-color: transparent;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%) translateY(20px);
  background: #11183c;
  border: 1px solid var(--panel-border);
  color: var(--ink);
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1.1rem;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Overlay anatomy (z-index ladder: 40 particles / 50 toast / 60 content overlays /
   100 pause / 120 brain break / 200 adult gate — reserve the same rungs). */
.gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 6, 20, 0.7);
  backdrop-filter: blur(6px);
}
.gate-box {
  width: min(440px, 100%);
  border-radius: 20px;
  padding: 22px;
  background: linear-gradient(160deg, #1a2350, #11183c);
  border: 1px solid var(--panel-border);
  box-shadow: 0 24px 60px -20px #000d;
}
.gate-err {
  color: var(--danger);
  min-height: 1.4em;
}

/* The idle pause overlay (z-index 100 on the ladder above): a full-screen,
   Resume-only takeover raised after 15s of no response (src/idlewatch.js). Its
   copy is positive redirection, no guilt — DESIGN §9's no-penalty tone. */
.pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 6, 20, 0.82);
  backdrop-filter: blur(6px);
  text-align: center;
}
.pause-box {
  width: min(440px, 100%);
  border-radius: 20px;
  padding: 28px 22px;
  background: linear-gradient(160deg, #1a2350, #11183c);
  border: 1px solid var(--panel-border);
  box-shadow: 0 24px 60px -20px #000d;
}
.pause-title {
  font-size: 1.6rem;
  margin: 0 0 10px;
}
.pause-body {
  color: var(--ink-dim);
  margin: 0 0 20px;
  line-height: 1.4;
}
.pause-resume {
  width: min(320px, 100%);
}

/* ---------- app chrome ---------- */

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 10px;
}
/* The title wraps to a second line rather than abbreviating — an ellipsis on
   a kid screen reads as a mistake. */
.app-header .header-title {
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.15;
  min-width: 0;
}
.btn-icon {
  min-width: 48px;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--ink);
  font-size: 1.5rem;
  cursor: pointer;
}
.app-header .header-right {
  margin-left: auto;
}

/* ---------- home ---------- */

.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  gap: 8px;
}
.home-title {
  font-size: clamp(2.4rem, 10vw, 3.6rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}
.home-title .beat-dot {
  color: var(--gold);
  display: inline-block;
  animation: dot-pulse var(--beat) ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}
.home-tag {
  color: var(--ink-dim);
  font-size: 1.05rem;
  margin: 0 0 26px;
}
.home .btn.primary {
  min-height: 96px;
  font-size: 1.5rem;
  align-self: center;
  width: min(340px, 100%);
}
.home-flow-label {
  color: var(--ink-dim);
  font-size: 0.9rem;
  margin: -8px 0 12px;
  text-align: center;
}
/* Secondary home menu entries (warm-up, lesson, advanced, create, 24, debug):
   one shared shape so the stack reads as a menu, not mismatched pills. */
.home .home-warmup,
.home .home-lesson,
.home .home-advanced,
.home .home-create,
.home .home-twentyfour,
.home .home-debug {
  align-self: center;
  width: min(280px, 100%);
  margin-top: 2px;
  color: var(--ink-dim);
}
/* The wallet (§5): the points balance as a quiet pill between tag and Play. */
.wallet-chip {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 8px 20px;
  margin: -10px 0 16px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  font-weight: 700;
  font-size: 1.1rem;
}
.wallet-star {
  color: var(--gold);
}
/* Sign-in (chunk 9): one quiet corner entry; the name shows small when
   signed in. Play owns the screen — this is chrome, kept tiny. */
.home-auth {
  position: absolute;
  top: 14px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.home-auth .btn.ghost {
  min-height: 44px;
  padding: 6px 16px;
  font-size: 0.95rem;
}
.home-user {
  color: var(--ink-dim);
  font-size: 0.95rem;
  max-width: 34vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* A signed-in student's class + link code (chunk 10): one quiet line at the
   bottom of home — the kid surface stays minimal, the dashboard is the tool. */
.home-family {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px 18px;
  flex-wrap: wrap;
  margin-top: 22px;
  color: var(--ink-dim);
  font-size: 0.9rem;
  min-height: 1.4em;
}
.home-family .home-join {
  min-height: 40px;
  padding: 4px 14px;
  font-size: 0.9rem;
  color: var(--ink-dim);
}
.home-family-code {
  -webkit-user-select: text;
  user-select: text;
}

/* ---------- sign-in screen ---------- */

.signin {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.signin-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  align-self: center;
  width: min(340px, 100%);
}
.signin-role {
  width: 100%;
}
.signin-name {
  min-height: var(--tap-min);
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  font-size: 1.2rem;
  text-align: center;
  padding: 12px 18px;
}
.signin-note {
  color: var(--ink-dim);
  text-align: center;
  margin: 0;
  min-height: 1.4em;
}

/* ---------- answer slots + number pad (the shared input surface) ---------- */

.play-body {
  flex: 1;
  min-height: 0; /* shrink to the viewport row #app hands out — never grow the page */
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 14px;
  padding-bottom: 8px;
  position: relative; /* the engagement overlay (.fx-layer) scopes to the screen */
}

.prompt {
  text-align: center;
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: auto 0;
}

.answer-slots {
  display: flex;
  justify-content: center;
  gap: 12px;
  min-height: 74px;
}
.answer-slot {
  width: 58px;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 700;
  border-bottom: 4px solid var(--panel-border);
  border-radius: 8px 8px 0 0;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.answer-slot.filled {
  border-bottom-color: var(--accent);
  background: rgba(122, 162, 255, 0.08);
}
/* The grey correct answer (§4.4): exposures and the fix-it copy show it dim;
   typed digits cover it slot by slot. */
.answer-slot.ghost {
  color: var(--ink-dim);
  opacity: 0.75;
}
/* Rung 3 (§4.4.3): pulse the answer — highlight, never a countdown or a red. */
.answer-slots.reveal .answer-slot {
  animation: reveal-pulse var(--beat) ease-in-out 2;
}
@keyframes reveal-pulse {
  0%, 100% { background: transparent; }
  50% { background: rgba(157, 141, 241, 0.25); border-bottom-color: var(--amethyst); }
}
/* Praise flash on the whole slot row; colour set inline from the tier tokens. */
.answer-slots.flash .answer-slot {
  animation: slot-flash var(--beat) ease-out 1;
}
@keyframes slot-flash {
  0% { background: var(--flash, rgba(255, 210, 63, 0.35)); border-bottom-color: var(--flash-border, var(--gold)); }
  100% { background: transparent; }
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(420px, 100%);
  margin: 0 auto;
}
.numpad button {
  min-height: max(var(--tap-min), 12dvh);
  border-radius: 18px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  font-size: 1.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.08s ease;
}
.numpad button:active,
.numpad button.pressed {
  transform: scale(0.94);
  background: rgba(122, 162, 255, 0.22);
}
.numpad .pad-back {
  font-size: 1.5rem;
  color: var(--ink-dim);
}
/* Locked (a wrong entry waits out the window): unmistakably off, never red. */
.numpad.locked button {
  opacity: 0.35;
  transform: none;
  background: var(--panel);
  transition: opacity 0.15s ease;
}
.numpad .pad-blank {
  visibility: hidden;
  pointer-events: none;
}

/* ---------- drill ---------- */

/* One shared strip between prompt and slots: the NEW! badge on exposures,
   hint text, or the praise flash. Height is reserved so trials never shift
   the pad under a moving finger. */
.feedback {
  min-height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 8px;
  font-size: 1.15rem;
}
.feedback.hint {
  color: var(--ink-dim);
}
/* Exposure scaffold (chunk-5 review): the NEW! badge carries the strategy
   line with it, so the derivation is taught with the fact. */
.feedback.scaffold {
  flex-direction: column;
  gap: 2px;
}
.feedback.scaffold .tag {
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  color: var(--gold);
}
.feedback.scaffold .scaffold-line {
  color: var(--ink-dim);
  font-size: 1.05rem;
}
.feedback.praise {
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  animation: praise-pop var(--beat) ease-out 1;
}
.feedback.praise.gold { color: var(--gold); }
.feedback.praise.cyan { color: var(--cyan); }
.feedback.praise.emerald { color: var(--emerald); }
.feedback.praise.amethyst { color: var(--amethyst); }
.feedback.praise.slate { color: var(--slate); }
/* A combo line (7a) replaces the tier phrase: louder type, same one-beat pop —
   nothing between answers outlasts the praise beat (§5). */
.feedback.praise.combo {
  font-size: 1.7rem;
  letter-spacing: 0.06em;
}
@keyframes praise-pop {
  0% { transform: scale(0.5); opacity: 0; }
  45% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}

.drill .prompt {
  margin: auto 0 0;
}

/* Session end: points earned front and center. */
.drill-end {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 14px;
}
.end-points {
  font-size: clamp(3rem, 14vw, 4.5rem);
  font-weight: 700;
  color: var(--gold);
}
.end-points-label {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-top: -14px;
}
/* The earn landing: old balance counts up to the new one (stilled to the
   final number under reduced-motion). */
.end-wallet {
  color: var(--ink-dim);
  font-size: 1.15rem;
  font-weight: 700;
}
.end-wallet-n {
  color: var(--ink);
}
.end-line {
  color: var(--ink-dim);
  font-size: 1.15rem;
  margin: 0 0 14px;
}
.drill-end .btn.primary {
  min-height: 84px;
  font-size: 1.35rem;
  width: min(320px, 100%);
}

/* ---------- create mode / the "factory" (§4.7 + §8.7, chunk 14b) ---------- */

.create-belt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: auto 0 0;
}
.create-op,
.create-eq {
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 700;
  color: var(--ink-dim);
}
.create-target {
  font-size: clamp(2rem, 8vw, 2.8rem);
  font-weight: 700;
  color: var(--gold);
  min-width: 1.4em;
  text-align: center;
}
.create-blank {
  min-height: 60px;
  padding: 2px 4px;
  border-radius: 8px;
  cursor: pointer;
}
.create-blank .answer-slot {
  width: 44px;
  height: 60px;
  font-size: 1.8rem;
}
.create-blank.active .answer-slot {
  border-bottom-color: var(--accent);
  background: rgba(122, 162, 255, 0.14);
}
.create-found {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--emerald);
}
.create-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.create-actions .btn {
  min-height: 56px;
}

/* ---------- 24 mode (§4.7, chunk 15) ---------- */

/* No number pad on this screen (tiles are tapped, not typed) — center the
   board instead of the shared play-body's bottom anchor (which exists to
   keep the pad thumb-reachable on the other modes). */
.play-body.twentyfour {
  justify-content: center;
}
.tf-target {
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  margin: 0 0 8px;
}
.tf-tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}
.tf-tile {
  min-width: 72px;
  min-height: 72px;
  font-size: 1.6rem;
}
.tf-tile.active {
  background: linear-gradient(150deg, #5f7bff, #8a5cff);
  border-color: transparent;
  color: #fff;
}
.tf-ops {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}
.tf-ops .btn {
  min-width: 56px;
}
.tf-ops .btn.active {
  border-color: var(--accent);
  background: rgba(122, 162, 255, 0.14);
  opacity: 1;
}
.tf-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.tf-actions .btn {
  min-height: 56px;
}

/* ---------- store + game harness (§5, chunk 11a) ---------- */

.store {
  justify-content: flex-start;
}
.store .wallet-chip {
  margin: 0;
  padding: 4px 14px;
  font-size: 1rem;
}
/* The catalogue is a list: it scrolls inside the screen, top-down, and the
   page itself never moves. */
.play-body.store {
  justify-content: flex-start;
  overflow-y: auto;
}
.store-game {
  margin-bottom: 12px;
}
.store-game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.store-game-head h2 {
  margin: 0;
  font-size: 1.15rem;
}
.store-play {
  min-height: 52px;
  padding: 8px 20px;
  font-size: 1.05rem;
}
.store-best {
  color: var(--ink-dim);
  font-size: 0.95rem;
  margin-top: 4px;
}
.store-items {
  margin-top: 10px;
}
.store-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  min-height: 52px;
}
.store-item + .store-item {
  border-top: 1px solid var(--panel-border);
}
/* Prices up front (§5): the button IS the price; arming it names the deal. */
.store-buy {
  min-height: 48px;
  padding: 6px 18px;
  font-size: 1rem;
  white-space: nowrap;
}
.store-buy.armed {
  border-color: var(--gold);
  color: var(--gold);
}
.store-item.owned .store-owned-mark {
  color: var(--emerald);
  font-weight: 700;
}
.store-item.flash {
  animation: praise-pop var(--beat) ease-out 1;
}
.store-note {
  color: var(--ink-dim);
  text-align: center;
  margin: 8px 0;
}
.store-exit {
  margin-top: auto;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
/* The harness: praise strip + stage; the only time signal is a state change. */
.store-lastround {
  min-height: 1.4em;
  text-align: center;
  color: var(--gold);
  font-weight: 700;
}
.game-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}
.game-stage .stub-go {
  min-height: 84px;
  width: min(320px, 100%);
  font-size: 1.35rem;
}
.stub-owned {
  color: var(--ink-dim);
}

/* Lane Dash (games overhaul, replaces Reaction Duel): three lanes, the field
   is the screen at 375px — content dominates, both halves of the field are a
   thumb target. Skins are token color-mixes (no new hex); the ★ and the rocks
   keep skin-independent colors so what to grab reads the same whatever the
   runner wears. Nothing here is red-alarm: rocks are slate, the oops flash is
   the soft danger pink. */
.lane-hud {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 16px;
  font-size: 1.1rem;
}
.lane-score {
  color: var(--ink);
  font-weight: 700;
}
.lane-combo {
  color: var(--gold);
  font-weight: 700;
  min-width: 2em;
}
.lane-lives {
  letter-spacing: 3px;
}
.lane-heart {
  color: var(--danger);
}
.lane-heart.lost {
  color: var(--panel-border);
}
.lane-status {
  color: var(--ink-dim);
  font-size: 1.05rem;
  min-height: 1.4em;
}
.lane-field {
  position: relative;
  width: min(360px, 92vw);
  flex: 1;
  min-height: min(52vh, 380px);
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--accent) 12%, var(--panel)),
    var(--panel)
  );
  overflow: hidden; /* the field edge: the lanes scroll within it, by design */
  touch-action: none;
}
.lane-stripes {
  position: absolute;
  inset: 0;
  display: flex;
}
.lane-stripe {
  flex: 1;
  border-right: 1px dashed color-mix(in srgb, var(--panel-border) 70%, transparent);
}
.lane-stripe:last-child {
  border-right: 0;
}
.lane-item {
  position: absolute;
  top: 0;
  left: 0;
  width: 40px; /* ITEM in games/lanedash.js */
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  will-change: transform;
}
.lane-item.star {
  background: color-mix(in srgb, var(--gold) 45%, var(--panel));
  border: 2px solid var(--gold);
  color: var(--gold);
}
.lane-item.rock {
  background: color-mix(in srgb, var(--slate) 45%, var(--panel));
  border: 2px solid var(--slate);
  color: var(--ink-dim);
  border-radius: 10px;
}
.lane-runner {
  position: absolute;
  bottom: 12px;
  left: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 55%, var(--panel));
  border: 2px solid var(--accent);
  will-change: transform;
}
.lane-runner.skin-flame {
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--danger) 55%, var(--panel)),
    color-mix(in srgb, var(--gold) 45%, var(--panel))
  );
  border-color: var(--danger);
}
.lane-runner.skin-ice {
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--cyan) 55%, var(--panel)),
    color-mix(in srgb, var(--accent) 40%, var(--panel))
  );
  border-color: var(--cyan);
}
.lane-runner.skin-nova {
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--amethyst) 55%, var(--panel)),
    color-mix(in srgb, var(--cyan) 40%, var(--panel))
  );
  border-color: var(--amethyst);
}
.lane-runner.trail-spark {
  box-shadow: 0 10px 12px -4px color-mix(in srgb, var(--gold) 55%, transparent);
}
.lane-runner.sparkle {
  animation: lane-sparkle 0.42s ease-out 1;
}
@keyframes lane-sparkle {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 60%, transparent); }
  100% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--gold) 0%, transparent); }
}
.lane-runner.oops {
  animation: lane-oops 0.26s ease-out 1;
}
@keyframes lane-oops {
  0% {
    border-color: var(--danger);
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--danger) 35%, transparent);
  }
  100% { border-color: var(--accent); }
}

/* The game chooser (games overhaul): the kid picks. One big Continue card when
   today's save has a game going, then a small card per game. Cards grow into a
   row on tablet/desktop and stack on a phone. */
.game-pick-title {
  color: var(--ink-dim);
  font-size: 1.05rem;
  margin: 0;
}
.game-pick {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: min(560px, 94vw);
}
.game-card {
  flex: 1 1 150px;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 1.1rem;
  font-weight: 700;
}
.game-card.continue {
  flex: 1 1 100%;
  min-height: 108px;
  font-size: 1.3rem;
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 22%, var(--panel));
}
.game-card-name {
  display: block;
}
.game-card-note {
  display: block;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--ink-dim);
}
.game-switch {
  min-height: 44px;
  font-size: 0.95rem;
}
.game-boost {
  color: var(--gold);
  font-weight: 700;
  font-size: 1.05rem;
  transition: opacity 0.6s ease-out;
}
.game-boost.gone {
  opacity: 0;
}

/* Drop Catch (chunk 12a): the field is the screen at 375px — content
   dominates, the catcher is thumb-driven. Skins are token color-mixes (no
   new hex); good/bad items keep skin-independent colors so what to catch
   reads the same regardless of the cosmetic worn. Nothing here is red-alarm:
   the bad item is slate, the oops flash is the soft danger pink. */
.catch-hud {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 16px;
  font-size: 1.1rem;
}
.catch-score {
  color: var(--ink);
  font-weight: 700;
}
.catch-combo {
  color: var(--gold);
  font-weight: 700;
  min-width: 2em;
}
.catch-lives {
  letter-spacing: 3px;
}
.catch-heart {
  color: var(--danger);
}
.catch-heart.lost {
  color: var(--panel-border);
}
.catch-status {
  color: var(--ink-dim);
  font-size: 1.05rem;
  min-height: 1.4em;
}
.catch-field {
  position: relative;
  width: min(360px, 92vw);
  flex: 1;
  min-height: min(52vh, 380px);
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  overflow: hidden; /* the field edge: items fall within it, by design */
  touch-action: none;
}
.catch-item {
  position: absolute;
  top: 0;
  left: 0;
  width: 40px; /* ITEM in games/dropcatch.js */
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  will-change: transform;
}
.catch-item.good {
  background: color-mix(in srgb, var(--gold) 45%, var(--panel));
  border: 2px solid var(--gold);
  color: var(--gold);
}
.catch-item.bad {
  background: color-mix(in srgb, var(--slate) 45%, var(--panel));
  border: 2px solid var(--slate);
  color: var(--ink-dim);
}
.catch-tray {
  position: absolute;
  bottom: 8px;
  left: 0;
  width: 88px;
  height: 26px;
  border-radius: 13px;
  border: 2px solid var(--panel-border);
  background: color-mix(in srgb, var(--accent) 55%, var(--panel));
  will-change: transform;
}
.catch-tray.wide {
  width: 132px; /* the one upgrade: catch-wide, pure geometry */
}
.catch-tray.skin-sunny {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--gold) 60%, var(--panel)),
    color-mix(in srgb, var(--danger) 40%, var(--panel))
  );
}
.catch-tray.skin-berry {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--amethyst) 60%, var(--panel)),
    color-mix(in srgb, var(--danger) 45%, var(--panel))
  );
}
.catch-tray.skin-mint {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--emerald) 55%, var(--panel)),
    color-mix(in srgb, var(--cyan) 45%, var(--panel))
  );
}
.catch-tray.sparkle {
  animation: catch-sparkle 0.42s ease-out 1;
}
@keyframes catch-sparkle {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 60%, transparent); }
  100% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--gold) 0%, transparent); }
}
.catch-tray.oops {
  animation: catch-oops 0.26s ease-out 1;
}
@keyframes catch-oops {
  0% { border-color: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 30%, transparent); }
  100% { border-color: var(--panel-border); }
}
.catch-again {
  min-height: 64px;
  width: min(280px, 100%);
  font-size: 1.1rem;
}

/* One-Tap Hopper (chunk 12b): the flight field is the screen at 375px — the
   whole field taps to hop, content dominates. Skins are token color-mixes (no
   new hex); the obstacle bars stay skin-independent so the gap reads the same
   whatever character is worn. Nothing here is red-alarm: a crash is the soft
   danger pink, never a buzzer. */
.hop-hud {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 16px;
  font-size: 1.1rem;
}
.hop-score {
  color: var(--ink);
  font-weight: 700;
}
.hop-combo {
  color: var(--gold);
  font-weight: 700;
  min-width: 2em;
}
.hop-shield {
  color: var(--cyan);
  font-weight: 700;
  min-width: 1.2em;
}
.hop-lives {
  letter-spacing: 3px;
}
.hop-heart {
  color: var(--danger);
}
.hop-heart.lost {
  color: var(--panel-border);
}
.hop-status {
  color: var(--ink-dim);
  font-size: 1.05rem;
  min-height: 1.4em;
}
.hop-field {
  position: relative;
  width: min(360px, 92vw);
  flex: 1;
  min-height: min(52vh, 380px);
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--accent) 12%, var(--panel)),
    var(--panel)
  );
  overflow: hidden; /* the field edge: the character flies within it, by design */
  touch-action: none;
}
.hop-bird {
  position: absolute;
  top: 0;
  left: 26%;
  margin-left: -17px;
  width: 34px; /* BIRD_PX in games/hopper.js */
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px; /* px, not rem: the chicken must fill the fixed 34px hitbox at any system font scale */
  line-height: 1;
  color: var(--gold);
  background: color-mix(in srgb, var(--gold) 45%, var(--panel));
  border: 2px solid var(--gold);
  will-change: transform;
}
.hop-bird.skin-robin {
  color: var(--ink);
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--danger) 55%, var(--panel)),
    color-mix(in srgb, var(--gold) 45%, var(--panel))
  );
  border-color: var(--danger);
}
.hop-bird.skin-blossom {
  color: var(--ink);
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--amethyst) 55%, var(--panel)),
    color-mix(in srgb, var(--danger) 40%, var(--panel))
  );
  border-color: var(--amethyst);
}
.hop-bird.skin-storm {
  color: var(--ink);
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--accent) 55%, var(--panel)),
    color-mix(in srgb, var(--cyan) 40%, var(--panel))
  );
  border-color: var(--accent);
}
.hop-bird.trail-comet {
  box-shadow: -10px 0 12px -4px color-mix(in srgb, var(--cyan) 55%, transparent);
}
.hop-bird.shielded {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--cyan) 45%, transparent);
}
.hop-bird.trail-comet.shielded {
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--cyan) 45%, transparent),
    -10px 0 12px -4px color-mix(in srgb, var(--cyan) 55%, transparent);
}
.hop-bird.sparkle {
  animation: hop-sparkle 0.42s ease-out 1;
}
@keyframes hop-sparkle {
  0% { filter: drop-shadow(0 0 0 color-mix(in srgb, var(--gold) 70%, transparent)); }
  100% { filter: drop-shadow(0 0 12px color-mix(in srgb, var(--gold) 0%, transparent)); }
}
.hop-bird.oops {
  animation: hop-oops 0.26s ease-out 1;
}
@keyframes hop-oops {
  0% {
    border-color: var(--danger);
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--danger) 35%, transparent);
  }
  100% { border-color: var(--gold); }
}
.hop-obstacle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 34px; /* OBST_PX in games/hopper.js */
  will-change: transform;
}
.hop-bar {
  position: absolute;
  left: 0;
  right: 0;
  background: color-mix(in srgb, var(--emerald) 38%, var(--panel));
  border: 2px solid color-mix(in srgb, var(--emerald) 60%, var(--panel));
}
.hop-bar.top {
  top: 0;
  border-radius: 0 0 10px 10px;
}
.hop-bar.bottom {
  bottom: 0;
  border-radius: 10px 10px 0 0;
}
.hop-again {
  min-height: 64px;
  width: min(280px, 100%);
  font-size: 1.1rem;
}

.store-gate .btn.primary {
  min-height: 84px;
  font-size: 1.35rem;
  width: min(320px, 100%);
}

/* ---------- lesson (pattern reveal, §4.2 + 8.1) ---------- */

/* The wall scrolls within itself when a long section outgrows a phone. Auto
   margins on the first/last child centre a short wall (justify-content: center
   would make overflowing chips unreachable above the scroll start). */
.lesson-wall {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  text-align: center;
}
.lesson-wall > :first-child {
  margin-top: auto;
}
.lesson-wall > :last-child {
  margin-bottom: auto;
}
.lesson-title {
  margin: 0;
  font-size: 1.3rem;
}
.lesson-caption {
  margin: 0;
  color: var(--ink-dim);
  font-size: 1.05rem;
}
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  width: min(420px, 100%);
}
/* Chain review: a fact with a substitution strategy transforms in place —
   tap the marked part of 3 + 4 = 7 and it reads 3 + 3 + 1 = 7; tap again to
   come back. One substitution, never a chain line. */
.lesson-chip {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: var(--panel);
  padding: 6px 4px;
  font-weight: 700;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  /* Fixed box: the transformed view is longer, so it wraps or shrinks inside
     the same footprint. Nothing on the wall moves when a chip is tapped. */
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  line-height: 1.15;
  white-space: normal;
}
button.lesson-chip {
  cursor: pointer;
}
/* The part that changes is the click-me. */
.swap-mark {
  color: var(--accent);
  border-bottom: 2px dashed color-mix(in srgb, var(--accent) 65%, transparent);
}
/* The transformed fact is longer: it shrinks to fit its own chip — never a
   wider cell, which would reflow every chip after it. */
.lesson-chip.swapped {
  border-color: var(--accent);
  font-size: 0.8rem;
}
/* Tap-every-problem gate: a tapped fact (swap or not) dims to "seen". */
.lesson-chip.tapped {
  opacity: 0.62;
}
/* Reinforcers (engine/facts.js reinforcersFor): facts from earlier sections
   that follow this section's rule. Lighter than the wall, tappable, but never
   part of the gate or the guided pass. */
.lesson-reinforce-line {
  margin: 4px 0 0;
  color: var(--ink-dim);
  font-size: 0.9rem;
}
.lesson-chip.reinforce {
  background: transparent;
  border-style: dashed;
  color: var(--ink-dim);
  font-size: 0.9rem;
  height: 44px;
}
.lesson-reinforcers {
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
}
.lesson-wall .lesson-speak {
  color: var(--ink-dim);
}
.lesson-gate-hint {
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.95rem;
}
/* The pattern sweeps the wall: each answer lights up in teaching order. */
.lesson-ans {
  color: var(--cyan);
  animation: lesson-pulse 6s ease-in-out infinite;
  animation-delay: var(--chip-delay, 0s);
}
@keyframes lesson-pulse {
  0%, 12%, 100% { text-shadow: none; }
  6% { text-shadow: 0 0 12px currentColor; color: var(--gold); }
}
.lesson-wall .btn.primary {
  min-height: 84px;
  font-size: 1.35rem;
  width: min(320px, 100%);
}
.lesson .prompt {
  margin: auto 0 0;
}
/* The guided pass's prompt is the fact itself — clickable when it has a
   transformed view, styled exactly like the plain prompt. */
.prompt-fact {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
}
button.prompt-fact {
  cursor: pointer;
}
/* The pass's strategy words with their read-aloud button right beside them
   (chain review); the words fade across the set, the button keeps its place. */
.feedback.lesson-hint {
  gap: 10px;
}
.feedback.lesson-hint .pass-words {
  font-size: 1.05rem;
}
.feedback.lesson-hint .pass-speak {
  min-width: 44px;
  min-height: 44px;
  font-size: 1.1rem;
  flex: none;
}

/* The practice-run star result (chunk 6): filled stars in gold, empty ones
   dim, then Try again / Continue stacked like the primary lesson button. */
.stars-row {
  font-size: 2.5rem;
  letter-spacing: 6px;
}
.stars-row .star {
  color: var(--ink-dim);
  opacity: 0.4;
}
.stars-row .star.filled {
  color: var(--gold);
  opacity: 1;
}
.lesson-stars .btn {
  width: min(320px, 100%);
}
/* Auto-select: the default star-screen button drains a thin bar over the idle
   window, then fires itself (screens/lesson.js). A keyframes animation, not a
   transition — the class is present from render, so there's no property change
   to transition off of; the animation runs on its own once painted. No digits,
   a quiet drain, not a countdown clock: a scoped exception to the app's
   no-visible-countdown rule, this one button only. */
.autoselect-arm {
  position: relative;
  overflow: hidden;
}
.autoselect-arm::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  width: 100%;
  background: color-mix(in srgb, var(--ink) 35%, transparent);
  transform-origin: left;
  animation: autoselect-drain 10s linear forwards;
}
@keyframes autoselect-drain {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .autoselect-arm::after { animation: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 480px) {
  #app {
    padding: 12px;
  }
  .answer-slot {
    width: 50px;
    height: 66px;
  }
  /* Narrow phones: smaller chips buy a third wall column, so long sections
     need far less internal scrolling. */
  .lesson-grid {
    grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
    gap: 6px;
  }
  .lesson-chip {
    font-size: 0.9rem;
  }
}

/* Tablet and desktop get a roomier lesson: the wall spreads out instead of
   sitting in a phone-width strip (mobile-first, not mobile-only). */
@media (min-width: 700px) {
  .lesson-grid {
    width: min(600px, 100%);
    gap: 10px;
  }
  .lesson-chip {
    font-size: 1.15rem;
    padding: 8px 6px;
    height: 64px;
  }
  .lesson-chip.swapped {
    font-size: 0.95rem;
  }
  .lesson-title {
    font-size: 1.6rem;
  }
  .lesson-caption,
  .feedback.lesson-hint .pass-words {
    font-size: 1.15rem;
  }
}

@media (min-width: 1025px) and (pointer: fine) {
  #app {
    max-width: 900px;
  }
  .numpad button {
    min-height: var(--tap-min);
  }
}

/* Common phone heights: the drill adds a feedback strip above the slots, so
   the pad drops to its tap-min floor to keep the whole surface above the fold. */
@media (max-height: 700px) {
  .numpad button {
    min-height: var(--tap-min);
  }
}

/* Short phones (iPhone SE class): every band on the trial surface gives a
   little so the whole pad stays on screen. 52px keys sit under the 64px
   tap-min ideal but well above the 44px accessibility floor. */
@media (max-height: 620px) {
  #app {
    padding: 10px 12px;
  }
  .app-header {
    min-height: 40px;
    margin-bottom: 4px;
  }
  .play-body {
    gap: 8px;
    padding-bottom: 4px;
  }
  .prompt {
    font-size: 2rem;
  }
  .feedback {
    min-height: 2em;
    font-size: 1rem;
  }
  .feedback.praise {
    font-size: 1.25rem;
  }
  .feedback.praise.combo {
    font-size: 1.4rem;
  }
  .answer-slots {
    min-height: 60px;
  }
  .answer-slot {
    width: 46px;
    height: 60px;
    font-size: 2rem;
  }
  .numpad {
    gap: 8px;
  }
  .numpad button {
    min-height: 52px;
  }
  .lesson-wall {
    gap: 10px;
  }
  .lesson-wall .btn.primary {
    min-height: 64px;
  }
}

@media (max-height: 520px) {
  .prompt {
    font-size: 2rem;
  }
}

/* ---------- debug menu (chunk 16 follow-up, ?debug=1 only) ---------- */

.play-body.debug {
  justify-content: flex-start;
  overflow-y: auto;
  align-items: stretch;
}
.debug-note {
  color: var(--ink-dim);
  font-size: 0.9rem;
  margin: 0 0 4px;
}
.debug-section {
  margin-bottom: 18px;
}
.debug-section h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.debug-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.debug-link {
  min-height: var(--tap-min);
  font-size: 0.9rem;
  text-decoration: none;
}
.debug-label {
  color: var(--ink-dim);
  font-size: 0.8rem;
  font-weight: 700;
  margin: 8px 0 4px;
}
.debug-toggle,
.debug-chip {
  font-size: 0.85rem;
  min-height: var(--tap-min);
}
.debug-toggle.on,
.debug-chip.active {
  background: linear-gradient(135deg, var(--gold), #ff9d4d);
  color: #201400;
  border-color: transparent;
}
.debug-meter {
  margin: 10px 0 4px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-border);
}
.debug-meter-line {
  color: var(--ink);
  font-weight: 800;
  font-size: 0.95rem;
}
/* ---------- engagement overlay (chunk 5) ---------- */
/* One layer sits over the drill's prompt/slots/pad; it never intercepts taps. */
.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 3;
}
.fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.fx-pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  animation: fx-pop-rise var(--fx-pop-ms, 900ms) ease-out forwards;
}
@keyframes fx-pop-rise {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -90%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -220%) scale(1); }
}
/* A milestone banner: the big centred "N STREAK!" from prototypes/juice.html. */
.fx-pop.fx-pop-banner {
  font-size: 2.1rem;
  color: var(--emerald);
  letter-spacing: 0.04em;
}

/* Screen shake (prototypes/lab.js shake()): the screen root the fx layer sits
   in gets one of these for the length of the animation. Stilled under
   prefers-reduced-motion — engagement/shake.js also refuses to add the class. */
.fx-shake-1 { animation: fx-shake 0.18s ease; }
.fx-shake-2 { animation: fx-shake 0.26s ease; --fx-shake: 7px; }
.fx-shake-3 { animation: fx-shake 0.34s ease; --fx-shake: 11px; }
@keyframes fx-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(calc(var(--fx-shake, 4px) * -1), 1px); }
  40% { transform: translate(var(--fx-shake, 4px), -1px); }
  60% { transform: translate(calc(var(--fx-shake, 4px) * -0.6), 1px); }
  80% { transform: translate(calc(var(--fx-shake, 4px) * 0.6), 0); }
}
@media (prefers-reduced-motion: reduce) {
  .fx-shake-1, .fx-shake-2, .fx-shake-3 { animation: none; }
}

/* reveal skin (chunk 7): a picture hides under a tile grid, top of the layer. */
.fx-reveal {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: min(88%, 320px);
  height: 200px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}
.fx-reveal-scene {
  position: absolute;
  inset: 0;
}
.fx-reveal-scene.space { background: linear-gradient(180deg, #0b1a3f, #26124a); }
.fx-reveal-scene.sea { background: linear-gradient(180deg, #053a5f, #021f3a); }
.fx-reveal-scene.dino { background: linear-gradient(180deg, #1c4a24, #0d2b14); }
.fx-reveal-scene.candy { background: linear-gradient(180deg, #5f2a6e, #31174d); }
.fx-reveal-scene.robot { background: linear-gradient(180deg, #20304d, #101726); }
.fx-reveal-scene.dragon { background: linear-gradient(180deg, #4d1f24, #1d0d16); }
.fx-reveal-sticker {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 30px;
}
.fx-reveal-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(4, 1fr);
}
.fx-reveal-tile {
  background: var(--bg-2);
  border: 1px solid var(--bg-0);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.fx-reveal-tile.gone {
  opacity: 0;
  transform: scale(0.4) rotate(18deg);
}
.fx-reveal-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--ink);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 0.4s ease;
}
.fx-reveal.done .fx-reveal-name { opacity: 1; }

/* beatline skin (chunk 7): the band strip the streak builds, top of the layer. */
.fx-band {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92%, 440px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.fx-band-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}
.fx-band-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 54px;
  padding: 6px 0 5px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  opacity: 0.25;
  transition: opacity 0.3s ease, transform 0.08s ease;
  font-size: 0.65rem;
  color: var(--ink-dim);
  font-weight: 700;
}
.fx-band-face { font-size: 1.5rem; }
.fx-band-slot.live { opacity: 1; color: var(--ink); }
.fx-band-slot.pulse { transform: scale(1.18); }
.fx-band-note {
  color: var(--ink-dim);
  font-size: 0.8rem;
  font-weight: 700;
  min-height: 20px;
}

/* odometer skin (2026-08-06): the speed counter. One big number, prominent, at
   the top of the layer. It is the whole visual for its minute — nothing else
   mounts beside it. --heat (0..1) is set per answer, so a fast answer flares and
   a slow one stays calm. */
.fx-odo {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 18px 10px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  --heat: 0;
}
.fx-odo-label {
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.22em;
  color: var(--ink-dim);
}
.fx-odo-digits {
  display: flex;
  gap: 1px;
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.2rem, 11vw, 3rem);
  font-weight: 900;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 calc(var(--heat) * 22px) var(--gold);
  transition: text-shadow 0.25s ease;
}
.fx-odo-digit {
  display: inline-block;
  min-width: 0.62em;
  text-align: center;
}
.fx-odo-digit.roll { animation: fx-odo-roll 0.16s ease-out; }
@keyframes fx-odo-roll {
  0% { transform: translateY(0.36em); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
.fx-odo-band {
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  min-height: 18px;
}
.fx-odo.hot .fx-odo-band { color: var(--gold); }
.fx-odo-pop.fast { color: var(--emerald); }
.fx-odo-pop.blazing { color: var(--gold); font-size: 2.2rem; }
@media (prefers-reduced-motion: reduce) {
  .fx-odo-digit.roll { animation: none; }
}

/* op + difficulty picker (chunk 11) */
.play-body.picker {
  justify-content: flex-start;
  gap: 10px;
  /* Large system fonts can outgrow a short phone: scroll inside the screen
     rather than ever cutting off the Start button. */
  overflow-y: auto;
}
.picker-lead {
  color: var(--ink-dim);
  font-weight: 700;
  margin: 8px 0 2px;
}
.picker-ops {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.picker-op {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap-min);
  font-size: 1rem;
  /* Shrink inside the 2-up grid on narrow phones — "Multiplication" must never
     push past the screen edge. */
  min-width: 0;
  padding-left: 10px;
  padding-right: 10px;
}
.picker-op-sym {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--gold);
}
.picker-op.selected {
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 14%, transparent);
}
.picker-diff {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.picker-mode {
  flex: 1;
  min-height: var(--tap-min);
}
.picker-mode.selected {
  border-color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 14%, transparent);
}
.picker-mode.locked {
  opacity: 0.45;
}
.picker-note {
  flex-basis: 100%;
  color: var(--ink-dim);
  font-size: 0.8rem;
  margin: 2px 0 0;
}
.picker-start {
  margin-top: 10px;
}
/* Phone widths (kept below the picker's base rules — later wins). */
@media (max-width: 480px) {
  .picker-op {
    font-size: 0.88rem;
    gap: 6px;
  }
  /* em-based auto-fit: if the user's font scaling ever makes a label too wide
     for a half-width cell, the grid drops to one full-width column instead of
     letting it poke past the button edge. With the short verb labels this
     stays 2-up on every common phone, so the picker fits without scrolling. */
  .picker-ops {
    /* The 132px floor stops a wide phone from fitting a lopsided third
       column; the em term is what collapses it to one under font scaling. */
    grid-template-columns: repeat(auto-fit, minmax(min(max(6.5em, 132px), 100%), 1fr));
  }
}

/* race skin (chunk 8): a ghost sprint across the top of the layer. */
.fx-race {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(90%, 360px);
}
.fx-race-lane {
  position: relative;
  height: 56px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  overflow: hidden;
}
.fx-race-runner,
.fx-race-ghost {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.6rem;
  transition: left 0.25s ease;
}
.fx-race-ghost { opacity: 0.6; top: 30%; }
.fx-race-runner { top: 66%; }
.fx-race-finish {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.4rem;
}
.fx-race-note {
  margin-top: 6px;
  text-align: center;
  color: var(--ink-dim);
  font-weight: 700;
  font-size: 0.85rem;
}
.fx-race.won .fx-race-note { color: var(--emerald); }
.fx-race.lost .fx-race-note { color: var(--amethyst); }

/* boss skin (chunk 8): a boss with an HP bar + the child's hearts. */
.fx-boss {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(90%, 340px);
  text-align: center;
}
.fx-boss-face {
  font-size: 2.6rem;
  transition: transform 0.1s ease;
}
.fx-boss-face.hit { animation: fx-boss-hit 0.25s ease; }
.fx-boss-face.hurt-player { animation: fx-boss-lunge 0.3s ease; }
@keyframes fx-boss-hit { 50% { transform: scale(0.82) rotate(-6deg); } }
@keyframes fx-boss-lunge { 50% { transform: translateY(8px) scale(1.12); } }
.fx-boss-hp {
  height: 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  overflow: hidden;
  margin: 6px auto 4px;
}
.fx-boss-hp i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--gold), var(--cyan));
  transition: width 0.25s ease;
}
.fx-boss-hearts {
  font-size: 1.1rem;
  letter-spacing: 3px;
  color: var(--gold);
}
.fx-boss-heart.lost { opacity: 0.25; }
.fx-boss-note {
  margin-top: 4px;
  color: var(--ink-dim);
  font-weight: 700;
  font-size: 0.85rem;
}
.fx-boss.won .fx-boss-note { color: var(--emerald); }
.fx-boss.lost .fx-boss-note { color: var(--amethyst); }

/* QA demo harness (chunk 5, ?engage=demo) — a positioned stage for the layer. */
.fx-demo-stage {
  position: relative;
  min-height: 340px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  margin-bottom: 12px;
}
.fx-demo-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.fx-demo-read {
  color: var(--ink-dim);
  font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
