/*
 * Page furniture for the duality game pages — Chalk & Turf.
 *
 * board.css owns the board: surfaces, cube faces, sprites, goal furniture, and
 * the floodlit dark mode. This file owns everything around it, and nothing in
 * here touches a .dg-cell, .dg-face, .dg-ball or .dg-goal.
 *
 * Load it AFTER board.css so the palette below wins:
 *
 *   <link rel="stylesheet" href="../games/ui/fonts.css?v=4.37.0" />
 *   <link rel="stylesheet" href="../games/ui/board.css?v=4.37.0" />
 *   <link rel="stylesheet" href="../games/ui/pages.css?v=4.37.0" />
 *
 * The three families they are set in come from fonts.css, which is served from
 * this repository — see that file.
 *
 * Like board.css this lives outside assets/css/, so purgecss never sees it.
 *
 * Two ways in. A standalone page puts the tokens on the body:
 *   <body class="dg">
 * The Jekyll landing page cannot own the body, so it scopes them to a wrapper:
 *   <div class="dg dg-scope"> … </div>
 * Everything below works the same either way.
 */

body.dg,
.dg-scope {
  --dg-paper: #f3efe6;
  --dg-desk: #e7e1d5;
  --dg-panel: #eae4d7;
  --dg-card: #faf8f3;
  /* A card that is deliberately not inviting: the locked door. */
  --dg-card-off: #f0ece1;
  --dg-ink: #191817;
  --dg-body: #282520;
  --dg-body-2: #3d3931;
  --dg-muted: #6f6a60;
  --dg-rule: #d8d2c6;
  --dg-rule-2: #cfc8ba;
  --dg-rule-3: #ddd6c7;
  --dg-gold: #c8963e;
  --dg-gold-ink: #a97d2c;
  --dg-green: #14452f;
  --dg-red: #a13a2a;
  --dg-lit: #f7efd0;
  --dg-link: #8a5a34;
  --dg-link-hover: #6b4526;

  --dg-serif: Spectral, Georgia, 'Times New Roman', serif;
  --dg-sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --dg-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  margin: 0;
  padding: 0 0 3rem;
  background: var(--dg-desk);
  color: var(--dg-ink);
  font-family: var(--dg-sans);
  line-height: 1.6;
}

/*
 * Floodlit, so a reader in dark mode does not get a lit board on chalk paper —
 * board.css switches the surface on the same signal. To opt a page out of both,
 * put data-dg-theme="light" on <html>.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-dg-theme='light']) body.dg,
  :root:not([data-dg-theme='light']) .dg-scope {
    --dg-paper: #12171e;
    --dg-desk: #0b0e12;
    --dg-panel: #161b22;
    --dg-card: #171d25;
    --dg-card-off: #12161c;
    --dg-ink: #e8e6e1;
    --dg-body: #dcd9d3;
    --dg-body-2: #c3c0b9;
    --dg-muted: #9aa1a9;
    --dg-rule: #2c343f;
    --dg-rule-2: #232a34;
    --dg-rule-3: #2c343f;
    --dg-gold: #f5c451;
    --dg-gold-ink: #f5c451;
    --dg-green: #7fc79a;
    --dg-red: #e0836f;
    --dg-lit: #ffe9a8;
    --dg-link: #e0b070;
    --dg-link-hover: #f0c690;
  }
}

/*
 * Both selectors need the prefix. As shipped the second was a bare `.dg-scope`,
 * which handed the floodlit palette to every scoped page in every colour
 * scheme — the landing page came up in night colours inside a white one. The
 * media query above has it right; this is the same list, qualified.
 */
