/* Number Lab — math, Grades 1–3.
   Shares Word Play's palette and chunky-button language so the pages read as
   one family. Numbers are set in a tabular face at a large size: at six or
   seven the digits themselves are still being read, and a 6 that could be a 5
   is a maths error that was never about maths. Light theme only — school
   tablets and projectors are almost always in light mode. */

:root {
  --bg: #fff8ef;
  --bg-2: #ffeedd;
  --ink: #2c2440;
  --ink-soft: #6b6180;
  --card: #ffffff;
  --line: #e8ddd0;
  --line-strong: #bfae99;

  --green: #22a06b;
  --green-soft: #d8f5e8;
  --orange: #f08c2e;
  --orange-soft: #ffead4;
  --blue: #3b82d6;
  --blue-soft: #ddeafc;
  --purple: #8b5cf6;
  --purple-soft: #ece5fe;
  --purple-deep: #5b21b6;
  /* Deep enough to be read, not just seen, on their own soft backgrounds:
     6.3 and 5.5 against them. The mid tones (--orange, --blue) sit at 2.1
     and 3.2 there, which is a colour you notice and a word you squint at.

     The blue is also chosen against the ink it sits next to, not only
     against its background. --ink is itself a blue-purple, so a deep navy
     came out as the same hue only more saturated: 50 against the rust's 65,
     and the blue mark read visibly weaker than the orange one. This brighter
     blue measures 63, so a marked word is equally findable in both panels.
     It costs contrast (7.2 down to 5.5) and is still well clear of 4.5. */
  --orange-deep: #9a3412;
  --blue-deep: #1d4ed8;

  --good: #22a06b;
  --good-soft: #d8f5e8;
  --oops: #e8734a;
  --oops-soft: #ffe4da;

  --radius: 22px;
  --shadow: 0 4px 0 rgba(44, 36, 64, .12);
  --shadow-lift: 0 8px 0 rgba(44, 36, 64, .12);

  --num: "SF Mono", "Menlo", "Consolas", "Roboto Mono", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  background: linear-gradient(170deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Nunito", "Quicksand", "Trebuchet MS", "Avenir Next", system-ui, -apple-system, sans-serif;
  font-size: 18px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: 12px; top: 12px; z-index: 20;
  background: var(--card); padding: 10px 16px; border-radius: 12px;
}

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

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top, 0px));
  max-width: 960px;
  margin: 0 auto;
}

.bar-title {
  flex: 1;
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -.01em;
  text-align: center;
}

/* On a phone the longer topic names ("Area and perimeter") wrap to two lines
   and push the bar down over the question. */
@media (max-width: 430px) {
  .bar-title { font-size: 1.05rem; }
  .bar { gap: 6px; padding: 12px 12px; }
}

.bar-btn {
  flex: none;
  width: 52px;
  height: 52px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.bar-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(44, 36, 64, .12); }

/* The way home to the Learning Corner, on a family device only (see the note
   in index.html). A link dressed as a bar button. It shows on the first
   screen, where there is no back button, and steps aside whenever there is
   one: two buttons side by side up there would be one too many on a phone. */
.bar-home { display: grid; place-items: center; text-decoration: none; }
.bar-home svg {
  width: 26px; height: 26px;
  fill: none; stroke: currentColor; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round;
}
.bar-home[hidden],
#backBtn:not([hidden]) + .bar-home { display: none; }

/* Anything bright sitting in a child's eyeline all lesson becomes one more
   thing to tap. The grown-up's buttons stay faint until they are wanted. */
.bar-btn-quiet {
  opacity: .38;
  box-shadow: none;
  border-color: transparent;
  background: transparent;
}
.bar-btn-quiet:hover, .bar-btn-quiet:focus-visible { opacity: 1; }

/* ---------------- screens ---------------- */

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 4px 16px 40px;
}

.screen { display: none; }
.screen.is-active { display: block; animation: rise .22s ease-out; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.lead {
  margin: 4px 0 12px;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink-soft);
}

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

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

/* Topics are rows, so one column on a phone — all seven then fit without
   scrolling, where the stacked cards ran out of screen after three and a
   half — and two side by side once there is room. */
#topicGrid { grid-template-columns: 1fr; gap: 9px; }

@media (min-width: 720px) {
  #topicGrid { grid-template-columns: 1fr 1fr; gap: 12px; }
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 148px;
  padding: 18px 14px;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.card:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(44, 36, 64, .12); }

.card-icon { font-size: 2.1rem; line-height: 1; }

