/* ═══════════════════════════════════════════════════════════════════════
   MEMSTACK

   One rule governs everything below: memory-bearing content never fades,
   never slides, never eases. A mutation and a slot value appear complete on
   their first visible frame, because an animated entrance shortens the time
   the text is actually legible and silently changes the difficulty (§10).

   Everything that is *not* content — pips, banners, panels, the background —
   is where the motion lives. During the phases where you are holding state,
   even that stops: `.hushed` freezes the field, and the world holds still
   while you do.
   ═══════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #06070a;
  --bg-2: #0a0c12;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-2: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);

  --ink: #eaecf2;
  --ink-2: #b6bcca;
  --ink-dim: #838a9b;
  --ink-faint: #4d5464;

  /* The accent hue advances by the golden angle each level, so no two nearby
     levels share a colour and the whole run never repeats one. */
  --accent-h: 168;
  --accent: hsl(var(--accent-h) 72% 62%);
  --accent-2: hsl(var(--accent-h) 62% 46%);
  --accent-glow: hsl(var(--accent-h) 80% 60% / 0.28);
  --accent-wash: hsl(var(--accent-h) 70% 55% / 0.1);

  --warn: #f0b352;
  --bad: #f2705f;
  --good: #62d9a8;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;

  --r: 14px;
  --r-sm: 9px;
  --pad: clamp(18px, 4vw, 40px);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

body { overflow: hidden; }

.label {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
}

code { font-family: var(--mono); font-size: 0.92em; color: var(--ink-2); }

/* ── Background field ───────────────────────────────────────────────
   Composited entirely on the GPU: transforms and opacity only, so it cannot
   steal a frame from a flash. It still stops during memory phases — partly
   for safety, mostly because the stillness reads. */

.field {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--bg-2), var(--bg) 60%),
    var(--bg);
  z-index: 0;
}

.field-blob {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.32;
  will-change: transform;
  transition: opacity 900ms var(--ease);
}

.field-blob-a {
  background: radial-gradient(circle, hsl(var(--accent-h) 70% 42% / 0.55), transparent 65%);
  top: -22vmax; left: -14vmax;
  animation: drift-a 44s ease-in-out infinite alternate;
}
.field-blob-b {
  background: radial-gradient(circle, hsl(calc(var(--accent-h) + 58) 65% 40% / 0.42), transparent 65%);
  bottom: -26vmax; right: -18vmax;
  animation: drift-b 57s ease-in-out infinite alternate;
}
.field-blob-c {
  background: radial-gradient(circle, hsl(calc(var(--accent-h) - 48) 60% 36% / 0.3), transparent 65%);
  top: 30%; left: 45%;
  animation: drift-c 71s ease-in-out infinite alternate;
}

@keyframes drift-a { to { transform: translate3d(14vw, 10vh, 0) scale(1.18); } }
@keyframes drift-b { to { transform: translate3d(-16vw, -8vh, 0) scale(1.12); } }
@keyframes drift-c { to { transform: translate3d(-10vw, 12vh, 0) scale(0.86); } }

/* Static grain, rendered once. Breaks up the gradient banding that large
   blurred fields always show on 8-bit displays. */
.field-grain {
  position: absolute;
  inset: -50%;
  opacity: 0.16;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

.app.hushed .field-blob { animation-play-state: paused; opacity: 0.14; }
.app.hushed .field-grain { opacity: 0.09; }

/* ── App shell ─────────────────────────────────────────────────────── */

.app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: grid;
}

.screen {
  grid-area: 1 / 1;
  display: none;
  min-height: 0;
  overflow: hidden;
}
.screen.is-active { display: flex; }

