/* Math HQ - playbook navy, chalk lines, jersey numerals, basketball orange. Greens are reserved for progress. */
:root {
  --bg: #0f1c3a; --bg2: #0b1530; --panel: #172a52; --panel2: #1d3466; --line: #2f4a86;
  --chalk: #eef3ff; --muted: #a3b4d8; --orange: #ff8a1f; --orange2: #ffb057; --gold: #ffc93c;
  --amber: #ffb648; --good: #46e07a;
  --h0: #2a3556; --h1: #1d5b3c; --h2: #1f8a4a; --h3: #2fc05e; --h4: #63ff93;
  --jersey: Impact, Haettenschweiler, "Arial Narrow Bold", "Roboto Condensed", "Arial Black", sans-serif;
  --body: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--chalk); font: 17px/1.5 var(--body); -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--jersey); font-weight: 400; letter-spacing: .03em; line-height: 1.1; margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.2rem; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.muted { color: var(--muted); }
.hide { display: none !important; }

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.rail { background: var(--bg2); border-right: 2px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: var(--vb, 0px); height: calc(100vh - var(--vb, 0px)); height: calc(100dvh - var(--vb, 0px)); overflow-y: auto; overscroll-behavior: contain; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
.rail .brand { font-family: var(--jersey); font-size: 1.7rem; letter-spacing: .05em; padding: 0 10px 14px; }
.rail .brand span { color: var(--orange); }
.rail a.nav { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; color: var(--chalk); text-decoration: none; font-weight: 700; border: 2px solid transparent; }
.rail a.nav .ico { font-size: 1.35rem; width: 1.6rem; text-align: center; }
.rail a.nav:hover { background: var(--panel); }
.rail a.nav.on { background: var(--panel); border-color: var(--orange); }
.rail .spacer { flex: 1; }
.rail .who { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--panel); border-radius: 12px; border: 0; text-align: left; width: 100%; }
.rail .who .av { font-size: 1.7rem; }
.rail .who b { display: block; line-height: 1.1; }
.rail .who small { color: var(--muted); }
.rail .who .wtxt { flex: 1; min-width: 0; }
.rail .who .xp { display: block; margin-top: 3px; font-weight: 800; color: var(--gold); font-size: .95rem; transition: transform .25s; transform-origin: left center; }
.rail .who .xp em { font-style: normal; font-weight: 600; color: var(--muted); font-size: .8rem; margin-left: 6px; }
.rail .who .xp.grew { transform: scale(1.18); }
.rail .who .xpbar { display: block; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .12); margin: 4px 0 5px; overflow: hidden; }
.rail .who .xpbar i { display: block; height: 100%; border-radius: 3px; background: var(--gold); transition: width .8s ease-out; }
.rail .row { display: flex; gap: 8px; margin-top: 8px; }
.rail .mini { flex: 1; background: transparent; border: 2px solid var(--line); border-radius: 10px; padding: 8px 4px; min-height: 44px; white-space: nowrap; font-size: .85rem; color: var(--muted); }
.rail .mini.snd[aria-pressed="true"] { color: var(--chalk); border-color: var(--good); }
/* 100vh on an iPad is the screen with Safari's bars hidden, so the foot of the menu sat below the fold; dvh is what is showing.
   On short screens the menu also tightens so Grown-ups and the sound switch stay on screen without scrolling. */
@media (min-width: 821px) and (max-height: 800px) {
  .rail { padding-top: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); gap: 3px; }
  .rail .brand { font-size: 1.4rem; padding-bottom: 6px; }
  .rail a.nav { padding: 8px 12px; line-height: 1.15; }
  .rail a.nav .ico { line-height: 1; }
  .rail .who { padding: 7px 10px; }
  .rail .row { margin-top: 4px; }
}
@media (min-width: 821px) and (max-height: 640px) {
  .rail a.nav { padding: 5px 12px; }
  .rail .brand { display: none; }
}
.app.norail { grid-template-columns: 1fr; padding-bottom: 0; }
.app.norail .rail { display: none; }
.app.norail .main { margin: 0 auto; }
.main { padding: clamp(16px, 3vw, 36px); max-width: 1100px; width: 100%; outline: 0; }