/* The level number, in the same chip the topic icons sit in. */
.grade-num {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 2px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: inset 0 0 0 2px rgba(44, 36, 64, .07);
  font-family: var(--num);
  font-size: 1.5rem;
  font-weight: 700;
}
.card-name { font-size: 1.15rem; font-weight: 800; }
.card-blurb { font-size: .9rem; color: var(--ink-soft); }

/* ---------------- a topic, as a row ---------------- */

.card-row {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  min-height: 88px;
  padding: 12px 16px;
  text-align: left;
}

/* The chip is what makes a list of mixed icons hold together. "+" and "−"
   are flat text glyphs while the rest are full-colour emoji, so unframed
   they sat at wildly different visual weights down the column; a circle of
   fixed size gives every one of them the same footprint. */
.card-row .card-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: inset 0 0 0 2px rgba(44, 36, 64, .07);
  font-size: 1.6rem;
  line-height: 1;
}

.card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card-row .card-name { font-size: 1.1rem; }
.card-row .card-blurb { font-size: .85rem; line-height: 1.25; }

/* Best ever on a topic. Earned stars are gold and solid; the ones still to
   get are faint, so a list of untouched topics reads as things to collect
   rather than things already lost. */
.card-stars {
  flex: none;
  font-size: 1.05rem;
  letter-spacing: .06em;
  line-height: 1;
  white-space: nowrap;
}
.stars-got { color: #f0a92e; }
.stars-left { color: rgba(44, 36, 64, .18); }

/* Two rounds running at nine or better. A gold edge down the side, which a
   row has and a centred card does not — the previous inset ring sat just
   inside the green border and read as a rendering fault rather than an
   achievement. */
.card.is-mastered {
  border-left-width: 9px;
  border-left-color: #f0a92e;
  padding-left: 11px;
}

/* The running total under the level cards. */
.collection {
  display: flex;
  justify-content: center;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 22px 0 0;
  font-weight: 700;
  color: var(--ink-soft);
}
.collection[hidden] { display: none; }
.chip {
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 2px solid var(--line);
  font-size: .9rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.chip b { font-weight: 800; }

/* The one line on the results screen that is about more than this round. */
.done-note {
  margin: 2px 0 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--green);
}
.done-note[hidden] { display: none; }


.tint-green  { border-color: var(--green);  background: var(--green-soft); }
.tint-blue   { border-color: var(--blue);   background: var(--blue-soft); }
.tint-purple { border-color: var(--purple); background: var(--purple-soft); }

/* ---------------- show me how, or just practise ---------------- */

/* A heading, not a card. The boxed version repeated the icon, name and blurb
   from the card he had just tapped and pushed the two buttons — the only
   things on the screen with a job — most of the way down a phone. */
.intro-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 8px 22px;
  text-align: center;
}

.intro-icon {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(44, 36, 64, .07);
  font-size: 2.3rem;
  line-height: 1;
}

.intro-name { margin: 10px 0 0; font-size: 1.5rem; font-weight: 800; }
.intro-blurb { margin: 0; color: var(--ink-soft); font-weight: 600; }
.intro-stars { margin: 6px 0 0; font-size: 1.25rem; letter-spacing: .08em; }
.intro-stars[hidden] { display: none; }
.intro-badge { font-size: 1.05rem; }

.intro-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
  margin: 0 auto;
}

/* ---------------- the explanation ---------------- */

/* One dot per step. A child who cannot yet read "3 of 4" can still see how
   much is left, which is the difference between waiting and giving up. */
.dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 6px 0 16px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(44, 36, 64, .16);
}
.dot.is-on { background: var(--green); transform: scale(1.25); }

/* Bigger and airier than a question: this is being read, not answered. */
.teach-text {
  margin: 4px 0;
  max-width: 30ch;
  font-size: clamp(1.3rem, 4.6vw, 1.75rem);
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

/* Driven from the height rather than the width, so a tall clock and a wide
   row of coins both come out a sensible size from one rule. A figure too wide
   to fit is scaled down by the viewBox, never squashed. */
#teachFig .fig {
  width: auto;
  height: clamp(96px, 19vh, 170px);
  max-width: 100%;
}

.teach-actions { display: flex; justify-content: center; margin-top: 18px; }

.link-quiet {
  display: block;
  margin: 16px auto 0;
  padding: 8px 14px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: .92rem;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}
.link-quiet[hidden] { display: none; }

/* ---------------- progress ---------------- */