.screen-doc, .screen-home, .screen-end, .screen-recap {
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ── Buttons ───────────────────────────────────────────────────────── */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: var(--r-sm);
  cursor: pointer;
  position: relative;
  isolation: isolate;
  transition: border-color 180ms var(--ease), background 180ms var(--ease),
              transform 120ms var(--ease), box-shadow 220ms var(--ease);
}
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(120% 140% at 50% 0%, hsl(var(--accent-h) 80% 60% / 0.18), transparent 70%);
  opacity: 0;
  transition: opacity 220ms var(--ease);
  z-index: -1;
}
.btn:hover { border-color: var(--line-2); background: var(--panel-2); }
.btn:hover::after { opacity: 1; }
.btn:active { transform: translateY(1px) scale(0.995); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn[disabled] { opacity: 0.35; pointer-events: none; }

.btn-primary {
  border-color: hsl(var(--accent-h) 60% 45% / 0.55);
  background: linear-gradient(hsl(var(--accent-h) 60% 46% / 0.2), hsl(var(--accent-h) 60% 40% / 0.1));
  box-shadow: 0 0 0 0 var(--accent-glow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 16px 34px;
  font-size: 17px;
}
.btn-primary:hover { box-shadow: 0 8px 40px -12px var(--accent-glow); border-color: var(--accent); }
.btn-primary .btn-meta { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-dim); padding: 8px 12px; }
.btn-ghost:hover { color: var(--ink); background: var(--panel); }
.btn-danger:hover { border-color: var(--bad); color: var(--bad); }

.link {
  appearance: none; border: 0; background: none; padding: 0;
  font: inherit; color: var(--accent); cursor: pointer;
  border-bottom: 1px solid hsl(var(--accent-h) 60% 55% / 0.35);
}
.link:hover { border-bottom-color: var(--accent); }

/* ── Home ──────────────────────────────────────────────────────────── */

.screen-home { align-items: center; justify-content: center; padding: var(--pad); }
.home-inner { max-width: 620px; width: 100%; display: grid; gap: 40px; justify-items: center; text-align: center; }

.brand { display: grid; gap: 14px; }
.brand-mark {
  margin: 0;
  font-size: clamp(38px, 9vw, 76px);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.94;
  background: linear-gradient(180deg, var(--ink), hsl(var(--accent-h) 40% 62%));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-slash { color: var(--accent); -webkit-text-fill-color: var(--accent); opacity: 0.75; }
.brand-sub { margin: 0; color: var(--ink-dim); font-size: clamp(14px, 2.4vw, 17px); letter-spacing: 0.01em; }

.home-actions { display: grid; gap: 16px; justify-items: center; }
.home-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.home-best {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center;
  padding: 12px 20px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel);
}
.best-score { font-family: var(--mono); font-size: 17px; letter-spacing: 0.06em; }

.home-note { color: var(--ink-faint); font-size: 13px; max-width: 46ch; line-height: 1.65; margin: 0; }

/* ── Docs (tutorial / model / settings / practice) ─────────────────── */

.screen-doc { justify-content: center; padding: var(--pad); }
.doc { max-width: 660px; width: 100%; padding-bottom: 80px; }
.doc-back { margin-bottom: 18px; margin-left: -12px; }
.doc h2 { font-size: clamp(26px, 5vw, 36px); letter-spacing: -0.03em; margin: 0 0 8px; }
.doc h3 { font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent);
          margin: 40px 0 12px; font-weight: 650; }
.doc p, .doc li, .doc dd { color: var(--ink-2); line-height: 1.7; font-size: 15px; }
.doc .lede { color: var(--ink); font-size: 17px; line-height: 1.65; }

.steps { padding-left: 20px; display: grid; gap: 8px; }
.three { padding-left: 20px; display: grid; gap: 6px; }

.rules { display: grid; gap: 4px; margin: 0; }
.rules dt { font-weight: 600; color: var(--ink); margin-top: 18px; font-size: 15px; }
.rules dd { margin: 4px 0 0; padding-left: 16px; border-left: 2px solid var(--line); }

.settings-list { display: grid; gap: 2px; margin-top: 8px; }
.setting {
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
  padding: 14px 4px; border-bottom: 1px solid var(--line);
}
.setting-text { display: grid; gap: 3px; }
.setting-name { font-size: 15px; color: var(--ink); }
.setting-desc { font-size: 12.5px; color: var(--ink-faint); line-height: 1.5; }