:root[data-dg-theme='dark'] body.dg,
:root[data-dg-theme='dark'] .dg-scope {
  --dg-paper: #12171e;
  --dg-desk: #0b0e12;
  --dg-panel: #161b22;
  --dg-card: #171d25;
  --dg-card-off: #12161c;
  --dg-ink: #e8e6e1;
  --dg-body: #dcd9d3;
  --dg-body-2: #c3c0b9;
  --dg-muted: #9aa1a9;
  --dg-rule: #2c343f;
  --dg-rule-2: #232a34;
  --dg-rule-3: #2c343f;
  --dg-gold: #f5c451;
  --dg-gold-ink: #f5c451;
  --dg-green: #7fc79a;
  --dg-red: #e0836f;
  --dg-lit: #ffe9a8;
  --dg-link: #e0b070;
  --dg-link-hover: #f0c690;
}

/* The sheet the page is printed on. Replaces .dg-wrap's bare max-width. */
.dg-wrap {
  max-width: 1060px;
  margin: 0 auto;
  background: var(--dg-paper);
  border: 1px solid var(--dg-rule-2);
}

/*
 * Links, in two ways that both had to change.
 *
 * Scoped: as shipped this was a bare `a`, which is harmless on a standalone
 * page but not on the Jekyll one, where it would repaint the site's own navbar
 * and footer. `.dg` is on the body of the standalone pages and on the wrapper
 * of the scoped one, so one prefix covers both.
 *
 * Tokenised: the dark colour was reachable only through the media query, so a
 * reader on a light machine who turns the *site* dark kept brown links on a
 * night-coloured page. As a token it follows the palette that is actually in
 * force, by either route.
 */
.dg a {
  color: var(--dg-link);
}

.dg a:hover {
  color: var(--dg-link-hover);
}

/* ------------------------------------------------------------- chrome ---- */

/*
 * One strip, two jobs: the way home on the left, where you are on the right.
 * These pages carry their own identity, so this is all that is left of the
 * site's masthead — the h1 belongs to the page, not to a nav bar.
 */
.dg-chrome {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 2.75rem;
  background: var(--dg-panel);
  border-bottom: 1px solid var(--dg-rule);
}

