/* Harry's teaching quiz: the quiz, Dad's usage page and the animation stage. No web fonts or CDN: some of
   those are blocked in China, so everything here is the phone's own system fonts. The navy matches his crib sheets. */
:root {
  color-scheme: light dark;
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1d2733;
  --muted: #3f4c5a;
  --faint: #5f6b78;          /* was #8794a2, 3.1:1: Andy found the stage faint (11 Oct 2026) */
  --line: #dbe2ea;
  --accent: #1f4e79;
  --accent-bg: #e6eef8;
  --accent-line: #a7c0dc;
  --on-accent: #ffffff;
  --good: #2b7a31;
  --good-bg: #e7f4e9;
  --good-line: #98cb9f;
  --bad: #b3261e;
  --bad-bg: #fbe9e7;
  --bad-line: #eba59f;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
  --warn-line: #efcd84;
  --paper-colour: #f2b544;
  --paper-colour-line: #c98a14;
  --paper-shade: #dc9a26;
  --court: #d9eedd;
  --court-edge: #7aae86;
  --court-line: #ffffff;
  --ball: #cddc39;
  --ball-line: #8a9a1a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --card: #18212b;
    --ink: #e6edf3;
    --muted: #c0cbd6;
    --faint: #8d9aa8;
    --line: #2b3744;
    --accent: #8db7e6;
    --accent-bg: #1b2d43;
    --accent-line: #3e6189;
    --on-accent: #0f1419;
    --good: #7ccb84;
    --good-bg: #16301b;
    --good-line: #2f6b39;
    --bad: #f19a91;
    --bad-bg: #3b1a18;
    --bad-line: #7d342d;
    --warn: #f0c56a;
    --warn-bg: #3a2c0e;
    --warn-line: #7c5c18;
    --paper-colour: #c98f2a;
    --paper-colour-line: #e2b04e;
    --paper-shade: #a7731c;
    --court: #1c3a26;
    --court-edge: #3f7a50;
    --court-line: #c6dbcb;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "PingFang SC", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) 56px max(16px, env(safe-area-inset-left));
}
h1 { font-size: 26px; line-height: 1.25; margin: 8px 0 6px; }
h2 { font-size: 19px; line-height: 1.3; margin: 24px 0 10px; }
p { margin: 0 0 10px; }
a { color: var(--accent); }
.lede { color: var(--muted); }
.note { color: var(--muted); font-size: 14px; margin-top: 20px; }
.loading, .error { color: var(--muted); padding: 40px 0; text-align: center; }
.error { color: var(--bad); }
.back { margin-bottom: 8px; }
.tester {
  background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); border-radius: 10px;
  padding: 8px 12px; font-size: 14px; margin: 0 0 12px;
}
.tester a { color: inherit; font-weight: 600; }
.back a { text-decoration: none; font-size: 15px; }

/* ---- Home ---- */
.crane-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; margin: 16px 0;
}
.crane-card h2 { margin: 0 0 4px; }
.crane-card p { margin: 0; color: var(--muted); font-size: 15px; }
.crane-card .mv-crane { flex: none; }
.modules { display: flex; flex-direction: column; gap: 10px; }
.module {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; color: var(--ink); text-decoration: none;
}
.module:hover, .module:focus-visible { border-color: var(--accent-line); }
.module-num {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-bg); color: var(--accent); font-weight: 600;
}
.module.passed .module-num { background: var(--good-bg); color: var(--good); }
.module-main { display: flex; flex-direction: column; min-width: 0; }
.module-title { font-size: 17px; font-weight: 600; }
.module-sub { color: var(--muted); font-size: 14px; }
.module-obs { color: var(--faint); font-size: 13px; }
.module-status { font-size: 14px; color: var(--muted); white-space: nowrap; }
.module.passed .module-status { color: var(--good); font-weight: 600; }
/* The next lesson: above the crane, outside the course. */
.lessons { margin-bottom: 14px; }
.module.lesson { border-color: var(--accent-line); background: var(--accent-bg); }
.module.lesson .module-num { background: var(--accent); color: var(--on-accent); }

/* ---- Buttons ---- */
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 46px;
  padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn[hidden] { display: none; }