.toggle {
  appearance: none; margin: 0; flex: none;
  width: 46px; height: 27px; border-radius: 99px;
  background: var(--panel-2); border: 1px solid var(--line);
  position: relative; cursor: pointer;
  transition: background 200ms var(--ease), border-color 200ms var(--ease);
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--ink-dim);
  transition: transform 240ms var(--ease-out), background 200ms var(--ease);
}
.toggle:checked { background: hsl(var(--accent-h) 55% 40% / 0.5); border-color: var(--accent-2); }
.toggle:checked::after { transform: translateX(19px); background: var(--accent); }
.toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.field-row { display: grid; gap: 8px; margin: 20px 0; font-size: 14px; color: var(--ink-2); }
.field-row.check { display: flex; align-items: center; gap: 12px; }
.field-row input[type="url"] {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--ink); font: inherit; font-size: 14px; padding: 11px 14px;
}
.field-row input[type="url"]:focus { outline: none; border-color: var(--accent-2); }
.field-row input[type="range"] { accent-color: var(--accent); }
.field-row input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; }

.practice-preview {
  margin: 20px 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel); font-size: 13.5px; color: var(--ink-dim); line-height: 1.7;
}
.practice-preview b { color: var(--ink-2); font-weight: 600; }

/* ── Play screen ───────────────────────────────────────────────────── */

.screen-play { flex-direction: column; padding: 0; }

.hud {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) var(--pad) 8px;
  flex: none;
}
.hud-level { display: flex; align-items: baseline; gap: 8px; }
.hud-level b { font-family: var(--mono); font-size: 15px; letter-spacing: 0.04em; }
.hud-quit {
  appearance: none; background: none; border: 0; color: var(--ink-faint);
  font-size: 16px; cursor: pointer; padding: 6px 10px; border-radius: var(--r-sm);
  transition: color 160ms var(--ease), background 160ms var(--ease);
}
.hud-quit:hover { color: var(--ink); background: var(--panel); }

/* The HUD is dimmed to 40% during the mutation phase, per §3.4. */
.app[data-phase="mutation"] .hud { opacity: 0.4; }
.app[data-phase="state-show"] .hud,
.app[data-phase="query"] .hud,
.app[data-phase="breath"] .hud { opacity: 0.4; }
.hud { transition: opacity 300ms var(--ease); }

.pips { display: flex; gap: 9px; }
.pip {
  width: 13px; height: 13px; border-radius: 50%;
  border: 1.5px solid var(--line-2);
  transition: background 250ms var(--ease), border-color 250ms var(--ease),
              transform 250ms var(--ease-out), clip-path 250ms var(--ease);
}
.pip.is-struck { background: var(--bad); border-color: var(--bad); }
/* Colourblind-safe: struck pips change *shape*, not only colour. */
.app.pips-shaped .pip.is-struck { border-radius: 2px; transform: rotate(45deg) scale(0.86); }
.pip.is-firing { animation: pip-fire 250ms var(--ease-out); }
@keyframes pip-fire {
  0% { transform: scale(1); box-shadow: 0 0 0 0 var(--bad); }
  45% { transform: scale(1.5); box-shadow: 0 0 0 9px rgba(242, 112, 95, 0); }
  100% { transform: scale(1); }
}
.app.pips-shaped .pip.is-firing { animation-name: pip-fire-shaped; }
@keyframes pip-fire-shaped {
  0% { transform: rotate(0) scale(1); }
  45% { transform: rotate(45deg) scale(1.45); }
  100% { transform: rotate(45deg) scale(0.86); }
}
.app.reduce-motion .pip { transition: none; }
.app.reduce-motion .pip.is-firing { animation: none; }

.stage {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  padding: 12px var(--pad);
  min-height: 0;
  position: relative;
}
.layer { grid-area: 1 / 1; display: none; width: 100%; max-width: 900px; }
.layer.is-on { display: block; }

/* ── Level intro ───────────────────────────────────────────────────── */

.intro { text-align: center; display: grid; gap: 18px; justify-items: center; }
.intro-level { font-size: clamp(44px, 12vw, 92px); font-weight: 700; letter-spacing: -0.05em; line-height: 1; }
.intro-level small { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.22em;
                     text-transform: uppercase; color: var(--ink-faint); margin-bottom: 10px; }
.intro-caption {
  font-size: 14px; color: var(--accent); letter-spacing: 0.05em;
  padding: 7px 16px; border: 1px solid hsl(var(--accent-h) 55% 50% / 0.35);
  border-radius: 99px; background: var(--accent-wash);
}
.intro-debut { font-size: 13px; color: var(--ink-dim); }
.intro-pips { display: flex; gap: 10px; }

