/* ==========================================================================
   Genius or Average — design system
   Dark, calm, precise. Springy easings, soft glows, tabular numerals.
   ========================================================================== */

:root {
  --bg: #0b0c0e;
  --surface: #111318;
  --surface-2: #181b22;
  --line: rgba(150, 158, 175, 0.13);
  --text: #e9ebef;
  --muted: #8d94a3;
  --accent: #d9a843;
  --game: var(--accent);
  --radius: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Book Antiqua', serif;
  --mono: ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background-color: var(--bg);
  background-image: radial-gradient(rgba(233, 235, 239, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(1060px, 92vw); margin: 0 auto; }

::selection { background: rgba(217, 168, 67, 0.35); }

button { font: inherit; color: inherit; }

a { color: inherit; text-decoration: none; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

/* ------------------------------------------------------------- header --- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 12, 14, 0.92);
  border-bottom: 1px solid var(--line);
}

.header-row {
  display: flex;
  align-items: center;
  gap: 22px;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  font-weight: 700;
  white-space: nowrap;
}
.logo i {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 0.92em;
  color: var(--accent);
}
.logo svg { width: 24px; height: 24px; color: var(--accent); flex: 0 0 auto; }

.site-nav { display: flex; gap: 2px; margin-left: auto; }
.site-nav a {
  padding: 7px 12px;
  border-radius: 7px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.site-nav a:hover { color: var(--text); background: rgba(150, 158, 175, 0.1); }
.site-nav a[aria-current] { color: var(--accent); background: rgba(217, 168, 67, 0.1); }

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 11px;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.2s, border-color 0.2s, transform 0.15s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: rgba(140, 150, 170, 0.35); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 19px; height: 19px; }

/* --------------------------------------------------------------- main ---- */

#view { flex: 1; padding: 34px 0 70px; }

.view-enter { animation: fadeUp 0.45s var(--ease) both; }

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

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

.hero { text-align: center; padding: 44px 0 30px; }

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5.5vw, 3.4rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.hero h1::after { content: '?'; color: var(--accent); }

.kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.hero-sub {
  max-width: 560px;
  margin: 14px auto 26px;
  color: var(--muted);
  font-size: 1.06rem;
}

.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.hero.compact { padding: 18px 0 8px; }
.hero.compact h1 { font-size: clamp(1.8rem, 4.5vw, 2.6rem); }
.hero.compact .hero-sub { margin: 8px auto 6px; font-size: 0.97rem; max-width: 620px; }

.feat-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  margin: 10px 0 16px;
}
.feat-name {
  font-weight: 700;
  font-size: 0.95rem;
  padding: 5px 13px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.link-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 9px;
  transition: color 0.2s, background 0.2s;
}
.link-btn:hover { color: var(--text); background: rgba(140, 150, 170, 0.1); }

.page-title { font-family: var(--font-display); font-size: 2.1rem; font-weight: 600; letter-spacing: -0.01em; }

.cat-title {
  margin: 34px 0 12px;
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
}
.cat-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* game list rows */
.game-rows { display: flex; flex-direction: column; gap: 8px; }

.grow {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  transition: transform 0.2s var(--ease), border-color 0.2s, box-shadow 0.2s;
}
.grow:hover {
  transform: translateX(3px);
  border-color: color-mix(in srgb, var(--game) 45%, transparent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.grow:active { transform: translateX(3px) scale(0.995); }

.gr-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: var(--game);
  background: color-mix(in srgb, var(--game) 14%, transparent);
}
.gr-icon svg { width: 23px; height: 23px; }

.gr-main { min-width: 0; }
.gr-main h3 { font-size: 0.99rem; font-weight: 700; letter-spacing: -0.01em; }
.gr-main .tag { font-size: 0.83rem; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.grow .best-chip { margin-top: 0; white-space: nowrap; }
.best-chip.empty { color: var(--muted); background: rgba(140, 150, 170, 0.09); }

.gr-play {
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 7px 15px;
  border-radius: 7px;
  color: var(--game);
  border: 1px solid color-mix(in srgb, var(--game) 45%, transparent);
  transition: background 0.2s, color 0.2s;
}
.grow:hover .gr-play { background: var(--game); color: #101114; }

.gr-dist {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 140px;
}
.spark { display: block; width: 132px; height: 36px; }
.spark svg { width: 100%; height: 100%; display: block; }
.gr-dist-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--game);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.gr-dist-label.empty { color: var(--muted); }

.best-chip {
  display: inline-block;
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--game);
  border: 1px solid color-mix(in srgb, var(--game) 35%, transparent);
  font-variant-numeric: tabular-nums;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.16s var(--ease), filter 0.2s, background 0.2s, border-color 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--game);
  color: #101114;
}
.btn-primary:hover { filter: brightness(1.1); }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost:hover { border-color: rgba(140, 150, 170, 0.4); background: rgba(140, 150, 170, 0.07); }

.btn-big { padding: 16px 34px; font-size: 1.05rem; background: var(--surface-2); border-color: var(--line); }
.btn-big:hover { border-color: color-mix(in srgb, var(--game) 55%, transparent); }
.btn-alt { background: var(--surface); }

.btn-start { min-width: 190px; padding: 14px 30px; font-size: 1.05rem; }

.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }

/* --------------------------------------------------------------- game ---- */

.game-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  min-height: 32px;
}
.back { color: var(--muted); font-size: 0.9rem; transition: color 0.2s; }
.back:hover { color: var(--text); }
.game-title { font-weight: 700; letter-spacing: -0.01em; }
.chip-holder { margin-left: auto; }

