/* ==========================================================================
   Math Quest - theme.css
   One bright theme. Vanilla CSS, no build. Mobile-first 360-1280px, tuned for
   a landscape tablet (>= 900px wide: the lesson splits into two columns).
   Rules (docs/DESIGN.md has the why):
   - Tokens only. Flat selectors: one class plus at most one state.
   - State lives in attributes, never in extra classes:
       data-state   .tile selected|correct|wrong   .eq output correct|wrong
                    .dots li done|now   .ring done
       aria-current="step" next lesson    aria-disabled="true" locked lesson
       aria-pressed="true" toggle is on   aria-busy="true" pill still working
       aria-current="page" shown world (map grade button)
     A node is gold (mastered) when its .stars has data-n="3"; no extra state.
   - Dashed outline = "empty / not yet / not this one".
     Pressed in (lip gone) = "selected / on".
   - Inline knobs: --p ring percent, --i stagger index, --cols tile columns,
     --unit island flag color.
   ========================================================================== */

:root {
  /* color */
  --bg: #FFF6E5;           /* warm sand: page */
  --surface: #FFFFFF;      /* cards, tiles, stage */
  --text: #1F2147;         /* ink: text, outlines, lips */
  --text-soft: #5B5E86;    /* secondary text, "not yet" dashes */
  --line: #E4E7F2;         /* tracks, table rules */
  --primary: #2468F2;      /* main action, progress, forward jumps */
  --primary-soft: #E3ECFF; /* selected / on */
  --accent: #FFC933;       /* stars, goal reached */
  --success: #3CC46C;      /* correct */
  --warning: #E06C00;      /* backward jumps, streak flame */
  --danger: #D6334A;       /* "not this one" dashes, adult errors */
  --danger-soft: #FFE6EA;  /* "not this one" fill */
  --sea: #9BE3F7;          /* world map water */
  /* counters for manipulatives, each >= 5:1 against the ink outline */
  --c-red: #FF5C6C;
  --c-blue: #4A94FF;
  --c-yellow: #FFCB2F;
  --c-green: #46C46E;
  --c-purple: #A77BFF;

  /* type */
  --font: "Fredoka", ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; /* parent page */
  --fs-sm: 1.25rem;                                /* 20px  smallest kid text */
  --fs-md: 1.5rem;                                 /* 24px  kid body, buttons */
  --fs-lg: 2rem;                                   /* 32px  headings, numpad */
  --fs-xl: clamp(2.5rem, 1.75rem + 2.5vw, 3.5rem); /* 40-56 equations, tiles */
  --fs-xxl: clamp(3.5rem, 2.5rem + 4vw, 5.5rem);   /* 56-88 results */

  /* space, shape, depth */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 16px; --sp-4: 24px; --sp-5: 32px; --sp-6: 48px;
  --r-sm: 12px; --r-md: 20px; --r-lg: 32px; --r-full: 999px;
  --bw: 3px;   /* ink outline */
  --lip: 5px;  /* solid under-shadow that says "press me" */
  --tap: 56px; /* minimum touch target */
  --shadow-card: 0 8px 0 rgb(31 33 71 / .12); /* static surfaces; never blurred */

  /* motion */
  --t-fast: 120ms; /* presses */
  --t-med: 240ms;  /* pops, answer feedback */
  --t-slow: 480ms; /* jumps, regrouping, stars */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-pop: cubic-bezier(.34, 1.56, .64, 1); /* small overshoot */

  /* ponytail: ink is hardcoded (%231F2147) because data URIs cannot read var() */
  --check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231F2147' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E");
}