.dg-chrome a,
.dg-label {
  font-family: var(--dg-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

/*
 * The label is muted; the way home is not. As shipped both took the muted grey,
 * which left the strip's one clickable thing looking like a caption. The design
 * file colours the back link like any other link, and it is the only thing in
 * the strip you can do anything with.
 */
.dg-label {
  color: var(--dg-muted);
}

.dg-chrome a {
  text-decoration: none;
}

.dg-chrome a:hover {
  text-decoration: underline;
}

.dg-label-gold { color: var(--dg-gold); }
.dg-label-red { color: var(--dg-red); }

/*
 * A label that is also a link is still a label — the landing page's "after
 * game 1" is one. Restated at anchor specificity, because a bare class loses
 * to `.dg a` above and the label would come out link-coloured.
 */
a.dg-label { color: var(--dg-muted); }
a.dg-label-gold { color: var(--dg-gold); }
a.dg-label-red { color: var(--dg-red); }

.dg-page {
  padding: 2rem 2.75rem 2.75rem;
}

/*
 * Let a grid track shrink below the board standing in it.
 *
 * A track's automatic minimum is its content's min-content width, and a board
 * is a slab of absolutely positioned cubes carrying an explicit pixel width. So
 * without this the track is sized to the board rather than the other way round:
 * the column comes out 441px wide inside a 302px page, and the whole thing
 * slides sideways on a phone instead of the board scaling down to fit, which is
 * what `fit()` in board.js is there to do.
 */
.dg-hero > *,
.dg-choices > *,
.dg-layout > *,
.dg-sandbox-intro > *,
.dg-replay-boards > * {
  min-width: 0;
}

/*
 * Phone gutters. 2.75rem down each side of a 390px screen is a quarter of the
 * screen given to margin, and the chrome strip's two nowrap labels do not fit
 * in what is left of it. Nothing above 560px changes.
 */
@media (max-width: 560px) {
  .dg-chrome,
  .dg-page,
  .dg-hero,
  .dg-choices {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .dg-build {
    margin-left: 1.25rem;
    margin-right: 1.25rem;
  }

  .dg-chrome {
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  /* The label drops under the title rather than squeezing the line beside it. */
  .dg-head {
    flex-wrap: wrap;
  }

  .dg-chrome .dg-label {
    white-space: normal;
  }
}

/* ---------------------------------------------------------- headings ---- */

.dg h1,
.dg h2 {
  font-family: var(--dg-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.dg h1 {
  font-size: 2.375rem;
  line-height: 1.1;
  margin: 0;
}

.dg-title-xl {
  font-size: 3.25rem;
  line-height: 1.04;
  max-width: 18ch;
}

.dg-lede {
  font-family: var(--dg-serif);
  font-size: 1.25rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--dg-body-2);
  margin: 1rem 0 0;
  max-width: 40ch;
}

/*
 * The default for a paragraph, which any component may overrule.
 *
 * `:where()` costs nothing in specificity, so this reads as (0,1,0) rather than
 * (0,1,1) and a plain class like `.dg-coach-hint` further down the file can win
 * on source order. As shipped it could not: every styled paragraph on these
 * pages came out body-coloured, which quietly cost the coach's hint its green
 * and its body its lighter grey.
 */
.dg :where(p) {
  max-width: 62ch;
  color: var(--dg-body);
}

.dg-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  padding-bottom: 0.9rem;
  border-bottom: 2px solid var(--dg-ink);
}

.dg-head-sub {
  font-size: 0.875rem;
  color: var(--dg-muted);
  margin-top: 0.25rem;
}

/* ------------------------------------------------------------- hero ---- */

/* Title left, the half-turf half-ice board right. No caption: it is the claim. */
.dg-hero {
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 2.25rem;
  align-items: center;
  padding: 2.75rem 2.75rem 1.75rem;
}

.dg-hero-board {
  background: radial-gradient(120% 90% at 50% 45%, rgba(20, 69, 47, 0.1) 0%, rgba(20, 69, 47, 0) 72%);
}

@media (max-width: 820px) {
  .dg-hero {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------- firewall and doors ---- */

/* The one rule the game cannot survive being broken. */
.dg-firewall {
  border-left: 3px solid var(--dg-red);
  padding: 2px 0 2px 1rem;
  margin: 1.5rem 0;
}

.dg-doors {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dg-door {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.1rem;
  background: var(--dg-card);
  border: 1px solid var(--dg-rule-3);
}

.dg-door[data-locked='true'] {
  background: var(--dg-card-off);
  border: 1px dashed var(--dg-rule-2);
}

.dg-door-n {
  font-family: var(--dg-serif);
  font-size: 1.875rem;
  line-height: 1;
  color: var(--dg-gold);
}

.dg-door[data-locked='true'] .dg-door-n {
  color: #a89b83;
}

.dg-door-title {
  font-family: var(--dg-serif);
  font-size: 1.1875rem;
  display: block;
}

.dg-door-note {
  font-size: 0.85rem;
  color: var(--dg-muted);
}

/*
 * The doors beside the "you will need" panel.
 *
 * Added rather than shipped: the design draws this grid inline and pages.css
 * arrived without a class for it. Not folded into `.dg-outro`, which is the
 * same 1fr/300px shape but carries a top rule and margins that belong to the
 * end of the reveal rather than the middle of a landing page.
 */
.dg-choices {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2.75rem;
  align-items: start;
  padding: 0.375rem 2.75rem 3.25rem;
}

@media (max-width: 820px) {
  .dg-choices {
    grid-template-columns: 1fr;
  }
}

/* An aside that is a list of requirements, not decoration. */
.dg-aside {
  background: var(--dg-panel);
  border: 1px solid var(--dg-rule-2);
  padding: 1.25rem 1.375rem;
}

.dg-aside ul {
  margin: 0.6rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.875rem;
  line-height: 1.8;
  color: var(--dg-body-2);
}

.dg-aside-foot {
  border-top: 1px solid var(--dg-rule-2);
  margin-top: 1.1rem;
  padding-top: 1rem;
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--dg-body-2);
}

.dg-aside-foot a {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

/*
 * The approach dot's colour, restated where the site cannot reach it.
 *
 * board.css puts `color: var(--dg-dot)` on `.dg-face` and lets the glyph
 * inherit it, which is right on a page that is only this stylesheet. Inside the
 * theme it is not: al-folio carries a `p, h1, …, div, li, span, strong` rule,
 * and an element selector matching the glyph directly beats a colour it would
 * otherwise have inherited, however specific the rule that set it. Every dot on
 * the hero board came out black — correct on the ice by accident, wrong on the
 * turf, and the same shade on both sides of a picture whose whole point is that
 * the two sides are different.
 *
 * Two classes, so `.dg-cell.is-visited .dg-glyph` still owns the ✕.
 */
.dg .dg-glyph {
  color: var(--dg-dot);
}

/*
 * One cube on the hero board, painted as the other sport.
 *
 * The values are the rink's, copied from board.css because a
 * `.dg-board[data-theme='hockey']` block cannot be reached from inside a board
 * whose theme is soccer. What is copied is the *surface* vocabulary — the two
 * mown shades, the two side faces, the colour of an approach dot — and not the
 * `--dg-face-*` a cube ends up painting with.
 *
 * That is the whole trick, and it is a cascade point rather than a taste one.
 * board.css has `.dg-cell` turn the surface colours into face colours at one
 * class of specificity, and then lets `.is-wall` and `.is-legal` overrule the
 * result at two. Set the face colours here and this rule outranks both: the
 * wall along the rink's goal row comes out ice-blue instead of black, and the
 * arms of the star that cross the seam lose their gold. Set the surface
 * colours instead and every state class still wins, exactly as it does on a
 * board that is only ever one sport.
 */
.dg-hero-board .dg-cell[data-surface='hockey'] {
  --dg-top-a: #e4f0f8;
  --dg-top-b: #dbebf5;
  --dg-side-l: #b3d3e4;
  --dg-side-r: #a4c8dc;
  /* Gold vanishes on ice; an approach is read off the black of a puck. */
  --dg-dot: #14181c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-dg-theme='light']) .dg-hero-board .dg-cell[data-surface='hockey'] {
    --dg-top-a: #d9edf8;
    --dg-top-b: #cee5f2;
    --dg-side-l: #5f8ba3;
    --dg-side-r: #527c95;
  }
}

:root[data-dg-theme='dark'] .dg-hero-board .dg-cell[data-surface='hockey'] {
  --dg-top-a: #d9edf8;
  --dg-top-b: #cee5f2;
  --dg-side-l: #5f8ba3;
  --dg-side-r: #527c95;
}

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

.dg-btn {
  font: inherit;
  font-size: 0.875rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--dg-green);
  border-radius: 0;
  background: transparent;
  color: var(--dg-green);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.dg-btn:hover:not(:disabled) {
  background: var(--dg-green);
  color: var(--dg-paper);
}

.dg-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.dg-btn-primary {
  display: inline-block;
  background: var(--dg-green);
  color: var(--dg-paper);
  text-decoration: none;
}

.dg-btn-primary:hover {
  background: var(--dg-green);
  color: var(--dg-paper);
  opacity: 0.9;
}

/*
 * A button that is a link. `.dg a` beats a bare `.dg-btn` on specificity, so
 * without these the landing page's two green buttons came out with link-brown
 * lettering on the green — legible in the light scheme by luck, and orange on
 * pale green in the dark one. Same colours, restated where they win.
 */
a.dg-btn { color: var(--dg-green); }

a.dg-btn-primary,
a.dg-btn-primary:hover {
  color: var(--dg-paper);
}

.dg-btn-quiet {
  border-color: var(--dg-rule-2);
  color: var(--dg-body-2);
}

.dg-btn-quiet:hover:not(:disabled) {
  background: var(--dg-rule-2);
  color: var(--dg-ink);
}

.dg-btn-wide {
  width: 100%;
  text-align: center;
}

.dg-link {
  font: inherit;
  font-size: 0.8125rem;
  background: none;
  border: 0;
  padding: 0;
  color: var(--dg-muted);
  text-decoration: underline;
  cursor: pointer;
}

.dg-link:hover {
  color: var(--dg-ink);
}

.dg-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  justify-content: center;
  margin-top: 1.125rem;
}

/* ------------------------------------------------------------ inputs ---- */

.dg-field {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.375rem;
}

.dg-field input,
.dg-dials input {
  font: inherit;
  font-size: 0.875rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--dg-rule-2);
  background: var(--dg-card);
  color: var(--dg-ink);
  border-radius: 0;
}

.dg-field input {
  flex: 1;
  min-width: 0;
}

/* --------------------------------------------------- coach and status ---- */

/*
 * The coach is a margin note, not a modal: a gold rule down its left edge, the
 * board beside it, and play never blocked. Sticky only while it sits beside the
 * board — stacked on a phone the positioned cubes would paint over it.
 */
.dg-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 2rem;
  align-items: start;
  margin-top: 1.625rem;
}

@media (max-width: 820px) {
  .dg-layout {
    grid-template-columns: 1fr;
  }
}

.dg-coach {
  border: 0;
  border-left: 2px solid var(--dg-gold);
  border-radius: 0;
  background: none;
  padding: 0 0 0 1rem;
  position: sticky;
  top: 1rem;
  z-index: 1;
}

@media (max-width: 820px) {
  .dg-coach {
    position: static;
  }
}

.dg-coach-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--dg-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dg-muted);
  margin-bottom: 0.5rem;
}

/* Five ticks, one per step: done, here, still to come. */
.dg-steps {
  display: flex;
  gap: 4px;
}

.dg-step-tick {
  width: 16px;
  height: 3px;
  background: var(--dg-rule-3);
}

.dg-step-tick[data-state='done'] {
  background: var(--dg-green);
}

.dg-step-tick[data-state='here'] {
  background: var(--dg-gold);
}

.dg .dg-coach-title {
  font-family: var(--dg-serif);
  font-size: 1.4375rem;
  font-weight: 500;
  line-height: 1.25;
  margin: 0 0 0.625rem;
}

.dg-coach-body {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--dg-body-2);
  margin: 0 0 0.75rem;
  white-space: pre-line;
}

