/* Morphology Forge.
   Deliberately not styled like a children's game. He is seven and reading at
   fourth-grade level, and software that looks like it is for little kids is
   itself a way of talking down to him. This reads like a workbench. */

:root {
  --ink: #0d1b2a;
  --paper: #f6f4ef;
  --line: #d9d3c6;
  --accent: #0f6d63;
  --accent-soft: #d9ece8;
  --warn: #9a4a2f;
  --warn-soft: #f6e3da;
  --muted: #6a6459;
}

* { box-sizing: border-box; }

/* The `hidden` attribute only gets `display: none` from the browser default
   stylesheet, so ANY author rule that sets display beats it. `.feedback` sets
   `display: grid`, which meant the previous round's answer stayed on screen
   underneath the next question. Global and !important on purpose: this is a
   trap every new hidden element on the page would fall into. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.55 ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: 22px 18px 60px;
}

.masthead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.masthead h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.masthead .back { font-size: 14px; color: var(--muted); text-decoration: none; }
.masthead .back:hover { color: var(--accent); }

.scoreboard { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.scoreboard b { color: var(--ink); font-variant-numeric: tabular-nums; }
/* Three in a row and the streak starts to glow. It is the only place on this
   page that keeps a running total of nothing but momentum. */
.scoreboard .streak.hot b { color: var(--accent); }

/* ---- name screen ---- */
#name-screen h2 { font-size: 26px; margin: 24px 0 6px; }
#name-screen p { color: var(--muted); margin: 0 0 20px; }
#name-form { display: flex; gap: 10px; flex-wrap: wrap; }
#name-input {
  flex: 1 1 200px; min-height: 48px; padding: 10px 14px; font-size: 17px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: inherit;
}
#name-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- prompt ---- */
.prompt-kind {
  font-size: 12px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--accent); font-weight: 700; margin-bottom: 8px;
}
.prompt { display: grid; gap: 8px; margin-bottom: 22px; }
.prompt .clue { font-size: 22px; line-height: 1.35; }
.prompt .root-hint { font-size: 15px; color: var(--muted); }
.prompt .origin { opacity: .7; }

/* ---- word sum ---- */
.sum {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  min-height: 60px; padding: 12px 14px; margin-bottom: 16px;
  background: #fff; border: 1px dashed var(--line); border-radius: 12px;
}
.sum-empty { color: var(--muted); font-size: 15px; }
.sum-part { font-weight: 700; font-size: 20px; }
.plus { color: var(--muted); }

/* Touch targets throughout are sized for a seven-year-old's finger on a tablet
   held at arm's length, not for a mouse. Everything tappable clears 56px. */
.tray { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.chip {
  min-height: 58px; padding: 12px 22px; font: inherit; font-weight: 700; font-size: 20px;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
  transition: transform .08s ease, background .12s ease;
}
.chip:hover:not(.used) { background: var(--accent-soft); border-color: var(--accent); }
.chip:active:not(.used) { transform: translateY(1px); }
.chip.used { opacity: .28; cursor: default; }

/* ---- choices ---- */
.choices { display: grid; gap: 12px; margin-bottom: 20px; }
.choice {
  min-height: 64px; padding: 16px 20px; font: inherit; font-size: 19px; line-height: 1.4;
  text-align: left;
  background: #fff; color: inherit; border: 1px solid var(--line); border-radius: 14px; cursor: pointer;
}
.choice:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.choice:disabled { opacity: .55; cursor: default; }
/* The one he picked, kept legible while everything else fades, so the
   explanation underneath has something to point at. */
.choice.chosen-wrong:disabled {
  opacity: 1; border-color: var(--warn); background: var(--warn-soft); color: var(--warn);
}

/* ---- buttons ---- */
.row { display: flex; gap: 12px; }
.primary, .ghost {
  min-height: 58px; padding: 14px 28px; font: inherit; font-weight: 600; font-size: 18px;
  border-radius: 12px; cursor: pointer; border: 1px solid transparent;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { filter: brightness(1.08); }
.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
#next { min-width: 180px; }

/* ---- feedback ---- */
.feedback {
  position: relative; overflow: hidden;
  padding: 16px 18px; border-radius: 12px; margin: 16px 0; display: grid; gap: 6px; font-size: 17px;
}
.feedback .verdict { font-weight: 700; }
.feedback .gloss { display: block; font-size: 14px; color: var(--muted); }
/* Why it was wrong. Bigger than the gloss and in full ink, because on a wrong
   answer this is the part worth reading and the rest is bookkeeping. */
.feedback .why {
  display: block; margin-top: 4px; padding-top: 10px;
  border-top: 1px solid rgb(0 0 0 / .08); font-size: 16px; line-height: 1.5;
}
/* When the explanation is the only thing under the verdict there is nothing
   for the rule to divide, so it goes away. */
.feedback .verdict + .why { border-top: 0; padding-top: 0; }
.feedback.good { background: var(--accent-soft); }
.feedback.bad, .feedback.nudge { background: var(--warn-soft); }

/* A right answer moves on by itself. The bar draining is the only signal that
   the pause is deliberate; without it the game looks like it froze. */
.feedback.advancing::after {
  content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
  background: var(--accent); transform-origin: left center;
  animation: drain var(--advance, 2s) linear forwards;
}
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---- hint ---- */
.hint-btn { margin-bottom: 16px; }
.hint-btn:disabled { opacity: .4; cursor: default; }

.hint {
  padding: 14px 16px; border-left: 3px solid var(--accent); background: #fff;
  font-size: 16px; color: var(--muted); margin-bottom: 16px; border-radius: 0 10px 10px 0;
}
.hint .hint-text { margin: 0; color: var(--ink); }
.hint .hint-text b { color: var(--accent); }

/* The teaching half of a hint: three words carrying the same piece. Laid out as
   a list rather than a sentence so the shared part is easy to see down the
   left edge, which is the whole lesson. */
.hint-family { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 7px; }
.hint-family li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.hint-family b { font-size: 17px; color: var(--ink); }
.hint-family span { font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  /* The bar still has to drain: it is a countdown, not decoration. Instant
     would leave a stripe sitting there through the whole pause. */
  .feedback.advancing::after { animation-duration: var(--advance, 2s); }
}