/* ── First-run demo ────────────────────────────────────────────────
   Plays on the real play screen in the real typography, so what you learn
   here is literally what you will see. The caption is chrome and may fade;
   the numbers and the instruction snap in, exactly as in a live round. */

.demo { display: grid; gap: 26px; justify-items: center; text-align: center; }
.demo-caption {
  font-size: clamp(13px, 2.6vw, 15px);
  letter-spacing: 0.02em;
  color: var(--ink-dim);
  max-width: 34ch;
  line-height: 1.6;
  animation: demo-caption-in 260ms var(--ease-out);
}
@keyframes demo-caption-in { from { opacity: 0; transform: translateY(-4px); } }
.app.reduce-motion .demo-caption { animation: none; }
.demo .slots, .demo .mutation { margin: 4px 0; }
.demo-actions { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 6px; }

/* ── Countdown ─────────────────────────────────────────────────────── */

.countdown { display: flex; gap: 20px; justify-content: center; }
.cd-pip {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line-2);
  transition: background 160ms var(--ease), transform 200ms var(--ease-out), border-color 160ms var(--ease);
}
.cd-pip.is-lit {
  background: var(--accent); border-color: var(--accent);
  transform: scale(1.25);
  box-shadow: 0 0 24px -2px var(--accent-glow);
}
.app.reduce-motion .cd-pip { transition: background 100ms linear, border-color 100ms linear; }

/* ── Slots ─────────────────────────────────────────────────────────
   Positions never change across a run: spatial position is part of the
   player's encoding (§3.3). Values snap in — no transition, ever. */

.slots {
  display: flex; gap: clamp(10px, 3vw, 30px); justify-content: center; align-items: flex-end;
  flex-wrap: nowrap;
}
.slot { display: grid; gap: 6px; justify-items: center; min-width: 0; flex: 0 1 auto; }
.slot-name {
  font-family: var(--mono); font-size: clamp(11px, 2vw, 13px);
  letter-spacing: 0.24em; color: var(--ink-faint); font-weight: 600;
}
.slot-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(30px, 9.5vw, 68px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
}
.slot-rule {
  width: 100%; height: 2px; margin-top: 4px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  animation: rule-sweep 620ms var(--ease-out) forwards;
}
@keyframes rule-sweep { from { opacity: 0; transform: scaleX(0.2); } to { opacity: 0.55; transform: scaleX(1); } }
.app.reduce-motion .slot-rule { animation: none; opacity: 0.55; }

/* ── Mutation text ─────────────────────────────────────────────────
   Complete on the first visible frame. No transition, no animation, no
   will-change. This is the one element on the page that must not move. */

.mutation { text-align: center; }
.mutation .mline {
  font-size: clamp(21px, 4.4vw, 36px);
  line-height: 1.42;
  letter-spacing: -0.015em;
  font-weight: 450;
  color: var(--ink);
}
.mutation.is-block { text-align: left; max-width: 24ch; margin: 0 auto; }
.mutation.is-block .mline { font-size: clamp(18px, 3.6vw, 29px); line-height: 1.5; }
.mutation.is-block .mline[data-indent="1"] { padding-left: 2.2ch; }
.mutation.is-block .mline[data-indent="2"] { padding-left: 4.4ch; }
.mutation.is-block { border-left: 2px solid var(--accent-wash); padding-left: 18px; }

.mutation .op { color: var(--accent); }
.mutation .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.step-dots { display: flex; gap: 6px; justify-content: center; margin-top: 28px; }
.step-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--line-2); }
.step-dot.is-done { background: var(--ink-faint); }
.step-dot.is-now { background: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }

/* ── Query ─────────────────────────────────────────────────────────── */

.query { text-align: center; display: grid; gap: 10px; justify-items: center; }
.query-index { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-faint); }
.query-text {
  font-size: clamp(22px, 4.6vw, 38px);
  line-height: 1.35; letter-spacing: -0.02em; font-weight: 450;
}
.query-echo { color: var(--warn); }
.query-entry {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: clamp(34px, 9vw, 60px); letter-spacing: 0.02em; min-height: 1.2em;
  color: var(--accent);
}
.query-entry:empty::after { content: "·"; color: var(--ink-faint); }
.caret { animation: caret 1.05s steps(1) infinite; color: var(--ink-faint); }
@keyframes caret { 50% { opacity: 0; } }
.app.reduce-motion .caret { animation: none; }

