/* mathlab shared theme — bright, big, kid-friendly. No framework, no build. */

:root {
  --bg: #f4f7ff;
  --card: #ffffff;
  --ink: #16233d;
  --muted: #5d6b8a;
  --line: #dde5f6;
  --brand: #4f5bd5;
  --brand-soft: #eaecff;
  --good: #12a05c;
  --good-soft: #e2f7ec;
  --bad: #d94848;
  --bad-soft: #fdeaea;
  --warn: #e08a13;
  --warn-soft: #fdf2e0;
  --field: #fbfcff;
  --on-brand: #ffffff;
  --shadow-tint: rgba(22, 35, 61, .5);
  --glow-on: rgba(224, 138, 19, .45);
  --glow-off: rgba(224, 138, 19, 0);
  --radius: 18px;
  --shadow: 0 2px 0 var(--line), 0 12px 28px -18px var(--shadow-tint);
  --font: "Nunito", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

/* The phone layout gives every button display: inline-flex, which beats the browser's own
   [hidden] rule — so "Next question" showed before she had answered. Hidden means hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 20px 18px 64px;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.topbar h1 {
  font-size: 1.4rem;
  margin: 0;
  flex: 1 1 auto;
}

.topbar .tagline {
  width: 100%;
  margin: 0;
  color: var(--muted);
  font-size: .95rem;
}

.back {
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.back:hover { color: var(--brand); }

/* ---------- scoreboard ---------- */

.scoreboard {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 1.5rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat span {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 700;
}

/* ---------- cards ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 16px;
}

.prompt {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 700;
}

.question {
  font-size: clamp(1.7rem, 6vw, 2.4rem);
  font-weight: 800;
  letter-spacing: .01em;
  margin: 0;
  overflow-x: auto;
}

.question .var { font-style: italic; }

.given {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.given li {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 1.05rem;
}

/* ---------- inputs / buttons ---------- */

.answer-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

input[type="text"] {
  flex: 1 1 180px;
  min-width: 0;
  font: 800 1.5rem/1.2 var(--mono);
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--field);
  color: var(--ink);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
}

button {
  font: 800 1rem var(--font);
  padding: 13px 22px;
  border: none;
  border-radius: 14px;
  background: var(--brand);
  color: var(--on-brand);
  cursor: pointer;
}

button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }

button.ghost {
  background: var(--card);
  color: var(--muted);
  box-shadow: inset 0 0 0 2px var(--line);
}

/* ---------- term chips (tap-to-select games) ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 0;
}

.chip {
  font: 800 1.35rem var(--font);
  padding: 10px 18px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--field);
  color: var(--ink);
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}

.chip.target {
  border-color: var(--warn);
  background: var(--warn-soft);
  color: var(--warn);
  cursor: default;
  animation: glow 1.4s ease-in-out infinite;
}

.chip.hit { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.chip.miss { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }

@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 var(--glow-on); }
  50% { box-shadow: 0 0 0 8px var(--glow-off); }
}

@media (prefers-reduced-motion: reduce) {
  .chip.target { animation: none; }
}

/* ---------- feedback ---------- */

.feedback {
  border-radius: var(--radius);
  padding: 16px 20px;
  font-weight: 700;
  margin-bottom: 16px;
}

