/* ============================================================
   recallgym — warm editorial design system

   Paper ground, Fraunces for anything you read as language,
   Karla for every piece of machinery. Rules and whitespace do
   the dividing; elevation is spent on exactly two things, the
   flash stage and the portrait.
   ============================================================ */

:root {
  --paper: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #f0e9db;
  --ink: #1f1b16;
  --ink-soft: #4a443b;
  --muted: #7c7365;
  --rule: #e2d9c8;
  --rule-strong: #c9bea8;
  --accent: #9a6700;
  --accent-ink: #fffaf0;
  --accent-wash: #f4e9cf;
  --accent-soft: #c58a12;
  --correct: #2f6b3a;
  --correct-wash: #e4efe3;
  --wrong: #a23b2a;
  --wrong-wash: #f6e3df;
  --shadow: 0 1px 2px rgba(60, 40, 10, .06), 0 8px 24px -16px rgba(60, 40, 10, .25);
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Karla', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --radius: 6px;
  --maxw: 840px;
  --gutter: 16px;

  /* Tokens a theme is most likely to want. Defaults reproduce the editorial look. */
  --font-numeric: var(--font-display);   /* digit grids, span digits, trial tables */
  --display-weight: 600;                 /* every heading set in --font-display */
  --button-hover: #2e2820;
  --danger-hover: #8a3123;
  --card-face: #fffefa;
  --card-red: #b1352b;
  --card-shadow: 0 1px 2px rgba(40, 28, 10, .12), 0 10px 26px -14px rgba(40, 28, 10, .35);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---- masthead ---------------------------------------------------------- */

/* The rule under the masthead ends exactly where the content column does, so
   it lines up with every rule below it rather than overhanging by a gutter. */
.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  width: calc(100% - 2 * var(--gutter));
  max-width: calc(var(--maxw) - 2 * var(--gutter));
  margin: 0 auto;
  padding: 26px 0 18px;
  border-bottom: 1px solid var(--rule);
}

.masthead__mark {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 20, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: 1.15rem;
  letter-spacing: -.01em;
  color: var(--ink);
  text-decoration: none;
}
.masthead__mark span { color: var(--accent); }

.masthead__nav { display: flex; gap: 20px; }
.masthead__nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}
.masthead__nav a:hover { color: var(--ink); }
.masthead__nav a[aria-current] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---- page -------------------------------------------------------------- */

main { max-width: var(--maxw); margin: 0 auto; padding: 40px var(--gutter) 96px; }
section[hidden] { display: none; }

.kicker {
  margin: 0 0 10px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
}