.stage {
  position: relative;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 28px 20px;
  overflow: hidden;
}

.stage.playing { padding-top: 68px; }

.stage-hint { color: var(--muted); font-size: 0.85rem; text-align: center; }

.stack { display: flex; flex-direction: column; align-items: center; gap: 20px; width: 100%; }

/* HUD */
.hud {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
}
.hud-item {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 7px;
  background: rgba(11, 12, 14, 0.6);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.hud-item b { color: var(--text); font-size: 0.95rem; }
.lives { color: #ff5c8a; letter-spacing: 2px; font-size: 1rem; }

/* time bar */
.time-bar {
  width: min(420px, 80%);
  height: 6px;
  border-radius: 999px;
  background: rgba(140, 150, 170, 0.15);
  overflow: hidden;
}
.time-bar .fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--game);
}

/* inputs */
.num-input {
  width: min(340px, 82%);
  padding: 14px 18px;
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  color: var(--text);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.num-input:focus {
  border-color: var(--game);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--game) 18%, transparent);
}

.ghost-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
}

/* -------------------------------------------------------------- intro ---- */

.intro { text-align: center; max-width: 520px; display: flex; flex-direction: column; align-items: center; gap: 14px; }

.game-icon {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: var(--game);
  background: color-mix(in srgb, var(--game) 11%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--game) 28%, transparent) inset;
}
.game-icon svg { width: 40px; height: 40px; }

.intro h2 { font-family: var(--font-display); font-size: 1.8rem; font-weight: 600; letter-spacing: -0.01em; }
.intro .desc { color: var(--text); opacity: 0.9; }
.intro .how { color: var(--muted); font-size: 0.92rem; }