.feedback[hidden] { display: none; }
.feedback.good { background: var(--good-soft); color: var(--good); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback .why {
  display: block;
  font-weight: 600;
  color: var(--ink);
  margin-top: 6px;
  font-size: .95rem;
}

.hint {
  background: var(--warn-soft);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 16px;
  font-size: .95rem;
}

.hint[hidden] { display: none; }
.hint b { color: var(--warn); }

/* ---------- level picker ---------- */

.levels {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.levels button {
  background: var(--card);
  color: var(--muted);
  box-shadow: var(--shadow);
  padding: 9px 16px;
  font-size: .9rem;
}

.levels button[aria-pressed="true"] {
  background: var(--brand);
  color: var(--on-brand);
}

/* ---------- hub grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

a.tile {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

a.tile:hover { transform: translateY(-2px); }
a.tile .emoji { font-size: 2rem; display: block; }
a.tile h2 { font-size: 1.1rem; margin: 8px 0 4px; }
a.tile p { margin: 0; color: var(--muted); font-size: .9rem; }


/* ---------- inline fractions ---------- */

.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 .18em;
  font-size: .78em;
  line-height: 1.15;
}

.frac .num { border-bottom: .09em solid currentColor; padding: 0 .3em .05em; }
.frac .den { padding: .05em .3em 0; }

/* ---------- dark theme ----------
   Only tokens are redefined; every component above styles through them. The bare :root
   block holds the complete light palette, so the un-stamped "system" state resolves too. */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10141f;
    --card: #1a2030;
    --ink: #e8edf9;
    --muted: #9aa8c4;
    --line: #2b3550;
    --brand: #8f9bff;
    --brand-soft: #262f4d;
    --good: #4fd396;
    --good-soft: #1b3a2e;
    --bad: #ff7d7d;
    --bad-soft: #3d2226;
    --warn: #f0ae4e;
    --warn-soft: #3a2e1a;
    --field: #141a28;
    --on-brand: #10141f;
    --shadow-tint: rgba(0, 0, 0, .75);
    --glow-on: rgba(240, 174, 78, .4);
    --glow-off: rgba(240, 174, 78, 0);
  }
}

:root[data-theme="dark"] {
  --bg: #10141f;
  --card: #1a2030;
  --ink: #e8edf9;
  --muted: #9aa8c4;
  --line: #2b3550;
  --brand: #8f9bff;
  --brand-soft: #262f4d;
  --good: #4fd396;
  --good-soft: #1b3a2e;
  --bad: #ff7d7d;
  --bad-soft: #3d2226;
  --warn: #f0ae4e;
  --warn-soft: #3a2e1a;
  --field: #141a28;
  --on-brand: #10141f;
  --shadow-tint: rgba(0, 0, 0, .75);
  --glow-on: rgba(240, 174, 78, .4);
  --glow-off: rgba(240, 174, 78, 0);
}

/* ---------- expressions you can operate on ---------- */

.expr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 4px 0 18px;
}

/* The joint is the whole point: + and - are seams between blocks, not instructions. */
.joint {
  font: 800 1.6rem var(--font);
  color: var(--muted);
  padding: 0 2px;
  transition: color .15s, transform .15s;
}

.joint.blocked {
  color: var(--bad);
  transform: scale(1.35);
}

.chip.picked {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  transform: translateY(-3px);
}

.chip .coeff { font-variant-numeric: tabular-nums; }

.chip.shake { animation: shake .34s; }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

.chip.fused { animation: fuse .38s; }

@keyframes fuse {
  0% { transform: scale(1); }
  45% { transform: scale(1.22); border-color: var(--good); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .chip.shake, .chip.fused { animation: none; }
}

/* why a move was refused, or what a merge just did */
.why-line {
  min-height: 1.5em;
  font-weight: 700;
  font-size: .95rem;
  color: var(--muted);
  margin: 0 0 12px;
}

.why-line.bad { color: var(--bad); }
.why-line.good { color: var(--good); }

/* the game -> paper bridge. Never let a round end without it. */
.bridge {
  background: var(--brand-soft);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-top: 16px;
}

.bridge b {
  display: block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--brand);
  margin-bottom: 6px;
}

.bridge .written {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--ink);
  overflow-x: auto;
}

/* ---------- the one idea, stated once on the hub ---------- */

.idea {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 5px solid var(--brand);
  padding: 18px 22px;
  margin-bottom: 18px;
}

.idea b {
  display: block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--brand);
  margin-bottom: 8px;
}

.idea p { margin: 0 0 8px; max-width: 62ch; }
.idea p:last-child { margin-bottom: 0; }
.idea em { font-style: italic; }

.idea .op {
  font-weight: 800;
  color: var(--warn);
  padding: 0 1px;
}

/* ---------- step builder ---------- */

.chip-label {
  display: inline-block;
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 4px 12px;
  border-radius: 999px;
  margin: 0 0 14px;
}