.display {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 48, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: clamp(1.9rem, 5vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: -.02em;
  margin: 0 0 14px;
}

.lede { margin: 0 0 32px; color: var(--ink-soft); max-width: 56ch; font-size: 1.02rem; }
.note { color: var(--muted); font-size: .88rem; margin-top: 18px; }

/* ---- home -------------------------------------------------------------- */

.modes { border-top: 1px solid var(--rule); }

.mode {
  display: block;
  padding: 26px 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
}
.mode:hover .mode__title { color: var(--accent); }

.mode__title {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 28, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: 1.5rem;
  margin: 0 0 6px;
  letter-spacing: -.01em;
  transition: color .15s ease;
}
.mode__body { margin: 0 0 8px; color: var(--ink-soft); max-width: 60ch; }
.mode__meta { margin: 0; color: var(--muted); font-size: .86rem; }

.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
}
.stat__value {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 32, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: 1.7rem;
  line-height: 1;
  display: block;
}
.stat__label {
  font-size: .74rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* A rounded card with a coloured stripe down one side is a tell, so this is a
   flat panel with a rule above it — the same emphasis, in the register the
   rest of the page is already using. */
.setup-card {
  margin-top: 30px;
  padding: 18px 0 0;
  border-top: 2px solid var(--accent);
}
.setup-card p { margin: 0 0 10px; }
.setup-card code {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85rem;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 9px 12px;
}

/* ---- tiers ------------------------------------------------------------- */

.tiers { border-top: 1px solid var(--rule); margin-bottom: 34px; }

.tier {
  display: flex;
  align-items: baseline;
  gap: 16px;
  width: 100%;
  text-align: left;
  padding: 16px 18px 16px 15px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--rule);
  border-left: 3px solid transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.tier:hover { background: var(--surface); }
.tier--active { background: var(--accent-wash); border-left-color: var(--accent); }
.tier__name {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 20, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: 1.1rem;
  min-width: 5.5em;
}
.tier__blurb { color: var(--ink-soft); flex: 1; }
.tier__count { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }

/* ---- controls ---------------------------------------------------------- */

.controls { display: grid; gap: 28px; margin-bottom: 26px; }
.control__label {
  display: block;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  padding: 7px 15px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.chip:hover { border-color: var(--accent-soft); }
.chip--active { background: var(--ink); border-color: var(--ink); color: var(--accent-ink); }

.control__number {
  font: inherit;
  margin-top: 10px;
  width: 6.5em;
  padding: 7px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.control__range { width: min(100%, 420px); accent-color: var(--accent); display: block; }
.control__value {
  display: inline-block;
  margin-top: 6px;
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 24;
  font-weight: var(--display-weight);
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.switch { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); cursor: pointer; }
.switch input { accent-color: var(--accent); width: 16px; height: 16px; }

.advanced { margin-bottom: 30px; border-top: 1px solid var(--rule); padding-top: 14px; }
.advanced summary {
  cursor: pointer;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.advanced > *:not(summary) { margin-top: 14px; }

.segmented { display: flex; gap: 0; border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; margin-bottom: 32px; }
.segment {
  flex: 1;
  font: inherit;
  padding: 13px 10px;
  background: var(--surface);
  border: none;
  border-right: 1px solid var(--rule-strong);
  cursor: pointer;
  color: var(--ink-soft);
  text-align: center;
}
.segment:last-child { border-right: none; }
.segment:disabled { color: var(--muted); cursor: not-allowed; opacity: .55; }
.segment--active { background: var(--ink); color: var(--accent-ink); }
.segment strong { display: block; font-weight: 700; font-size: .98rem; }
.segment span { font-size: .78rem; font-variant-numeric: tabular-nums; opacity: .8; }

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

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 8px; }
.actions .note { margin: 0; }

.button {
  font: inherit;
  font-weight: 600;
  font-size: .95rem;
  padding: 11px 22px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.button:hover { border-color: var(--accent-soft); }
.button--primary { background: var(--ink); border-color: var(--ink); color: var(--accent-ink); }
.button--primary:hover { background: var(--button-hover); border-color: var(--button-hover); }
.button:disabled { opacity: .45; cursor: not-allowed; }

.counter { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; margin-right: auto; }

/* ---- flash ------------------------------------------------------------- */
/* The one screen where the design has to get out of the way entirely. */

.screen--bare { padding: 0; }
body.is-flashing .masthead { display: none; }
body.is-flashing main { padding: 0; max-width: none; }

.flash__progress { position: fixed; inset: 0 0 auto 0; height: 2px; background: var(--rule); }
.flash__progress span { display: block; height: 100%; width: 0; background: var(--accent); }

.flash__stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 24px;
  text-align: center;
  background: var(--paper);
}
.flash__word {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 96, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: clamp(2.2rem, 9vw, 5.5rem);
  letter-spacing: -.02em;
  line-height: 1.05;
  word-break: break-word;
}
.flash__count {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 144;
  font-weight: 400;
  font-size: clamp(4rem, 18vw, 10rem);
  color: var(--rule-strong);
  line-height: 1;
}

/* ---- recall ------------------------------------------------------------ */

.recall__input {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.7;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
  margin-bottom: 18px;
}
.recall__input:focus { outline: 2px solid var(--accent-soft); outline-offset: 1px; }

/* ---- scoring ----------------------------------------------------------- */

.scoreline { border-bottom: 1px solid var(--rule); padding-bottom: 22px; margin-bottom: 8px; }
.scoreline__pct {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 96, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: clamp(3rem, 11vw, 4.6rem);
  line-height: 1;
  letter-spacing: -.03em;
}
.scoreline__detail { color: var(--ink-soft); margin: 6px 0 0; }

.review { margin-bottom: 34px; }
.entry { padding: 18px 0 18px 15px; border-bottom: 1px solid var(--rule); border-left: 3px solid transparent; }
.entry--missed { background: var(--accent-wash); border-left-color: var(--accent); }
.entry__word {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 28, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: 1.35rem;
  letter-spacing: -.01em;
}
.entry__pos { font-style: italic; color: var(--muted); font-size: .88rem; margin-left: 8px; }
.entry__def { margin: 4px 0 0; color: var(--ink-soft); }
.entry__ex { margin: 4px 0 0; font-style: italic; color: var(--muted); font-size: .92rem; }
.entry__mark { font-size: .76rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.entry__mark--correct { color: var(--correct); }
.entry__mark--typo { color: var(--accent); }
.entry__mark--missed { color: var(--wrong); }
.entry__typed { color: var(--muted); font-size: .88rem; }

/* ---- portraits --------------------------------------------------------- */

/* The study and quiz screens are a single object on a page — kicker, portrait
   and controls all share its centre line rather than hanging off the margin. */
.screen--centered { text-align: center; }
.screen--centered .actions { justify-content: center; }

.portrait { display: grid; justify-items: center; gap: 4px; margin-bottom: 20px; }

/* UTKFace frames are already aligned to one face, so --face-zoom is 1 and the
   image is shown whole. The hook stays because it is driven by cropFraction in
   the manifest: a differently framed source can be dialled in without touching
   the CSS or re-downloading anything. */
.face {
  position: relative;
  aspect-ratio: 1;
  /* The source frames are 200px. Displaying much past this turns a face into a
     smear, and a smeared face is a worse memory cue than a small sharp one. */
  width: min(280px, 72vw);
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow);
}
.face__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(var(--face-zoom, 1));
  transform-origin: 50% 46%;
}

.portrait__name {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 40, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  letter-spacing: -.02em;
  margin: 18px 0 0;
}
.portrait__meta { margin: 0; color: var(--muted); font-size: .84rem; }
.portrait__history { margin: 14px 0 0; color: var(--accent); font-size: .88rem; font-weight: 600; }

.retire { margin: 22px 0 0; }
.linkish {
  font: inherit;
  font-size: .85rem;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 1px solid var(--rule-strong);
  padding: 0 0 1px;
  cursor: pointer;
}
.linkish:hover { color: var(--wrong); border-bottom-color: var(--wrong); }

.dots { display: flex; justify-content: center; gap: 7px; margin-bottom: 22px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rule-strong); }
.dot--done { background: var(--muted); }
.dot--active { background: var(--accent); transform: scale(1.35); }

.interlude { display: grid; place-items: center; text-align: center; padding: 60px 0; }
.interlude__count {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 144;
  font-weight: 400;
  font-size: clamp(4rem, 16vw, 8rem);
  line-height: 1;
  color: var(--rule-strong);
  margin: 0 0 12px;
}

.nameform { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 4px; }
.nameform__input {
  font-family: var(--font-body);
  font-size: 1.05rem;
  padding: 11px 14px;
  width: 190px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
.nameform__input:focus { outline: 2px solid var(--accent-soft); outline-offset: 1px; }

.verdict { text-align: center; margin-top: 22px; }
.verdict__name {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 36, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: 1.7rem;
}
.verdict__label { font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.verdict--right .verdict__label { color: var(--correct); }
.verdict--half .verdict__label { color: var(--accent); }
.verdict--wrong .verdict__label { color: var(--wrong); }
.verdict__yours { color: var(--muted); font-size: .9rem; margin: 2px 0 0; }

/* ---- grids ------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 22px 18px;
  margin: 24px 0 34px;
}
.card .face { width: 100%; box-shadow: none; border: 1px solid var(--rule); }
.card__name {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 18, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: 1.02rem;
  margin: 9px 0 0;
  line-height: 1.25;
}
.card__yours { margin: 1px 0 0; font-size: .82rem; color: var(--muted); text-decoration: line-through; }
.card__mark { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }
.card__mark--right { color: var(--correct); }
.card__mark--half { color: var(--accent); }
.card__mark--wrong { color: var(--wrong); }
.card__bar { height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: 7px; overflow: hidden; }
.card__bar span { display: block; height: 100%; background: var(--wrong); }
.card__score { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 3px; }

.empty { color: var(--muted); padding: 28px 0; border-top: 1px solid var(--rule); }
.subhead {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 20, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: 1.15rem;
  margin: 30px 0 4px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
}

/* ==== account ============================================================ */

.masthead__nav { align-items: baseline; }
.account { display: inline-flex; align-items: baseline; gap: 14px; padding-left: 20px; border-left: 1px solid var(--rule); }
.account__name {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 18, 'SOFT' 20;
  font-weight: var(--display-weight);
  color: var(--ink);
}
.masthead__nav .account__signin { color: var(--accent); }
.account__out {
  font: inherit;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.account__out:hover { color: var(--ink); }

.auth { max-width: 440px; }
.auth__form { display: grid; gap: 18px; margin-bottom: 22px; }
.auth__row { display: grid; gap: 6px; }
.auth__hint { font-size: .8rem; color: var(--muted); }
.auth__error { margin: 0; min-height: 1.2em; color: var(--wrong); font-size: .9rem; }
.auth__swap { color: var(--ink-soft); }
.auth__swap a, .savenote a { color: var(--accent); }

.field {
  font: inherit;
  font-size: 1.02rem;
  padding: 11px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}
.field:focus { outline: 2px solid var(--accent-soft); outline-offset: 1px; }
.field--sm { font-size: .95rem; padding: 7px 10px; }

.backlink { display: inline-block; margin-bottom: 18px; color: var(--muted); text-decoration: none; font-size: .86rem; }
.backlink:hover { color: var(--ink); }

.savenote { margin: 14px 0 0; color: var(--ink-soft); font-size: .95rem; }
.savenote--best strong { color: var(--accent); font-family: var(--font-display); font-weight: var(--display-weight); }
.savenote--warn { color: var(--wrong); }

/* While a round is running the masthead goes, so a stray click cannot leave
   the game mid-clock. Escape is the way out, and it asks first. */
body.is-playing .masthead { display: none; }
body.is-playing main { padding-top: 22px; }

/* ==== hub ================================================================ */

.hub { border-top: 1px solid var(--rule); }
.hub__section {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 2.4fr;
  gap: 8px 40px;
  padding: 30px 0;
  border-bottom: 1px solid var(--rule);
}
.hub__heading {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 30, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: 1.4rem;
  letter-spacing: -.01em;
  margin: 0 0 8px;
}
.hub__blurb { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.hub__list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; }

.game {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 12px 0 13px;
  border-top: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
}
.hub__list .game:nth-child(-n + 2) { border-top: none; padding-top: 0; }
.game__title {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 20, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: 1.08rem;
  transition: color .15s ease;
}
.game:hover .game__title { color: var(--accent); }
.game__line { color: var(--ink-soft); font-size: .9rem; }
.game__best { color: var(--accent); font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.game__best--none { color: var(--muted); font-weight: 400; }

/* ==== shared game chrome ================================================= */

.gamebar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-bottom: 12px;
}
.gamebar__label {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: auto;
}
.gamebar__time {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 36;
  font-weight: var(--display-weight);
  font-size: 1.7rem;
  font-variant-numeric: tabular-nums;
  min-width: 3.2ch;
  text-align: right;
}
.gamebar__time--low { color: var(--wrong); }
.gamebar__rule { height: 2px; background: var(--rule); margin-bottom: 28px; }
.gamebar__rule span { display: block; height: 100%; width: 0; background: var(--accent); }

.getready {
  display: grid;
  place-items: center;
  min-height: 50vh;
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 144;
  font-size: clamp(4rem, 16vw, 9rem);
  color: var(--rule-strong);
}

.memfoot { margin: 22px 0 0; text-align: center; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; white-space: pre; }
.recallhint { margin: 0 0 14px; color: var(--muted); font-size: .86rem; }

.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin-top: 26px; }
.pager__dot {
  width: 9px; height: 9px; padding: 0;
  border-radius: 50%;
  border: none;
  background: var(--rule-strong);
  cursor: pointer;
}
.pager__dot--past { background: var(--muted); }
.pager__dot--on { background: var(--accent); transform: scale(1.3); }

.review { margin: 26px 0 32px; }
.is-right { --mark: var(--correct); }
.is-wrong { --mark: var(--wrong); }

/* ==== league setup ======================================================= */

.levels { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; max-width: 560px; }
.level {
  display: grid;
  gap: 1px;
  justify-items: center;
  padding: 8px 0 7px;
  font: inherit;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
}
.level:hover { border-color: var(--accent-soft); }
.level__n { font-weight: 700; font-size: .95rem; }
.level__count { font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.level--cleared { background: var(--accent-wash); border-color: var(--accent-wash); }
.level--active { background: var(--ink); border-color: var(--ink); color: var(--accent-ink); }
.level--active .level__count { color: var(--rule-strong); }

/* ==== numbers ============================================================ */

.digits {
  display: grid;
  grid-template-columns: repeat(var(--cols, 12), minmax(0, 1fr));
  gap: 6px 0;
  /* Narrow enough that a group reads as one unit, not as digits that happen
     to sit near each other. */
  max-width: min(100%, calc(var(--cols, 12) * 44px + 80px));
  margin: 0 auto;
}
.digit {
  display: grid;
  place-items: center;
  height: 52px;
  font-family: var(--font-numeric);
  font-variation-settings: 'opsz' 48;
  font-weight: 500;
  font-size: 1.85rem;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--ink);
  background: none;
  border: none;
  border-radius: 0;
  cursor: pointer;
}
/* A gap after each group, so the grouping you chose is visible as shape. */
.digit--groupend { margin-right: 10px; }
.digit--on { background: var(--accent-wash); color: var(--ink); }
.digits--recall .digit { border-bottom: 1px solid var(--rule-strong); font-size: 1.6rem; }
.digit--cursor { background: var(--accent-wash); border-bottom: 2px solid var(--accent) !important; }
.digits--review .digit { flex-direction: column; height: 62px; cursor: default; align-content: center; gap: 0; }
.digit--right .digit__truth { color: var(--correct); }
.digit--wrong { background: var(--wrong-wash); }
.digit--wrong .digit__truth { color: var(--wrong); }
.digit__said { font-family: var(--font-body); font-size: .8rem; color: var(--muted); line-height: 1; text-decoration: line-through; }

.keypad { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 6px; max-width: 720px; margin: 26px auto 0; }
.keypad__key {
  font: inherit;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 10px 0;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.keypad__key:active { background: var(--accent-wash); }

/* ==== cards ============================================================== */

.cardrow, .imgrow, .facerow { display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; }

.pcard {
  --w: 150px;
  position: relative;
  width: var(--w);
  aspect-ratio: 5 / 7;
  border-radius: calc(var(--w) * .07);
  background: var(--card-face);
  color: var(--ink);
  box-shadow: var(--card-shadow);
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 36;
  user-select: none;
}
.pcard--red { color: var(--card-red); }
.pcard--lg { --w: clamp(120px, 22vw, 180px); }
.pcard--sm { --w: 46px; box-shadow: none; border: 1px solid var(--rule-strong); }
.pcard--xs { --w: 34px; box-shadow: none; border: 1px solid var(--rule-strong); }
.pcard__corner {
  position: absolute;
  display: grid;
  justify-items: center;
  line-height: .95;
  font-weight: 600;
  font-size: calc(var(--w) * .16);
}
.pcard__corner--tl { top: 6%; left: 7%; }
.pcard__corner--br { bottom: 6%; right: 7%; transform: rotate(180deg); }
.pcard__pip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--w) * .46);
}
.pcard--sm .pcard__pip, .pcard--xs .pcard__pip { display: none; }
.pcard--sm .pcard__corner--br, .pcard--xs .pcard__corner--br { display: none; }
.pcard--sm .pcard__corner, .pcard--xs .pcard__corner { inset: 0; place-content: center; font-size: calc(var(--w) * .34); }

.slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 6px;
  margin-bottom: 26px;
}
.slots--images { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.slot {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 62px;
  padding: 14px 2px 4px;
  font: inherit;
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}
.slots--images .slot { min-height: 84px; }
/* A filled slot is just the card in it — no box around the box. */
.slot--full { border-color: transparent; background: transparent; }
.slots--images .slot--full { padding-top: 14px; }
.slot--cursor { border: 2px solid var(--accent); background: var(--accent-wash); }
.slot__n { position: absolute; top: 2px; left: 5px; font-size: .64rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.tray { display: grid; gap: 6px; padding-top: 20px; border-top: 1px solid var(--rule); }
.tray--cards { grid-template-columns: repeat(13, minmax(0, 1fr)); }
.tray--images { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.trayitem { padding: 0; border: none; background: none; cursor: pointer; display: grid; place-items: center; }
.trayitem:hover .pcard, .trayitem:hover .photo { outline: 2px solid var(--accent-soft); outline-offset: 1px; }
.trayitem--used { opacity: .28; }

.cardreview { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px 8px; }
.cardreview__cell { display: grid; justify-items: center; gap: 4px; padding: 6px 0 8px; border-top: 3px solid var(--mark); }
.cardreview__n { font-size: .66rem; color: var(--muted); }
.cardreview__blank { font-size: .7rem; color: var(--muted); }

/* ==== images ============================================================= */

.photo {
  display: block;
  width: clamp(220px, 34vw, 340px);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--surface-2);
}
.photo--thumb { width: 100%; box-shadow: none; border-radius: 3px; }
.imgreview { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px 12px; }
.imgreview__cell { display: grid; gap: 4px; padding-top: 6px; border-top: 3px solid var(--mark); }
.imgreview__n { font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.imgreview__said { font-size: .76rem; color: var(--wrong); }

/* ==== words ============================================================== */

.wordcols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0 26px; }
.wordcol { margin: 0; padding: 0 0 0 2.2em; font-variant-numeric: tabular-nums; }
.wordcol li::marker { color: var(--muted); font-size: .8rem; }
.wordcol__w {
  padding: 4px 6px;
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 20, 'SOFT' 20;
  font-size: 1.12rem;
  cursor: pointer;
}
.wordcol__w--on { background: var(--accent-wash); }
.review .wordcol__w { cursor: default; display: list-item; }
.review .wordcol__w.is-right { color: var(--correct); }
.review .wordcol__w.is-wrong > span:first-child { color: var(--wrong); }
.wordcol__said { display: block; font-family: var(--font-body); font-size: .8rem; color: var(--muted); text-decoration: line-through; }
.wordcols--recall .wordcol { padding: 0; display: grid; gap: 6px; align-content: start; }
.wordinput { display: grid; grid-template-columns: 2.2em 1fr; align-items: center; }
.wordinput__n { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ==== names ============================================================== */

.namecard { margin: 0; display: grid; justify-items: center; gap: 12px; }
.namecard .face { width: clamp(180px, 22vw, 230px); }
.namecard__name {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 40, 'SOFT' 20;
  font-weight: var(--display-weight);
  font-size: 1.7rem;
  letter-spacing: -.01em;
}
.namegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 18px 14px; }
.namegrid__cell { display: grid; gap: 7px; align-content: start; }
.namegrid .face { width: 100%; box-shadow: none; border: 1px solid var(--rule); }
.namegrid--review .namegrid__cell { padding-top: 7px; border-top: 3px solid var(--mark); }
.namegrid__name { margin: 0; font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.02rem; }
.namegrid__country { margin: -4px 0 0; font-size: .74rem; color: var(--muted); }
.namegrid__said { margin: 0; font-size: .82rem; color: var(--muted); text-decoration: line-through; }
.namegrid__blank, .wordcol__blank { margin: 0; display: block; font-family: var(--font-body); font-size: .78rem; font-style: italic; color: var(--wrong); }

/* ==== span =============================================================== */

.span__stage { position: relative; inset: auto; min-height: 56vh; background: transparent; }
.span__ready { font-size: .8rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.span__digit { font-size: clamp(5rem, 22vw, 11rem); font-variant-numeric: lining-nums; }
.span__ask { max-width: 520px; margin: 8vh auto 0; text-align: center; }
.span__form { display: flex; gap: 10px; }
.span__input {
  font-family: var(--font-numeric);
  font-variation-settings: 'opsz' 48;
  font-size: 2rem;
  letter-spacing: .25em;
  text-align: center;
  font-variant-numeric: tabular-nums lining-nums;
}
.span__verdict { display: grid; place-items: center; min-height: 50vh; text-align: center; }
.span__mark { margin: 0; font-size: .8rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--mark); }
.span__expected {
  margin: 8px 0 0;
  font-family: var(--font-numeric);
  font-variation-settings: 'opsz' 72;
  font-size: clamp(2rem, 7vw, 3.4rem);
  font-variant-numeric: lining-nums;
}

.trials, .scores { width: 100%; border-collapse: collapse; margin: 22px 0 30px; font-variant-numeric: tabular-nums; }
.trials th, .scores th {
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 12px 8px 0;
  border-bottom: 1px solid var(--rule-strong);
}
.trials td, .scores td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.trials__digits { font-family: var(--font-numeric); font-variant-numeric: lining-nums; letter-spacing: .04em; }
.trials__mark { font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mark); }

/* ==== pattern ============================================================ */

.pattern { max-width: 460px; margin: 0 auto; }
.pattern__hud { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.pattern__level { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.25rem; }
.pattern__status { margin-right: auto; color: var(--muted); font-size: .88rem; }
.pattern__lives { display: flex; gap: 6px; }
.life { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.life--lost { background: var(--rule-strong); }

.tiles { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 8px; }
.tile {
  aspect-ratio: 1;
  font: inherit;
  font-weight: 700;
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  transition: background-color .12s ease;
}
.tile:disabled { cursor: default; }
.tile:not(:disabled):hover { background: var(--rule); }
.tile--lit { background: var(--ink) !important; }
.tile--hit { background: var(--accent) !important; }
.tile--wrong { background: var(--wrong) !important; }
.tile--missed { background: transparent !important; box-shadow: inset 0 0 0 3px var(--accent); color: var(--accent); }

/* ==== profile ============================================================ */

.profile__section { padding-top: 26px; margin-top: 8px; border-top: 1px solid var(--rule); }
.scores { margin-top: 10px; }
.scores__game {
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 18, 'SOFT' 20;
  font-weight: var(--display-weight);
}
.scores__game:hover { color: var(--accent); }
.scores tr.is-unplayed td { color: var(--muted); }
.spark { width: 96px; height: 22px; display: block; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; }
.spark circle { fill: var(--accent); }
.spark--empty { display: block; width: 96px; height: 1px; background: var(--rule); }

.danger { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--rule); }
.danger summary { cursor: pointer; color: var(--muted); font-size: .86rem; }
.danger summary:hover { color: var(--wrong); }
.danger__form { display: grid; gap: 10px; max-width: 360px; margin-top: 12px; }
.danger__form .note { margin: 0; }
.button--danger { background: var(--wrong); border-color: var(--wrong); color: var(--accent-ink); }
.button--danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }

/* ---- responsive -------------------------------------------------------- */

@media (max-width: 720px) {
  .masthead { flex-direction: column; align-items: flex-start; gap: 10px; }
  .account { padding-left: 14px; }
  .tier { flex-direction: column; gap: 2px; }
  .tier__name { min-width: 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 18px 14px; }
  .nameform__input { width: 100%; }
  .hub__section { grid-template-columns: 1fr; padding: 24px 0; row-gap: 16px; }
  .hub__list { grid-template-columns: 1fr; }
  .hub__list .game:nth-child(2) { border-top: 1px solid var(--rule); padding-top: 12px; }
  .levels { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .digit { font-size: 1.3rem; height: 40px; }
  .digit--groupend { margin-right: 5px; }
  .keypad { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .tray--cards { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .wordcols { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
  .scores th:nth-child(5), .scores td:nth-child(5) { display: none; }
}

/* The countdown and reveal are decoration. The flash timing is the task, so it
   is deliberately not reduced. */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
