/* hyxor.com site stylesheet: the shared classes for the patterns in
 * docs/design/DESIGN.md. Values come from tokens.css (loaded first; a copy
 * of docs/design/tokens.css). No colours or sizes outside the tokens except
 * layout arithmetic. Templates (hillsrv/views.ml) use these classes and no
 * inline styles. */

/* ---- fonts (files are self-hosted; the @font-face rules with their hashed
   URLs are emitted by views.ml) ---- */

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

body { line-height: 1.5; }

/* The text-width rule (DESIGN.md "Type"): running text never runs wider
   than --text-max. Tables, code blocks, figures and the game screen keep
   the full column and scroll inside their own box. */
p, li, dd, dt, blockquote, label, summary,
.meta, .copy-slot, .field-note, .form-error, .caption, .sub-title {
  max-width: var(--text-max);
}
.copy-slot { display: inline-block; }
ol, ul { margin: 0; padding: 0; }

/* ---- page skeleton ---- */
.page {
  max-width: calc(var(--page-max) + 2 * var(--space-6));
  margin: 0 auto;
  padding: 44px var(--space-6) 56px;
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
  min-height: 100vh;
}
.page > main {
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
  flex: 1 0 auto;
}
.page--manual > main { gap: var(--space-12); }

h1, h2, h3 { margin: 0; font-weight: 500; }
p { margin: 0; }

/* ---- header and navigation ---- */
.site-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  column-gap: var(--space-8);
  padding-bottom: var(--space-2);
  border-bottom: var(--rule) solid var(--rule-color);
}
.wordmark {
  font-size: var(--text-logo);
  letter-spacing: var(--track-logo);
  text-decoration: none;
  grid-column: 1;
}
.nav, .user-links, .subnav {
  display: flex;
  flex-wrap: wrap;
  column-gap: 22px;
}
.nav { grid-column: 2; }
.subnav { grid-column: 2; grid-row: 2; font-size: var(--text-sm); }
.user-links { grid-column: 3; column-gap: var(--space-5); color: var(--dim); }
.nav a, .subnav a, .user-links a, .inline-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
}
.nav a.active, .subnav a.active {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: var(--accent-bar);
  text-underline-offset: 6px;
}

@media (max-width: 720px) {
  .site-header { grid-template-columns: 1fr; }
  .wordmark, .nav, .subnav, .user-links { grid-column: 1; grid-row: auto; }
}

/* ---- header band ---- */
.band {
  display: flex;
  flex-wrap: wrap;
  gap: 28px 56px;
  align-items: flex-end;
}
.band-title {
  flex: 2 1 320px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.band-title h1 {
  font-size: var(--text-h1);
  letter-spacing: var(--track-heading);
  overflow-wrap: anywhere;
}
.band-title .prefix { color: var(--dim); }
.meta { color: var(--dim); }
.band-summary {
  flex: 1 1 240px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.band-summary--wide { flex: 3 1 420px; }
.summary-label { color: var(--dim); font-size: var(--text-sm); }
.stats { display: flex; flex-wrap: wrap; gap: var(--space-2) 28px; align-items: flex-end; }
.stat { display: flex; flex-direction: column; gap: var(--space-1); }
.stat-value { font-size: var(--text-stat); }
.switch { display: flex; gap: var(--space-2); align-items: center; font-size: var(--text-sm); color: var(--faint); }
.switch a { display: inline-flex; align-items: center; min-height: var(--tap); }
.switch .active {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: var(--accent-bar);
  text-underline-offset: 6px;
}
.placements { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); }
.placement { display: inline-flex; align-items: center; gap: var(--space-2); }
.rank { color: var(--dim); }
.inline-links { display: flex; flex-wrap: wrap; column-gap: var(--space-5); color: var(--dim); }
.on-this-page { font-size: 14px; column-gap: var(--space-5); }

.won { color: var(--won); }
.lost, .dim { color: var(--dim); }

/* ---- section label on a rule (the signature pattern) ---- */
.sec {
  position: relative;
  border-top: var(--rule) solid var(--rule-color);
  padding-top: 22px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  scroll-margin-top: var(--space-6);
}
.sec-label {
  position: absolute;
  top: -11px;
  left: 0;
  margin: 0;
  padding-right: 10px;
  background: var(--bg);
  color: var(--dim);
  font-size: var(--text-sm);
  font-weight: 400;
  letter-spacing: var(--track-mono);
  line-height: 20px;
}
.page--manual .sec { padding-top: 28px; gap: 18px; }
.intro { display: flex; flex-direction: column; gap: 18px; }
.sub { display: flex; flex-direction: column; gap: var(--space-3); padding-top: var(--space-3); }
.sub-title { font-size: var(--text-h2); letter-spacing: var(--track-heading); font-weight: 600; }
.sub-title .dim { font-weight: 400; letter-spacing: var(--track-mono); }

/* ---- prose (field manual) ---- */
.prose {
  font-family: var(--font-prose);
  font-size: var(--text-prose);
  line-height: 1.6;
  letter-spacing: 0;
  color: var(--fg-prose);
  max-width: var(--measure);
}
.step { display: flex; flex-direction: column; gap: 10px; }
/* code inside running text (with_code): mono, a touch smaller than the
   serif around it, on the code-block surface */
.prose code, .field-note code, .caption code, .meta code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  letter-spacing: var(--track-mono);
  background: var(--surface);
  padding: 0 0.25em;
  overflow-wrap: anywhere;
}