.intro-stats, .res-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 6px 0 10px;
}
.is-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 108px;
  padding: 11px 16px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.is-item b { font-size: 1.02rem; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.is-item span { font-family: var(--mono); font-size: 0.64rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }

/* ------------------------------------------------------------ results ---- */

.results { text-align: center; max-width: 620px; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }

.res-label {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.newbest {
  color: #ffd166;
  font-weight: 700;
  font-size: 0.95rem;
  animation: pop 0.5s var(--ease) both;
}

.big-score {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.big-score .num {
  font-family: var(--mono);
  font-size: clamp(3.2rem, 9vw, 4.8rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.big-score .unit { color: var(--muted); font-size: 1.1rem; font-weight: 600; }

.detail { color: var(--muted); font-size: 0.9rem; }

.pct-line { font-size: 1.05rem; }
.pct-line b { color: var(--game); font-size: 1.15rem; }

.chart { width: 100%; max-width: 560px; }
.chart svg { width: 100%; height: auto; display: block; }
.ch-tick { fill: var(--muted); font-size: 11px; text-anchor: middle; font-variant-numeric: tabular-nums; }
.ch-tickline { stroke: rgba(140, 150, 170, 0.3); }
.ch-better { fill: rgba(140, 150, 170, 0.55); font-size: 10.5px; letter-spacing: 0.06em; }
.ch-marker { stroke: #fff; stroke-width: 1.6; stroke-dasharray: 3 3; opacity: 0.9; }
.ch-dot { fill: #fff; }
.ch-you { fill: #fff; font-size: 12px; font-weight: 700; }
.ch-beat { animation: chartIn 0.9s var(--ease) both 0.15s; transform-origin: bottom; }

@keyframes chartIn {
  from { opacity: 0; transform: scaleY(0.6); }
  to { opacity: 1; transform: none; }
}

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

.pop { animation: pop 0.35s var(--ease) both; }
/* pop animates the standalone `scale` property, NOT `transform` — elements
   keep the .pop class, and a transform keyframe with fill-mode `both` would
   permanently override class transforms (card flips, target centering). */
@keyframes pop {
  0% { scale: 0.82; opacity: 0; }
  100% { scale: 1; opacity: 1; }
}

.shake { animation: shake 0.35s ease both; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

/* ----------------------------------------------------------- reaction ---- */

.rx-zone {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s linear;
  border-radius: 21px;
}
.rx-idle { background: var(--surface); }
.rx-wait { background: #a83a46; }
.rx-go { background: #2f9e5f; }
.rx-early { background: #a8873a; }
.rx-result { background: var(--surface); }

.rx-title { font-size: clamp(2rem, 6vw, 3.2rem); font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.rx-sub { color: rgba(255, 255, 255, 0.75); font-size: 1rem; }
.rx-result .rx-sub, .rx-idle .rx-sub { color: var(--muted); }

/* ---------------------------------------------------------------- aim ---- */

.aim-arena {
  position: relative;
  width: 100%;
  max-width: 860px;
  height: 440px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
  touch-action: manipulation;
}

.aim-target {
  position: absolute;
  width: 54px;
  height: 54px;
  transform: translate(-50%, -50%);
  background: none;
  border: none;
  cursor: crosshair;
  padding: 0;
  animation: pop 0.18s var(--ease) both;
}
.aim-target svg { width: 100%; height: 100%; display: block; }
.aim-target:active { transform: translate(-50%, -50%) scale(0.9); }

.aim-hint {
  position: absolute;
  bottom: 14px;
  width: 100%;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  pointer-events: none;
}

/* ------------------------------------------------------------ sequence --- */

.seq-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: min(380px, 84vw);
}
.seq-grid.locked { pointer-events: none; }

.seq-cell {
  aspect-ratio: 1;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s var(--ease), box-shadow 0.2s;
}
.seq-cell:hover { background: #1e2531; }
.seq-cell:active { transform: scale(0.95); }
.seq-cell.lit {
  background: var(--game);
  box-shadow: 0 0 26px color-mix(in srgb, var(--game) 65%, transparent);
  transform: scale(1.04);
}
.seq-cell.miss { background: #c2434e; box-shadow: 0 0 26px rgba(194, 67, 78, 0.6); }

/* -------------------------------------------------------------- number --- */

.digits {
  font-size: clamp(2.4rem, 8vw, 4.4rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
  text-align: center;
  word-break: break-all;
  max-width: 90%;
}
.digits.ok-flash { color: #51cf66; }

.num-row { display: flex; align-items: baseline; gap: 14px; }
.num-label { color: var(--muted); font-size: 0.85rem; min-width: 92px; text-align: right; }
.num-cmp .dg {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
}
.num-cmp .dg.err { color: #ff5c8a; text-decoration: line-through; }

/* -------------------------------------------------------------- verbal --- */

.word {
  font-size: clamp(2.2rem, 7vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  min-height: 1.3em;
}
.vm-buttons { display: flex; gap: 16px; }

/* --------------------------------------------------------------- chimp --- */

.chimp-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 8px;
  width: min(760px, 92%);
  height: 380px;
}

.chimp-cell {
  border-radius: 12px;
  border: 1.5px solid color-mix(in srgb, var(--game) 55%, transparent);
  background: color-mix(in srgb, var(--game) 12%, var(--surface-2));
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: transform 0.12s var(--ease), background 0.15s;
}
.chimp-cell:active { transform: scale(0.94); }
.chimp-cell.masked { background: #dfe4ee; border-color: #dfe4ee; }
.chimp-cell.masked span { visibility: hidden; }
.chimp-cell.done { visibility: hidden; }
.chimp-cell.wrong { background: #c2434e; border-color: #c2434e; }

/* -------------------------------------------------------------- visual --- */

.vm2-grid {
  display: grid;
  grid-template-columns: repeat(var(--dim), 1fr);
  gap: 8px;
  width: min(420px, 86vw);
}

.vtile {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  transition: background 0.2s, transform 0.25s var(--ease);
  transform-style: preserve-3d;
}
.vtile:active { transform: scale(0.94); }
.vtile.show { background: var(--game); transform: rotateY(180deg); box-shadow: 0 0 18px color-mix(in srgb, var(--game) 55%, transparent); }
.vtile.found { background: var(--game); box-shadow: 0 0 14px color-mix(in srgb, var(--game) 45%, transparent); }
.vtile.wrong { background: #3a2a33; border-color: #c2434e; }

/* -------------------------------------------------------------- typing --- */

.type-text {
  max-width: 720px;
  font-size: 1.35rem;
  line-height: 1.9;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;
  user-select: none;
  padding: 0 8px;
}
.tchar { color: var(--muted); border-radius: 3px; transition: color 0.08s; white-space: pre-wrap; }
.tchar.ok { color: var(--text); }
.tchar.err { color: #ff5c8a; background: rgba(255, 92, 138, 0.14); }
.tchar.cur { box-shadow: -2px 0 0 var(--game); animation: caret 1.1s steps(1) infinite; }

@keyframes caret { 50% { box-shadow: -2px 0 0 transparent; } }

/* -------------------------------------------------------------- stroop --- */

.stroop-rule { color: var(--muted); font-size: 0.9rem; margin-top: 26px; }

.stroop-word {
  font-size: clamp(2.6rem, 8vw, 4.2rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  min-height: 1.25em;
}

.stroop-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: min(560px, 90%);
}

.sbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 15px 6px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 750;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.13s var(--ease), border-color 0.2s, background 0.2s;
}
.sbtn:hover { border-color: rgba(140, 150, 170, 0.4); background: #1e2531; }
.sbtn:active { transform: scale(0.95); }
.sbtn small { color: var(--muted); font-size: 0.68rem; font-weight: 600; }

/* ------------------------------------------------------------ timewarp --- */

.tw-zone {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  cursor: pointer;
  user-select: none;
}

.tw-face {
  font-size: clamp(3rem, 9vw, 5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}
.tw-face.hidden-time { color: var(--muted); }
.tw-zone .stage-hint { max-width: 420px; }

/* ----------------------------------------------------------------- hue --- */

.hue-grid {
  display: grid;
  grid-template-columns: repeat(var(--dim), 1fr);
  gap: 6px;
  width: min(420px, 86vw);
}

.hue-tile {
  aspect-ratio: 1;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.2s;
}
.hue-tile:active { transform: scale(0.93); }
.hue-tile.found { box-shadow: 0 0 0 3px #fff inset; }

/* -------------------------------------------------------------- knight --- */

.kboard {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(480px, 88vw);
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.kcell {
  border: none;
  cursor: pointer;
  font-size: clamp(1.4rem, 4.5vw, 2.1rem);
  line-height: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #0a0d13;
  transition: background 0.18s, transform 0.12s var(--ease);
  position: relative;
}
.kcell.light { background: #a9b4c9; }
.kcell.dark { background: #5d6b85; }
.kcell.visited.light { background: #3d4557; }
.kcell.visited.dark { background: #333b4c; }
.kcell.hint::after {
  content: '';
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: var(--game);
  border: 1.5px solid rgba(10, 12, 14, 0.9);
  box-sizing: border-box;
  animation: pop 0.25s var(--ease) both;
}
.kcell.hint { cursor: pointer; }
.kcell.knight { color: #0d0f16; text-shadow: 0 0 14px rgba(255, 255, 255, 0.35); }
.kcell.knight.visited { color: #e8ecf3; }

/* ---------------------------------------------------------------- math --- */

.mm-problem {
  font-size: clamp(2.6rem, 8vw, 4.2rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  min-height: 1.25em;
}

/* --------------------------------------------------------------- pitch --- */

.pp-face {
  font-size: clamp(2.6rem, 8vw, 4rem);
  font-weight: 800;
  color: var(--game);
  transition: transform 0.3s var(--ease), opacity 0.3s;
}
.pp-face.playing { animation: pulse 0.8s ease-in-out infinite; }

@keyframes pulse {
  50% { transform: scale(1.12); opacity: 0.75; }
}

.pp-buttons { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; }

.pp-mute {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(10, 13, 19, 0.88);
  backdrop-filter: blur(6px);
  border-radius: 21px;
  z-index: 5;
}

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

.fr-target {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
}
.fr-label {
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.fr-symbol { font-size: 2.6rem; line-height: 1; }

.fr-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 10px;
  width: min(440px, 88vw);
}

.fcard {
  position: relative;
  aspect-ratio: 3 / 4;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.45s var(--ease), opacity 0.3s;
  border-radius: 12px;
}
.fcard.down { transform: rotateY(180deg); }
.fcard.done { opacity: 0.35; pointer-events: none; }
.fcard:not(.down):not(.done):active { transform: scale(0.95); }

.fcard .face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  font-size: clamp(1.5rem, 5vw, 2.2rem);
}
.fcard .front {
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.fcard .back {
  transform: rotateY(180deg);
  color: color-mix(in srgb, var(--game) 70%, #fff);
  background: linear-gradient(150deg, color-mix(in srgb, var(--game) 26%, var(--surface-2)), var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--game) 35%, transparent);
  font-size: 1.1rem;
}

/* --------------------------------------------------------------- stats --- */

.stats-page h1, .about-page h1 { font-family: var(--font-display); font-size: 2.1rem; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 22px; }

.overall {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 26px;
  flex-wrap: wrap;
}

.ring { position: relative; width: 120px; height: 120px; flex: 0 0 auto; }
.ring svg { width: 100%; height: 100%; }
.ring-fill { animation: ringIn 1.1s var(--ease) both; }

@keyframes ringIn { from { stroke-dashoffset: 326.7; } }

.overall-num {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.overall-num b { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.overall-num span { font-size: 0.62rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; margin-top: 3px; }

.overall-copy h2 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 6px; }

.stat-rows { display: flex; flex-direction: column; gap: 8px; }

.stat-row {
  display: grid;
  grid-template-columns: 40px minmax(120px, 1fr) minmax(90px, auto) minmax(80px, 2fr) 48px;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color 0.2s, transform 0.2s var(--ease);
  font-variant-numeric: tabular-nums;
}
.stat-row:hover { border-color: color-mix(in srgb, var(--game) 45%, transparent); transform: translateX(3px); }
.stat-row.empty { opacity: 0.55; }

.sr-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--game); background: color-mix(in srgb, var(--game) 13%, transparent); }
.sr-icon svg { width: 19px; height: 19px; }
.sr-name { font-weight: 650; font-size: 0.94rem; }
.sr-best { color: var(--muted); font-size: 0.88rem; text-align: right; }
.sr-bar { height: 7px; border-radius: 999px; background: rgba(140, 150, 170, 0.14); overflow: hidden; }
.sr-fill { display: block; height: 100%; border-radius: 999px; background: var(--game); transition: width 0.9s var(--ease); }
.sr-pct { text-align: right; font-weight: 700; font-size: 0.92rem; color: var(--game); }

.stats-page .muted.small { margin-top: 18px; }
.stats-page > .btn { margin-top: 8px; }

/* --------------------------------------------------------------- about --- */

.about-page { max-width: 680px; }
.about-page h2 { font-size: 1.2rem; margin: 26px 0 8px; letter-spacing: -0.01em; }
.about-page p, .about-page li { color: #c6cddb; }
.about-page ul { padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }

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

.site-footer {
  border-top: 1px solid var(--line);
  padding: 26px 0 34px;
  font-size: 0.88rem;
}
.site-footer .muted { font-size: 0.8rem; margin-top: 4px; }
.footer-links a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.footer-links a:hover { color: var(--text); }

.inline-link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* Reserved advertising containers — fixed height so mounting an ad unit
   causes zero layout shift. Rendered only when config.adsEnabled is true. */
.ad-slot {
  width: 100%;
  max-width: 728px;
  min-height: 266px;
  margin: 22px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: rgba(150, 158, 175, 0.03);
}
.ad-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.6;
}

/* ------------------------------------------------------------- overlay --- */

.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 16px);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  z-index: 70;
  box-shadow: var(--shadow);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

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

@media (max-width: 640px) {
  .site-nav a { padding: 6px 7px; font-size: 0.66rem; }
  .logo { font-size: 0.95rem; gap: 6px; }
  .header-row { gap: 10px; }
  .stage { min-height: 480px; padding: 22px 12px; }
  .chimp-grid { height: 300px; gap: 5px; }
  .chimp-cell { font-size: 0.95rem; border-radius: 8px; }
  .stroop-buttons { grid-template-columns: repeat(2, 1fr); }
  .stat-row { grid-template-columns: 34px 1fr auto; }
  .sr-bar, .sr-pct { display: none; }
  .grow { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; }
  .gr-play { display: none; }
  .spark { display: none; }
  .gr-dist { min-width: 0; }
  .aim-arena { height: 380px; }
  .type-text { font-size: 1.08rem; }
  .hud { flex-wrap: wrap; padding: 0 10px; }
  .chip-holder { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