/* ---------- reset + type ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 500 var(--fs-md)/1.35 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* no double-tap zoom on fast taps */
}
img, svg { display: block; max-width: 100%; }
button, input, output, select { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 700; line-height: 1.1; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
a { color: var(--primary); }
:focus-visible { outline: 4px solid var(--primary); outline-offset: 3px; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.screen {
  display: flex; flex-direction: column; gap: var(--sp-4);
  width: 100%; max-width: 1280px; min-height: 100vh; min-height: 100dvh;
  margin-inline: auto; padding: var(--sp-3);
}
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.col { display: flex; flex-direction: column; gap: var(--sp-3); }
.grow { flex: 1 1 0; min-width: 0; }
.spread { justify-content: space-between; }
.center { justify-content: center; align-items: center; text-align: center; }
.split { display: grid; gap: var(--sp-4); align-items: start; }
@media (min-width: 900px) {
  .screen { padding: var(--sp-4) var(--sp-5); }
  .split { grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr); align-items: center; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- pressables: .btn .tile .node share the lip ---------- */
:is(.btn, .tile, .node) {
  box-shadow: 0 var(--lip) 0 var(--text);
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  transition: translate var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) var(--ease-out), background-color var(--t-med) var(--ease-out);
}
/* ponytail: hover is a 2px lift only; touch is the main input */
@media (hover: hover) { :is(.btn, .tile, .node):hover { translate: 0 -2px; } }
:is(.btn, .tile, .node):active { translate: none; transform: translateY(var(--lip)); box-shadow: none; }
:is(.btn, .tile):disabled, .node[aria-disabled="true"] { pointer-events: none; }
.tile[data-state="selected"], .btn[aria-pressed="true"], .btn[aria-current="page"] {
  transform: translateY(var(--lip)); box-shadow: none;
  background: var(--primary-soft); border-color: var(--primary);
}

/* ---------- buttons: .btn alone = secondary ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-width: var(--tap); min-height: var(--tap); padding: var(--sp-2) var(--sp-4);
  background: var(--surface); color: var(--text);
  border: var(--bw) solid var(--text); border-radius: var(--r-full);
  font: 600 var(--fs-md)/1 var(--font); white-space: nowrap;
}
.btn.primary { background: var(--primary); color: var(--surface); }
.btn.ghost {
  --lip: 0px; background: transparent; border-color: transparent;
  color: var(--primary); text-decoration: underline; text-underline-offset: 4px;
}
.btn.huge { --lip: 7px; min-height: 80px; padding-inline: var(--sp-6); font-size: var(--fs-lg); }
.btn.icon { width: var(--tap); padding: 0; }
.btn:disabled {
  background: var(--surface); color: var(--text-soft);
  border-style: dashed; border-color: var(--text-soft); box-shadow: none;
}

/* ---------- icons: <svg class="ico"><use href="#i-star"/></svg>, sprite in docs/styleguide.html ---------- */
.ico {
  flex: none; width: 1.25em; height: 1.25em;
  fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- surfaces ---------- */
.card, .stage {
  padding: var(--sp-4);
  background: var(--surface);
  border: var(--bw) solid var(--text);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.stage { position: relative; display: grid; place-items: center; min-height: 240px; padding: var(--sp-3); }
.stage > svg { width: 100%; max-height: 60vh; }
.stage > .pill { position: absolute; top: var(--sp-2); right: var(--sp-2); } /* running count while tapping pieces */

/* ---------- top bar + status bits ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3);
  padding-block: var(--sp-2); background: var(--bg);
}
.topbar h1 { font-size: var(--fs-lg); min-width: min-content; } /* never narrower than its longest word, which would run under the dots */
.topbar .mascot { width: 56px; height: 56px; }
.pill {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: 44px; padding: var(--sp-1) var(--sp-3);
  background: var(--surface); border: var(--bw) solid var(--text); border-radius: var(--r-full);
  font-weight: 600; white-space: nowrap;
}
.pill[aria-busy="true"] { border-style: dashed; border-color: var(--text-soft); color: var(--text-soft); }

/* progress ring toward the daily goal: style="--p:40" (0-100) */
.ring {
  position: relative; isolation: isolate;
  display: inline-grid; place-items: center; flex: none;
  width: 64px; aspect-ratio: 1;
  border: var(--bw) solid var(--text); border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--p, 0) * 1%), var(--line) 0);
  font: 700 var(--fs-sm)/1 var(--font);
}
.ring::before { /* inner disc; z-index -1 stays inside the ring thanks to isolation */
  content: ""; position: absolute; inset: 9px; z-index: -1;
  background: var(--surface); border: var(--bw) solid var(--text); border-radius: 50%;
}
.ring[data-state="done"] { background: var(--accent); }

/* stars: data-n="0..3" on the wrapper, three <svg><use href="#i-star"/></svg> inside */
.stars { display: inline-flex; gap: .15em; }
.stars svg {
  width: 1.2em; height: 1.2em;
  fill: none; stroke: var(--text-soft); stroke-width: 2; stroke-dasharray: 3 2.5; stroke-linejoin: round;
}
.stars[data-n="1"] svg:nth-child(1),
.stars[data-n="2"] svg:nth-child(-n+2),
.stars[data-n="3"] svg { fill: var(--accent); stroke: var(--text); stroke-dasharray: none; }
.stars .pop { animation-duration: var(--t-slow); animation-delay: calc(var(--i, 0) * 300ms + 200ms); }
.stars.huge { font-size: var(--fs-xxl); }

/* ---------- Pip + speech bubble ---------- */
.mascot {
  flex: none; width: 96px; height: 96px;
  transform-origin: 50% 90%;
  animation: bump var(--t-slow) var(--ease-pop); /* replays whenever the element is re-inserted */
}
.mascot.huge { /* results + goal: pops, then dances twice */
  width: 160px; height: 160px;
  animation: bump var(--t-slow) var(--ease-pop), wobble 1s ease-in-out var(--t-slow) 2;
}
.bubble {
  position: relative; max-width: 34ch; padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: var(--bw) solid var(--text); border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  transform-origin: 0 50%;
  animation: pop var(--t-med) var(--ease-pop) both;
}
.bubble::before { /* tail points left, at Pip */
  content: ""; position: absolute; top: 50%; left: -12px; width: 20px; height: 20px;
  background: inherit;
  border-left: var(--bw) solid var(--text); border-bottom: var(--bw) solid var(--text);
  transform: translateY(-50%) rotate(45deg);
}

/* ---------- answers ---------- */
.eq {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .3em;
  font: 700 var(--fs-xl)/1.1 var(--font); font-variant-numeric: tabular-nums;
}
.eq output {
  position: relative; display: inline-grid; place-items: center;
  min-width: 1.8em; min-height: 1.4em; padding-inline: .2em;
  background: var(--surface); border: var(--bw) solid var(--text); border-radius: var(--r-md);
}
.eq output:empty { border-style: dashed; border-color: var(--text-soft); }
.eq output:empty::before { content: "?"; color: var(--text-soft); }

.tiles { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: var(--sp-3); }
.tile {
  position: relative; display: grid; place-items: center;
  min-height: 88px; padding: var(--sp-2);
  background: var(--surface); color: var(--text);
  border: var(--bw) solid var(--text); border-radius: var(--r-md);
  font: 700 var(--fs-xl)/1 var(--font);
}
.tiles.long .tile { font-size: calc(var(--fs-xl) * .75); padding-inline: 0; white-space: nowrap; } /* a row with a 4-digit tile (1000), a time (11:30), 3 word tiles (Wed) or a 5-character fraction (14/24, 3 3/8): the text fits on one line, with no side padding at 900-1100px, and the row stays one size */

/* feedback: same look on tiles and on the answer slot */
.tile[data-state="correct"], .eq [data-state="correct"] {
  background-color: var(--success);
  animation: bump var(--t-med) var(--ease-pop);
}
.tile[data-state="correct"]::after, .eq [data-state="correct"]::after { /* check sticker */
  content: ""; position: absolute; top: -14px; right: -14px; width: 36px; height: 36px;
  background: var(--surface) var(--check) center / 22px no-repeat;
  border: var(--bw) solid var(--text); border-radius: 50%;
  animation: pop var(--t-med) var(--ease-pop) both;
}
/* the answer slot hugs its digits: a smaller sticker further off the corner leaves the last digit of 8,017 readable */
.eq [data-state="correct"]::after { top: -20px; right: -16px; width: 30px; height: 30px; background-size: 18px; }
.tile[data-state="wrong"], .eq [data-state="wrong"] {
  background-color: var(--danger-soft); color: var(--text-soft);
  border-style: dashed; border-color: var(--danger); box-shadow: none;
  animation: wobble var(--t-slow) var(--ease-out); /* once, gently; never shake the screen */
}

.numpad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); width: min(100%, 320px); }
.numpad .btn { min-height: 64px; padding-inline: 0; border-radius: var(--r-md); font-size: var(--fs-lg); }