.progress {
  /* The width has to be said. On a tablet the play screen is a flex column
     (and, on its side, a grid), and there an item with auto side margins
     shrinks to its content — which for an empty bar is nothing. Without this
     the bar was simply not there at tablet width. */
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(44, 36, 64, .12);
  overflow: hidden;
  max-width: 520px;
  margin: 0 auto;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--green);
  transition: width .3s ease-out;
}

.progress-text {
  margin: 8px 0 14px;
  text-align: center;
  font-size: .92rem;
  font-weight: 700;
  color: var(--ink-soft);
}

/* ---------------- the question ---------------- */

/* A question, a slot and a number pad are a narrow column of work. Left to
   the page's 960px, "5 + 7 = ?" floated alone in a white bar three times
   wider than the keypad underneath it, which looked like a mistake on a
   laptop. The column is capped at the width the pad actually wants, and on
   a tall screen it sits in the middle of the viewport rather than clinging
   to the top with 400px of nothing below. */
#screen-play.is-active,
#screen-done.is-active,
#screen-intro.is-active,
#screen-teach.is-active {
  max-width: 520px;
  margin: 0 auto;
}

@media (min-width: 700px) and (min-height: 640px) {
  #screen-play.is-active,
  #screen-done.is-active {
    min-height: calc(100vh - 210px);
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  #screen-play.is-active .progress { margin-bottom: 0; }
}

/* A tablet on its side: wide, and short. Stacked, the question and the number
   pad together ran to about 810px, so on a 1024 × 768 iPad — less once the
   browser's own bars are counted — the pad's bottom row, with 0 and the ✓ he
   needs for every single answer, was below the edge of the screen, and the
   hint under that. Here they sit side by side instead: the question on the
   left with its help underneath it, the pad or the choices on the right,
   where a hand already is. Nothing is made smaller to fit.

   Only for a short landscape screen. A tablet held upright and a tall
   laptop window have the height for the single column, and keep it. The
   940px is measured, not chosen: the single column with a hint and the
   feedback line showing ends at 938px. */
@media (min-width: 800px) and (max-height: 940px) and (orientation: landscape) {
  #screen-play.is-active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 348px;
    /* progress · its label · the question · hint · feedback · whatever is
       left. The last row takes the slack, so a short question keeps its
       help tucked under it instead of being spread down the pad's height. */
    grid-template-rows: auto auto auto auto auto 1fr;
    column-gap: 28px;
    align-content: center;
    max-width: 900px;
  }
  #screen-play .progress,
  #screen-play .progress-text { grid-column: 1 / -1; }
  #screen-play .q-card   { grid-column: 1; grid-row: 3; }
  #screen-play .hint     { grid-column: 1; grid-row: 4; }
  #screen-play .feedback { grid-column: 1; grid-row: 5; }
  #screen-play .answer {
    grid-column: 2;
    grid-row: 3 / 7;
    align-self: start;
    margin-top: 0;
  }
}

.q-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 14px;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.fig-wrap { display: flex; justify-content: center; width: 100%; }
.fig-wrap[hidden] { display: none; }

/* Scaled down to fit a narrow phone, never blown up past its drawn size —
   a clock face stretched to fill a laptop is not easier to read. */
.fig {
  max-width: 100%;
  max-height: 210px;
  height: auto;
}

.ask {
  margin: 0;
  font-family: var(--num);
  font-size: clamp(1.9rem, 7vw, 2.7rem);
  font-weight: 700;
  letter-spacing: .02em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* A worded question ("Round 480 to the nearest hundred") is a sentence, not a
   sum: the monospaced digit face is there to keep 6 from reading as 5, and it
   only makes prose harder. app.js sets this class when the prompt is mostly
   words. */
/* A word problem is three short sentences, and at question size they would
   push the number pad off the bottom of a phone. The numbers inside it stay
   in the digit face, which is the one thing he has to pick out of the
   sentence. */
.ask.is-story {
  font-family: inherit;
  font-size: clamp(1.15rem, 4.2vw, 1.45rem);
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: 0;
  max-width: 26ch;
  font-variant-numeric: tabular-nums;
}

.ask.is-words {
  font-family: inherit;
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0;
}

/* ---------------- the way out of a stuck question ---------------- */

/* Offered, not pushed: it only appears after a third miss, and it is warm
   rather than loud — asking for help should not feel like ringing an alarm. */
.show-me {
  border: 2px solid var(--orange);
  border-radius: 14px;
  background: var(--orange-soft);
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  padding: 10px 20px;
  min-height: 48px;
  cursor: pointer;
}
.show-me:active { transform: translateY(2px); }
.show-me[hidden] { display: none; }

.solution { margin: 2px 0 0; text-align: center; }
.solution[hidden] { display: none; }

.solution-answer {
  margin: 0;
  font-family: var(--num);
  font-size: clamp(2rem, 8vw, 2.8rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--good);
}

.solution-do {
  margin: 2px 0 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink-soft);
}