/* the working builds downwards — this is the thing she takes to paper */
ol.working {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

ol.working li {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--muted);
  padding: 6px 12px;
  border-left: 3px solid var(--line);
  overflow-x: auto;
}

ol.working li.now {
  color: var(--ink);
  border-left-color: var(--brand);
  font-size: clamp(1.5rem, 5.5vw, 2rem);
}

.moves {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

button.move {
  background: var(--card);
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--line), var(--shadow);
  font-size: 1rem;
  padding: 14px 20px;
}

button.move:hover { box-shadow: inset 0 0 0 2px var(--brand), var(--shadow); }

button.move.done {
  background: var(--good-soft);
  color: var(--good);
  box-shadow: inset 0 0 0 2px var(--good-soft), var(--shadow);
}

.bridge .process {
  margin: 10px 0 0;
  font-size: .9rem;
  font-weight: 700;
  color: var(--muted);
}

/* ---------- banned values: the second half of a fraction question ---------- */

.banned {
  background: var(--warn-soft);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 16px;
}

.banned b {
  display: block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--warn);
  margin-bottom: 6px;
}

.banned p { margin: 0 0 12px; font-size: .95rem; }
.banned .chips { margin: 0; }
.banned .chip { font-size: 1.1rem; padding: 8px 14px; }
.banned .answer-row { margin-top: 14px; }
.banned .why-line { margin: 10px 0 0; }

/* ---------- HCF pieces + word-problem options ---------- */

.piece-label {
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 0 0 8px;
}

.hcf-and {
  display: inline-block;
  font-size: .8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0 14px;
  vertical-align: middle;
}

.chip.quiet {
  opacity: .7;
  cursor: default;
  border-style: dashed;
}

.chips + .piece-label { margin-top: 20px; }

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 4px;
}

button.option {
  text-align: left;
  font: 800 1.25rem var(--font);
  background: var(--card);
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--line), var(--shadow);
  padding: 15px 20px;
}

button.option:hover:not(:disabled) { box-shadow: inset 0 0 0 2px var(--brand), var(--shadow); }
button.option.hit { box-shadow: inset 0 0 0 2px var(--good); background: var(--good-soft); color: var(--good); }
button.option.miss { box-shadow: inset 0 0 0 2px var(--bad); background: var(--bad-soft); color: var(--bad); }
button.option:disabled { opacity: 1; }

/* the story sits in the prompt slot and needs room to breathe */
.prompt { line-height: 1.55; }

/* ---------- predict the result ---------- */

.predict {
  background: var(--brand-soft);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 14px;
}

.predict b {
  display: block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--brand);
  margin-bottom: 10px;
}

.predict .options { gap: 8px; }
.predict button.option { font-size: 1.15rem; padding: 13px 18px; }

/* ==================================================================
   Phones. Measured at 390–500px: the level picker wrapped to two or
   three rows and the scoreboard took another 64px, so 44% of the
   screen was gone before any maths appeared, and every tap target was
   35–37px against the 44px guideline. The maths is the point; the
   chrome around it gets out of the way.
   ================================================================== */

@media (max-width: 620px) {
  .wrap { padding: 12px 14px 56px; }

  .topbar { gap: 8px; margin-bottom: 12px; }
  .topbar h1 { font-size: 1.15rem; }
  .topbar .tagline { font-size: .88rem; }

  /* one swipeable row instead of three stacked ones */
  .levels {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* No full-bleed negative margin: it makes the strip wider than the viewport, and the
       whole page then scrolls sideways instead of just the strip. */
    margin: 0 0 12px;
    padding: 2px 0 6px;
  }

  .levels::-webkit-scrollbar { display: none; }

  .levels button {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 44px;
  }

  /* the score is not the point — keep it, shrink it */
  .scoreboard { gap: 6px; margin-bottom: 12px; }
  .stat { padding: 7px 8px; }
  .stat b { font-size: 1.15rem; }
  .stat span { font-size: .6rem; letter-spacing: .06em; }

  .card { padding: 16px 15px; }
  .prompt { font-size: .98rem; }

  /* everything you tap clears 44px */
  button,
  .back { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; }
  .chip { min-height: 44px; display: inline-flex; align-items: center; }
  button.move { width: 100%; }
  /* inline-flex turns every bit of maths markup into a flex item and eats the spaces
     between them: "2x − 6y = 6" rendered as "2x− 6y= 6". Options hold maths — keep them block. */
  button.option { display: block; }
  .moves { gap: 8px; }

  ol.working li { font-size: 1.15rem; padding: 4px 10px; }
  ol.working li.now { font-size: clamp(1.4rem, 7vw, 1.9rem); }

  .bridge, .banned, .predict, .idea { padding: 14px 16px; }
  .bridge .written { font-size: 1.05rem; }

  .feedback, .hint { padding: 13px 16px; }
  .answer-row { margin-top: 14px; }
  input[type="text"] { font-size: 1.25rem; min-height: 48px; }
}