/* progress dots: <ol class="dots"><li data-state="done|now"></li>... */
.dots { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: 0; list-style: none; }
.dots li { width: 20px; height: 20px; border: var(--bw) dashed var(--text-soft); border-radius: 50%; }
.dots [data-state="done"] { background: var(--primary); border: var(--bw) solid var(--text); }
.dots [data-state="now"] { scale: 1.35; background: var(--accent); border: var(--bw) solid var(--text); }

/* ---------- world map ---------- */
.map {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  align-items: start; gap: var(--sp-5) var(--sp-4);
  padding: var(--sp-5) var(--sp-4) var(--sp-6);
  background: var(--sea) radial-gradient(circle, rgb(255 255 255 / .55) 2px, transparent 3px) 0 0 / 40px 40px;
  border: var(--bw) solid var(--text); border-radius: var(--r-lg);
}
.island {
  --unit: var(--c-yellow);
  display: grid; justify-items: center; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-3) var(--sp-6);
  background: var(--bg); border: var(--bw) solid var(--text);
  border-radius: 40% 52% 44% 48% / 26% 30% 34% 38%;
  box-shadow: 0 0 0 10px rgb(255 255 255 / .55); /* shore foam */
}
/* ponytail: the zig-zag is nth-child, not hand-placed coordinates */
@media (min-width: 700px) { .island:nth-child(even) { margin-top: var(--sp-6); } }
.island > h2 { /* flag */
  padding: var(--sp-1) var(--sp-3); rotate: -2deg;
  background: var(--unit); border: var(--bw) solid var(--text); border-radius: var(--r-sm);
  font-size: var(--fs-md);
}
.island > ol { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-5) var(--sp-3); padding: 0; list-style: none; }
.node {
  position: relative; display: grid; place-items: center; width: 64px; height: 64px;
  background: var(--surface); color: var(--text);
  border: var(--bw) solid var(--text); border-radius: 50%;
  font: 700 var(--fs-lg)/1 var(--font);
}
.node .stars { position: absolute; inset: calc(100% + 10px) -24px auto; justify-content: center; font-size: 16px; }
.node:has(.stars[data-n="3"]) { background: var(--accent); } /* mastered */
.node[aria-current="step"] { /* the glowing next lesson: pops in on every map visit, then bobs */
  scale: 1.15; background: var(--primary); color: var(--surface);
  box-shadow: 0 var(--lip) 0 var(--text), 0 0 0 8px var(--accent);
  animation: pop var(--t-slow) var(--ease-pop), bob 1.6s ease-in-out var(--t-slow) infinite;
}
.node[aria-disabled="true"] {
  background: transparent; color: var(--text-soft);
  border-style: dashed; border-color: var(--text-soft); box-shadow: none;
}