/* ---------------- answering ---------------- */

.answer { margin-top: 18px; }

.answer-choices { display: grid; gap: 12px; }
.answer-choices.grid-up { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.answer-choices.two-up { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.opt {
  min-height: 96px;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  font-family: var(--num);
  font-size: 1.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.opt:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(44, 36, 64, .12); }

.opt.is-on { border-color: var(--good); background: var(--good-soft); }
/* A wrong option dims rather than disappears: he can see what he already
   ruled out, and nothing is taken away as a punishment. */
.opt.is-off { opacity: .4; }

/* ---------------- the number pad ---------------- */

.answer-pad { display: flex; justify-content: center; }

/* The answer he is building, inside the question card. A slot, not a second
   card: as a dashed panel of its own it weighed the same as the question and
   the two competed for the eye. */
.readout {
  display: block;
  min-width: 2.4em;
  min-height: 1.2em;
  margin: 2px 0 0;
  padding: 0 .18em 6px;
  border-bottom: 5px solid var(--line-strong);
  font-family: var(--num);
  font-size: clamp(2rem, 8vw, 2.6rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  text-align: center;
  color: var(--blue);
}
.readout[hidden] { display: none; }
.readout.is-empty { border-bottom-color: var(--blue); animation: slot 1.6s ease-in-out infinite; }

/* A slow pulse on the empty slot says "this is where it goes" without a
   label. It stops the moment he types. */
@keyframes slot {
  0%, 100% { border-bottom-color: var(--line-strong); }
  50% { border-bottom-color: var(--blue); }
}

.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(100%, 340px);
}

.key {
  height: 74px;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  font-family: var(--num);
  font-size: 1.7rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(44, 36, 64, .12); }

.key-soft { background: var(--bg-2); font-size: 1.4rem; }
.key-go { background: var(--good-soft); border-color: var(--good); color: var(--good); font-size: 1.6rem; }

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

.hint {
  margin: 16px auto 0;
  max-width: 520px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--orange-soft);
  border: 2px solid var(--orange);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
}

/* The same slot, saying what he just did rather than how to do it. Blue, not
   orange and not the red of being wrong: three different jobs want three
   different colours — red says "no", orange says "here is how", and this one
   says "here is what you did", which is information and should not look like
   a telling-off. */
.hint.is-why {
  background: var(--blue-soft);
  border-color: var(--blue);
  animation: hint-in .28s ease-out;
}

@keyframes hint-in {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: none; }
}

/* The word a teaching step is actually about. Purple: the play screen has
   already spent green on right, red on wrong and orange on the method, and a
   fourth meaning needs a colour of its own or it borrows one of theirs. The
   tint is a soft highlighter stripe rather than a block, so a sentence with
   two marked words still reads as a sentence. Named `term` because `.key`
   is the number pad's buttons. */