/* very narrow: give the maths every pixel it can have */
@media (max-width: 400px) {
  .wrap { padding: 10px 12px 56px; }
  .stat b { font-size: 1rem; }
  .question { font-size: clamp(1.45rem, 8vw, 1.9rem); }
  button.option { font-size: 1.05rem; padding: 13px 14px; }
}

/* ==================================================================
   Simultaneous equations chapter: grid, keypad, goal banner, stories.
   ================================================================== */

/* ---------- coordinate grid ---------- */

.grid-wrap { margin: 4px auto 10px; max-width: 440px; }

.grid-readout {
  text-align: center;
  font: 700 .9rem var(--font);
  color: var(--muted);
  min-height: 1.6em;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.grid-readout.live { color: var(--brand); font: 800 1.6rem var(--mono); }

.grid-svg {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* only a grid that wants taps swallows the touch — elsewhere the page still scrolls */
.grid-svg.tappable { touch-action: none; cursor: crosshair; }

.g-bg { fill: var(--field); }
.g-grid { stroke: var(--line); stroke-width: 1.2; }
.g-axis { stroke: var(--muted); stroke-width: 2.4; }
.g-tick { fill: var(--muted); font-family: var(--font); font-weight: 700; }
.g-name { fill: var(--ink); font: italic 800 18px var(--font); }
.g-label { font: 800 17px var(--font); paint-order: stroke; stroke: var(--field); stroke-width: 5px; }

.g-line line { stroke-width: 4.5; stroke-linecap: round; }
.g-line-a line { stroke: var(--brand); }
.g-line-a .g-label { fill: var(--brand); }
.g-line-b line { stroke: var(--warn); }
.g-line-b .g-label { fill: var(--warn); }
.g-line-user line { stroke: var(--ink); }
.g-line-good line { stroke: var(--good); }
.g-line-bad line { stroke: var(--bad); }
.g-line-ghost line { stroke: var(--good); opacity: .55; }
.g-dashed line { stroke-dasharray: 10 8; }

.g-pt circle { stroke: var(--field); stroke-width: 3; }
.g-pt-user circle { fill: var(--ink); }
.g-pt-good circle { fill: var(--good); }
.g-pt-bad circle { fill: var(--bad); }
.g-pt-given circle { fill: var(--brand); }
.g-pt-hot circle { fill: var(--warn); }
.g-pt-hot { animation: pulse 1.3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.g-pt .g-label { fill: var(--ink); }

@keyframes pulse { 50% { transform: scale(1.35); } }
@media (prefers-reduced-motion: reduce) { .g-pt-hot { animation: none; } }

.g-cross line { stroke: var(--brand); stroke-width: 1.5; stroke-dasharray: 4 5; }
.g-cross circle { fill: none; stroke: var(--brand); stroke-width: 3; }

/* equation chips that say which colour is which line */
.eqs { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 10px; }
.eqn {
  font-size: clamp(1.15rem, 4.8vw, 1.45rem);
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--field);
  border-left: 5px solid var(--line);
  overflow-x: auto;
}
.eqn.a { border-left-color: var(--brand); }
.eqn.b { border-left-color: var(--warn); }
.eqn .tag { color: var(--muted); font-size: .8em; margin-right: 8px; }

/* ---------- goal banner: the finish line stays on screen ---------- */

.goal {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  background: var(--warn-soft);
  border-radius: 12px;
  padding: 8px 12px;
  margin: 0 0 12px;
  font-weight: 800;
}
.goal b {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--warn);
}
.goal .slot { font-size: 1.1rem; color: var(--ink); }
.goal .slot.done { color: var(--good); }

/* ---------- typed answers with an on-screen keypad ---------- */

.fields { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 8px; }
.field { display: flex; align-items: center; gap: 10px; }
.field label { font-weight: 800; font-size: 1.15rem; min-width: 2.2em; text-align: right; }
.field label.long { min-width: 6.4em; text-align: left; flex: 0 0 auto; font-size: 1rem; white-space: nowrap; }
.field input[type="text"] { flex: 1 1 auto; font-size: 1.3rem; padding: 10px 14px; }
.field input.on { border-color: var(--brand); }
.field input.wrong { border-color: var(--bad); background: var(--bad-soft); }
.field input.right { border-color: var(--good); background: var(--good-soft); }
.field .unit { color: var(--muted); font-weight: 700; }

.keypad {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin: 8px 0 4px;
}
.keypad button {
  padding: 0;
  min-height: 46px;
  font: 800 1.2rem var(--font);
  background: var(--card);
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--line);
}
.keypad button.wide { grid-column: span 2; }
.keypad button.k-var { font-style: italic; color: var(--brand); }
.keypad button.k-del { color: var(--bad); }