/* ---- data tables ---- */
.table-wrap { overflow-x: auto; max-width: 100%; }
.table-wrap--figure { max-width: var(--figure-max); }
table.data { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 14px; }
table.data--fit { width: auto; min-width: 520px; }
table.data th {
  text-align: left;
  color: var(--dim);
  font-size: var(--text-xs);
  font-weight: 400;
  padding: var(--space-2) var(--space-3);
}
table.data td { padding: var(--space-3); border-top: var(--rule) solid var(--rule-soft); vertical-align: baseline; }
table.data tbody tr:last-child td { border-bottom: var(--rule) solid var(--rule-soft); }
table.data th:first-child, table.data td:first-child { padding-left: 0; }
table.data th:last-child, table.data td:last-child { padding-right: 0; }
table.data .nowrap { white-space: nowrap; }
table.data .end { text-align: right; white-space: nowrap; }
table.data .desc { color: var(--fg-prose); }
table.data .key { padding-right: var(--space-6); white-space: nowrap; }

/* ---- code blocks ---- */
pre.code {
  margin: 0;
  max-width: var(--figure-max);
  background: var(--surface);
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  letter-spacing: var(--track-mono);
  color: var(--fg);
  overflow-x: auto;
  white-space: pre;
}
pre.code code { font: inherit; }
pre.code--tall { max-height: 420px; overflow-y: auto; }

/* ---- game figure: the board on its dark screen ---- */
.game-figure { margin: 0; display: flex; flex-direction: column; gap: 14px; }
.screen {
  background: var(--screen);
  padding: 28px;
  display: flex;
  justify-content: center;
}
/* Match videos and their posters are 1600x1200 (the recorder's frame for
   both games): a box of that shape, so nothing is letterboxed. Set here,
   not taken from the file, because feed videos load nothing up front. */