/* ---------- manipulatives: <svg class="pic" viewBox="..."> inside .stage ---------- */
.pic {
  overflow: visible;
  fill: var(--surface); stroke: var(--text); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
  font: 600 24px var(--font);
}
.pic text { fill: var(--text); stroke: none; text-anchor: middle; dominant-baseline: central; }
.pic .a { fill: var(--c-red); }  /* colour A: first number */
.pic .b { fill: var(--c-blue); } /* colour B: second number, extras */
.pic .sand { fill: var(--bg); }  /* frames, plates, the whole */
.pic .away { stroke: var(--text-soft); stroke-dasharray: 5 6; } /* gone, empty or unknown (use instead of .a/.b); crossed adds an ink X */
.pic .arc { fill: none; stroke: var(--primary); stroke-width: 5; } /* jumps, loops, outlines */
.pic .arc.back { stroke: var(--warning); } /* backward jumps */
.pic .halo { stroke: var(--surface); stroke-width: 8px; paint-order: stroke; } /* text on water or across a line: a white rim keeps it readable (a glow halo still wins) */
.pic .glow { stroke-width: 6; animation: glow 1.2s ease-in-out infinite; } /* highlight: on a wrapping <g> only */
.pic .glow text { stroke: var(--accent); stroke-width: 12px; stroke-linejoin: round; paint-order: stroke; } /* text has no outline to thicken: a glowing label (a comma, a digit) gets a marker halo */
.pic * { /* JS moves shapes with style.transform (regrouping, dealing, turning); this animates it */
  transform-box: fill-box; transform-origin: center; /* shapes scale and turn around their own center */
  transition: transform var(--t-slow) var(--ease-out), opacity var(--t-med) var(--ease-out);
  transition-delay: calc(var(--i, 0) * 30ms);
}