.dg-coach-hint {
  font-family: var(--dg-serif);
  font-style: italic;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--dg-green);
  margin: 0 0 0.875rem;
}

.dg-coach[data-done='true'] {
  border-left-color: var(--dg-green);
}

/* Whose move it is, and how far in. Not a status box; a line of type. */
.dg-status {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 0 0.625rem;
  border: 0;
  border-bottom: 1px solid var(--dg-rule);
  border-radius: 0;
  background: none;
  font-family: var(--dg-serif);
  font-size: 1.25rem;
  font-weight: 500;
  min-height: 0;
}

.dg-status[data-tone='win'] {
  color: var(--dg-green);
}

.dg-status-move {
  font-family: var(--dg-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dg-muted);
  white-space: nowrap;
}

/* Which way you are playing, said at both ends of the board. */
.dg-goal-hint {
  font-family: var(--dg-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dg-muted);
  padding: 0 0.5rem;
}

.dg-goal-hint[data-end='yours'] {
  text-align: right;
  margin-top: 0.875rem;
}

.dg-pitch {
  background: radial-gradient(120% 90% at 50% 45%, rgba(20, 69, 47, 0.1) 0%, rgba(20, 69, 47, 0) 70%);
}

.dg-court {
  background: radial-gradient(120% 90% at 50% 45%, rgba(138, 90, 52, 0.1) 0%, rgba(138, 90, 52, 0) 70%);
}