.screen video, .screen img {
  display: block;
  width: 100%;
  max-width: var(--board-max);
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: var(--screen);
}
.screen-empty {
  width: 100%;
  max-width: var(--board-max);
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-6);
}
.screen a { display: block; width: 100%; max-width: var(--board-max); }
.game-controls { display: flex; align-items: center; gap: 14px; }
.play {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  background: transparent;
  border: var(--rule) solid var(--control);
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.play svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.play .icon-pause { display: none; }
.play.playing .icon-play { display: none; }
.play.playing .icon-pause { display: block; }
.scrub { flex: 1; min-width: 0; height: var(--tap); accent-color: var(--accent); margin: 0; }
.position { color: var(--dim); font-size: var(--text-sm); white-space: nowrap; }
/* Without JavaScript the native controls stay and ours are hidden. */
.game-controls[hidden] { display: none; }

@media (max-width: 600px) {
  .screen { padding: var(--space-3); }
}

/* ---- explanatory diagrams (field manual): follow the theme ---- */
.diagram { margin: 0; display: flex; flex-direction: column; gap: 10px; max-width: var(--figure-max); }
.diagram-panel { background: var(--panel); padding: var(--space-6); overflow-x: auto; }
.diagram svg { width: 100%; min-width: 560px; display: block; font-family: var(--font-mono); }
.diagram figcaption, .caption { color: var(--dim); font-size: var(--text-sm); }
.dg-label { fill: var(--dim); font-size: 13px; }
.dg-small { fill: var(--dim); font-size: 11px; }
.dg-span { fill: var(--dim); font-size: 12px; }
.dg-text { fill: var(--fg); font-size: 13px; }
.dg-leader { stroke: var(--control); fill: none; }
.dg-divider { stroke: var(--rule-color); }
.dg-path { stroke: var(--control); stroke-dasharray: 2 6; }
.dg-goal { stroke: var(--control); stroke-width: 2; fill: none; stroke-dasharray: 4 4; }
.dg-owner { stroke: var(--player-3); stroke-width: 2; fill: none; }
.dg-owner-fill { fill: var(--player-3); }

/* ---- anatomy diagrams: a command, each token underlined in its colour ---- */
.anatomy-wrap { overflow-x: auto; max-width: var(--figure-max); }
.anatomy {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: auto auto;
  justify-content: start;
  column-gap: 22px;
  min-width: 520px;
  font-size: 22px;
}
.anatomy .field {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: var(--accent-bar) solid;
  font-size: var(--text-xs);
  color: var(--dim);
}
.tok-1 { color: var(--accent); }
.field.tok-1 { border-color: var(--accent); }
.tok-2 { color: var(--player-3-text, var(--player-3)); }
.field.tok-2 { border-color: var(--player-3); }
.tok-3 { color: var(--player-1-text, var(--player-1)); }
.field.tok-3 { border-color: var(--player-1); }
.tok-4 { color: var(--player-4-text, var(--player-4)); }
.field.tok-4 { border-color: var(--player-4); }
.tok-5 { color: var(--player-5-text, var(--player-5)); }
.field.tok-5 { border-color: var(--player-5); }
.anatomy .field { color: var(--dim); }

/* ---- owner-only section ---- */
.owner { border-top: var(--rule) solid var(--rule-color); padding-top: var(--space-1); }
.owner > summary {
  color: var(--dim);
  font-size: var(--text-sm);
  min-height: var(--tap);
  display: flex;
  align-items: center;
  cursor: pointer;
}
.owner-body { display: flex; flex-direction: column; gap: var(--space-4); padding-top: var(--space-2); }

/* ---- forms ---- */
.form { display: flex; flex-direction: column; gap: var(--space-5); max-width: 420px; }
.field-group { display: flex; flex-direction: column; gap: var(--space-2); }
.field-group label { color: var(--dim); font-size: var(--text-sm); }
.field-note { color: var(--dim); font-size: var(--text-sm); }
.form input, .form select {
  height: var(--tap);
  padding: 0 var(--space-3);
  border: var(--rule) solid var(--control);
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  letter-spacing: var(--track-mono);
  width: 100%;
}
.form input:focus-visible, .form select:focus-visible, .play:focus-visible, .button:focus-visible {
  outline: var(--accent-bar) solid var(--accent);
  outline-offset: 2px;
}
.button {
  appearance: none;
  align-self: flex-start;
  min-height: var(--tap);
  padding: 0 var(--space-5);
  border: var(--rule) solid var(--control);
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  letter-spacing: var(--track-mono);
  cursor: pointer;
}
.button:hover { border-color: var(--fg); }
.form-error { color: var(--fg); border-left: var(--accent-bar) solid var(--accent); padding-left: var(--space-3); }

/* ---- copy slots: visible placeholders for text the maintainer writes ---- */
.copy-slot { color: var(--faint); }

/* ---- footer ---- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
  border-top: var(--rule) solid var(--rule-color);
  padding-top: 14px;
  color: var(--dim);
  font-size: var(--text-xs);
}
.site-footer .tag { color: var(--accent); margin-right: 10px; }

.inline { display: inline; }
.form-submit-link {
  background: none;
  border: none;
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--control);
  font: inherit;
  cursor: pointer;
  min-height: var(--tap);
}
.screen .copy-slot, .screen-empty { color: var(--screen-text); }

/* ---- the video feed (Matches page): full-size boards ---- */
.video-feed { list-style: none; display: flex; flex-direction: column; gap: var(--space-10); }
/* a video row is a figure, not running text: the full column, like the match page */
.video-row { max-width: none; }
.video-row .screen-empty { display: block; width: 100%; max-width: var(--board-max); }
.video-caption { display: flex; flex-direction: column; gap: var(--space-1); }
.video-caption p { max-width: var(--text-max); overflow-wrap: anywhere; }

/* ---- feeds: thumbnail rows ---- */
.feed { list-style: none; display: flex; flex-direction: column; }
.feed-row {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-3) 0;
  border-top: var(--rule) solid var(--rule-soft);
  max-width: none;
}
.feed-row:last-child { border-bottom: var(--rule) solid var(--rule-soft); }
.thumb, .thumb-space { flex: none; width: 120px; aspect-ratio: 6 / 5; display: block; }
.thumb { background: var(--screen); }
.thumb-img, .thumb-empty { display: block; width: 100%; height: 100%; object-fit: cover; background: var(--screen); }
.feed-text { min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.feed-text p { overflow-wrap: anywhere; }
.feed-time { color: var(--dim); font-size: var(--text-sm); }
@media (max-width: 600px) {
  .thumb, .thumb-space { width: 88px; }
}
.pager { display: flex; gap: var(--space-5); align-items: center; }
.pager a { display: inline-flex; align-items: center; justify-content: center; min-width: var(--tap); min-height: var(--tap); text-decoration: none; border: var(--rule) solid var(--control); }

/* ---- the still in a game figure links to its match ---- */
.screen-empty a, .screen > a { color: inherit; }

/* ---- toggle (My bots' Active?) ---- */
.toggle-form { margin: 0; }
.toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-2) 0 0;
  border: none;
  background: transparent;
  color: var(--dim);
  font: inherit;
  letter-spacing: var(--track-mono);
  cursor: pointer;
}
.toggle.on { color: var(--fg); }
.toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  border: var(--rule) solid var(--control);
  flex: none;
}
.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  background: var(--control);
}
.toggle.on .toggle-knob { left: 19px; background: var(--won); }
.toggle:focus-visible { outline: var(--accent-bar) solid var(--accent); outline-offset: 2px; }

