/* ARC Race — dark, flat, pixel-honest. No gradients, no SaaS glow. */

:root {
  --bg: #0d0e11;
  --surface: #131519;
  --surface-2: #181b21;
  --line: #24282f;
  --line-bright: #343a44;
  --text: #e6e8ec;
  --text-dim: #8b929d;
  --text-faint: #5e646e;

  --human: #1e93ff;
  --ai: #4fcc30;
  --warn: #ffdc00;
  --danger: #f93c31;
  --accent: #a356d6;

  /* Hairlines between ARC cells, so black cells still read as a grid. */
  --grid-line: #3a3f48;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo,
    Consolas, "Liberation Mono", monospace;

  --gap: 18px;
  --radius: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: 24px clamp(14px, 3vw, 40px) 56px;
  max-width: 1500px;
  margin: 0 auto;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 12px;
  top: 12px;
  background: var(--surface-2);
  padding: 8px 12px;
  z-index: 10;
  border: 1px solid var(--line-bright);
}

/* ------------------------- ARC-AGI-1 colours -------------------------- */
/* The palette of the original ARC testing interface, indices 0-9. */
.c0 { background: #000000; }
.c1 { background: #0074d9; }
.c2 { background: #ff4136; }
.c3 { background: #2ecc40; }
.c4 { background: #ffdc00; }
.c5 { background: #aaaaaa; }
.c6 { background: #f012be; }
.c7 { background: #ff851b; }
.c8 { background: #7fdbff; }
.c9 { background: #870c25; }

/* ------------------------------ masthead ------------------------------ */
.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.masthead h1 {
  margin: 0;
  font-size: clamp(22px, 3.4vw, 34px);
  letter-spacing: 0.16em;
  font-weight: 600;
}

.subtitle {
  margin: 4px 0 0;
  font-size: clamp(12px, 1.6vw, 15px);
  letter-spacing: 0.42em;
  color: var(--text-dim);
}

.subtitle .vs { color: var(--accent); }

.brand-meta { display: flex; gap: 8px; flex-wrap: wrap; }

.pill {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 4px 9px;
  border-radius: var(--radius);
}

/* ------------------------------ controls ------------------------------ */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--gap);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-actions { flex-direction: row; gap: 10px; margin-left: auto; align-items: center; }
.field-check { justify-content: flex-end; }

.field label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.field-check label {
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

select, input[type="number"], .readonly {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  padding: 8px 10px;
  min-width: 190px;
}

.readonly {
  color: var(--text-dim);
  background: var(--surface-2);
  border-style: dashed;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

select:focus-visible,
input:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--human);
  outline-offset: 2px;
}

button {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  padding: 10px 16px;
  cursor: pointer;
  transition: background 120ms linear, border-color 120ms linear;
}

/* Colour swatches keep their colour on hover. */
button:hover:not(:disabled):not(.swatch) { background: #20242b; border-color: #454c58; }
button:disabled { opacity: 0.38; cursor: not-allowed; }

button.primary { border-color: var(--human); color: #cfe6ff; }
button.primary:hover:not(:disabled) { background: #10243a; }
button.danger { border-color: #6d2b26; color: #ffbdb8; }
button.danger:hover:not(:disabled) { background: #2a1512; }

kbd {
  font-family: var(--mono);
  font-size: 10px;
  background: var(--bg);
  border: 1px solid var(--line-bright);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 4px;
  color: var(--text-dim);
}

/* ------------------------------- banner ------------------------------- */
.banner {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-bright);
  background: var(--surface);
  color: var(--warn);
  font-size: 12.5px;
}
.banner.error { color: #ffb4ae; border-color: #6d2b26; background: #1c1211; }

/* ----------------------------- race clock ----------------------------- */
.raceclock {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-bright);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: var(--gap);
  transition: border-color 200ms linear;
}

.raceclock.warn { border-left-color: var(--warn); }
.raceclock.danger { border-left-color: var(--danger); }
.raceclock.over { border-left-color: var(--text-faint); opacity: 0.75; }

.clock-main { display: flex; flex-direction: column; gap: 2px; }

.clock-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.clock-value {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--text);
  transition: color 200ms linear;
}

.raceclock.warn .clock-value { color: var(--warn); }
.raceclock.danger .clock-value { color: var(--danger); }
.raceclock.over .clock-value { color: var(--text-faint); }

/* A subtle pulse only in the last stretch (disabled for reduced motion). */
.raceclock.danger .clock-value { animation: pulse 1s steps(2, end) infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

.clock-bar {
  height: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  min-width: 80px;
}

.clock-bar span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--human);
  transition: width 250ms linear, background 200ms linear;
}

.raceclock.warn .clock-bar span { background: var(--warn); }
.raceclock.danger .clock-bar span { background: var(--danger); }
.raceclock.over .clock-bar span { background: var(--text-faint); }

.clock-goal { display: flex; flex-direction: column; gap: 2px; text-align: right; }
.clock-goal-value { font-size: 13px; color: var(--text-dim); white-space: nowrap; }

/* -------------------------------- grids ------------------------------- */
/* --cols and --cell are set per grid from JavaScript (CSSOM, CSP-safe). */
.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-auto-rows: var(--cell);
  gap: 1px;
  width: max-content;
  background: var(--grid-line);
  border: 1px solid var(--grid-line);
}

.cell { display: block; }

.grid.editable { touch-action: none; user-select: none; }
.grid.editable .cell { cursor: crosshair; }
.grid.editable .cell:hover { outline: 1px solid #ffffff; outline-offset: -1px; }
.locked .grid { opacity: 0.55; }
.locked .grid.editable .cell { cursor: not-allowed; }

.block-label,
.pair figcaption {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ------------------------------- puzzle ------------------------------- */
.task-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: var(--gap);
  min-height: 180px;
}

.task-head h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.2em;
  font-weight: 600;
}

.task-id {
  margin-left: 10px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.task-hint { margin: 6px 0 14px; max-width: 72ch; font-size: 12.5px; color: var(--text-dim); }

.task-body { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: flex-start; }

.examples { display: flex; flex-wrap: wrap; gap: 12px; flex: 1 1 520px; min-width: 0; }

.pair,
.test-block {
  margin: 0;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.test-block { border-color: #37506b; }

.pair-row { display: flex; align-items: center; gap: 10px; }
.arrow { font-size: 16px; color: var(--text-faint); }

.task-veil {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(9, 10, 12, 0.92);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
}
.task-veil[hidden] { display: none; }

/* ------------------------------- arena -------------------------------- */
.arena {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}

#human-panel { border-top: 2px solid var(--human); }
#ai-panel { border-top: 2px solid var(--ai); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.3em;
  font-weight: 600;
}

#human-panel .panel-head h2 { color: var(--human); }
#ai-panel .panel-head h2 { color: var(--ai); }

.state-chip {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 4px 9px;
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  color: var(--text-dim);
  white-space: nowrap;
}
.state-chip.live { color: var(--warn); border-color: #5a4f18; }
.state-chip.thinking { color: var(--accent); border-color: #4a2f63; }
.state-chip.won { color: var(--ai); border-color: #2c5c1c; }
.state-chip.over { color: var(--danger); border-color: #6d2b26; }
.state-chip.err { color: var(--danger); border-color: #6d2b26; }

/* ------------------------------- editor ------------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.toolbar button { padding: 7px 10px; font-size: 11px; }

.toolbar .size {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.toolbar .size input { min-width: 0; width: 58px; padding: 6px 7px; }

.tool-group { display: inline-flex; gap: 4px; margin-left: auto; }
.tool[aria-pressed="true"] { border-color: var(--human); color: #cfe6ff; background: #10243a; }

.palette {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 4px;
  max-width: 420px;
  margin-bottom: 12px;
}

.swatch {
  height: 30px;
  padding: 0;
  border: 2px solid transparent;
  font-size: 11px;
  letter-spacing: 0;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 0 2px #000000, 0 0 2px #000000;
}
.swatch:hover:not(:disabled) { border-color: var(--text-dim); }
.swatch[aria-pressed="true"] { border-color: #ffffff; outline: 1px solid #000000; outline-offset: -3px; }

.editor-wrap,
.ai-work {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 200px;
  padding: 12px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--line-bright);
  border-radius: 2px;
}

.submit-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.result { margin: 0; font-size: 12.5px; }
.result.ok { color: var(--ai); }
.result.bad { color: #ffb4ae; }

.ai-hidden { margin: 0; max-width: 34ch; font-size: 12px; text-align: center; color: var(--text-faint); }
.ai-hidden[hidden] { display: none; }

/* ------------------------------ AI play ------------------------------- */
.ai-work-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  width: 100%;
}
.ai-verdict { font-size: 11.5px; letter-spacing: 0.06em; }
.ai-verdict.ok { color: var(--ai); }
.ai-verdict.bad { color: #ffb4ae; }

.ai-thinking { margin: 0; font-size: 12px; color: var(--accent); font-variant-numeric: tabular-nums; }
.ai-thinking[hidden] { display: none; }
.ai-thinking::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  vertical-align: middle;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s steps(2, end) infinite;
}

.ai-work.flash { animation: flash 900ms ease-out; }
@keyframes flash {
  from { box-shadow: 0 0 0 2px var(--ai); }
  to { box-shadow: 0 0 0 0 transparent; }
}

.ai-gallery { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.ai-gallery[hidden] { display: none; }

.attempt {
  margin: 0;
  padding: 8px;
  max-width: 210px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.attempt.ok { border-color: #2c5c1c; }
.attempt.bad { border-color: #5a2723; }
.attempt figcaption { font-size: 11px; font-variant-numeric: tabular-nums; }
.attempt.ok figcaption { color: #dff5d6; }
.attempt.bad figcaption { color: #ffcfcb; }
.attempt-rule { margin: 0; font-size: 11px; line-height: 1.35; color: var(--text-dim); }

/* -------------------------------- stats ------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 0;
}

.stats > div {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 9px;
  min-width: 0;
}

.stats dt {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 3px;
}

.stats dd {
  margin: 0;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

dd.frozen { color: var(--ai); }

.history {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.history li {
  font-size: 11px;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  padding: 3px 7px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 3px;
}
.history li.ok { color: #dff5d6; border-color: #2c5c1c; background: #14240e; }
.history li.bad { color: #ffcfcb; border-color: #5a2723; }

/* -------------------------------- agent ------------------------------- */
.agent { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }

.agent-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px dotted var(--line);
  padding-bottom: 6px;
}

.agent-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.agent-value { font-size: 13px; font-variant-numeric: tabular-nums; }

.agent-note { display: flex; flex-direction: column; gap: 6px; }

.agent-note blockquote {
  margin: 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border-left: 2px solid var(--ai);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 12.5px;
  color: var(--text-dim);
  min-height: 3.4em;
  word-break: break-word;
}

.agent-error {
  margin: 0;
  font-size: 12px;
  color: #ffb4ae;
  border: 1px solid #6d2b26;
  background: #1c1211;
  border-radius: var(--radius);
  padding: 8px 10px;
}

/* ------------------------------ results ------------------------------- */
.scoreboard {
  margin-top: var(--gap);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  text-align: center;
}

.scoreboard h2 {
  margin: 0 0 8px;
  font-size: clamp(18px, 3vw, 26px);
  letter-spacing: 0.2em;
}
.scoreboard h2.human-won { color: var(--human); }
.scoreboard h2.ai-won { color: var(--ai); }

.verdict {
  margin: 0 0 14px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.results {
  width: 100%;
  max-width: 560px;
  margin: 0 auto 16px;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.results th,
.results td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.results thead th {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 400;
  border-bottom-color: var(--line-bright);
}

.results tbody th,
.results thead th:first-child { text-align: left; letter-spacing: 0.18em; }
.results .lane-human { color: var(--human); }
.results .lane-ai { color: var(--ai); }
.results tr.is-winner td,
.results tr.is-winner th { background: #16201a; }
.results .r-outcome.done { color: var(--ai); }
.results .r-outcome.miss { color: var(--text-faint); }
.results .r-time.best { color: var(--warn); }

.efficiency { margin: 0 0 6px; font-size: 13px; color: var(--text-dim); }
.efficiency strong { color: var(--warn); letter-spacing: 0.1em; }
.caveat { margin: 0; font-size: 11.5px; color: var(--text-faint); }

/* -------------------------------- log --------------------------------- */
.log-wrap {
  margin-top: var(--gap);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.log-wrap summary {
  cursor: pointer;
  padding: 11px 14px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex;
  gap: 10px;
  align-items: center;
}

.log-count {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 10px;
  color: var(--text-faint);
}

.log {
  list-style: none;
  margin: 0;
  padding: 0 14px 14px;
  max-height: 260px;
  overflow-y: auto;
  font-size: 12px;
}

.log li {
  display: flex;
  gap: 10px;
  padding: 3px 0;
  border-bottom: 1px dotted #1e2128;
  white-space: nowrap;
}

.log .ts { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.log .who { width: 5.5em; letter-spacing: 0.08em; flex-shrink: 0; }
.log .who.human { color: var(--human); }
.log .who.ai { color: var(--ai); }
.log .who.sys { color: var(--text-faint); }
.log .what { color: var(--text-dim); white-space: normal; }
.log li.hl .what { color: var(--warn); }
.log li.err .what { color: #ffb4ae; }

/* ------------------------------- legend ------------------------------- */
.legend {
  margin-top: 26px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--text-faint);
  font-size: 11.5px;
  text-align: center;
}
.legend p { margin: 0 0 4px; }
.legend-dim { opacity: 0.75; }

/* ----------------------------- responsive ----------------------------- */
@media (max-width: 940px) {
  .arena { grid-template-columns: 1fr; }
  .field-actions { margin-left: 0; width: 100%; }
  .field-actions button { flex: 1; }
  select, .readonly { min-width: 0; width: 100%; }
  .field { flex: 1 1 200px; }
  .tool-group { margin-left: 0; }
}

@media (max-width: 620px) {
  .raceclock { grid-template-columns: 1fr; gap: 10px; }
  .clock-goal { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------- static build (GitHub Pages) additions ---------------- */
.topnav { display: flex; gap: 14px; align-items: baseline; }
.topnav a { color: var(--text-dim); font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase; }
.topnav a:hover { color: var(--human); }

.keyrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.keyrow input {
  flex: 1 1 320px;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
}
.keyrow .hint { flex-basis: 100%; margin: 0; font-size: 11.5px; color: var(--text-faint); }

/* An explicit `display` beats the browser's built-in [hidden] rule, so any
   component with one stayed on screen while reporting hidden === true. That had
   already been patched per-component four times; this settles it everywhere. */
[hidden] { display: none !important; }

.r-attempts { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.howto {
  margin: 0 0 18px;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--human);
  border-radius: var(--radius);
}
/* Collapsed by default: the rules are there when wanted, not in the way of
   someone who already knows them. <details> gives keyboard and screen-reader
   behaviour for free, so none of this needs script. */
.howto > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.howto > summary::-webkit-details-marker { display: none; }
.howto > summary::before {
  content: "▸";
  font-size: 11px;
  line-height: 1;
  transition: transform 130ms ease;
}
.howto[open] > summary::before { transform: rotate(90deg); }
.howto > summary:hover { color: var(--human); }
.howto[open] > summary { margin-bottom: 12px; }

@media (prefers-reduced-motion: reduce) {
  .howto > summary::before { transition: none; }
}
.howto .steps {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
}
.howto .steps strong { color: var(--human); font-weight: 600; }
.howto .steps em { font-style: normal; color: var(--text-dim); }
.howto-foot {
  margin: 13px 0 0;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-faint);
}

.answer-size {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  white-space: nowrap;
}
.answer-size strong { color: var(--human); font-weight: 600; }

/* ------------------------- MNIST-Pro: the canvas ------------------------ */
.scorebar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  margin: 0 0 18px;
  padding: 14px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.score-cell { display: flex; flex-direction: column; gap: 4px; }
.score-cell.ai { text-align: right; }
.score-cell.mid { text-align: center; }
.score-label {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.score-note { text-transform: none; letter-spacing: 0; opacity: 0.7; }
.score-value {
  font-family: var(--mono);
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.score-cell.human .score-value { color: var(--human); }
.score-cell.ai .score-value { color: var(--ai); }
.score-value.dim { font-size: 20px; color: var(--text-dim); }

.canvas-wrap { position: relative; display: flex; justify-content: center; }
.board {
  /* The canvas is 224px of real pixels; never smooth it when scaling up. */
  image-rendering: pixelated;
  width: 100%;
  max-width: 320px;
  height: auto;
  aspect-ratio: 1 / 1;
  background: #808080;
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(2, 40px);
  gap: 6px;
  justify-content: center;
  margin-top: 14px;
}
.dpad button {
  font-size: 17px;
  padding: 0;
  font-family: var(--mono);
}
#dp-up { grid-column: 2; grid-row: 1; }
#dp-left { grid-column: 1; grid-row: 2; }
#dp-down { grid-column: 2; grid-row: 2; }
#dp-right { grid-column: 3; grid-row: 2; }
.canvas-veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(12, 13, 16, 0.82);
  border-radius: var(--radius);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.guessrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.guess-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.guess-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.guess-buttons button {
  width: 38px;
  height: 38px;
  font-family: var(--mono);
  font-size: 16px;
  padding: 0;
}
.guess-buttons button.wrong {
  border-color: var(--bad);
  color: var(--bad);
  opacity: 0.55;
  cursor: not-allowed;
}
.guess-buttons button.right { border-color: var(--good); color: var(--good); }

@media (max-width: 560px) {
  .scorebar { grid-template-columns: 1fr; text-align: center; }
  .score-cell.ai, .score-cell.mid { text-align: center; }
  .score-cell { align-items: center; }
}

.hint-box { margin-top: 10px; }
.hint-btn {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
}
.hint-text {
  margin: 9px 0 0;
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  border-left: 2px solid var(--ai);
  border-radius: 0 var(--radius) var(--radius) 0;
}