/* ---------- multi-step rounds ---------- */

.step-prompt { font-weight: 800; margin: 4px 0 10px; }
ol.working li .tag { font-size: .7em; color: var(--muted); margin-right: 8px; font-weight: 700; }
.letters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.letters span {
  background: var(--brand-soft);
  color: var(--ink);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .92rem;
  font-weight: 700;
}
.story { font-size: 1.08rem; line-height: 1.6; margin: 0 0 12px; }
.story b { color: var(--brand); }
.checks { font-size: .98rem; font-weight: 700; margin: 8px 0 0; }
.checks div { padding: 2px 0; }
.checks .ok { color: var(--good); }
.checks .no { color: var(--bad); }
.kind-blurb { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-top: 2px; }
.figure { display: block; max-width: 300px; width: 100%; margin: 0 auto 12px; }
.figure text { font: 700 15px var(--font); fill: var(--ink); }
.figure .shape { fill: var(--brand-soft); stroke: var(--brand); stroke-width: 3; }
.figure .tick { stroke: var(--brand); stroke-width: 3; }

/* ---------- report ---------- */

.report h3 { margin: 18px 0 8px; font-size: 1rem; }
.report table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.report td, .report th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.report td.n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; }
.report .bar { height: 8px; border-radius: 4px; background: var(--brand); }
.summary-big { font-size: 2.2rem; font-weight: 800; margin: 4px 0; }

@media (max-width: 620px) {
  .keypad button { min-height: 46px; font-size: 1.15rem; }
  .story { font-size: 1rem; }
  .goal .slot { font-size: 1rem; }
}

.opt-body { display: block; }

/* ---------- explanations ---------- */

details.explain {
  margin-top: 12px;
  background: var(--card);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
}
details.explain summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--brand);
  min-height: 32px;
  display: flex;
  align-items: center;
}
.explain-body { margin-top: 8px; line-height: 1.6; font-size: .98rem; }
.explain-body ol { margin: 6px 0 0; padding-left: 1.2em; }
.explain-body li { margin: 4px 0; }
.explain-body .m { font-weight: 800; white-space: nowrap; }

button.continue { background: var(--good); color: var(--on-brand); }

.worked { margin: 4px 0 6px; }
.worked-title { display: block; margin-bottom: 8px; }
ol.worked-steps { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 12px; }
ol.worked-steps li { padding-left: 4px; }
.w-line { font-size: 1.25rem; font-weight: 800; overflow-x: auto; }
.w-why { color: var(--muted); font-weight: 600; font-size: .95rem; margin-top: 2px; }