/* ---- create bot: the image path preview ---- */
.image-path { color: var(--fg); font-family: var(--font-mono); font-size: var(--text-sm); overflow-wrap: anywhere; }

/* ---- numbered steps (field manual) ---- */
.steps { list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: var(--space-5); }
.steps > li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2.5em minmax(0, 1fr);
  row-gap: 10px;
  max-width: none;
}
.steps > li::before {
  content: counter(step) ".";
  grid-row: 1;
  color: var(--dim);
  font-size: var(--text-prose);
  line-height: 1.6;
}
.steps > li > * { grid-column: 2; }
.steps > li > .prose { grid-row: 1; }

/* ---- data marks: score bar, sparkline ---- */
.bar { display: inline-block; width: 100px; height: 6px; flex: none; }
.bar-track { fill: var(--rule-soft); }
.bar-fill { fill: var(--fg); }
.spark { display: inline-block; width: 110px; height: 26px; flex: none; vertical-align: middle; }
.spark-line { fill: none; stroke: var(--dim); stroke-width: 1.5; }
.spark-dot { fill: var(--dim); }
.spark-last { fill: var(--fg); }

/* ---- the ranked board (/llm): a table, one block per row on a phone ---- */
table.board { min-width: 1040px; }
table.board td { vertical-align: middle; white-space: nowrap; }
.board-model { color: var(--fg); }
.mark-cell { display: flex; align-items: center; gap: 10px; }
.trend-text { font-size: var(--text-xs); }
.board-best a { display: inline-flex; align-items: center; min-height: var(--tap); }

/* ---- a bot's versions: finish squares and the versions table ---- */
.squares { display: flex; flex-wrap: wrap; gap: 6px; }
.sq {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  border: var(--rule) solid var(--control);
  text-decoration: none;
}
.sq:hover { border-color: var(--fg); }
.sq--won { color: var(--won); border-color: var(--won); font-weight: 600; }
.sq--last { color: var(--dim); border-color: var(--rule-color); }
.sq:focus-visible { outline: var(--accent-bar) solid var(--accent); outline-offset: 2px; }
table.versions { min-width: 900px; }
table.versions td { vertical-align: middle; white-space: nowrap; }
.ver-tag { color: var(--dim); font-size: var(--text-xs); }

