/* Math Racing: one full-screen canvas (the race inside the wheel) with the HUD on top.
   Tokens follow Tilt Cube's (same maker); the world colours (track, sky, terrain, runner) are read by the renderer. */
:root{
  --paper:#edf2f8; --ink:#18263f; --muted:#5b6983;
  --tile:#ffffff; --tile-edge:#c3cfe0; --given:#dfe7f2; --slot:#f8fafd; --slot-line:#9cadc9;
  --you:#2f5bff; --you-soft:#dde5ff; --you-edge:#1c3dc2; --on-you:#ffffff;
  --good:#12a165; --on-good:#ffffff; --bad:#e0434a; --bad-soft:#ffd9da; --gold:#f2b705;
  --r0:#ef5a4f; --r1:#f39a1e; --r2:#13a89e; --r3:#8b5cf6; --r4:#e2468f; --r5:#1f9fd6; --r6:#6aa121; --r7:#c2410c; --r8:#4f46e5;
  --ball-face:#ffffff; --ball-ink:#18263f;
  --panel:rgba(255,255,255,.9); --panel-line:rgba(24,38,63,.12); --scrim:rgba(237,242,248,.82);   /* (no backdrop blur: it re-blurs the live canvas every frame) */
  /* World */
  --sky-top:#9fc2ff; --sky-bot:#f4e9ff; --fog:#e6ecfb; --spoke:#5b74b8;
  --track-a:#93a8cc; --track-b:#8499bf; --track-band:#7c92b9; --lane-line:#f4f7ff; --wall:#4a5fa6; --wall-top:#ffd23f;
  --shoulder-a:#9ed98a; --shoulder-b:#86c873; --shoulder-c:#72b862;
  --card:#ffffff; --card-edge:#b4c1d8; --op:#ffc83d; --op-edge:#cf9300; --on-op:#3b2a00;
  --runner:#ff8a3d; --runner-dark:#c9531c; --runner-light:#ffd2ad; --runner-sole:#ffffff; --runner-band:#2f5bff; --runner-leaf:#34c46b;
  --prop-a:#3fae6a; --prop-b:#a3adbf; --prop-c:#c9a0ff; --prop-d:#58bb6f; --prop-trunk:#8a5a3c; --gate:#3a4b85; --gate-light:#ffd23f;
  --font-display:"Fredoka","Baloo 2","Trebuchet MS","Avenir Next Rounded","Segoe UI Rounded",system-ui,sans-serif;
  --font-body:"Nunito","Avenir Next",system-ui,-apple-system,"Segoe UI",sans-serif;
}
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]){
  --paper:#0e1525; --ink:#e6ecfa; --muted:#93a0bb;
  --tile:#1b2640; --tile-edge:#070b15; --given:#24304d; --slot:#121a2d; --slot-line:#4a5b82;
  --you:#6684ff; --you-soft:#1d2858; --you-edge:#3550d0; --on-you:#ffffff;
  --good:#38d895; --on-good:#062a1a; --bad:#ff6a70; --bad-soft:#4a1a1f; --gold:#ffd23f;
  --r0:#ff7a6e; --r1:#ffb347; --r2:#2fd0c3; --r3:#a98bff; --r4:#ff6fb1; --r5:#4cc3f5; --r6:#8fd14f; --r7:#ff8a4c; --r8:#8b8cff;
  --ball-face:#ffffff; --ball-ink:#18263f;
  --panel:rgba(22,31,52,.9); --panel-line:rgba(230,236,250,.12); --scrim:rgba(14,21,37,.84);
  --sky-top:#070c1c; --sky-bot:#26245a; --fog:#161d3a; --spoke:#6f7fd0;
  --track-a:#33416a; --track-b:#2c3960; --track-band:#29355a; --lane-line:#8fa2e0; --wall:#4054a0; --wall-top:#ffd23f;
  --shoulder-a:#235a52; --shoulder-b:#1d4d47; --shoulder-c:#18413d;
  --card:#ffffff; --card-edge:#8e9cc0; --op:#ffc83d; --op-edge:#b98200; --on-op:#3b2a00;
  --runner:#ff8f45; --runner-dark:#b94d17; --runner-light:#ffd2ad; --runner-sole:#f4f6ff; --runner-band:#7f9aff; --runner-leaf:#45d77c;
  --prop-a:#2f8f62; --prop-b:#5d6987; --prop-c:#9b7ae6; --prop-d:#34905f; --prop-trunk:#6b4630; --gate:#8e9fe0; --gate-light:#ffd23f;
  color-scheme:dark;
}}
:root[data-theme="dark"]{
  --paper:#0e1525; --ink:#e6ecfa; --muted:#93a0bb;
  --tile:#1b2640; --tile-edge:#070b15; --given:#24304d; --slot:#121a2d; --slot-line:#4a5b82;
  --you:#6684ff; --you-soft:#1d2858; --you-edge:#3550d0; --on-you:#ffffff;
  --good:#38d895; --on-good:#062a1a; --bad:#ff6a70; --bad-soft:#4a1a1f; --gold:#ffd23f;
  --r0:#ff7a6e; --r1:#ffb347; --r2:#2fd0c3; --r3:#a98bff; --r4:#ff6fb1; --r5:#4cc3f5; --r6:#8fd14f; --r7:#ff8a4c; --r8:#8b8cff;
  --ball-face:#ffffff; --ball-ink:#18263f;
  --panel:rgba(22,31,52,.9); --panel-line:rgba(230,236,250,.12); --scrim:rgba(14,21,37,.84);
  --sky-top:#070c1c; --sky-bot:#26245a; --fog:#161d3a; --spoke:#6f7fd0;
  --track-a:#33416a; --track-b:#2c3960; --track-band:#29355a; --lane-line:#8fa2e0; --wall:#4054a0; --wall-top:#ffd23f;
  --shoulder-a:#235a52; --shoulder-b:#1d4d47; --shoulder-c:#18413d;
  --card:#ffffff; --card-edge:#8e9cc0; --op:#ffc83d; --op-edge:#b98200; --on-op:#3b2a00;
  --runner:#ff8f45; --runner-dark:#b94d17; --runner-light:#ffd2ad; --runner-sole:#f4f6ff; --runner-band:#7f9aff; --runner-leaf:#45d77c;
  --prop-a:#2f8f62; --prop-b:#5d6987; --prop-c:#9b7ae6; --prop-d:#34905f; --prop-trunk:#6b4630; --gate:#8e9fe0; --gate-light:#ffd23f;
  color-scheme:dark;
}
html,body{height:100%; margin:0; overflow:hidden; overscroll-behavior:none}
body{background:var(--paper); color:var(--ink); font-family:var(--font-body); -webkit-tap-highlight-color:transparent; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none}
button{font:inherit; color:inherit; cursor:pointer}
[hidden]{display:none!important}