/* ── Verdict ───────────────────────────────────────────────────────── */

.verdict { text-align: center; display: grid; gap: 12px; justify-items: center; }
.verdict-word {
  font-size: clamp(34px, 9vw, 64px); font-weight: 700; letter-spacing: -0.04em;
  animation: verdict-in 260ms var(--ease-out);
}
.verdict.is-pass .verdict-word { color: var(--good); }
.verdict.is-fail .verdict-word { color: var(--bad); }
@keyframes verdict-in { from { opacity: 0; transform: translateY(9px) scale(0.97); } }
.app.reduce-motion .verdict-word { animation: none; }
.verdict-sub { color: var(--ink-dim); font-size: 14px; }

/* ── Input pad ─────────────────────────────────────────────────────── */

.padwrap {
  flex: none;
  padding: 0 var(--pad) max(18px, env(safe-area-inset-bottom));
  display: grid; gap: 12px; justify-items: center;
  opacity: 0; pointer-events: none;
  transition: opacity 180ms var(--ease);
}
.padwrap.is-live { opacity: 1; pointer-events: auto; }

.par {
  width: min(420px, 100%); height: 3px; border-radius: 2px;
  background: var(--panel-2); overflow: hidden;
}
.par-fill {
  height: 100%; width: 0%;
  background: var(--accent);
  transition: background 260ms linear;
}
.par-fill.is-past { background: var(--warn); }
.par-fill.is-late { background: var(--bad); }

.pad { display: grid; gap: 8px; width: min(340px, 100%); }
.pad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pad-row { display: grid; grid-auto-flow: column; gap: 8px; }
.app.left-pad .pad-grid { direction: rtl; }

.key {
  appearance: none; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); font-family: var(--mono); font-size: 22px; font-weight: 500;
  height: 56px; border-radius: var(--r-sm); cursor: pointer;
  display: grid; place-items: center; user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 90ms var(--ease), border-color 90ms var(--ease), transform 70ms var(--ease);
}
.key:hover { background: var(--panel-2); border-color: var(--line-2); }
.key:active, .key.is-hit { background: hsl(var(--accent-h) 55% 45% / 0.28); border-color: var(--accent-2); transform: scale(0.96); }
.key[disabled] { opacity: 0.3; pointer-events: none; }
.key-wide { grid-column: span 3; font-size: 17px; font-family: var(--sans); font-weight: 600; }
.key-ok { border-color: hsl(var(--accent-h) 55% 45% / 0.6); background: hsl(var(--accent-h) 55% 42% / 0.16); }
.key-slot { font-size: 20px; letter-spacing: 0.1em; }
.key-yes, .key-no { font-family: var(--sans); font-size: 17px; font-weight: 600; }

/* ── Recap ─────────────────────────────────────────────────────────── */

.screen-recap { justify-content: center; padding: var(--pad); }
.recap { max-width: 720px; width: 100%; padding-bottom: 60px; }
.recap-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.recap-head h2 { margin: 4px 0 0; font-size: clamp(22px, 4vw, 30px); letter-spacing: -0.03em; }
.recap-controls { display: flex; gap: 8px; flex: none; }

.recap-row {
  border: 1px solid var(--line); border-radius: var(--r); background: var(--panel);
  padding: 14px 16px; margin-bottom: 8px;
  opacity: 0.28;
  transition: opacity 300ms var(--ease), border-color 300ms var(--ease), background 300ms var(--ease);
}
.recap-row.is-shown { opacity: 1; }
.recap-row.is-diverge { border-color: var(--bad); background: rgba(242, 112, 95, 0.07); }
.recap-row.is-current { border-color: var(--accent-2); }

.recap-step-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.recap-step-n { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); letter-spacing: 0.1em; }
.recap-text { font-size: 15px; line-height: 1.5; color: var(--ink); flex: 1; white-space: pre-wrap; }