@media (max-width: 600px) {
  table.board, table.versions { min-width: 0; }
  .board thead, .versions thead { display: none; }
  .board, .board tbody, .versions, .versions tbody { display: block; }
  .board tr, .versions tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: var(--space-4);
    row-gap: var(--space-2);
    padding: 18px 0;
    border-top: var(--rule) solid var(--rule-soft);
  }
  .board tr:last-child, .versions tr:last-child { border-bottom: var(--rule) solid var(--rule-soft); }
  table.data.board tbody tr:last-child td, table.data.versions tbody tr:last-child td { border: none; }
  table.board td, table.versions td {
    display: block;
    flex: 1 0 100%;
    padding: 0;
    border: none;
    text-align: left;
    white-space: normal;
  }
  .board [data-label]::before, .versions [data-label]::before { content: attr(data-label) " "; color: var(--dim); }
  /* the board: rank beside the model, then one line each */
  .board tr { position: relative; padding-left: 32px; }
  table.board td.board-rank { position: absolute; left: 0; top: 18px; }
  .board-name { font-size: var(--text-h2); overflow-wrap: anywhere; }
  .board-name .dim { display: block; font-size: var(--text-xs); }
  .board-detail { color: var(--dim); font-size: var(--text-sm); }
  .board-score .score-num { font-size: 20px; }
  .board-score .bar { flex: 1 1 auto; width: auto; }
  table.board td.board-stat, table.versions td.ver-stat { flex: 0 0 auto; font-size: var(--text-sm); }
  .board-trend .trend-text { font-size: var(--text-sm); }
  /* a version: name and when on one line, the squares, then the numbers */
  table.versions td.ver-name { flex: 1 1 auto; }
  table.versions td.ver-seen { flex: 0 0 auto; font-size: var(--text-sm); }
}

/* ---- versions that never played, folded into one dim row ---- */
.ver-folded summary { display: flex; align-items: center; min-height: var(--tap); cursor: pointer; font-size: var(--text-sm); }
.ver-folded-list { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-5); padding-bottom: var(--space-2); font-size: var(--text-sm); }
table.versions tr.ver-folded td { white-space: normal; padding-top: var(--space-1); padding-bottom: var(--space-1); }

/* ---- match history: a table, one block per match on a phone ---- */
@media (max-width: 600px) {
  table.history { min-width: 0; }
  .history thead { display: none; }
  .history, .history tbody { display: block; }
  .history tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: var(--space-4);
    padding: var(--space-3) 0;
    border-top: var(--rule) solid var(--rule-soft);
  }
  .history tr:last-child { border-bottom: var(--rule) solid var(--rule-soft); }
  table.data.history tbody tr:last-child td { border: none; }
  table.history td { display: block; padding: 0; border: none; text-align: left; }
  table.history td.hist-vs { order: 1; flex: 1 0 100%; overflow-wrap: anywhere; font-size: var(--text-sm); }
  table.history td.hist-links { order: 2; flex: 1 0 100%; }
  .history a { display: inline-flex; align-items: center; min-height: var(--tap); }
}
.ver-folded summary { list-style: none; }
.ver-folded summary::-webkit-details-marker { display: none; }
.ver-folded summary::before { content: "+"; display: inline-block; width: 1.5em; }
.ver-folded details[open] > summary::before { content: "\2212"; }

/* ---- field manual: lists, notes, a colour key ---- */
.prose-list {
  font-family: var(--font-prose);
  font-size: var(--text-prose);
  line-height: 1.6;
  letter-spacing: 0;
  color: var(--fg-prose);
  max-width: var(--measure);
  padding-left: 1.4em;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
ul.prose-list { list-style: square; }
.prose-list li::marker { color: var(--dim); }
.prose-list code, .data code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  letter-spacing: var(--track-mono);
  background: var(--surface);
  padding: 0 0.25em;
}
.prose-list code { overflow-wrap: anywhere; }
.data code { font-size: inherit; background: none; padding: 0; }
.note {
  max-width: var(--measure);
  border-left: var(--rule) solid var(--control);
  padding-left: var(--space-4);
}
.color-key { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); font-size: var(--text-sm); }
.color-key-item { display: inline-flex; align-items: center; gap: var(--space-2); }
.swatch { display: inline-block; width: 11px; height: 11px; flex: none; }

/* ---- game figures with a caption; a recorded unit on a canvas ---- */
.game-figure > .caption { max-width: var(--text-max); }
.replay .screen canvas {
  display: block;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1;
  image-rendering: pixelated;
}
.replay .game-controls { max-width: 560px; }

/* ---- every section of a long manual page, folded ---- */
.section-index { margin-top: calc(-1 * var(--space-6)); }
.section-index > summary {
  color: var(--dim);
  font-size: var(--text-sm);
  min-height: var(--tap);
  display: flex;
  align-items: center;
  cursor: pointer;
}

/* ---- small diagrams (a few tiles): their own size, not the full width ---- */
.diagram--small svg { min-width: 0; max-width: 560px; }
.dg-tile { fill: var(--surface); stroke: var(--rule-color); }
.dg-tile-own { fill: var(--player-3); stroke: var(--rule-color); }
.dg-unit { fill: var(--fg); }