#view{position:fixed; inset:0; width:100%; height:100%; display:block; touch-action:none; background:var(--sky-bot)}

/* Thumb slider (src/run/app/input.js): the lanes as dots just above a resting thumb; the lit dot is your lane. */
.steer-rail{position:fixed; left:0; top:0; height:0; pointer-events:none; opacity:0; transition:opacity .25s; z-index:5}
.steer-rail.show{opacity:1; transition:opacity .08s}
.steer-rail::before{content:""; position:absolute; left:-12px; right:-12px; top:-11px; height:22px; border-radius:11px; background:rgba(24,38,63,.38)}
.steer-rail i{position:absolute; top:-5px; width:10px; height:10px; margin-left:-5px; border-radius:50%; background:rgba(255,255,255,.7); transition:transform .08s}
.steer-rail i.on{background:var(--gold); transform:scale(1.6); box-shadow:0 0 0 2px rgba(24,38,63,.45)}
.steer-rail b{position:absolute; top:13px; width:0; height:0; margin-left:-6px; border:6px solid transparent; border-top:0; border-bottom:8px solid rgba(255,255,255,.85)}
@media (prefers-reduced-motion: reduce){ .steer-rail, .steer-rail.show, .steer-rail i{transition:none} }

/* HUD: sits over the canvas; only its controls take touches, the rest goes through to the race. */
#app{position:fixed; inset:0; pointer-events:none; box-sizing:border-box; display:grid; gap:6px;
  padding:max(8px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  grid-template-columns:auto minmax(0, 1fr); grid-template-rows:auto auto minmax(0, 1fr) auto;
  grid-template-areas:"hud hud" "goal rule" ". ." "expr expr"}
#app button{pointer-events:auto}
#app.prerace{visibility:hidden; opacity:0}   /* no HUD behind the start card and map before the first race (game.js startRace removes it) */
.hud{grid-area:hud; display:flex; align-items:center; gap:8px; min-width:0}
.chip{padding:6px 10px; border-radius:999px; border:1px solid var(--panel-line); background:var(--panel); font-size:12px; font-weight:800}
.iconchip{width:40px; height:40px; padding:0; display:grid; place-items:center; font:700 15px/1 var(--font-display); flex:none; box-shadow:0 2px 0 var(--tile-edge)}
.iconchip[aria-pressed="false"]{color:var(--muted); text-decoration:line-through}
.chip:focus-visible,.btn:focus-visible,.exprbar:focus-visible{outline:3px solid var(--you); outline-offset:2px}
.race{flex:1 1 auto; min-width:0; display:flex; align-items:center; gap:8px; padding:5px 10px 5px 6px; border-radius:16px; background:var(--panel); border:1px solid var(--panel-line)}
.place{flex:none; display:flex; align-items:baseline; gap:3px; padding:2px 9px; border-radius:11px; background:var(--ink); color:var(--paper)}
.place b{font:700 20px/1.05 var(--font-display); font-variant-numeric:tabular-nums}
.place span{font-size:11px; font-weight:800; opacity:.75}
.place.up b{animation:bump .4s ease}
.progress{position:relative; flex:1 1 auto; min-width:40px; height:22px}
.progress .bar{position:absolute; left:0; right:14px; top:8px; height:6px; border-radius:6px; background:color-mix(in srgb, var(--ink) 14%, transparent); overflow:hidden}
.progress .bar i{display:block; height:100%; width:100%; transform-origin:0 50%; transform:scaleX(0); background:var(--you); border-radius:6px}
.progress .dots{position:absolute; left:0; right:14px; top:0; bottom:0}
/* Each dot is a full-width, zero-height box moved by transform (a % of its own width is a % of the bar: no layout);
   ::before draws the dot. */