/* ---------- confetti: <div class="confetti" aria-hidden="true"> with 24 empty <i> ---------- */
/* ponytail: variety comes from nth-child, no JS; 24 pieces is plenty */
.confetti {
  position: fixed; inset: 0; z-index: 50;
  display: flex; justify-content: space-around; overflow: hidden; pointer-events: none;
}
.confetti i {
  --sway: 24px; width: 12px; height: 18px;
  background: var(--c-red); border: 2px solid var(--text); border-radius: 3px;
  animation: fall 2.8s linear both;
}
.confetti i:nth-child(5n+2) { --sway: -32px; background: var(--c-blue); animation-delay: .15s; }
.confetti i:nth-child(5n+3) { --sway: 40px; background: var(--c-yellow); animation-delay: .4s; animation-duration: 3.2s; }
.confetti i:nth-child(5n+4) { --sway: -20px; background: var(--c-green); animation-delay: .25s; animation-duration: 2.5s; }
.confetti i:nth-child(5n) { --sway: 28px; background: var(--c-purple); animation-delay: .55s; }
.confetti i:nth-child(3n) { width: 14px; height: 14px; border-radius: 50%; }
.confetti i:nth-child(4n) { animation-delay: .8s; }

/* ---------- goal celebration: <dialog class="card"> + showModal(); layout classes go on a child ---------- */
dialog { max-width: min(100% - 32px, 560px); color: inherit; }
::backdrop { background: rgb(31 33 71 / .5); } /* ponytail: literal ink; older ::backdrop cannot read :root vars */

/* ---------- parent page: <body class="parent"> calm, adult, not game-styled ---------- */
/* ponytail: re-skins by overriding --bw/--lip instead of a second component set */
.parent { --bw: 1px; --lip: 0px; background: var(--surface); font: 400 1rem/1.5 var(--font-ui); }
.parent :is(h1, h2, h3, .btn) { font-family: var(--font-ui); font-weight: 600; }
.parent h1 { font-size: 1.5rem; }
.parent h2 { font-size: 1.125rem; }
.parent .btn { font-size: 1rem; border-radius: var(--r-sm); }
.parent :is(.card, .stage) { border-color: var(--line); border-radius: var(--r-sm); box-shadow: none; overflow-x: auto; }
.parent table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.parent :is(th, td) { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.parent th { color: var(--text-soft); font-size: .875rem; font-weight: 600; }
.parent .screen { max-width: 48rem; }
.parent h3 { font-size: 1rem; }
.parent pre { font: inherit; white-space: pre-wrap; }
.parent form.row { align-items: flex-end; } /* the button sits level with the input, not with its label */
.field { display: grid; gap: var(--sp-1); font-weight: 600; }
.field :is(input, select) {
  min-height: var(--tap); padding: var(--sp-2) var(--sp-3);
  background: var(--surface); border: var(--bw) solid var(--text-soft); border-radius: var(--r-sm); font-weight: 400;
}
.err { color: var(--danger); font-weight: 600; }

/* ---------- motion: add .pop / .draw, stagger with style="--i:n" ---------- */
.pop {
  animation: pop var(--t-med) var(--ease-pop) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}
.draw { /* needs pathLength="1" on the path */
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: draw var(--t-slow) var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * var(--t-slow));
}
.draw + .pop { animation-delay: calc((var(--i, 0) + 1) * var(--t-slow)); } /* arrowhead lands after its arc */
.drawdown { transform-box: fill-box; transform-origin: top; animation: drawdown var(--t-slow) var(--ease-out) both; } /* a dashed line draws down (a dash pattern can't .draw) */

