@font-face { font-family: Spectral; src: url(/fonts/spectral-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Spectral; src: url(/fonts/spectral-latin-400-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: Spectral; src: url(/fonts/spectral-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(/fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --paper: #f1f2ee;
  --ink: #1b1d24;
  --mute: #63666e;
  --rule: #c8cac3;
  --grid: #e3e5df;
  --coop: #2348d8;
  --defect: #e0412b;
  --ai: #8a5d0b; /* AI house players: ochre, away from the move colours and the house grey */
  --cell: 24px; /* graph-paper module; layout snaps to it */
  --measure: 34rem;
  font-family: Spectral, Georgia, serif;
  font-size: 19px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: lining-nums tabular-nums;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
}

a { color: var(--coop); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--coop); outline-offset: 3px; }

h1, h2, h3 { font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; letter-spacing: -0.01em; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; max-width: var(--measure); }

.wrap { max-width: 64rem; margin: 0 auto; padding: 0 calc(var(--cell) * 1.5); }

/* Header: the two squares are the mark (one cooperate, one defect). */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(var(--cell) * 1.5) 0;
}
.mark { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 600; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.mark i { display: inline-block; width: 12px; height: 12px; }
.mark i:first-child { background: var(--coop); }
.mark i + i { background: var(--defect); margin-left: -0.45rem; }
.top nav { display: flex; gap: 1.4rem; align-items: center; }
.top nav a { color: var(--ink); text-decoration: none; }
.top nav a:hover, .top nav a[aria-current] { text-decoration: underline; }

main { padding-bottom: calc(var(--cell) * 4); }
section { padding: calc(var(--cell) * 3) 0; border-top: 1px solid var(--rule); }
section:first-child { border-top: 0; }

.lede { font-size: 1.25rem; color: var(--ink); }
.mute { color: var(--mute); }
.small { font-size: 0.85rem; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
  padding: 0.55rem 1.1rem; border: 1.5px solid var(--ink); background: var(--ink); color: var(--paper);
  text-decoration: none;
}
.btn:hover { background: var(--coop); border-color: var(--coop); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; background: var(--ink); }

/* Moves: the only places colour appears. */
.c { color: var(--coop); }
.d { color: var(--defect); }
.sq { display: inline-block; width: 10px; height: 10px; vertical-align: baseline; }
.sq.c { background: var(--coop); }
.sq.d { background: var(--defect); }

/* Hero: text left, live matrix right */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 26rem); gap: calc(var(--cell) * 3); align-items: start; padding-top: calc(var(--cell) * 2); }
.hero h1 { margin-bottom: 1.2rem; max-width: 14ch; }
.hero .actions { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-top: 1.6rem; }
.clock { margin-top: calc(var(--cell) * 2); }
.clock b { font-size: 2.6rem; font-weight: 400; letter-spacing: -0.02em; line-height: 1; display: block; }

/* Payoff matrix */
.matrix { border-collapse: collapse; width: 100%; table-layout: fixed; }
.matrix th { font-weight: 400; color: var(--mute); font-size: 0.85rem; padding: 0.4rem; text-align: center; }
.matrix th[scope="row"] { text-align: right; padding-right: 0.8rem; white-space: nowrap; }
.matrix td {
  border: 1.5px solid var(--ink); text-align: center; height: 6.5rem;
  font-size: 1.9rem; background: var(--paper); transition: background-color 0.35s, color 0.35s;
}
.matrix td small { display: block; font-size: 0.8rem; color: var(--mute); transition: color 0.35s; padding: 0 0.4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.matrix td .you { font-weight: 600; }
.matrix td.on { background: var(--ink); color: var(--paper); transition: none; }
.matrix td.on small { color: var(--grid); transition: none; }
.matrix .side { color: var(--mute); }

.tape { margin-top: 1.2rem; font-size: 0.85rem; }
.tape .row { display: grid; grid-template-columns: 7.5rem 1fr 2.6rem; align-items: center; gap: 0.6rem; min-height: 1.6rem; }
.tape .tag { display: none; font-style: normal; font-weight: 600; color: var(--mute); }
.tape.tagged .row { grid-template-columns: 0.8rem minmax(0, 11rem) 1fr 2.6rem; }
.tape.tagged .tag { display: block; }
.tape .moves { display: flex; flex-wrap: nowrap; gap: 2px; overflow: hidden; height: 10px; justify-content: flex-end; }
.tape .moves .sq { flex: none; }
.tape .score { text-align: right; }
.tape .who { all: unset; cursor: help; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: underline dotted var(--rule); text-underline-offset: 3px; }
.tape .who:focus-visible { outline: 2px solid var(--coop); outline-offset: 2px; }
.tape .who.mute { color: var(--mute); }
.tape .who.ai { color: var(--ai); }

/* Steps are a real sequence, so they're numbered. */
.steps { list-style: none; padding: 0; margin: 1.6rem 0 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: calc(var(--cell) * 1.5); counter-reset: step; }
.steps li { counter-increment: step; border-top: 1.5px solid var(--ink); padding-top: 0.8rem; }
.steps li::before { content: counter(step); display: block; font-size: 2rem; line-height: 1; margin-bottom: 0.6rem; }
.steps li p { font-size: 0.95rem; }

.cols { display: grid; grid-template-columns: 14rem minmax(0, 1fr); gap: calc(var(--cell) * 2); }
.rules { margin: 0; padding-left: 1.1rem; max-width: var(--measure); }
.rules li { margin-bottom: 0.5rem; }
.rules li::marker { color: var(--mute); }

/* Forms */
form { max-width: var(--measure); }
.field { margin-bottom: 1.6rem; }
label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.hint { display: block; color: var(--mute); font-size: 0.85rem; margin-top: 0.3rem; }
input[type="text"], input[type="email"], textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fbfbf9;
  border: 1.5px solid var(--ink); padding: 0.55rem 0.7rem; border-radius: 0;
}
textarea { min-height: 12rem; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus { outline: none; border-color: var(--coop); box-shadow: 0 0 0 1px var(--coop); }
.check { display: flex; gap: 0.7rem; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 0.4rem; width: 1rem; height: 1rem; accent-color: var(--ink); flex: none; }
.count { float: right; font-weight: 400; color: var(--mute); font-size: 0.85rem; }
.count.over { color: var(--defect); }
.err { color: var(--defect); min-height: 1.6em; }

/* Ticket */
.ticket { font-size: clamp(4rem, 14vw, 8rem); line-height: 1; letter-spacing: -0.04em; margin: 0.6rem 0 1.4rem; }
.ticket::before { content: "#"; color: var(--mute); font-size: 0.5em; vertical-align: 0.6em; margin-right: 0.08em; }
.linkbox { font-size: 0.85rem; word-break: break-all; border: 1.5px solid var(--ink); padding: 0.6rem 0.8rem; background: #fbfbf9; max-width: var(--measure); }

/* Status track: three states in order */
.track { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 2rem 0; max-width: 40rem; }
.track div { border-top: 3px solid var(--rule); padding-top: 0.6rem; color: var(--mute); font-size: 0.95rem; }
.track div.done { border-color: var(--ink); color: var(--ink); }
.track div.now { border-color: var(--coop); color: var(--ink); font-weight: 600; }
.track div.bad { border-color: var(--defect); color: var(--ink); font-weight: 600; }
blockquote { margin: 0 0 1.4rem; padding-left: 1rem; border-left: 1.5px solid var(--rule); max-width: var(--measure); white-space: pre-wrap; }

/* Leaderboard */
.board { width: 100%; border-collapse: collapse; }
.board th { text-align: left; font-weight: 400; color: var(--mute); font-size: 0.85rem; padding: 0 0.6rem 0.5rem; border-bottom: 1.5px solid var(--ink); }
.board td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--rule); vertical-align: middle; background: var(--paper); }
.board .num { text-align: right; white-space: nowrap; }
.board .rank { width: 3rem; color: var(--mute); }
.board tr.house td:not(.rank) { color: var(--mute); }
.board tr.ai td:not(.rank), .board tr.ai .name small { color: var(--ai); }
.board .bar { width: 30%; }
.board .bar span { display: block; height: 10px; background: var(--ink); border-radius: 0 4px 4px 0; }
.board .name b { font-weight: 600; }
.board .name small { color: var(--mute); }
.board button.open { all: unset; cursor: pointer; }
.board button.open:focus-visible { outline: 2px solid var(--coop); outline-offset: 3px; }
.board tr.detail td { padding: 0.4rem 0.6rem 1.4rem; }

.heat { border-collapse: collapse; font-size: 0.7rem; }
.heat td, .heat th { width: 22px; height: 22px; padding: 0; text-align: center; }
.heat th { font-weight: 400; color: var(--mute); }
.heat th[scope="row"] { text-align: right; padding-right: 0.5rem; white-space: nowrap; width: auto; font-size: 0.8rem; }
.heat td { border: 1px solid var(--paper); cursor: crosshair; }
.heat tr:hover th[scope="row"] { color: var(--ink); }
.heatwrap { overflow-x: auto; padding-bottom: 1rem; }
.legend { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: var(--mute); margin: 0.8rem 0 1.2rem; }
.legend i { display: inline-block; width: 140px; height: 10px; background: linear-gradient(90deg in oklab, var(--paper), var(--ink)); border: 1px solid var(--rule); }

.foot { border-top: 1px solid var(--rule); padding: calc(var(--cell) * 1.5) 0 calc(var(--cell) * 2); font-size: 0.85rem; color: var(--mute); }
.foot p { max-width: none; }

@media (max-width: 52rem) {
  :root { font-size: 17px; }
  .hero, .cols { grid-template-columns: minmax(0, 1fr); gap: calc(var(--cell) * 2); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top nav { gap: 1rem; }
  .board .bar { display: none; }
}
@media (max-width: 30rem) {
  .steps { grid-template-columns: minmax(0, 1fr); }
  .top { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
blockquote + h3, .lede + div h3, #note-wrap h3, #reason-wrap h3 { margin: 1.6rem 0 0.5rem; }
h3 + blockquote { margin-top: 0.5rem; }
.tip {
  position: fixed; left: 0; top: 0; z-index: 10; pointer-events: none; max-width: 22rem; white-space: pre-line;
  background: var(--ink); color: var(--paper); font-size: 0.8rem; line-height: 1.4; padding: 0.4rem 0.6rem;
}
main > [hidden] + section { border-top: 0; }
.board tr.detail .board td { padding: 0.3rem 0.6rem; }

/* Code: guide page, submit page. Monospace only where it's literally code. */
/* Plex Mono is drawn a touch large next to Spectral, so code sits at 0.82em. */
code, pre, textarea.code { font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 0.82em; font-variant-ligatures: none; }
code { white-space: nowrap; }
pre.code { background: #fbfbf9; border: 1px solid var(--rule); padding: 1rem 1.2rem; margin: 0 0 1.6rem; overflow-x: auto; line-height: 1.6; max-width: 40rem; tab-size: 4; }
pre.code code, pre.code { white-space: pre; }
textarea.code { min-height: 16rem; white-space: pre; tab-size: 4; line-height: 1.6; }

/* The state specimen: one real moment of a match, field by field. */
.specimen { border-collapse: collapse; width: 100%; max-width: 40rem; margin: 0 0 1.4rem; }
.specimen th, .specimen td { text-align: left; vertical-align: top; padding: 0.55rem 0.8rem 0.55rem 0; border-bottom: 1px solid var(--rule); }
.specimen th { font-weight: 400; white-space: nowrap; }
.specimen td.val { white-space: nowrap; }
.specimen .sq { width: 12px; height: 12px; margin-right: 2px; vertical-align: -1px; }
.specimen td:last-child { color: var(--mute); font-size: 0.9rem; }

/* Words / Python switch on the submit page */
.mode { display: inline-flex; border: 1.5px solid var(--ink); margin: 0 0 1.6rem; }
.mode label { margin: 0; font-weight: 400; cursor: pointer; }
.mode input { position: absolute; opacity: 0; pointer-events: none; }
.mode span { display: block; padding: 0.3rem 0.9rem; font-size: 0.9rem; }
.mode input:checked + span { background: var(--ink); color: var(--paper); font-weight: 600; }
.mode input:focus-visible + span { outline: 2px solid var(--coop); outline-offset: 2px; }
.test-row { display: flex; gap: 1rem; align-items: baseline; margin-top: 0.8rem; }
.test-row .btn { flex: none; font-size: 0.9rem; padding: 0.35rem 0.9rem; }
.test-out { font-size: 0.85rem; margin: 0; color: var(--mute); }
.test-out.bad { color: var(--defect); }
textarea.short { min-height: 5rem; }