/* The three marks, spelled out under the board. */
.dg-legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.125rem;
  justify-content: center;
  margin-top: 1rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--dg-rule);
  font-size: 0.78rem;
  color: var(--dg-muted);
}

.dg-legend-row > span {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.dg-swatch {
  width: 14px;
  height: 14px;
  display: inline-block;
  background: var(--dg-lit);
  border: 2px solid var(--dg-gold);
}

.dg-mark {
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
}

/*
 * The ✕ in the legend takes the page's muted ink, not the board's.
 *
 * On the board a spent square is drawn near-black in both schemes, because the
 * court it sits on stays pale in both. Down here it sits on the page, so the
 * shipped rgba(25, 24, 23, 0.55) disappeared entirely in the dark — a legend
 * with one of its three marks missing.
 */
.dg-mark[data-kind='spent'] { color: var(--dg-muted); }

/* The sandbox's legend names the palette's centre cell, so it shows the sprite. */
.dg-mark[data-kind='ball'] {
  background: url('../img/ball-soccer.png') center / contain no-repeat;
}
.dg-mark[data-kind='dot'] { color: var(--dg-gold-ink); }

/* The rules, folded shut, above the board — not buried under it. */
.dg-rules {
  border: 1px solid var(--dg-rule-3);
  border-radius: 0;
  background: var(--dg-card);
  padding: 0.75rem 1rem;
  margin: 1.125rem 0 0;
}

.dg-rules > summary {
  font-family: var(--dg-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dg-muted);
  font-weight: 400;
  cursor: pointer;
}

.dg-rules > .dg-legend {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--dg-body-2);
  margin: 0.625rem 0 0;
  max-width: 78ch;
}