@keyframes pop { from { scale: 0; rotate: -20deg; } }
@keyframes bump { 50% { scale: 1.12; } }
@keyframes wobble { 25% { rotate: -4deg; } 50% { rotate: 3deg; } 75% { rotate: -1.5deg; } }
@keyframes bob { 50% { translate: 0 -6px; } }
@keyframes glow { 50% { scale: 1.08; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes drawdown { from { scale: 1 0; } }
@keyframes fall {
  from { translate: 0 -40px; rotate: 0deg; }
  25% { translate: var(--sway) 25vh; }
  50% { translate: 0 50vh; }
  75% { translate: var(--sway) 75vh; }
  to { translate: 0 105vh; rotate: 540deg; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
    transition-duration: 1ms !important; transition-delay: 0s !important;
  }
  .confetti { display: none; }
}

/* ---------- app additions ---------- */
.pip { flex-wrap: nowrap; } /* Pip, bubble and speaker stay on one line, so the tail points at Pip */
.pip .bubble { flex: 1 1 auto; min-width: 0; }
.pic [data-v] { cursor: pointer; } /* tap to count */
.eq .tight { display: inline-flex; align-items: center; } /* "?¢", "$?": the answer slot hugs its symbol */
.eq sup { font-size: .5em; line-height: 1; vertical-align: super; align-self: flex-start; } /* 10^3: a small raised 3; in "10^?" (.tight) the slot rides up top */
.tiles.longer .tile { font-size: calc(var(--fs-xl) * .5); } /* a row with a 5-6 digit tile (407,253) */
/* who is playing: <div class="who"> of .btn.huge (Pip over the name); the PIN: <ol class="dots pin"> */
.who { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-4); }
.who .btn { flex-direction: column; min-width: 180px; padding-block: var(--sp-3); border-radius: var(--r-lg); white-space: normal; }
.pin li { width: 32px; height: 32px; }
.numpad [data-k="del"] { grid-column: 1; } /* extra keys (- . /) get their own row after 7 8 9; del 0 ok stay the last row */
dialog { margin: auto; } /* the reset's margin: 0 would pin the modal to the top-left corner */
@media (max-width: 899px) { /* one column: the quiz keypad stays on a portrait tablet's or a phone's screen */
  .stage > svg { max-height: 30vh; } /* a 600x960 tablet: a 2-line prompt, a 2-line eq and the keypad's last row end above 960px */
  /* 3 stacked word tiles and Hint end above 960px there and above 812px on a phone, under a 3-line bubble too; the picture gives way, the tiles keep their size */
  .split:has(.tiles.stack) .stage { min-height: 160px; }
  .split:has(.tiles.stack) .stage > svg { max-height: 18vh; }
  .tiles.stack .tile { min-height: 64px; } /* still a full-width target */
  .ctl .numpad .btn { min-height: 56px; }
  /* the quiz keypad is 3 rows of 5 (1-5, 6-0, then - . / del ok), not 4-5 rows of 3. ponytail: CSS order only, so Tab keeps the DOM order */
  .ctl .numpad { grid-template-columns: repeat(5, minmax(0, 1fr)); width: min(100%, 400px); }
  .ctl .numpad > * { order: 2; }
  .ctl .numpad > :nth-child(-n+9) { order: 0; }
  .ctl .numpad [data-k="0"] { order: 1; }
  .ctl .numpad [data-k="del"] { grid-column: 3; }
  .ctl .numpad [data-k="ok"] { grid-column: 4 / span 2; }
}
@media (max-width: 767px) { /* one row needs about 720px: narrower, the title squeezed to 3 lines and the bar grew with the score */
  /* the lesson bar takes 2 rows: map, title, ring, sound; then the dots and the points. A 60% basis never fits after the title row and leaves the points room */
  .topbar .dots { order: 1; flex: 1 1 60%; }
  .topbar .pts { order: 2; }
}
@media (max-width: 599px) { /* phones: a two-row sticky bar would cover the picture; the results row must fit 343px */
  .screen, .split, .split .col { gap: var(--sp-2); }
  .stage { min-height: 160px; padding: var(--sp-2); } /* a one-row picture (16 dots) is 20px tall here; 240 pushed three stacked word tiles off screen */
  .stage > svg { max-height: 28vh; } /* with a 4-line prompt the quiz keypad's last row still ends above 812px */
  .topbar { position: static; gap: var(--sp-2); }
  .topbar h1 { font-size: var(--fs-sm); min-width: min-content; hyphens: auto; } /* a long title wraps (or hyphenates) instead of running under the dots */
  .topbar .ring { width: 56px; }
  .pip .mascot { width: 64px; height: 64px; } /* leaves the bubble about 190px */
  .bubble { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); } /* a 3-4 line prompt still leaves the tiles on screen */
  .mascot.huge { width: 96px; height: 96px; }
}