.term {
  color: var(--purple-deep);
  font-weight: 800;
  background: var(--purple-soft);
  border-radius: 6px;
  padding: 1px 5px;
  margin: 0 -1px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* The same mark inside the help panel. It cannot stay purple there: the
   panel is already orange for the method or blue for the mistake, and a
   third colour inside a coloured box is just noise. So it takes the panel's
   own hue, concentrated — "the important part of this", not a new kind of
   thing — and drops the stripe, which would be a tint on top of a tint.
   Weight carries it without colour: 800 against the panel's 600. */
.hint .term {
  color: var(--orange-deep);
  background: none;
  padding: 0;
  margin: 0;
  /* A shape, not just a colour. Both panel marks are *lighter* than the ink
     around them — vivid in colour, but with the colour taken away they turn
     into the palest words in the sentence, so the emphasis reads backwards.
     The teaching screen is safe without this because its mark sits on a
     stripe, which is already a shape. Here the underline is that shape.
     (Checked against deuteranopia and protanopia too, where all three marks
     hold up on colour alone — this is for the grey end of the range, and for
     a washed-out screen in sunlight.) */
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.hint.is-why .term { color: var(--blue-deep); }

.feedback {
  margin: 14px 0 0;
  min-height: 1.7em;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
}
.feedback.is-good { color: var(--good); }
.feedback.is-oops { color: var(--oops); }

/* A wrong answer wobbles and invites another try. Nothing is locked, nothing
   is scored on screen, and the round never moves on without a right answer. */
.is-wobble { animation: wobble .42s ease-in-out; }

@keyframes wobble {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
  .is-wobble { animation: none; outline: 3px solid var(--oops); }
  .screen.is-active { animation: none; }
  .hint.is-why { animation: none; }
}

/* ---------------- finished ---------------- */

#screen-done { text-align: center; padding-top: 24px; }

.done-emoji { font-size: 4.5rem; line-height: 1; }
.done-title { margin: 10px 0 4px; font-size: 1.6rem; font-weight: 800; }
.done-stars { margin: 0; font-size: 2rem; letter-spacing: .1em; }
.done-score { margin: 4px 0 8px; color: var(--ink-soft); font-weight: 700; }

/* Spaced from here rather than from the score, so the gap is the same whether
   or not the note above it is showing. A stack of equal widths: sized to
   their own text they came out three different widths centred under each
   other, which looked like three unrelated things. */
.done-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
  margin: 18px auto 0;
}

.btn {
  min-height: 56px;
  padding: 0 22px;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(44, 36, 64, .12); }
.btn-primary { background: var(--green-soft); border-color: var(--green); color: var(--green); }
/* Must come after .btn — same specificity, so source order is what decides.
   Warmer than a plain button but quieter than "Go again": an invitation to
   move up should not shove him out of something he has just succeeded at. */
.btn-next { background: var(--orange-soft); border-color: var(--orange); color: var(--ink); }
.btn-next[hidden] { display: none; }
.btn-small { min-height: 44px; font-size: .9rem; padding: 0 14px; }
/* The two choices before a round, and Next through the explanation — a tablet
   target, in the same family as the answer buttons. */
.btn-big { min-height: 74px; font-size: 1.15rem; padding: 0 30px; }
.btn[hidden] { display: none; }

/* ---------------- grown-up panel ---------------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(28, 22, 40, .45);
}

/* `display: flex` above beats the `hidden` attribute's own `display: none`,
   so the panel needs telling explicitly — without this it is open on load. */
.sheet[hidden] { display: none; }

.sheet-box {
  width: min(680px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  border-radius: 26px 26px 0 0;
  background: var(--bg);
  box-shadow: 0 -8px 30px rgba(28, 22, 40, .2);
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 2px solid var(--line);
}
.sheet-head h2 { flex: 1; margin: 0; font-size: 1.2rem; }

.sheet-body {
  overflow-y: auto;
  padding: 6px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  -webkit-overflow-scrolling: touch;
}

.block { padding: 16px 0; border-bottom: 1px solid var(--line); }
.block:last-child { border-bottom: 0; }
.block h3 { margin: 0 0 8px; font-size: 1rem; }
.block-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

.muted { color: var(--ink-soft); font-size: .92rem; margin: 0 0 8px; }
.stat-row { margin: 0; font-weight: 700; }

.weak-list { list-style: none; margin: 0; padding: 0; }
.weak-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-weight: 600;
}
.weak-list li span:first-child { flex: 1; }

.tag {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--oops-soft);
  color: var(--oops);
  font-size: .8rem;
  font-weight: 800;
}

.log-wrap { max-height: 300px; overflow: auto; border: 2px solid var(--line); border-radius: 14px; }

.log { width: 100%; border-collapse: collapse; font-size: .9rem; }
.log th, .log td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.log th { position: sticky; top: 0; background: var(--bg-2); font-size: .82rem; }
.log td:first-child { font-family: var(--num); }
/* What he actually answered, under the question it belongs to. */
.log .tried {
  display: block;
  color: var(--oops);
  font-family: inherit;
  font-size: .82rem;
  font-weight: 700;
}

.count { color: var(--ink-soft); font-size: .85rem; font-weight: 700; }
.muted-inline { color: var(--ink-soft); font-size: .82rem; font-weight: 600; }
/* Boxes filled on the way to being retired — quiet, because it is a to-do
   list for the page, not a score for the child. */
.tag-quiet { background: var(--bg-2); color: var(--ink-soft); letter-spacing: .12em; }

.log .ans { color: var(--good); font-weight: 700; }
.log .ans::before { content: "→ "; color: var(--ink-soft); font-weight: 400; }
.log tr.is-missed td { background: var(--oops-soft); }

select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
}

/* ---------------- site footer ---------------- */

.site-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 26px 16px calc(30px + env(safe-area-inset-bottom, 0px));
  border-top: 2px solid var(--line);
  color: var(--ink-soft);
  font-size: .9rem;
}
.site-foot p { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.site-foot a { color: var(--blue); font-weight: 700; }
.site-mark { display: flex; }
.site-mark img { border-radius: 9px; }