.recap-state { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.rs {
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 15px;
  padding: 4px 9px; border-radius: 7px; background: rgba(255,255,255,0.045);
  border: 1px solid transparent; color: var(--ink-2);
}
.rs b { color: var(--ink-faint); font-weight: 600; font-size: 11px; letter-spacing: 0.14em; margin-right: 6px; }
.rs.is-changed { color: var(--accent); border-color: hsl(var(--accent-h) 55% 45% / 0.4); background: var(--accent-wash); }
.rs.is-stale { color: var(--warn); border-color: rgba(240,179,82,0.3); }
.rs.is-masked b { margin-right: 0; }

.recap-tags { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.tag {
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600;
  padding: 3px 8px; border-radius: 5px; border: 1px solid var(--line);
  color: var(--ink-dim);
}
.tag.fired { color: var(--good); border-color: rgba(98,217,168,0.32); }
.tag.suppressed { color: var(--ink-faint); }
.tag.snapshot { color: var(--accent); border-color: hsl(var(--accent-h) 50% 50% / 0.32); }
.tag.remap { color: var(--warn); border-color: rgba(240,179,82,0.32); }

.recap-q { border-left: 2px solid var(--line-2); }
.recap-q.is-right { border-left-color: var(--good); }
.recap-q.is-wrong { border-left-color: var(--bad); }
.recap-answer { display: flex; gap: 16px; flex-wrap: wrap; align-items: baseline; margin-top: 8px; font-size: 14px; }
.recap-answer .given { font-family: var(--mono); color: var(--bad); }
.recap-answer .given.is-right { color: var(--good); }
.recap-answer .truth { font-family: var(--mono); color: var(--ink-2); }
.recap-answer .aging { color: var(--ink-faint); font-size: 12.5px; }

.recap-foot { margin-top: 24px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; color: var(--ink-faint); font-size: 12.5px; }
.recap-foot .btn { margin-left: auto; }



/* ── Run end ───────────────────────────────────────────────────────── */

.screen-end { align-items: center; justify-content: center; padding: var(--pad); }
.end { max-width: 520px; width: 100%; display: grid; gap: 26px; justify-items: center; text-align: center; }
.end-score { display: grid; gap: 6px; justify-items: center; }
.end-level {
  font-size: clamp(76px, 22vw, 168px); font-weight: 700; letter-spacing: -0.06em; line-height: 0.86;
  background: linear-gradient(180deg, var(--ink), hsl(var(--accent-h) 55% 50%));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: end-in 620ms var(--ease-out);
}
@keyframes end-in { from { opacity: 0; transform: translateY(16px) scale(0.94); } }
.app.reduce-motion .end-level { animation: none; }
.end-sub { color: var(--ink-dim); font-size: 15px; }

.end-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1px;
             width: 100%; margin: 0; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.end-stat { background: var(--bg); padding: 14px 12px; display: grid; gap: 4px; }
.end-stat dt { font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
.end-stat dd { margin: 0; font-family: var(--mono); font-size: 18px; color: var(--ink); }

.end-seed {
  appearance: none; border: 1px dashed var(--line); background: none; cursor: pointer;
  display: flex; align-items: center; gap: 12px; padding: 9px 16px; border-radius: var(--r-sm);
  transition: border-color 180ms var(--ease);
}
.end-seed:hover { border-color: var(--accent-2); }
.end-seed code { font-size: 13px; letter-spacing: 0.08em; }
.end-note { color: var(--ink-faint); font-size: 12.5px; margin: 0; max-width: 44ch; line-height: 1.6; }

/* ── Toast ─────────────────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(12px);
  background: rgba(14, 16, 22, 0.94); border: 1px solid var(--line-2);
  padding: 12px 20px; border-radius: 99px; font-size: 14px; color: var(--ink);
  backdrop-filter: blur(12px); z-index: 50;
  opacity: 0; transition: opacity 220ms var(--ease), transform 260ms var(--ease-out);
  pointer-events: none; max-width: calc(100vw - 40px); text-align: center;
}
.toast.is-up { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Motion & density preferences ──────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .field-blob { animation: none; }
  .slot-rule { animation: none; opacity: 0.55; }
  * { scroll-behavior: auto; }
}

/* Reduce-motion disables pip animations only — never a memory-bearing
   timing (§12). The field stops too, because it is pure chrome. */
.app.reduce-motion .field-blob { animation: none; }
.app.reduce-motion .verdict-word,
.app.reduce-motion .end-level { animation: none; }

@media (max-width: 420px) {
  .key { height: 50px; font-size: 20px; }
  .slots { gap: 8px; }
}

@media (min-height: 900px) {
  .stage { padding-bottom: 4vh; }
}