/* ---- the Dye playground: editor beside the board (the one two-column
   page, DESIGN.md "One column"), stacked under 960px ---- */
.playground {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-10) var(--space-8);
  align-items: start;
}
.pg-col { display: flex; flex-direction: column; gap: var(--space-10); min-width: 0; }
.pg-row { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: flex-end; }
.pg-control { display: flex; flex-direction: column; gap: var(--space-1); }
.pg-control label, .pg-group-label { color: var(--dim); font-size: var(--text-sm); max-width: none; }
.playground select, .playground input[type="number"] {
  height: var(--tap);
  padding: 0 var(--space-2);
  border: var(--rule) solid var(--control);
  border-radius: 0;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  letter-spacing: var(--track-mono);
}
.playground input[type="number"] { width: 6em; }
.playground .button { align-self: auto; }
.button--primary { border-color: var(--fg); }
.button[aria-pressed="true"] {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: var(--accent-bar);
  text-underline-offset: 6px;
}
.playground select:focus-visible, .playground input:focus-visible, .playground textarea:focus-visible {
  outline: var(--accent-bar) solid var(--accent);
  outline-offset: 2px;
}
.pg-opponents { align-items: center; }
.pg-group-label { width: 100%; }
.pg-check { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap); padding-right: var(--space-3); max-width: none; }
.pg-check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

/* the editor: a textarea over a highlighted backdrop, sharing scroll */
.pg-editor {
  position: relative;
  height: 430px;
  background: var(--surface);
  overflow: hidden;
}
.pg-gutter, .pg-backdrop, .pg-editor textarea {
  position: absolute;
  top: 0;
  bottom: 0;
  margin: 0;
  padding: var(--space-2) 10px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: var(--track-mono);
  white-space: pre;
  overflow: hidden;
}
.pg-gutter { left: 0; width: 48px; text-align: right; color: var(--faint); user-select: none; border-right: var(--rule) solid var(--rule-color); }
.pg-backdrop { left: 48px; right: 0; color: transparent; }
.pg-editor textarea {
  left: 48px;
  right: 0;
  width: calc(100% - 48px);
  border: 0;
  resize: none;
  background: transparent;
  color: var(--fg);
  caret-color: var(--fg);
  overflow: auto;
}
.pg-backdrop span { display: inline-block; min-width: 100%; }
.pg-backdrop .hl-err { background: color-mix(in srgb, var(--player-4) 22%, transparent); box-shadow: inset 3px 0 var(--player-4); }
.pg-backdrop .hl-pc { background: color-mix(in srgb, var(--accent) 18%, transparent); box-shadow: inset 3px 0 var(--accent); }
.pg-status { font-size: var(--text-sm); min-height: 1.5em; color: var(--dim); }
.pg-status--err { color: var(--fg); border-left: var(--accent-bar) solid var(--player-4); padding-left: var(--space-2); }

.pg-screen { padding: var(--space-3); }
.pg-board { display: block; width: 100%; max-width: 640px; aspect-ratio: 1; image-rendering: pixelated; cursor: crosshair; }
.pg-clock { font-size: var(--text-sm); }
.pg-inspector { display: flex; flex-direction: column; gap: var(--space-2); font-size: 14px; overflow-wrap: anywhere; }
.pg-regs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-1); }
.pg-ram { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 3px; font-size: var(--text-xs); }
.pg-regs div, .pg-ram div { background: var(--surface); padding: 2px 6px; }
.pg-table-wrap { overflow-x: auto; }
.pg-players { border-collapse: collapse; width: 100%; font-size: 14px; }
.pg-players th { text-align: left; color: var(--dim); font-size: var(--text-xs); font-weight: 400; padding: var(--space-1) var(--space-2) var(--space-1) 0; }
.pg-players td { padding: var(--space-2) var(--space-2) var(--space-2) 0; border-top: var(--rule) solid var(--rule-soft); white-space: nowrap; }
.pg-players .swatch { margin-right: var(--space-2); vertical-align: -1px; }
.pg-log { margin: 0; max-height: 140px; overflow: auto; white-space: pre-wrap; font-family: var(--font-mono); font-size: var(--text-sm); color: var(--dim); }

@media (max-width: 960px) {
  .playground { grid-template-columns: minmax(0, 1fr); }
  .pg-editor { height: 320px; }
}
.section-index > summary { list-style: none; }
.section-index > summary::-webkit-details-marker { display: none; }
.section-index > summary::before { content: "+"; display: inline-block; width: 1.5em; }
.section-index[open] > summary::before { content: "\2212"; }