/*
 * A fold inside the fold: the hint ladder nests one <details> per piece inside
 * the rules card, so each hint costs its own deliberate click.
 */
.dg-rules details {
  margin: 0.625rem 0 0;
}

.dg-rules details > summary {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--dg-body-2);
  cursor: pointer;
}

.dg-rules details > .dg-legend {
  margin-top: 0.375rem;
}

/* The end-early bar: right under the status line, where a weary player looks. */
.dg-endgame {
  display: flex;
  justify-content: flex-end;
  gap: 0.625rem;
  margin-top: 0.75rem;
}

.dg-endgame:not(:has(> button:not([hidden]))) {
  display: none;
}

/*
 * The board with the hint ladder beside it. One column until there is
 * something to stand in the second one, and again on a phone.
 */
.dg-play-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  align-items: start;
}

.dg-play-row > * {
  min-width: 0;
}

.dg-play-row:has(> .dg-rules:not([hidden])) {
  grid-template-columns: 1fr 300px;
}

.dg-play-row > .dg-rules {
  margin-top: 1.125rem;
}

@media (max-width: 820px) {
  .dg-play-row:has(> .dg-rules:not([hidden])) {
    grid-template-columns: 1fr;
  }
}

/*
 * The gate between a finished game and its reveal: the outcome, the
 * instruction to call, and the one way on. Gold rather than the firewall's
 * red — nothing is being forbidden any more; something is about to be given.
 */
.dg-gate {
  border-left: 3px solid var(--dg-gold);
  padding: 2px 0 2px 1rem;
  margin: 1.375rem 0;
}

.dg-gate .dg-btn {
  margin-top: 0.25rem;
}

/* ------------------------------------------------------------- room ---- */

/*
 * Loud while you are waiting, quiet once you are playing. Waiting, it is a
 * panel with the invite in it; playing, it is one line at the foot of the page,
 * because the board is the thing now.
 */
.dg-room {
  background: var(--dg-panel);
  border: 1px solid var(--dg-rule-2);
  padding: 1.375rem 1.5rem;
}