/* ---- A question ---- */
.scorebar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 6px 0 12px; }
.pos { color: var(--muted); font-size: 14px; }
.board {
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px;
  background: var(--accent-bg); color: var(--accent); border-radius: 999px; padding: 4px 12px;
}
.kind { color: var(--accent); font-size: 13px; font-weight: 600; margin: 0 0 6px; }
.scene {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent-line); border-radius: 0 12px 12px 0;
  padding: 10px 14px; color: var(--muted);
}
.question { font-size: 20px; margin: 14px 0; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  width: 100%; display: flex; align-items: flex-start; gap: 12px; text-align: left;
  min-height: 52px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; cursor: pointer;
}
.option:disabled { cursor: default; }
.option .letter {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-bg); color: var(--accent); font-size: 14px; font-weight: 600;
}
.option.right { background: var(--good-bg); border-color: var(--good-line); }
.option.right .letter { background: var(--good); color: var(--card); }
.option.wrong { background: var(--bad-bg); border-color: var(--bad-line); }
.option.wrong .letter { background: var(--bad); color: var(--card); }
.why { margin: 6px 6px 2px 54px; font-size: 14px; color: var(--muted); }
.why[hidden] { display: none; }
.feedback { margin-top: 16px; scroll-margin-top: 12px; }
.verdict { font-size: 18px; font-weight: 600; }
.verdict.right { color: var(--good); }
.verdict.wrong { color: var(--bad); }
.analogy {
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: 12px; padding: 12px 14px; margin: 10px 0;
}
.analogy.tennis { background: var(--good-bg); }
.analogy.origami { background: var(--warn-bg); }
.analogy p { margin: 0; }
.analogy-icon { flex: none; font-size: 22px; line-height: 1; }
.rule { border: 1px dashed var(--accent-line); border-radius: 12px; padding: 10px 14px; margin: 10px 0; }
.watch-bit { margin: 10px 0; }
/* Say it aloud: the prompt, "Show me", the model answer, then he marks himself. */
.say-hint { color: var(--muted); font-size: 15px; margin: 0 0 12px; }
.model { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 16px 8px; }
.model[hidden], .selfmark[hidden] { display: none; }
.model-head { color: var(--accent); font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
.model li { margin: 6px 0; }
.selfmark { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.selfmark .btn.chosen { border-width: 2px; }
.selfmark .btn.said.chosen { background: var(--good-bg); border-color: var(--good-line); color: var(--good); }
.selfmark .btn.missed.chosen { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.player-host.small:empty { display: none; }

/* ---- The end of a round ---- */
.end { text-align: center; margin: 16px 0; }
.end-score { font-size: 46px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 0; color: var(--accent); }
.end .mv-crane { margin-top: 6px; }
.remember, .reread {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px 16px 10px;
}
.reread { margin-top: 12px; }
.remember h2, .reread h2 { margin-top: 12px; }
.remember li, .reread li { margin: 6px 0; }

/* ---- The animation player ---- */
.player-host { margin: 12px 0; }
.mv { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px 12px; }
.mv-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); min-height: 20px; }
.mv-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mv-stage { display: block; width: 100%; height: auto; margin: 4px 0; font-family: inherit; }
.mv-cap { font-size: 15px; min-height: 4.5em; margin: 6px 0 10px; }
.mv-controls { display: flex; align-items: center; gap: 8px; }
.mv-btn {
  min-width: 44px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-size: 17px; cursor: pointer;
}
.mv-dots { display: flex; flex-wrap: wrap; gap: 4px; margin-left: 6px; }
.mv-dot { width: 22px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer; position: relative; }
.mv-dot::after {
  content: ""; position: absolute; inset: 6px; border-radius: 50%;
  border: 1px solid var(--faint); background: var(--card);
}
.mv-dot.on::after { background: var(--accent); border-color: var(--accent); }
.mv-bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.mv-bar-fill { display: block; height: 100%; width: 0; background: var(--accent); }

.rotate-hint { display: none; color: var(--muted); font-size: 14px; margin: 8px 0 0; }

/* A phone held upright shrinks the 680-wide stage to half size: run it edge to edge and suggest turning the
   phone. Held sideways, the player takes the whole width and the stage's words come out at about 16px. */
@media (max-width: 600px) and (orientation: portrait) {
  .player-host { margin-left: -16px; margin-right: -16px; }
  .player-host .mv { border-radius: 0; border-left: 0; border-right: 0; }
  .rotate-hint { display: block; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .player-host {
    width: 100vw; margin-left: calc(50% - 50vw);
    padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
  }
  .player-host .mv { border-radius: 0; border-left: 0; border-right: 0; padding-top: 6px; }
  /* Stage, caption and controls on one screen: the stage gives up height, keeping its shape. */
  .mv-stage { height: calc(100vh - 124px); height: calc(100dvh - 124px); width: auto; max-width: 100%; margin: 0 auto; }
  .mv-cap { min-height: 0; margin: 4px 0 6px; }
}

/* "Bigger": the player on its side, filling the screen of a phone held upright (motion.js). Positioned at the right
   edge and turned a quarter clockwise about its top-left corner, its width runs down the screen's height. */
.mv-big-btn { display: none; margin-left: auto; font-size: 15px; padding: 0 12px; }
@media (max-width: 600px) and (orientation: portrait) {
  .mv-big-btn { display: inline-block; }
}
.mv.big { margin: 0; border: 0; border-radius: 0; overflow: hidden; }
@media (orientation: portrait) {
  .mv.big {
    position: fixed; z-index: 100; top: 0; left: 100vw;
    width: 100vh; width: 100dvh; height: 100vw;
    transform-origin: top left; transform: rotate(90deg);
    padding: 8px max(16px, env(safe-area-inset-top)) 8px 16px;
  }
  .mv.big .mv-stage { height: calc(100vw - 112px); width: auto; max-width: 100%; margin: 0 auto; }
}
/* Held sideways with the rotation lock off, the screen itself turns: turning the player too stood it back upright
   (Andy, 11 Oct 2026). Then it just fills the screen. */
@media (orientation: landscape) {
  .mv.big {
    position: fixed; z-index: 100; top: 0; left: 0; width: 100vw; height: 100vh; height: 100dvh;
    padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  }
  .mv.big .mv-stage { height: calc(100vh - 112px); height: calc(100dvh - 112px); width: auto; max-width: 100%; margin: 0 auto; }
}
.mv.big .mv-big-btn { display: inline-block; }      /* Close, whichever way the phone is held */
.mv.big .mv-cap { min-height: 0; margin: 4px 0 6px; }
.mv.big .mv-bar { display: none; }
html.mv-locked, html.mv-locked body { overflow: hidden; }

/* The stage itself */
.mv-head { fill: var(--card); stroke: var(--faint); stroke-width: 2; }
.mv-head.hi { stroke: var(--accent); }
.mv-body { fill: var(--bg); stroke: var(--faint); stroke-width: 1.8; }
.mv-body.hi { fill: var(--accent-bg); stroke: var(--accent); }
.mv-name { fill: var(--ink); font-weight: 500; }
.mv-name.hi { fill: var(--accent); font-weight: 700; }
.mv-bubble, .mv-card, .mv-pill { stroke-width: 1.8; }
.mv-bubble.n, .mv-card.n, .mv-pill.n { fill: var(--card); stroke: var(--faint); }
.mv-bubble.g, .mv-card.g, .mv-pill.g { fill: var(--good-bg); stroke: var(--good); }
.mv-bubble.b, .mv-card.b, .mv-pill.b { fill: var(--bad-bg); stroke: var(--bad); }
.mv-bubble.a, .mv-card.a, .mv-pill.a { fill: var(--accent-bg); stroke: var(--accent); }
.mv-card.a { stroke: var(--accent); stroke-width: 2; }
.mv-bubble.whisper { stroke-dasharray: 4 3; }
.mv-bubble-text, .mv-pill-text { fill: var(--ink); font-weight: 500; }
.mv-pill-text { font-weight: 600; }
.mv-bubble-text.whisper { font-style: italic; }
.mv-bubble-text.g, .mv-pill-text.g, .mv-card-title.g { fill: var(--good); }
.mv-bubble-text.b, .mv-pill-text.b, .mv-card-title.b { fill: var(--bad); }
.mv-bubble-text.a, .mv-pill-text.a, .mv-card-title.a, .mv-card-text.a { fill: var(--accent); }
.mv-pill-dash { stroke-width: 1.5; stroke: var(--muted); }
.mv-pill-dash.g { stroke: var(--good); }
.mv-strike { stroke: var(--bad); stroke-width: 2; }
.mv-card-title { font-weight: 700; fill: var(--ink); }
.mv-card-text { fill: var(--ink); }
.mv-label { fill: var(--ink); font-weight: 500; }
.mv-label.muted { fill: var(--muted); }
.mv-label.g { fill: var(--good); font-weight: 600; }
.mv-label.b { fill: var(--bad); font-weight: 600; }
.mv-label.it { font-style: italic; }
.mv-callout { fill: var(--card); stroke: var(--accent); stroke-width: 2; }
.mv-callout-text { fill: var(--ink); font-weight: 500; }
.mv-arrow { stroke: var(--accent); stroke-width: 2.2; fill: none; }
.mv-arrowhead { fill: var(--accent); }
.mv-badge.g { fill: var(--good-bg); stroke: var(--good); stroke-width: 1.8; }
.mv-badge.b { fill: var(--bad-bg); stroke: var(--bad); stroke-width: 1.8; }
.mv-badge.q { fill: var(--warn-bg); stroke: var(--warn); stroke-width: 1.8; }
.mv-badge-mark { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mv-badge-mark.g { stroke: var(--good); }
.mv-badge-mark.b { stroke: var(--bad); }
.mv-badge-q { fill: var(--warn); font-weight: 700; }
.mv-paper { fill: var(--card); stroke: var(--faint); stroke-width: 1.6; stroke-linejoin: round; }
.mv-paper.colour { fill: var(--paper-colour); stroke: var(--paper-colour-line); }
.mv-crease { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 6 5; }
.mv-court { fill: var(--court); stroke: var(--court-edge); stroke-width: 2; }
.mv-court-line { stroke: var(--court-line); stroke-width: 2; }
.mv-court-box { fill: var(--ball); opacity: 0.45; }
.mv-net { stroke: var(--ink); stroke-width: 2.5; }
.mv-player { fill: var(--accent); }
.mv-ball { fill: var(--ball); stroke: var(--ball-line); stroke-width: 1.5; }
.mv-trace { fill: none; stroke: var(--faint); stroke-width: 1.6; stroke-dasharray: 3 4; }
.mv-token { fill: var(--warn-bg); stroke: var(--warn); stroke-width: 1.6; }
.mv-board { fill: var(--card); stroke: var(--faint); stroke-width: 1.5; }
.mv-board-title { font-weight: 700; fill: var(--ink); }
.mv-board-item { fill: var(--ink); font-weight: 500; }
.mv-board-item.done { fill: var(--muted); }
.mv-card-label { fill: var(--muted); font-weight: 500; }
.mv-intro-title { font-weight: 700; fill: var(--ink); }
.mv-intro-item { fill: var(--ink); font-weight: 500; }
.mv-intro-item.todo { fill: var(--muted); }
.mv-num { fill: var(--accent-bg); stroke: var(--accent); stroke-width: 1.5; }
.mv-num-text { font-weight: 600; fill: var(--accent); }
.mv-todo { fill: none; stroke: var(--faint); stroke-width: 1.5; }
.mv-crane-w { fill: var(--card); stroke: var(--faint); stroke-width: 1.5; stroke-linejoin: round; }
.mv-crane-c { fill: var(--paper-colour); stroke: var(--paper-colour-line); stroke-width: 1.5; stroke-linejoin: round; }
.mv-crane-d { fill: var(--paper-shade); stroke: var(--paper-colour-line); stroke-width: 1.5; stroke-linejoin: round; }

/* ---- Dad's usage page ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 16px 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; }
.tile-label { color: var(--muted); font-size: 13px; }
.tile-value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--card); border-radius: 12px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; font-size: 13px; }
.table tr.passed td:nth-child(3) { color: var(--good); font-weight: 600; }
.rows { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.rows li { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.rows li:last-child { border-bottom: 0; }
.rows li:has(> .row-what:first-child) { grid-template-columns: minmax(0, 1fr) auto; }
.row-when { color: var(--muted); }
.row-sub { color: var(--muted); font-size: 13px; }
.row-mins { color: var(--muted); white-space: nowrap; }
.row-mins.miss { color: var(--bad); }
@media (max-width: 480px) {
  .rows li { grid-template-columns: minmax(0, 1fr) auto; }
  .row-when { grid-column: 1 / -1; }
}