.btn { background: var(--orange); color: #1a1200; border: 0; border-radius: 14px; padding: 14px 26px; font-family: var(--jersey); font-size: 1.35rem; letter-spacing: .05em; box-shadow: 0 5px 0 #b85a00; transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #b85a00; }
.btn.big { font-size: 1.9rem; padding: 18px 40px; }
.btn.ghost { background: transparent; color: var(--chalk); border: 2px solid var(--line); box-shadow: none; font-family: var(--body); font-size: 1rem; font-weight: 700; letter-spacing: 0; padding: 12px 20px; }
.btn.ghost:active { transform: none; background: var(--panel); }
.btn[disabled] { opacity: .45; cursor: default; }

.panel { background: var(--panel); border: 2px solid var(--line); border-radius: var(--r); padding: 20px; }
.grid2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
.stack { display: grid; gap: 18px; }
.stack > *, .grid2 > *, .panel { min-width: 0; }
.lede { font-size: 1.15rem; color: var(--muted); margin-top: 6px; max-width: 60ch; }

/* home: the play card is drawn like a play on a chalkboard */
.playcard { position: relative; padding: 28px; border-radius: 20px; border: 3px solid var(--chalk); background:
  repeating-linear-gradient(0deg, transparent 0 46px, rgba(255,255,255,.05) 46px 48px), var(--panel2); overflow: hidden; }
.playcard .sample { font-family: var(--jersey); font-size: clamp(4rem, 13vw, 8rem); line-height: 1; letter-spacing: .02em; }
.playcard .sample i { font-style: normal; color: var(--orange); padding: 0 .12em; }
.playcard .sample .q { color: var(--gold); }
.playcard p { margin: 10px 0 22px; font-size: 1.15rem; max-width: 34ch; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { background: var(--bg2); border: 2px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 700; }
.chip b { font-family: var(--jersey); font-weight: 400; font-size: 1.2rem; letter-spacing: .04em; color: var(--gold); margin-right: 4px; }
.tile .num { font-family: var(--jersey); font-size: 3rem; line-height: 1; color: var(--gold); }
.tile .num small { font-size: 1.2rem; color: var(--muted); }
.bar { height: 14px; background: var(--bg2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--h2), var(--h4)); border-radius: 999px; min-width: 6px; }
.bar.gold > i { background: linear-gradient(90deg, var(--orange), var(--gold)); }
.keys { display: flex; gap: 8px; font-size: 1.9rem; }
.keys span { filter: grayscale(1) brightness(.5); }
.keys span.on { filter: none; }

/* session */
.arena { max-width: 560px; margin: 0 auto; text-align: center; }
.dots { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.dots i { width: 22px; height: 8px; border-radius: 4px; background: var(--h0); }
.dots i.ok { background: var(--h4); } .dots i.slow { background: var(--h2); } .dots i.miss { background: var(--amber); } .dots i.now { background: var(--chalk); }
.timer { height: 8px; background: var(--bg2); border-radius: 4px; overflow: hidden; margin: 0 auto 6px; max-width: 320px; position: relative; }
.timer i { display: block; height: 100%; width: 100%; background: var(--good); transform-origin: left; }
.timer b { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: var(--chalk); opacity: .85; }
.fact { font-family: var(--jersey); font-size: clamp(4.5rem, 20vw, 9rem); line-height: 1.05; letter-spacing: .02em; margin: 10px 0 0; }
.fact i { font-style: normal; color: var(--orange); padding: 0 .1em; }
.answer { font-family: var(--jersey); font-size: clamp(3rem, 12vw, 5rem); min-height: 1.25em; line-height: 1.2; border-bottom: 5px solid var(--chalk); width: 4ch; margin: 0 auto 6px; color: var(--gold); }
.answer.ok { color: var(--h4); border-color: var(--h4); }
.answer.miss { color: var(--amber); border-color: var(--amber); }
.said { min-height: 3.4em; font-size: 1.25rem; font-weight: 700; padding-top: 6px; }
.said.ok { color: var(--h4); } .said.miss { color: var(--amber); }
.said small { display: block; color: var(--gold); font-family: var(--jersey); font-size: 1.3rem; letter-spacing: .05em; font-weight: 400; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 360px; margin: 6px auto 0; }
.pad button { background: var(--panel); border: 2px solid var(--line); border-radius: 14px; font-family: var(--jersey); font-size: 2rem; padding: 12px 0; box-shadow: 0 4px 0 var(--bg2); touch-action: manipulation; }
.pad button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--bg2); }
.pad button.go { background: var(--orange); color: #1a1200; border-color: var(--orange); }
.pulse { animation: pulse .45s ease-out; }
@keyframes pulse { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
.quit { margin-top: 18px; background: none; border: 0; color: var(--muted); text-decoration: underline; }
/* practice rounds: combo, the fix-it step after a miss, XP pop */
.combo { min-height: 1.5em; font-family: var(--jersey); font-size: 1.35rem; letter-spacing: .05em; color: var(--gold); }
.arena.practice .said { min-height: 5.6em; }
.said .hint { display: block; color: var(--chalk); font-size: 1rem; font-weight: 600; max-width: 34ch; margin: 2px auto 0; }
.said .xpop { display: block; color: var(--gold); font-family: var(--jersey); font-weight: 400; font-size: 1.15rem; letter-spacing: .05em; animation: xpop .6s ease-out both; }
@keyframes xpop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.answer.fix { border-bottom-style: dashed; border-color: var(--amber); }
.shake { animation: shake .3s ease-in-out; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* today's training: power-round pips and quests */
.pips { display: inline-flex; gap: 4px; margin-left: 8px; vertical-align: middle; }
.pips i { font-style: normal; filter: grayscale(1) brightness(.5); }
.pips i.on { filter: none; }
.train .actions { margin-top: 14px; }
.quests { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.quests li { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.quests li b { font-family: var(--jersey); font-weight: 400; font-size: 1.15rem; letter-spacing: .04em; color: var(--gold); }
.quests li em { font-style: normal; font-weight: 600; font-size: .9rem; color: var(--muted); margin-left: auto; }
.quests li.done { color: var(--h4); }
.best { margin-top: 12px; font-weight: 700; color: var(--gold); }
.best b { font-family: var(--jersey); font-weight: 400; font-size: 1.3rem; }
.reveal .gift { font-size: 4.5rem; line-height: 1.1; animation: drop .7s cubic-bezier(.2, 1.4, .4, 1) both; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti i { position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px; animation: fall 1.8s linear both; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .9; } }

/* summary */
.score { font-family: var(--jersey); font-size: clamp(4rem, 14vw, 7rem); line-height: 1; color: var(--gold); }
.score small { font-size: .3em; color: var(--muted); display: block; letter-spacing: .05em; }
.reveal { text-align: center; border-color: var(--gold); background: radial-gradient(circle at 50% 20%, #2a4688, var(--panel)); }
.reveal .badge { width: 170px; margin: 0 auto; animation: drop .7s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes drop { from { transform: scale(.2) rotate(-25deg); opacity: 0; } to { transform: none; opacity: 1; } }
.fixlist { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.fixlist li { background: var(--bg2); border: 2px solid var(--line); border-left: 6px solid var(--amber); border-radius: 10px; padding: 10px 14px; font-family: var(--jersey); font-size: 1.6rem; letter-spacing: .03em; }
.fixlist li b { color: var(--h4); font-weight: 400; }
.fixlist.slow li { border-left-color: var(--h2); }
.actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }

/* badges */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
.bcard { text-align: center; position: relative; padding: 6px; }
.badge { position: relative; display: block; }
.badge svg { width: 100%; height: auto; display: block; }
.bcard .badge { width: 120px; margin: 0 auto 8px; }
.bcard b { display: block; line-height: 1.2; }
.bcard small { color: var(--muted); display: block; line-height: 1.3; margin-top: 3px; }
.bcard.locked .badge { filter: grayscale(1) brightness(.55); }
.bcard.locked b { color: var(--muted); }
.times { position: absolute; right: -6px; bottom: 0; background: var(--orange); color: #1a1200; font-family: var(--jersey); font-size: 1.15rem; padding: 2px 9px; border-radius: 999px; border: 3px solid var(--bg); }

/* heatmap */
.heat { display: grid; grid-template-columns: 1.6em repeat(12, 1fr); gap: 4px; max-width: 520px; font-size: .85rem; }
.heat .h { color: var(--muted); display: grid; place-items: center; font-weight: 700; }
.heat button { aspect-ratio: 1; border: 0; border-radius: 5px; background: var(--h0); padding: 0; min-width: 0; }
.heat .s1 { background: var(--h1); } .heat .s2 { background: var(--h2); } .heat .s3 { background: var(--h3); } .heat .s4 { background: var(--h4); }
.heat button.sel { outline: 3px solid var(--chalk); outline-offset: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; color: var(--muted); font-size: .9rem; margin-top: 12px; }
.legend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; vertical-align: -2px; margin-right: 5px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; max-width: 260px; }
.cal i { aspect-ratio: 1; border-radius: 50%; background: var(--h0); }
.cal i.on { background: var(--orange); } .cal i.today { outline: 2px solid var(--chalk); outline-offset: 1px; }
.days { display: grid; grid-auto-flow: column; grid-template-rows: 1.3em repeat(7, 16px); grid-template-columns: 2.6em; grid-auto-columns: 16px; gap: 4px; overflow-x: auto; padding-bottom: 6px; font-size: .75rem; }
.days > :nth-child(-n+8) { position: sticky; left: 0; background: var(--panel); z-index: 1; }
.days .h { color: var(--muted); line-height: 16px; white-space: nowrap; }
.days .h.m { line-height: 1.3em; overflow: visible; }
.days button { border: 0; border-radius: 4px; padding: 0; background: var(--h0); }
.days .s1 { background: var(--h1); } .days .s2 { background: var(--h2); } .days .s3 { background: var(--h3); } .days .s4 { background: var(--h4); }
.days button.sel { outline: 2px solid var(--chalk); outline-offset: 1px; }
.mapwrap { overflow-x: auto; }
.qmap { width: 100%; min-width: 620px; height: auto; display: block; }
.qmap .wname { font-family: var(--jersey); font-size: 19px; letter-spacing: .05em; }
.qmap .trail { stroke: #3a4a78; stroke-width: 5; stroke-dasharray: 2 12; stroke-linecap: round; }
.qmap .trail.done { stroke: var(--gold); stroke-dasharray: none; stroke-width: 4; opacity: .8; }
.qmap .node { cursor: pointer; outline: none; }
.qmap .node.locked { opacity: .6; }
.qmap .node.sel > circle:not(.pulse), .qmap .node:focus-visible > circle:not(.pulse) { stroke: var(--chalk); stroke-width: 6; }
.qmap .nlabel { font-family: var(--jersey); font-size: 19px; fill: var(--chalk); pointer-events: none; }
.qmap .nstars { font-size: 13px; fill: var(--gold); pointer-events: none; }
.qmap .nother { font-size: 15px; pointer-events: none; }
.qmap .nme { font-size: 30px; pointer-events: none; animation: bob 1.4s ease-in-out infinite; }
.qmap .pulse { fill: none; stroke: var(--gold); stroke-width: 3; opacity: .7; transform-box: fill-box; transform-origin: center; animation: ring 1.6s ease-out infinite; }
/* tap a level: a small card opens at that level with Play (game.js openPop) */
.qpanel { position: relative; }
/* the map on Stats says whether World Quest can be played today: a chip with the runs, one line, a gold frame when it can */
.qpanel.live { border-color: var(--gold); }
.qhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px; }
.qchip { display: inline-flex; align-items: center; gap: 10px; }
.qchip .keys.runs { font-size: 1.25rem; gap: 3px; }
.qline { margin: 8px 0 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.qline b { color: var(--chalk); } .qpanel.live .qline b { color: var(--gold); }
.qline .btn { white-space: nowrap; }
.qpanel a.btn { text-decoration: none; }
.qpop { position: absolute; z-index: 4; width: max-content; max-width: min(250px, calc(100% - 12px)); text-align: center; background: var(--bg2); border: 2px solid var(--gold); border-radius: 14px; padding: 10px 16px 14px; box-shadow: 0 10px 24px rgba(4, 10, 28, .6); animation: qpop .14s ease-out; }
.qpop::after { content: ""; position: absolute; left: var(--ax, 50%); width: 14px; height: 14px; margin-left: -7px; background: var(--bg2); border: 0 solid var(--gold); transform: rotate(45deg); }
.qpop.up::after { bottom: -9px; border-width: 0 2px 2px 0; }
.qpop.down::after { top: -9px; border-width: 2px 0 0 2px; }
.qpop b { display: block; font-family: var(--jersey); font-weight: 400; font-size: 1.3rem; letter-spacing: .04em; line-height: 1.2; }
.qpop small { display: block; color: var(--muted); }
.qpop .stars { color: var(--gold); letter-spacing: .08em; }
.qpop p { margin: 8px 0 0; color: var(--muted); font-size: .95rem; line-height: 1.35; }
.qpop .btn { display: inline-block; margin-top: 10px; }
.qpop .btn[data-play] { min-width: 140px; padding: 10px 26px; }
@keyframes qpop { from { opacity: 0; transform: scale(.92); } }
@keyframes ring { from { transform: scale(.8); opacity: .9; } to { transform: scale(1.35); opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-6px); } }
.keys.runs { font-size: 1.7rem; }
.gwrap { position: relative; max-width: 960px; margin: 0 auto; border: 3px solid var(--chalk); border-radius: 16px; overflow: hidden; background: #000; }
.gwrap canvas { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
/* A World Quest run gets the whole window: the menu steps aside and game.js sizes the frame to fit what is left. */
.app:has(.gwrap) { grid-template-columns: 1fr; padding-bottom: 0; }
.app:has(.gwrap) .rail { display: none; }
.app:has(.gwrap) .main { max-width: none; margin: 0 auto; padding: 10px max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.gfoot { text-align: center; margin: 8px 0 0; }
@media (max-height: 520px) { .gfoot .gtip { display: none; } .gwrap .gtouch { width: 56px; height: 56px; bottom: 6px; } .gwrap .gtouch.back { width: 44px; height: 44px; } }
.gover { position: absolute; inset: 0; background: rgba(8, 14, 32, .88); display: grid; place-content: center; text-align: center; padding: 16px; }
.bigstars { font-size: clamp(2.6rem, 9vw, 4.2rem); color: var(--gold); letter-spacing: .1em; line-height: 1.1; animation: drop .6s cubic-bezier(.2, 1.4, .4, 1) both; }
.bigstars span { opacity: .22; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
@media (min-width: 400px) { .tile.wide { grid-column: span 2; } }   /* room for the bonus-play buttons */
.goal { margin-top: 14px; } .goal div:first-child { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 5px; }

/* vault */
.intel { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.file { background: #f3ead2; color: #2a2210; border-radius: 6px 16px 6px 6px; padding: 18px; border-top: 10px solid #d9c58f; }
.file .em { font-size: 2rem; } .file h3 { color: #2a2210; margin: 4px 0 8px; font-size: 1.35rem; }
.file .topic { font-weight: 700; color: #8a5a00; font-size: .85rem; }
.file p { font-size: .98rem; } .file .try { margin-top: 10px; font-style: italic; color: #5a4a20; }
.cipher { font-family: var(--jersey); font-size: clamp(2.4rem, 9vw, 4rem); letter-spacing: .25em; color: var(--gold); word-break: break-all; }
.decoded { font-family: var(--jersey); font-size: clamp(2rem, 8vw, 3.2rem); letter-spacing: .25em; }
input[type=range] { width: 100%; max-width: 420px; accent-color: var(--orange); height: 34px; }
.dials { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.dial { background: var(--bg2); border: 2px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.dial span { font-family: var(--jersey); font-size: 1.8rem; display: block; }
input.txt, select.txt { font: inherit; background: var(--bg2); color: var(--chalk); border: 2px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.dial input { width: 5.5ch; text-align: center; font-family: var(--jersey); font-size: 1.8rem; }

/* picker + parent */
.center { min-height: 80vh; display: grid; place-items: center; text-align: center; }
.tilesel { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin: 24px 0; }
.ptile { background: var(--panel); border: 3px solid var(--line); border-radius: 20px; padding: 22px 30px; min-width: 150px; }
.ptile:hover { border-color: var(--orange); }
.ptile .av { font-size: 3.4rem; display: block; } .ptile b { font-family: var(--jersey); font-weight: 400; font-size: 1.6rem; letter-spacing: .04em; }
.avs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0; }
.avs button { font-size: 2rem; background: var(--panel); border: 3px solid transparent; border-radius: 14px; padding: 6px 10px; }
.avs button[aria-pressed="true"] { border-color: var(--orange); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 700; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; max-height: 420px; overflow-y: auto; }
.form { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: 12px 18px; align-items: center; }
.form label { font-weight: 700; } .form small { display: block; color: var(--muted); font-weight: 400; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.tabs button { background: transparent; border: 2px solid var(--line); border-radius: 999px; padding: 8px 18px; font-weight: 700; }
.tabs button[aria-selected="true"] { background: var(--chalk); color: var(--bg); border-color: var(--chalk); }
.flag { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--h0); font-weight: 700; }
.flag.on { background: var(--amber); color: #1a1200; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); background: var(--chalk); color: var(--bg); padding: 12px 20px; border-radius: 12px; font-weight: 700; opacity: 0; pointer-events: none; transition: .25s; z-index: 9; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; padding-bottom: 76px; }
  .rail { position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row; padding: 6px; border-right: 0; border-top: 2px solid var(--line); z-index: 5; gap: 2px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .rail .brand, .rail .spacer, .rail .who small, .rail .who b, .rail .row .lbl { display: none; }
  .rail a.nav { flex: 1; flex-direction: column; gap: 0; padding: 6px 2px; font-size: .68rem; text-align: center; line-height: 1.2; }
  .rail .who { width: auto; padding: 4px 6px; flex-direction: column; gap: 0; } .rail .who .av { font-size: 1.35rem; line-height: 1.2; }
  .rail .who .wtxt { flex: none; } .rail .who .xp { margin: 0; font-size: .66rem; white-space: nowrap; transform-origin: center; } .rail .who .xp em, .rail .who .xpbar { display: none; }
  .rail .row { margin: 0; gap: 2px; } .rail .mini { border: 0; padding: 4px 6px; font-size: 1.2rem; }
  .grid2 { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; gap: 4px 0; } .form > :nth-child(even) { margin-bottom: 12px; }
  body.playing .rail { display: none; } body.playing .app { padding-bottom: 0; }
}
@media (max-width: 560px) {                                   /* phones: icons only, the current page keeps its name */
  .rail a.nav { min-width: 0; padding: 8px 0; }
  .rail a.nav:not(.on) span:not(.ico) { display: none; }
  .rail a.nav.on { flex: 0 0 auto; padding: 4px 8px; }
  .rail .who { padding: 4px; } .rail .mini { padding: 4px 3px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Grown-up view switcher (Parent view / Child view) */
.viewbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 8px 16px; background: #3a2a08; border-bottom: 2px solid var(--amber); color: var(--chalk); position: sticky; top: 0; z-index: 30; }
.viewbar b { color: var(--amber); }
.viewbar .vnote { flex: 1 1 16em; color: var(--chalk); font-size: .95rem; }
.viewbar .txt { padding: 6px 10px; max-width: 100%; }
.viewbar .btn.ghost { padding: 6px 14px; }
body.playing .viewbar { display: none; }

/* Two-digit problems are wider, so the big numbers step down a size */
.fact.long { font-size: clamp(3rem, 15vw, 6.5rem); }
.playcard .sample.long { font-size: clamp(2.6rem, 11vw, 5.5rem); }

/* Wide but short screens (an iPad held sideways, a small laptop): the question stacked on top of the
   keypad is about 850px tall, so GO fell below the fold. Here the keypad moves beside the question. */
@media (min-width: 821px) and (max-height: 880px) and (orientation: landscape) {
  body.playing .main { padding-top: 14px; padding-bottom: 14px; }
  .arena { max-width: 900px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 320px); column-gap: clamp(16px, 3vw, 44px); align-items: start; }
  .arena > * { grid-column: 1; min-width: 0; }
  .arena .pad { grid-column: 2; grid-row: 1 / span 9; align-self: center; margin: 0; width: 100%; max-width: none; }
  .arena .fact { font-size: clamp(4rem, 11vw, 9rem); }
  .arena .fact.long { font-size: clamp(3rem, 8vw, 6.5rem); }
  .arena .quit { margin-top: 8px; justify-self: center; }
}

/* Upgraded badges (earned 10 times): a glint sweeps across every few seconds */
.bshine { animation: bshine 3.6s ease-in-out infinite; }
@keyframes bshine { 0%, 60% { transform: translateX(0); } 100% { transform: translateX(240px); } }
.bcard .upg { display: block; color: var(--gold); font-weight: 700; margin-top: 4px; }
.bcard .upg.dim { color: var(--muted); font-weight: 400; }

/* Gold tokens and the trophy shelf */
.coins { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; margin: 8px 0 4px; }
.coins i, .coin { width: 26px; height: 26px; border-radius: 50%; display: inline-block; border: 2px dashed var(--line); flex: none; }
.coins i.on, .coin { border: 2px solid #7a4d00; background: radial-gradient(circle at 35% 30%, #fff6c2, #ffc93c 45%, #b97a00); box-shadow: inset 0 0 0 3px rgba(122, 77, 0, .35); }
.coin.sm { width: 16px; height: 16px; box-shadow: inset 0 0 0 2px rgba(122, 77, 0, .35); vertical-align: -2px; }
.coin.big { width: 88px; height: 88px; border-width: 4px; box-shadow: inset 0 0 0 10px rgba(122, 77, 0, .3); margin-bottom: 10px; }
.trophy svg { width: 100%; height: auto; display: block; }
.shelf { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 18px 14px; }
.tcard { text-align: center; padding: 6px 6px 12px; border-bottom: 6px solid var(--line); border-radius: 0 0 4px 4px; }
.tcard .trophy { display: block; width: 108px; margin: 0 auto 6px; }
.tcard b { display: block; line-height: 1.2; }
.tcard small { display: block; color: var(--muted); line-height: 1.3; margin-top: 3px; }
.tcard small.won { color: var(--gold); font-weight: 700; }
.tcard.locked .trophy { filter: grayscale(1) brightness(.42); }
.tcard.locked b { color: var(--muted); }
.tcard.next { border-bottom-color: var(--gold); }
.tcard.next .trophy, .trophy.ghosted { filter: grayscale(.9) brightness(.62); }
.prize { text-align: center; }
.prize .lede { margin-left: auto; margin-right: auto; }
.prize .trophy.big { display: block; width: 170px; margin: 0 auto 10px; }
.prize .trophy.mid { display: block; width: 110px; margin: 10px auto 4px; }
.prize .actions, p.actions { justify-content: flex-start; }
.drop { animation: drop .7s cubic-bezier(.2, 1.4, .4, 1) both; }

/* Logbook */
.tlist { list-style: none; margin: 0; padding: 0; }
.tlist li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-weight: 700; }
.steps { display: inline-flex; gap: 4px; flex: none; }
.steps i { width: 16px; height: 9px; border-radius: 3px; background: var(--h0); }
.steps i.on { background: var(--h3); }
.chip.beat { border-color: var(--h2); font-weight: 700; }

/* Grown-ups tables: sort and filter */
.phead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.phead .fcount { margin-right: auto; }
.phead .fbtn { padding: 6px 14px; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--chalk); }
th[data-dir="asc"]::after { content: " \25B2"; color: var(--gold); }
th[data-dir="desc"]::after { content: " \25BC"; color: var(--gold); }
.frow th { padding: 4px 6px; }
.frow input.txt { width: 100%; min-width: 6ch; padding: 5px 8px; font-size: .9rem; font-weight: 400; }

/* ---- gems and the World Quest Workshop ---- */
.wish { margin-top: 10px; }
.wish span { display: block; font-size: .95rem; color: var(--muted); margin-bottom: 5px; }
.wish b { color: var(--gold); }
.gemhome { margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--line); }
.gemhome p b { font-family: var(--jersey); font-weight: 400; font-size: 1.3rem; letter-spacing: .04em; color: var(--gold); }
.loot .lootlist { list-style: none; margin: 12px auto 6px; padding: 0; display: grid; gap: 6px; justify-content: center; text-align: left; }
.loot .lootlist li { font-weight: 700; animation: xpop .45s ease-out both; }
.loot .lootlist li b { display: inline-block; min-width: 2.4ch; text-align: right; font-family: var(--jersey); font-weight: 400; font-size: 1.3rem; letter-spacing: .04em; color: var(--gold); }
.loot .lootlist .gem { margin: 0 8px 0 4px; }
.loot h1 { margin-top: 8px; color: var(--gold); }
.loot #gemcount { display: inline-block; }
.loot #gemcount.bump { animation: pulse .35s ease-out; }
.loot .wish { max-width: 420px; margin: 12px auto 0; text-align: left; }
.shop h3 { margin: 18px 0 8px; }
.shop h3 small { font-family: var(--body); font-size: .85rem; letter-spacing: 0; }
.gembal { font-weight: 700; white-space: nowrap; }
.gembal b { font-family: var(--jersey); font-weight: 400; font-size: 1.6rem; letter-spacing: .04em; color: var(--gold); }
.shopgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.sitem { display: grid; grid-template-columns: 44px 1fr; gap: 4px 12px; align-items: center; background: var(--bg2); border: 2px solid var(--line); border-radius: 14px; padding: 12px; }
.sitem.owned { border-color: var(--h2); }
.sitem .swatch { width: 40px; height: 40px; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .5); }
.sitem .sicon { font-size: 1.8rem; line-height: 1; text-align: center; font-family: var(--jersey); color: var(--h4); }
.sitem .sname small { display: block; color: var(--muted); font-size: .85rem; line-height: 1.3; }
.sitem .sact { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.btn.sm, .btn.ghost.sm { font-family: var(--body); font-size: .95rem; font-weight: 800; letter-spacing: 0; padding: 8px 14px; border-radius: 10px; box-shadow: none; }
.tag { display: inline-block; border: 2px solid var(--line); border-radius: 999px; padding: 3px 11px; font-weight: 700; font-size: .9rem; color: var(--muted); }
.tag.on { border-color: var(--h3); color: var(--h4); }
.tomorrow { border-color: var(--gold); }
.tomorrow ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.tomorrow li span { display: inline-block; width: 1.8em; }
@media (max-width: 560px) { .shopgrid { grid-template-columns: 1fr; } }

/* ---- World Quest phase 2: star gates, pets, treasure chests, touch sprint ---- */
.qmap .glabel { font-size: 15px; }
.qmap .gcount { font-size: 12px; font-weight: 700; fill: var(--gold); pointer-events: none; }
.sitem.rare { border-color: var(--gold); }
.chestwait { border-color: var(--gold); }
.chestcard { margin: 0 auto 16px; max-width: 420px; text-align: center; }
.chestcard .gift { font-size: 3.2rem; line-height: 1.1; animation: drop .7s cubic-bezier(.2, 1.4, .4, 1) both; }
.chestcard .chestitem { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-top: 8px; font-size: 1.15rem; }
.chestcard .swatch { display: inline-block; width: 34px; height: 34px; border-radius: 9px; border: 2px solid rgba(255, 255, 255, .5); }
.chestcard .sicon { font-size: 1.9rem; line-height: 1; }
.chestcard.rare .chestitem b { color: var(--gold); }
.gtouch { position: absolute; bottom: 12px; width: 76px; height: 76px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .55);
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 1.25rem; font-weight: 800; letter-spacing: -.1em; padding: 0;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: pointer; }
.gtouch.fwd { right: 12px; }
.gtouch.back { left: 12px; width: 58px; height: 58px; }
.gtouch.on { background: rgba(255, 201, 60, .5); border-color: var(--gold); }
.pethome { margin-top: 8px; color: var(--muted); font-size: .95rem; }
.pethome b { color: var(--gold); }
.ratebox { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 14px; }
.ratebox label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
@media (max-width: 560px) { .gtouch { width: 60px; height: 60px; bottom: 8px; } .gtouch.back { width: 48px; height: 48px; } }

/* ---- online copy: sign-in, codes, family page, crews ---- */
.signin { width: min(460px, 100%); display: grid; gap: 16px; text-align: left; }
.signin .brand.big { font-family: var(--jersey); font-size: clamp(2.6rem, 9vw, 3.6rem); letter-spacing: .04em; text-align: center; line-height: 1; }
.signin .brand.big span { color: var(--orange); }
.signin > .lede { text-align: center; margin: -6px auto 4px; }
.signin .panel { display: grid; gap: 10px; }
.signin .panel[hidden] { display: none; }
.signin .btn { width: 100%; }
.codein { display: flex; flex-wrap: wrap; gap: 10px; }
.txt.code { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 1.25rem; letter-spacing: .08em; text-transform: uppercase; width: 100%; min-width: 0; flex: 1 1 11em; }
.txt.code::placeholder { letter-spacing: .04em; opacity: .5; }
.notice { border: 2px solid var(--amber); border-radius: var(--r); padding: 10px 14px; color: var(--chalk); background: rgba(255, 182, 72, .1); }
.small { font-size: .9rem; }
.linkb { background: none; border: 0; padding: 4px 0; color: var(--orange2); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.consent { text-align: left; margin: 0 0 16px; }
.consent label { display: flex; gap: 12px; align-items: flex-start; }
.consent input { width: 24px; height: 24px; flex: none; margin-top: 3px; }
.codebox { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
.bigcode { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: clamp(1.5rem, 6vw, 2.2rem); font-weight: 700; letter-spacing: .1em; color: var(--gold); border: 2px dashed var(--gold); border-radius: var(--r); padding: 6px 16px; user-select: all; white-space: nowrap; }
.crewlist, .crewgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.crewtile, .ccard { display: grid; gap: 6px; justify-items: center; text-align: center; text-decoration: none; color: inherit; }
.crewtile b { font-family: var(--jersey); font-weight: 400; font-size: 1.5rem; letter-spacing: .03em; }
a.crewtile:hover, a.ccard:hover { border-color: var(--orange); }
.ccard .av { font-size: 3rem; line-height: 1.1; }
.ccard b { font-size: 1.15rem; } .ccard b small { color: var(--muted); font-weight: 400; }
.ccard.me { border-color: var(--gold); }
.cstats { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { background: var(--panel2); border: 2px solid var(--line); border-radius: 999px; padding: 10px 18px; font-weight: 800; }
.chip:hover:not(:disabled) { border-color: var(--orange); }
.chip:disabled { opacity: .5; cursor: default; }
.news { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.news li { display: flex; gap: 10px; align-items: baseline; }

.signin a, .doc a { color: var(--orange2); }