.dg-presence {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--dg-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dg-muted);
  min-height: 0;
  margin: 0 0 0.5rem;
}

.dg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dg-green);
  display: inline-block;
}

.dg-dot[data-state='waiting'] { background: var(--dg-gold); }
.dg-dot[data-state='absent'] { background: none; border: 1px solid #a89b83; }

.dg-room-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1.375rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--dg-rule);
  font-size: 0.8125rem;
  color: var(--dg-muted);
}

/* A board that is not in play yet: dimmed, and said to be dimmed. */
.dg-board-asleep {
  opacity: 0.42;
  filter: saturate(0.65);
}

/* Waiting: what you have to do on the right, what you are waiting for on the left. */
.dg-pair {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 2rem;
  align-items: start;
  margin-top: 1.5rem;
}

.dg-pair > * {
  min-width: 0;
}

@media (max-width: 820px) {
  .dg-pair {
    grid-template-columns: 1fr;
  }
}

/* The panel's own small headings sit above the thing they name. */
.dg-room .dg-label {
  display: block;
  margin: 1.125rem 0 0;
}

.dg-room .dg-btn-wide {
  margin-top: 1.125rem;
}

/* The foot of a board that is in play: what room this is, and the way out. */
.dg-foot-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ----------------------------------------------------------- reveal ---- */

.dg-replay-boards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.75rem;
  margin-top: 1.625rem;
}

@media (max-width: 900px) {
  .dg-replay-boards {
    grid-template-columns: 1fr;
  }
}

.dg-replay-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--dg-ink);
  padding-bottom: 0.375rem;
}

.dg-replay-label {
  font-family: var(--dg-serif);
  font-size: 1.125rem;
  font-weight: 500;
  white-space: nowrap;
}

.dg-replay-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  margin-top: 1.125rem;
}

.dg-replay-scrub {
  flex: 1 1 12rem;
  max-width: 22rem;
  accent-color: var(--dg-green);
}

.dg-replay-count {
  font-family: var(--dg-mono);
  font-size: 0.7rem;
  color: var(--dg-muted);
  white-space: nowrap;
}

/*
 * Whose move you are looking at, under the controls rather than in them. The
 * counter beside the scrubber has to stay on one short line; this does not, and
 * it is the thing that makes the two boards readable as one game.
 */
.dg-replay-note {
  font-family: var(--dg-mono);
  font-size: 0.7rem;
  line-height: 1.6;
  color: var(--dg-muted);
  text-align: center;
  margin-top: 0.5rem;
}

/* The reveal's own masthead: label, title, and the one paragraph above the boards. */
.dg-reveal-head {
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--dg-ink);
}

.dg .dg-reveal-head h1 {
  margin: 0.25rem 0 0;
}

.dg-reveal-body {
  margin: 0.75rem 0 0;
  /* Escher Chess's reveal opens with two paragraphs, written as one string. */
  white-space: pre-line;
}

/*
 * The punchline, as two lists rather than two paragraphs: what survived the
 * translation and what did not. This is the page's whole argument.
 */
.dg-ledger {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 2px solid var(--dg-ink);
}

@media (max-width: 700px) {
  .dg-ledger {
    grid-template-columns: 1fr;
  }
}

.dg-ledger h3 {
  font-family: var(--dg-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 0.5rem;
}

.dg-ledger[data-side='agree'] h3,
.dg-ledger-col[data-side='agree'] h3 { color: var(--dg-green); }

.dg-ledger-col[data-side='disagree'] h3 { color: var(--dg-red); }

.dg-ledger-col ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--dg-body-2);
}

/*
 * The worked example under a ledger claim: the same question asked of two real
 * squares. Its own line, quieter and a size down, so the claims still read as a
 * list when the eye runs down the column — and the extra leading below keeps a
 * claim attached to its own example rather than floating between two.
 */