.progress .dots i{position:absolute; left:0; right:0; top:0; height:0}
.progress .dots i::before{content:""; position:absolute; top:6px; left:-5px; width:10px; height:10px; border-radius:50%; background:var(--c); opacity:.75; box-shadow:0 0 0 1.5px var(--panel)}
.progress .dots i.me{z-index:2}
.progress .dots i.me::before{top:3px; left:-8px; width:16px; height:16px; background:var(--runner); opacity:1; box-shadow:0 0 0 2px var(--panel), 0 1px 3px rgba(0,0,0,.3)}
.progress .flag{position:absolute; right:0; top:2px; width:12px; height:18px; border-radius:2px;
  background:repeating-conic-gradient(#1d2233 0 25%, #fff 0 50%) 0 0/6px 6px; box-shadow:0 0 0 1px var(--panel-line)}
.stat{flex:none; display:flex; flex-direction:column; align-items:center; padding:3px 10px; border-radius:14px; background:var(--panel); border:1px solid var(--panel-line)}
.stat .lab{font-size:9px; font-weight:800; letter-spacing:.08em; text-transform:uppercase; color:var(--muted)}
.stat b{font:600 18px/1.1 var(--font-display); font-variant-numeric:tabular-nums; color:var(--you)}
.stat.bump b{animation:bump .35s ease}
@keyframes bump{40%{transform:scale(1.25)}}

/* Goal: a big bingo ball, like Tilt Cube's */
.goalwrap{grid-area:goal; justify-self:start; display:flex; flex-direction:column; align-items:center; gap:2px}
.goallab{font-size:10px; font-weight:800; letter-spacing:.12em; text-transform:uppercase; color:var(--ink); background:var(--panel); padding:2px 9px; border-radius:999px}
.ball{--B:76px; position:relative; width:var(--B); height:var(--B); border-radius:50%; display:grid; place-items:center;
  font:700 calc(var(--B) * .4)/1 var(--font-display); color:var(--ball-ink); font-variant-numeric:tabular-nums;
  background:radial-gradient(circle at 50% 52%, var(--ball-face) 0 38%, transparent 39%), radial-gradient(circle at 34% 28%, color-mix(in srgb, var(--rc) 35%, #fff) 0, var(--rc) 45%, color-mix(in srgb, var(--rc) 60%, #000) 100%);
  box-shadow:0 6px 14px rgba(0,0,0,.28)}
.ball span{display:block; white-space:nowrap}
.ball.long span{font-size:.8em; letter-spacing:-.03em}
.ball.xlong span{font-size:.56em; letter-spacing:-.04em}
.ball.xxlong span{font-size:.42em; letter-spacing:-.04em}
/* Answer runs: the ball holds a formula, drawn as a wide pill with a white face so "12 × 11" stays big. */
.ball.goal.formula{width:auto; min-width:var(--B); height:calc(var(--B) * .78); border-radius:999px; padding:0 8px; box-sizing:border-box;
  background:linear-gradient(var(--ball-face), var(--ball-face)) padding-box, var(--rc) border-box; border:6px solid transparent}
.ball.goal.formula span{font-size:.72em; letter-spacing:-.02em; padding:0 6px}
.ball.goal.formula.f2 span{font-size:.62em} .ball.goal.formula.f3 span{font-size:.52em}   /* long bracketed formulas: "(4×10⁻³) ÷ (8×10³)" */
/* Second-chance facts (v4-H, src/run/topic/second.js): a ball that came back wears a small plaster on its rim; met first go,
   the plaster becomes a heart for a moment. A picture only (no text, nothing to learn), off the white face, never red. */
.ball.goal.second::after, .ball.goal.mended::after{content:''; position:absolute; top:-3px; right:-6px; pointer-events:none}
.ball.goal.second::after{width:24px; height:11px; border-radius:6px; transform:rotate(38deg);
  background:radial-gradient(circle at 50% 50%, #fbe9cf 0 3px, transparent 3.5px), linear-gradient(90deg, #e2ad7b, #f1c99e 30% 70%, #e2ad7b); box-shadow:0 1px 3px rgba(0,0,0,.35)}
.ball.goal.mended::after{content:'\2665\FE0E'; top:-10px; right:-8px; width:auto; height:auto; background:none; box-shadow:none; transform:none;
  font:400 24px/1 system-ui, sans-serif; color:#ff8ec6; text-shadow:0 1px 3px rgba(0,0,0,.35); animation:mended 1.4s ease-out both}
@keyframes mended{0%{transform:scale(.3); opacity:0} 25%{transform:scale(1.25); opacity:1} 45%{transform:scale(1)} 80%{opacity:1} 100%{transform:scale(1); opacity:0}}
@media (prefers-reduced-motion: reduce){ .ball.goal.mended::after{animation:none} }
html.calm .ball.goal.mended::after{animation:none}
.mend-heart{font:400 1.1em/1 system-ui, sans-serif; color:#ff8ec6}   /* results card chip: a heart and "3 mended" (second-ui.js) */
.goal.formula.pop{animation:formulapop .45s cubic-bezier(.3,1.6,.5,1)}
@keyframes formulapop{0%{transform:scale(.6)}100%{transform:none}}
.goal.pop span{animation:ballpop .6s cubic-bezier(.3,1.8,.5,1)}
.goal.pop{animation:goalpop .6s cubic-bezier(.3,1.6,.5,1)}
@keyframes ballpop{0%{transform:scale(.3) rotate(-120deg)}100%{transform:none}}
@keyframes goalpop{0%{transform:scale(.6)}60%{transform:scale(1.12)}}
.speedo{width:60px; height:5px; border-radius:5px; background:color-mix(in srgb, var(--ink) 16%, transparent); overflow:hidden; margin-top:3px}
.speedo i{display:block; height:100%; width:100%; transform-origin:0 50%; transform:scaleX(.2); background:linear-gradient(90deg, var(--r5), var(--gold), var(--r0)); border-radius:5px}

/* Rule pill (worked example) */
.rulebar{grid-area:rule; justify-self:start; align-self:center; max-width:calc(100% - 92px); min-height:32px; box-sizing:border-box; display:flex; align-items:center; gap:7px; padding:3px 12px 3px 4px; border-radius:999px;
  background:var(--given); border:2px solid var(--panel-line); font:600 14px/1.2 var(--font-display); color:var(--ink); cursor:pointer;
  box-shadow:0 2px 0 var(--tile-edge); transition:transform .15s cubic-bezier(.3,1.6,.5,1), border-color .2s, opacity .2s; touch-action:manipulation}
.rulebar .rt{min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.rulebar .rq{flex:none; width:22px; height:22px; border-radius:50%; display:grid; place-items:center; background:var(--you); color:var(--on-you); font:700 14px/1 var(--font-display)}
.rulebar:hover{border-color:var(--you)}
.rulebar:active{transform:translateY(2px) scale(.97); box-shadow:0 0 0 var(--tile-edge)}
.rulebar[aria-expanded="true"]{border-color:var(--you); background:var(--you-soft)}
.rulebar:focus-visible{outline:3px solid var(--you); outline-offset:2px}
.rulebar.plain{padding-right:10px; font:800 11px/1 var(--font-body); letter-spacing:.08em; text-transform:uppercase; color:var(--muted); background:var(--panel)}
.rulebar.plain .rq{width:20px; height:20px; font-size:13px; letter-spacing:0; background:var(--given); color:var(--you); box-shadow:inset 0 0 0 2px var(--you)}
.rulebar.off{visibility:hidden; pointer-events:none!important}
/* Worked-example sheet (packages/core/ui/example-sheet.js) */
.ex-scrim{position:fixed; inset:0; z-index:30; background:color-mix(in srgb, var(--paper) 35%, transparent)}
.ex-sheet{position:fixed; z-index:31; left:50%; width:min(420px, calc(100vw - 32px)); max-height:min(60vh, 340px); box-sizing:border-box; transform:translateX(-50%);
  padding:12px 14px 14px; border-radius:18px; background:var(--tile); border:1px solid var(--panel-line); box-shadow:0 6px 0 var(--tile-edge), 0 18px 40px rgba(0,0,0,.22);
  display:flex; flex-direction:column; gap:8px; transform-origin:50% -10px; overflow:auto}
.ex-sheet::before{content:''; position:absolute; top:-7px; left:var(--axo, 50%); width:12px; height:12px; margin-left:-6px; background:var(--tile); border-left:1px solid var(--panel-line); border-top:1px solid var(--panel-line); transform:rotate(45deg)}
.ex-sheet.in{animation:exIn .34s cubic-bezier(.3,1.5,.5,1) both}
.ex-sheet.out{animation:exOut .16s ease-in both}
@keyframes exIn{0%{opacity:0; transform:translateX(-50%) translateY(-10px) scale(.86)}}
@keyframes exOut{to{opacity:0; transform:translateX(-50%) translateY(-6px) scale(.94)}}
.ex-head{display:grid; grid-template-columns:1fr auto; align-items:center; column-gap:8px}
.ex-kicker{grid-column:1; font-size:10px; font-weight:800; letter-spacing:.1em; text-transform:uppercase; color:var(--you)}
.ex-head h3{grid-column:1; margin:0; font:700 20px/1.1 var(--font-display)}
.ex-close{grid-column:2; grid-row:1 / span 2; width:40px; height:40px; border-radius:50%; border:0; background:var(--given); font:700 16px/1 var(--font-body); color:var(--muted); padding:0}
.ex-close:focus-visible{outline:3px solid var(--you); outline-offset:2px}
.ex-rule{margin:0; padding:6px 10px; border-radius:10px; background:var(--you-soft); color:var(--ink); font:600 14px/1.3 var(--font-display)}
.ex-lines{margin:0; padding:0; list-style:none; counter-reset:ex; display:flex; flex-direction:column; gap:6px}
.ex-lines li{counter-increment:ex; display:grid; grid-template-columns:22px 1fr; gap:8px; align-items:start; font:500 16px/1.35 var(--font-display); color:var(--ink); overflow-wrap:anywhere}
.ex-lines li::before{content:counter(ex); width:22px; height:22px; border-radius:50%; display:grid; place-items:center; background:var(--given); color:var(--muted); font:700 12px/1 var(--font-body); margin-top:1px}
.ex-sheet.in .ex-lines li{animation:exLine .4s cubic-bezier(.3,1.5,.5,1) both; animation-delay:calc(120ms + var(--i, 0) * 110ms)}
@keyframes exLine{0%{opacity:0; transform:translateX(-12px)}}

/* Mini map (src/run/hud/minimap.js draws a canvas here) */
.minimap-slot{position:fixed; width:84px; height:84px; pointer-events:none;
  top:calc(max(8px, env(safe-area-inset-top, 0px)) + 56px); right:max(12px, env(safe-area-inset-right, 0px))}
.minimap-slot canvas{display:block}
/* Results: final standings (src/run/progress/results.js), two columns so the card never scrolls */
.standings{margin:0; padding:0; list-style:none; display:grid; grid-template-columns:1fr 1fr; grid-template-rows:repeat(4, auto); grid-auto-flow:column; column-gap:10px; row-gap:2px}
.standings li{display:grid; grid-template-columns:34px minmax(0, 1fr) auto; align-items:center; gap:4px; padding:3px 6px 3px 4px; border-radius:9px; font-size:13px; font-weight:700; min-width:0}
.standings .pl{font:600 13px/1 var(--font-display); color:var(--muted); display:flex; align-items:center; gap:4px}
.standings .pl::before{content:''; flex:none; width:8px; height:8px; border-radius:50%; background:var(--c)}
.standings .nm{white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.standings .tm{font-variant-numeric:tabular-nums; color:var(--muted); font-size:12px}
.standings li.me{background:var(--you-soft); box-shadow:inset 0 0 0 2px var(--you)}
.standings li.me .nm,.standings li.me .pl{color:var(--ink)}
/* Short portrait phones: tighten the results card so the standings fit without scrolling */
@media (max-aspect-ratio: 5/4) and (max-height:780px){
  #endOv .card{gap:9px; padding:16px 18px} #endOv .medal{width:48px; height:48px; font-size:20px} #endOv h2{font-size:26px}
  #endOv .tally{gap:2px} #endOv .tally div{padding:3px 0; font-size:14px} #endOv .tally b{font-size:17px}
  #endOv .btns{gap:8px} #endOv .btn{padding:10px 14px; font-size:18px} #endOv .btn.ghost{font-size:16px}
}
/* Short landscape: the results card goes two columns (summary left, standings + buttons right) so it never scrolls */
@media (min-aspect-ratio: 5/4) and (max-height:560px){
  #endOv .card{max-width:780px; display:grid; grid-template-columns:minmax(0, .9fr) minmax(0, 1.1fr); column-gap:20px; row-gap:8px; align-items:start;
    grid-template-areas:"medal st" "title st" "tally note" "tally btns"; grid-template-rows:auto auto auto 1fr}
  #endOv .medal{grid-area:medal; justify-self:center; width:48px; height:48px; font-size:20px} #endOv h2{grid-area:title; font-size:24px}
  #endOv .tally{grid-area:tally} #endOv .tally div{padding:3px 0; font-size:14px} #endOv .tally b{font-size:17px}
  #endOv .standings{grid-area:st; align-self:center} #endOv .practice{grid-area:note; padding:6px 10px; font-size:14px}
  #endOv .btns{grid-area:btns; display:grid; grid-template-columns:1fr 1fr; gap:8px} #endOv .btns .btn{padding:10px 12px; font-size:16px} #endOv #nextBtn{grid-column:1 / -1}
}

/* The formula you are building */
.exprwrap{grid-area:expr; justify-self:center; max-width:100%; min-width:0}
.exprbar{display:flex; align-items:center; gap:8px; max-width:100%; box-sizing:border-box; padding:7px 8px 7px 10px; border-radius:20px; border:2px solid var(--panel-line);
  background:var(--panel); box-shadow:0 4px 0 var(--tile-edge), 0 10px 24px rgba(0,0,0,.14); touch-action:manipulation; transition:background .2s, border-color .2s}
.slots{display:flex; align-items:center; gap:6px; min-width:0}
.slot{flex:none; box-sizing:border-box; min-width:46px; height:46px; padding:0 6px; display:grid; place-items:center; border-radius:12px; border:2px dashed var(--slot-line); background:var(--slot);
  font:600 23px/1 var(--font-display); color:var(--ink); white-space:nowrap; font-variant-numeric:tabular-nums}
.slot.op{min-width:40px; width:40px; height:40px; padding:0; border-radius:50%}
.slot.next{border-style:solid; border-color:var(--you); box-shadow:0 0 0 3px color-mix(in srgb, var(--you) 22%, transparent)}
.slot.full{border:2px solid var(--card-edge); border-bottom-width:4px; background:var(--card); color:var(--ball-ink)}
.slot.op.full{background:var(--op); border-color:var(--op-edge); color:var(--on-op)}
.slot.long{font-size:17px} .slot.xlong{font-size:13px; letter-spacing:-.02em}
.slot.op.word{font-size:13px; font-family:var(--font-body); font-weight:800}
.slot.pop{animation:slotpop .35s cubic-bezier(.3,1.7,.5,1)}
@keyframes slotpop{0%{transform:scale(.4)}}
.clr{flex:none; width:28px; height:28px; border-radius:50%; display:grid; place-items:center; background:var(--given); color:var(--muted); font:800 13px/1 var(--font-body); opacity:.35; transition:opacity .2s}
.exprbar.has .clr{opacity:1}
.exprbar.bad{background:var(--bad-soft); border-color:var(--bad)}
.exprbar.bad .slot.full{border-color:var(--bad); color:var(--bad); background:var(--card)}
.exprbar.bad{animation:shake .42s ease}
.exprbar.ok{background:color-mix(in srgb, var(--good) 22%, var(--panel)); border-color:var(--good)}
.exprbar.ok .slot.full{border-color:var(--good)}
.exprbar .eqv{font:700 22px/1 var(--font-display); color:var(--good); padding:0 2px; white-space:nowrap}
.exprbar .eqv.live{color:var(--ink, currentColor); opacity:.75}
@keyframes shake{15%{transform:translateX(-7px)}35%{transform:translateX(7px)}55%{transform:translateX(-4px)}75%{transform:translateX(3px)}}

.toast{position:fixed; left:50%; bottom:calc(max(10px, env(safe-area-inset-bottom, 0px)) + 84px); transform:translateX(-50%); max-width:calc(100vw - 32px); overflow:hidden; text-overflow:ellipsis; pointer-events:none; padding:7px 14px; border-radius:999px; background:var(--panel); border:1px solid var(--panel-line);
  font:700 15px/1.2 var(--font-body); color:var(--ink); white-space:nowrap; opacity:0; transition:opacity .25s; box-shadow:0 6px 18px rgba(0,0,0,.15)}
.toast.on{opacity:1}
.count{position:fixed; left:50%; top:40%; transform:translate(-50%,-50%); pointer-events:none; font:700 clamp(64px, 22vmin, 150px)/1 var(--font-display); color:var(--ink);
  text-shadow:0 5px 0 var(--paper), 0 0 22px var(--paper)}
.count.go{color:var(--good)}
.count.tick{animation:tick .5s cubic-bezier(.3,1.6,.5,1)}
@keyframes tick{0%{transform:translate(-50%,-50%) scale(1.8); opacity:0}}

/* FX */
#fx{position:fixed; inset:0; pointer-events:none; z-index:50; overflow:hidden}
.fly{position:fixed; left:0; top:0; display:grid; place-items:center; min-width:34px; height:34px; padding:0 6px; box-sizing:border-box; border-radius:10px; font:600 19px/1 var(--font-display);
  background:var(--card); color:var(--ball-ink); box-shadow:0 4px 10px rgba(0,0,0,.25); transition:transform .32s cubic-bezier(.5,0,.6,1), opacity .32s; will-change:transform}
.fly.op{border-radius:50%; background:var(--op); color:var(--on-op); min-width:34px; width:34px; padding:0}
/* (subtle on purpose, user 2026-11-10: small, see-through, a soft fade and drift, no pop or spin, gone in under a second) */
/* In-race praise sits on a plate of its colour (play test 2026-11-12, G1 forest/f/0346: yellow words on a yellow-lit
   road): readable on every world's road, lava, sun, snow, candy and space included. */
.praise{position:fixed; left:50%; top:var(--y); transform:translate(-50%,-50%); font-family:var(--font-display); font-weight:600; font-size:clamp(17px,4.6vw,24px); white-space:nowrap;
  padding:2px 14px 3px; border-radius:999px; background:var(--c); color:var(--pc, #ffffff); border:2px solid rgba(255,255,255,.9); box-shadow:0 2px 0 rgba(15,26,46,.28), 0 0 0 1px rgba(15,26,46,.25);
  pointer-events:none; animation:praise .9s ease-out forwards}
.praise.good{--pc:var(--on-good)} .praise.gold{--pc:#2b2000}
@keyframes praise{0%{opacity:0; transform:translate(-50%,-30%)}20%{opacity:.95; transform:translate(-50%,-50%)}65%{opacity:.95; transform:translate(-50%,-60%)}100%{opacity:0; transform:translate(-50%,-80%)}}
@media (prefers-reduced-motion: reduce){ .praise{animation-name:praise-calm} }
html.calm .praise{animation-name:praise-calm}
@keyframes praise-calm{0%{opacity:0}20%{opacity:.95}65%{opacity:.95}100%{opacity:0}}
/* (v5-F) The finish praise ("6 formulas!"): the same plate, a little larger, held until the results card (about 1.75 s);
   it rises a touch and settles, never pops; Calm and reduced motion: a plain fade in and out. */
.praise.fin{font-size:clamp(20px,5.4vw,30px); padding:3px 18px 4px; animation:praise-fin 1.95s ease-out forwards}
@keyframes praise-fin{0%{opacity:0; transform:translate(-50%,-30%)}18%{opacity:.97; transform:translate(-50%,-50%)}82%{opacity:.97; transform:translate(-50%,-56%)}100%{opacity:0; transform:translate(-50%,-60%)}}
@media (prefers-reduced-motion: reduce){ .praise.fin{animation-name:praise-fin-calm} }
html.calm .praise.fin{animation-name:praise-fin-calm}
@keyframes praise-fin-calm{0%{opacity:0}18%{opacity:.97}82%{opacity:.97}100%{opacity:0}}
.confetti{position:fixed; inset:0; width:100%; height:100%; pointer-events:none; z-index:60}

/* Cards (start, results, pause) */
.overlay{position:fixed; inset:0; z-index:40; display:grid; place-items:center; background:var(--scrim); overflow:auto; overscroll-behavior:contain;
  padding-left:max(16px, env(safe-area-inset-left, 0px)); padding-right:max(16px, env(safe-area-inset-right, 0px)); padding-block:max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-bottom, 0px))}
.card{width:100%; max-width:420px; box-sizing:border-box; padding:22px 20px; border-radius:22px; background:var(--tile); border:1px solid var(--panel-line); box-shadow:0 8px 0 var(--tile-edge),0 24px 50px rgba(0,0,0,.18); display:flex; flex-direction:column; gap:14px; animation:cardIn .4s cubic-bezier(.3,1.4,.5,1)}
@keyframes cardIn{0%{transform:translateY(20px) scale(.95); opacity:0}}
h1,h2{margin:0; font-family:var(--font-display); font-weight:700; line-height:1.05; text-wrap:balance; text-align:center}
h1{font-size:40px} h2{font-size:30px}
.lede{margin:0; font-size:15px; line-height:1.45; color:var(--muted); font-weight:600}
.rules{margin:0; padding-left:20px; display:flex; flex-direction:column; gap:7px; font-size:14px; line-height:1.4}
.k-bad{color:var(--bad); font-weight:800}
.btn{border:0; border-radius:14px; padding:14px 18px; font-family:var(--font-display); font-weight:600; font-size:20px; background:var(--you); color:var(--on-you); box-shadow:0 5px 0 var(--you-edge)}
.btn:active{transform:translateY(3px); box-shadow:0 2px 0 var(--you-edge)}
.btn.ghost{background:var(--given); color:var(--ink); box-shadow:0 5px 0 var(--tile-edge); font-size:17px}
.btn[disabled]{opacity:.55; pointer-events:none}
.btns{display:flex; flex-direction:column; gap:10px}
/* Calm motion switch (start card, pause menu): a quiet pill, filled when on */
.calm{align-self:center; min-height:34px; padding:6px 14px; border-radius:999px; border:2px solid var(--panel-line); background:var(--given); font:600 14px/1 var(--font-display); color:var(--muted)}
.calm span{font-weight:700; margin-right:2px}
.calm[aria-checked="true"]{background:var(--you-soft); border-color:var(--you); color:var(--ink)}
.calm[aria-checked="true"]::after{content:" · on"}
.calm:focus-visible{outline:3px solid var(--you); outline-offset:2px}
.tally{display:flex; flex-direction:column; gap:4px}
.tally div{display:flex; justify-content:space-between; align-items:baseline; font-weight:700; font-size:15px; padding:5px 0; border-bottom:1px solid var(--panel-line)}
.tally b{font-family:var(--font-display); font-size:20px; font-variant-numeric:tabular-nums; color:var(--you)}
.practice{margin:0; padding:8px 12px; border-radius:12px; background:var(--you-soft); color:var(--ink); text-align:center; font-family:var(--font-display); font-weight:500; font-size:15px}
.medal{align-self:center; width:64px; height:64px; border-radius:50%; display:grid; place-items:center; font:700 26px/1 var(--font-display); color:#3b2a00;
  background:radial-gradient(circle at 35% 30%, #fff6c4, var(--mc, #ffc83d) 55%, color-mix(in srgb, var(--mc, #ffc83d) 60%, #000)); box-shadow:0 5px 0 color-mix(in srgb, var(--mc, #ffc83d) 55%, #000), 0 10px 20px rgba(0,0,0,.2)}
.demo{display:flex; justify-content:center; align-items:center; gap:7px}
.demo .dtile{width:40px; height:40px; border-radius:10px; display:grid; place-items:center; background:var(--card); border:2px solid var(--card-edge); border-bottom-width:5px; font:600 22px/1 var(--font-display); color:var(--ball-ink); animation:demo 2.4s ease-in-out infinite}
.demo .dop{width:34px; height:34px; border-radius:50%; display:grid; place-items:center; background:var(--op); border-bottom:4px solid var(--op-edge); font:700 22px/1 var(--font-display); color:var(--on-op); animation:demo 2.4s ease-in-out infinite .15s}
.demo .dtile:nth-child(3){animation-delay:.3s}
.demo .deq{font:700 24px/1 var(--font-display); color:var(--muted)}
.demo .ball{--B:44px; animation:demo 2.4s ease-in-out infinite .45s}
@keyframes demo{0%,100%{transform:translateY(0)}20%{transform:translateY(-7px) rotate(-6deg)}40%{transform:translateY(0)}}

/* Start card: strand tabs, the strand's topics with a grade pill each (2026-11-12, menu-review.md Option 1; game.js,
   src/run/topic/strands.js). The card never grows past the screen: the topic list is what scrolls (fading at its bottom edge
   while more is below), so tabs, Difficulty and Race always stay in view. Portrait: one column; landscape and desktop:
   two (play.css). */
.card.start{max-width:460px; gap:12px; overflow:auto; overscroll-behavior:contain;
  max-height:calc(100dvh - max(16px, env(safe-area-inset-top, 0px)) - max(16px, env(safe-area-inset-bottom, 0px)))}
.card.start > :not(.pick){flex-shrink:0} .card.start > *{min-width:0}
.strands{display:grid; grid-template-columns:repeat(5, minmax(0, 1fr)); gap:6px}
.strand{min-height:46px; min-width:44px; padding:4px 2px; border-radius:14px; border:2px solid var(--panel-line); background:var(--given); box-shadow:0 3px 0 var(--tile-edge);
  font:600 19px/1 var(--font-display); color:var(--ink); white-space:nowrap; display:flex; align-items:center; justify-content:center}
.strand > span{display:inline-flex; align-items:center}
.strand[aria-selected="true"]{background:var(--you); border-color:var(--you-edge); color:var(--on-you); box-shadow:0 3px 0 var(--you-edge)}
.pick{display:flex; flex-direction:column; gap:8px; flex:1 1 auto; min-height:min(190px, 40dvh)}
.strand-name{flex:none; font-size:19px; text-align:left; text-wrap:nowrap; overflow:hidden; text-overflow:ellipsis}
.topics{display:grid; grid-template-columns:repeat(auto-fill, minmax(132px, 1fr)); gap:8px; align-content:start; flex:0 1 auto; min-height:0; overflow:auto; overscroll-behavior:contain;
  padding:3px 3px 6px; margin:-3px -3px 0}   /* (room for the focus ring and the cards' bottom edge) */
.topics.more{-webkit-mask-image:linear-gradient(#000 calc(100% - 34px), transparent); mask-image:linear-gradient(#000 calc(100% - 34px), transparent)}
.topic{display:flex; flex-direction:column; align-items:flex-start; gap:4px; padding:8px 10px; border-radius:14px; border:2px solid var(--panel-line); background:var(--given); box-shadow:0 3px 0 var(--tile-edge); text-align:left; min-width:0}   /* (no min-height: rows would shrink to it and cut the sample when the list scrolls) */
.topic .tline{display:flex; align-items:flex-start; gap:6px; max-width:100%}
.topic b{font-family:var(--font-display); font-weight:600; font-size:16px; line-height:1.15; min-width:0}
.gpill{flex:none; margin-top:-1px; padding:2px 6px; border-radius:999px; border:1.5px solid var(--panel-line); background:var(--tile); font:700 13px/1.15 var(--font-display); color:var(--muted)}
.topic .sample{display:block; font:600 15px/1.3 var(--font-display); color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%}
.topic .sample .mx-f.fr,.modehint .mx-f.fr{font-size:.9em}
.topic[aria-checked="true"]{border-color:var(--you); background:var(--you-soft); box-shadow:0 3px 0 var(--you)}
.topic[aria-checked="true"] .gpill{border-color:var(--you); color:var(--ink)}
.start-foot{display:flex; flex-wrap:wrap; align-items:center; justify-content:center; gap:6px 14px}
.start-foot .how[open]{flex-basis:100%}
.diffs{display:flex; justify-content:center; align-items:center; gap:6px}
.diffs .lab{font-size:11px; font-weight:800; letter-spacing:.08em; text-transform:uppercase; color:var(--muted); margin-right:2px}
.diff{min-width:64px; min-height:36px; padding:6px 12px; border-radius:999px; border:2px solid var(--panel-line); background:var(--given); font:600 14px/1 var(--font-display); color:var(--ink)}
.diff[aria-checked="true"]{background:var(--you); border-color:var(--you-edge); color:var(--on-you)}
.diff:focus-visible,.strand:focus-visible,.topic:focus-visible{outline:3px solid var(--you); outline-offset:2px}
.modehint{flex:none; margin:0; font-size:14px; line-height:1.45; font-weight:600; text-align:center; color:var(--ink); background:var(--given); border-radius:12px; padding:8px 10px}
.how summary{cursor:pointer; font-weight:800; font-size:14px; color:var(--muted)}
.how[open]{display:flex; flex-direction:column; gap:10px}

/* Short phones */
@media (max-height:700px){ .ball.goal{--B:64px} .goallab{display:none} .slot{min-width:42px; height:42px; font-size:21px} .slot.op{width:36px; min-width:36px; height:36px} }
@media (max-width:360px){ .stat{display:none} }

/* Landscape: the HUD moves to the sides, leaving the middle for the track. */
@media (min-aspect-ratio: 5/4){
  #app{grid-template-columns:minmax(150px, 300px) minmax(0, 1fr) minmax(96px, 300px); grid-template-rows:auto auto auto minmax(0, 1fr) auto;
    grid-template-areas:"hud hud hud" "goal . ." "rule . ." ". . ." "expr expr ."}
  .hud{max-width:760px; width:100%; justify-self:center}
  .goalwrap{justify-self:start; flex-direction:row; gap:10px; align-items:center}
  .goallab{writing-mode:horizontal-tb}
  .goalwrap .speedo{display:none}
  .rulebar{justify-self:start; align-self:start; max-width:100%}
  .exprwrap{justify-self:start}
  .minimap-slot{top:auto; bottom:max(10px, env(safe-area-inset-bottom, 0px)); width:96px; height:96px}
  .toast{bottom:max(14px, env(safe-area-inset-bottom, 0px)); left:calc(50% + 60px)}
}
@media (min-aspect-ratio: 5/4) and (max-height:500px){
  #app{gap:4px}
  .ball.goal{--B:58px}
  .iconchip{width:34px; height:34px}
  .place b{font-size:17px} .stat b{font-size:16px}
  .slot{min-width:38px; height:38px; font-size:19px; border-radius:10px} .slot.op{width:32px; min-width:32px; height:32px}
  .exprbar{padding:5px 6px 5px 8px; gap:6px}
  .clr{width:24px; height:24px}
  .card{padding:16px 16px; gap:10px}
}
@media (prefers-reduced-motion: reduce){ .card,.goal.pop,.goal.pop span,.slot.pop,.exprbar.bad,.count.tick,.demo *,.ex-sheet.in,.ex-sheet.out,.ex-sheet.in .ex-lines li,.place.up b,.stat.bump b{animation:none!important} .fly{transition:none} }
/* The in-game Calm motion switch (game.js sets html.calm) does the same as the OS setting */
html.calm :is(.card,.goal.pop,.goal.pop span,.slot.pop,.exprbar.bad,.count.tick,.demo *,.ex-sheet.in,.ex-sheet.out,.ex-sheet.in .ex-lines li,.place.up b,.stat.bump b,.wr-gauge.wr-pulse,.wr-chip,.exprbar.ok .slot.full,.exprbar.pl-grow,.pl-chip){animation:none!important}
html.calm .fly{transition:none} html.calm .pl-chip{opacity:1}