.dg-ledger-col ul:has(.dg-eg) li + li {
  margin-top: 0.375rem;
}

.dg-ledger-col .dg-eg {
  display: block;
  margin-top: 0.125rem;
  font-family: var(--dg-mono);
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--dg-muted);
}

.dg-outro {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  align-items: start;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--dg-rule);
}

/*
 * Two paragraphs, written as one string with a blank line in it — the same
 * convention the coach panel uses, so the copy lives in one place in coach.js
 * rather than being split across markup.
 */
.dg-outro p {
  white-space: pre-line;
  margin: 0;
}

.dg-outro-actions {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

@media (max-width: 820px) {
  .dg-outro {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------------------------------- sandbox ---- */

.dg-sandbox-intro {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: start;
  margin-top: 1.5rem;
}

@media (max-width: 820px) {
  .dg-sandbox-intro {
    grid-template-columns: 1fr;
  }
}

/* Three claims about what the duality does. One accent: it is not a key. */
.dg-claims {
  list-style: none;
  margin: 1.375rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  max-width: 52ch;
}

.dg-claims li {
  padding: 0.625rem 0.875rem;
  background: var(--dg-card);
  border-left: 4px solid var(--dg-gold);
  font-size: 0.875rem;
  line-height: 1.5;
}

.dg-dials {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0;
  padding: 1.125rem 1.25rem;
  background: var(--dg-panel);
  border: 1px solid var(--dg-rule-2);
  border-radius: 0;
}

.dg-dials label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;
  font-size: 0.85rem;
  color: var(--dg-body-2);
}

.dg-dials input {
  width: 4.5rem;
  padding: 0.3rem 0.5rem;
}

/*
 * The dial the whole trick turns on.
 *
 * Its background is the lit gold of a legal square, which stays pale in both
 * colour schemes — so its ink has to stay dark in both too. Following
 * `--dg-ink` put a near-white number on pale gold and the one dial that
 * matters became the one you could not read.
 */
.dg-dials input[data-dial='duality'] {
  border-color: var(--dg-gold);
  background: var(--dg-lit);
  color: #191817;
}

.dg-dial-note {
  font-family: var(--dg-mono);
  font-size: 0.7rem;
  line-height: 1.6;
  color: var(--dg-muted);
  border-top: 1px solid var(--dg-rule-2);
  padding-top: 0.625rem;
  margin: 0;
  text-align: left;
  max-width: none;
}

.dg-palette-title,
.dg-palette-note {
  font-family: var(--dg-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dg-muted);
  text-align: center;
}

.dg-palette-cell {
  border: 1px solid var(--dg-rule-3);
  border-radius: 0;
  background: var(--dg-card);
}

.dg-palette-cell[data-on='true'] {
  background: var(--dg-lit);
  border-color: var(--dg-gold);
}

.dg-palette-cell[data-centre='true'] {
  border-color: var(--dg-ink);
  background: var(--dg-card) center / 16px 16px no-repeat;
}

/* The sprites the board already uses, so palette and board agree. */
.dg-palette[data-theme='soccer'] .dg-palette-cell[data-centre='true'] {
  background-image: url('../img/ball-soccer.png');
}

.dg-palette[data-theme='hockey'] .dg-palette-cell[data-centre='true'] {
  background-image: url('../img/ball-puck.png');
}

.dg-palette[data-theme='basketball'] .dg-palette-cell[data-centre='true'] {
  background-image: url('../img/ball-basketball.png');
}

/* ------------------------------------------------------------- misc ---- */

.dg-build {
  font-family: var(--dg-mono);
  font-size: 0.66rem;
  color: var(--dg-muted);
  opacity: 0.8;
  margin: 2rem 2.75rem 0;
}

.dg-seats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.875rem;
}

.dg-seat {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--dg-rule-2);
  border-radius: 0;
}

.dg-seat[data-active='true'] {
  border-color: var(--dg-gold);
  font-weight: 500;
}
