html:has(.dc), body:has(.dc) { margin: 0; background: #0b0b0c; color-scheme: dark; }

.dc {
  --bg: #0b0b0c;
  --panel: #111111;
  --line: #24231f;
  --ink: #ece8de;
  --muted: #a29d91;
  --faint: #6f6b62;
  --gold: #f2c21b;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 48px) 48px;
}
.dc * { box-sizing: border-box; }
.dc a { color: inherit; text-decoration-color: rgba(242, 194, 27, 0.55); text-underline-offset: 3px; }
.dc :is(p, li) a:not(.dc-button) { text-decoration-line: underline; }
.dc a:hover { color: var(--gold); }
.dc :focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.dc canvas { display: block; }

.dc-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.dc-eyebrow, .dc-kicker, .dc-label, .dc-jump a { font: 600 10.5px/1.4 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; }
.dc-eyebrow { text-decoration: none; color: var(--muted) !important; }
.dc-jump { display: flex; gap: 22px; }
.dc-jump a { text-decoration: none; color: var(--muted); }
.dc-kicker { color: var(--gold); margin: 0 0 14px; }
.dc-label { color: var(--faint); margin: 0 0 10px; }

/* Hero: intro beside the specimen sheet */
.dc-hero { display: grid; grid-template-columns: minmax(370px, 0.8fr) minmax(0, 1.6fr); gap: clamp(28px, 4vw, 64px) clamp(28px, 7vw, 112px); align-items: center; padding: clamp(28px, 5vw, 64px) 0; }
.dc h1 { font-size: clamp(42px, 5.4vw, 76px); font-weight: 600; letter-spacing: -0.04em; line-height: 0.98; margin: 0 0 22px; }
.dc-lede { font-size: 18px; line-height: 1.6; margin: 0 0 16px; color: var(--ink); }
.dc-credit { font-size: 14.5px; line-height: 1.7; color: var(--muted); margin: 0 0 26px; }
.dc-cta { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }

.dc-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 15px; border-radius: 8px;
  border: 1px solid #3a3832; background: transparent; color: var(--ink) !important;
  font: 500 13.5px/1 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.dc-button:hover { background: #1b1a17; border-color: #555047; }
.dc-button-primary { background: var(--gold); border-color: var(--gold); color: #17140a !important; font-weight: 650; }
.dc-button-primary:hover { background: #ffd23d; border-color: #ffd23d; }

.dc-sheet { margin: 0; }
/* Beside the intro, the sheet fills its column and the tiles take their
   height from the window, so all three rows stay on screen. Each creature is
   fitted inside its tile, so wider tiles only add space around it. */
@media (min-width: 1061px) {
  .dc-tile { aspect-ratio: auto; height: clamp(170px, calc((100svh - 300px) / 3), 330px); }
}
.dc-sheet-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: clamp(4px, 1vw, 12px); padding: clamp(10px, 2vw, 26px); background: var(--panel); border-radius: 18px; box-shadow: 0 0 0 1px #1d1c19, 0 30px 80px rgba(0, 0, 0, 0.45); }
.dc-tile { position: relative; aspect-ratio: 9 / 21; padding: 0; border: 0; border-radius: 8px; background: transparent; cursor: zoom-in; transition: background 0.2s; }
.dc-tile:hover { background: #1a1916; }
.dc-tile canvas { width: 100%; height: 100%; }
.dc-sheet figcaption { margin-top: 12px; font-size: 12.5px; color: var(--faint); text-align: center; }

/* The guide */
.dc-guide, .dc-lab, .dc-notes { border-top: 1px solid var(--line); padding: clamp(40px, 6vw, 72px) 0 0; scroll-margin-top: 12px; }
.dc-section-head { max-width: 720px; margin-bottom: clamp(24px, 4vw, 44px); }
.dc h2 { font-size: clamp(28px, 3.4vw, 44px); font-weight: 600; letter-spacing: -0.03em; line-height: 1.08; margin: 0 0 12px; }
.dc-section-head > p:not(.dc-kicker) { font-size: 15.5px; line-height: 1.7; color: var(--muted); margin: 0; }

.dc-step { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: clamp(24px, 4vw, 64px); align-items: start; padding: 0 0 clamp(40px, 6vw, 72px); }
.dc-step-last { grid-template-columns: minmax(0, 720px); }
.dc h3 { font-size: 21px; font-weight: 600; letter-spacing: -0.015em; margin: 0 0 14px; display: flex; gap: 12px; align-items: baseline; }
.dc h3 span { font: 600 12px var(--mono); color: var(--gold); letter-spacing: 0.06em; }
.dc-step-text p, .dc-recipe li { font-size: 15.5px; line-height: 1.75; color: var(--muted); margin: 0 0 14px; }
.dc-step-text b { color: var(--ink); font-weight: 600; }
.dc-recipe { margin: 0 0 16px; padding-left: 22px; }
.dc-recipe li { padding-left: 4px; margin-bottom: 8px; }
.dc-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px !important; }

.dc-figure { margin: 0; background: var(--panel); border-radius: 14px; padding: 18px; box-shadow: 0 0 0 1px #1d1c19; }
.dc-figure figcaption { font-size: 12.5px; line-height: 1.6; color: var(--faint); margin-top: 12px; }
.dc-figure figcaption b { color: var(--ink); font-weight: 600; margin-right: 4px; }

/* Rule icons: three cells over one */
.dc-genome { display: flex; flex-wrap: wrap; gap: 10px 9px; }
.dc-case { --cell: 9px; display: inline-grid; justify-items: center; gap: 2px; padding: 4px; border-radius: 4px; transition: background 0.12s, box-shadow 0.12s; }
.dc-case-in, .dc-case-out { display: flex; gap: 1px; }
.dc-case i { display: block; width: var(--cell); height: var(--cell); border-radius: 1px; }
.dc-case i.is-empty { background: #262522 !important; box-shadow: inset 0 0 0 1px #34322d; }
.dc-case.is-active { background: #3a3218; box-shadow: 0 0 0 2px var(--gold); }
.dc-genome-compact { gap: 3px 2px; margin-top: 14px; }
.dc-genome-compact .dc-case { --cell: 7px; padding: 3px; }
.dc-genome-dialog { gap: 4px 3px; margin-bottom: 22px; }
.dc-genome-dialog .dc-case { --cell: 7px; padding: 3px; }
.dc-case-inline { vertical-align: middle; --cell: 8px; padding: 2px 3px; background: #1d1c19; }
.dc-case-outs { align-items: center; gap: 5px; }
.dc-case-outs b { font: 500 11px var(--mono); color: var(--muted); line-height: 1; }
.dc-case-change { --cell: 12px; }

.dc-growth-canvas { width: 100%; height: clamp(260px, 34vw, 420px); }
.dc-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dc-pair canvas { width: 100%; height: clamp(260px, 30vw, 380px); }
.dc-pair figcaption { text-align: center; }
.dc-fates { display: grid; grid-template-columns: 0.7fr 1fr 1fr; gap: 14px; align-items: start; }
.dc-fates canvas { width: 100%; height: clamp(280px, 34vw, 440px); }
.dc-fade { position: relative; }
.dc-fade::after { content: ""; position: absolute; left: 0; right: 0; top: calc(clamp(280px, 34vw, 440px) - 120px); height: 120px; background: linear-gradient(transparent, var(--panel)); pointer-events: none; }

/* The lab */
.dc-lab-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; }
.dc-lab-stage { position: relative; background: var(--panel); border-radius: 14px; box-shadow: 0 0 0 1px #1d1c19; min-height: 0; }
.dc-lab-stage canvas { width: 100%; height: clamp(420px, 72vh, 780px); }
.dc-lab-inspect { position: absolute; right: 12px; top: 12px; min-height: 32px; padding: 0 12px; border-radius: 7px; border: 1px solid #3a3832; background: rgba(17, 17, 17, 0.8); color: var(--ink); font: 500 12px var(--sans); cursor: zoom-in; }
.dc-lab-inspect:hover { border-color: #6a655b; }
.dc-lab-panel { display: flex; flex-direction: column; gap: 20px; background: var(--panel); border-radius: 14px; box-shadow: 0 0 0 1px #1d1c19; padding: 20px; min-width: 0; }
.dc-counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.dc-counters div { display: flex; flex-direction: column; justify-content: space-between; background: #181815; border-radius: 9px; padding: 11px 12px; min-width: 0; }
.dc-counters dt { font: 600 9.5px/1.3 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.dc-counters dd { margin: 6px 0 0; font: 600 22px/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.dc-counters div:last-child dd { color: var(--gold); }
.dc-chart canvas { width: 100%; height: 96px; background: #151512; border-radius: 8px; }
/* Messages change many times a second, so their boxes hold a fixed number
   of lines (every message fits in three) and nothing below them moves. */
.dc-last-row { display: flex; gap: 14px; align-items: center; height: calc(13.5px * 1.5 * 3); }
.dc-last-row p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.dc-last-row p[data-state="improved"] { color: var(--gold); }
.dc-last-row p[data-state="kept"] { color: #c9c4b6; }
.dc-last-row p[data-state="rejected"] { color: #8f8a80; }
.dc-lab-controls { display: flex; flex-direction: column; gap: 14px; border-top: 1px solid var(--line); padding-top: 18px; }
.dc-playback { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dc-field { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.dc-field select, .dc-field input { font: 500 13px var(--sans); color: var(--ink); background: #181815; border: 1px solid #3a3832; border-radius: 7px; min-height: 36px; padding: 0 10px; }
.dc-field select { width: 200px; }
.dc-seed-input { width: 200px; font-family: var(--mono) !important; }
.dc-status { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--faint); height: calc(12.5px * 1.55 * 3); overflow: hidden; }
.dc-hint { margin: 0; display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--faint); }
.dc kbd { font: 11px var(--mono); border: 1px solid #3a3832; border-radius: 4px; padding: 1px 5px; }
.dc-fossils { margin-top: 18px; }
.dc-fossil-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; min-height: 140px; }
.dc-fossil { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; width: 78px; height: 140px; padding: 8px 6px 7px; border-radius: 9px; border: 1px solid #22211d; background: var(--panel); color: var(--muted); font: 500 11px var(--mono); cursor: zoom-in; }
.dc-fossil:hover { border-color: #4a463e; color: var(--ink); }
.dc-fossil-art { max-width: 100%; max-height: 104px; width: auto; height: auto; object-fit: contain; image-rendering: auto; margin: auto 0 0; }

/* Notes */
.dc-notes-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(22px, 3vw, 44px); }
.dc-notes h3 { font-size: 16px; margin-bottom: 10px; }
.dc-notes p { font-size: 14px; line-height: 1.75; color: var(--muted); margin: 0 0 12px; }
.dc-notes b { color: var(--ink); font-weight: 600; }
.dc-colophon { border-top: 1px solid var(--line); margin-top: 36px !important; padding-top: 20px; font-size: 12.5px !important; color: var(--faint) !important; }
.dc-noscript { color: var(--muted); text-align: center; }

/* Specimen viewer */
.dc-dialog { position: fixed; inset: 0; margin: auto; width: min(1180px, calc(100vw - 32px)); height: fit-content; max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 16px; background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px #2a2924, 0 40px 120px rgba(0, 0, 0, 0.7); font-family: var(--sans); }
.dc-dialog::backdrop { background: rgba(5, 5, 6, 0.78); backdrop-filter: blur(3px); }
.dc-dialog-body { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: min(860px, calc(100dvh - 32px)); }
.dc-dialog-stage { min-width: 0; min-height: 0; overflow: hidden; display: flex; align-items: stretch; justify-content: center; }
.dc-dialog-stage.is-zoomed { overflow: auto; display: block; }
.dc-dialog-stage canvas { width: 100%; height: 100%; }
.dc-dialog-stage canvas.is-zoomed { image-rendering: pixelated; margin: 16px auto; max-width: none; }
.dc-dialog-info { position: relative; border-left: 1px solid var(--line); padding: 26px 24px; overflow-y: auto; }
.dc-dialog-info h2 { font-size: 26px; font-style: italic; margin: 0 40px 4px 0; letter-spacing: -0.02em; }
.dc-common { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.dc-dialog-close { position: absolute; right: 14px; top: 14px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid #3a3832; background: transparent; color: var(--ink); font-size: 22px; line-height: 1; cursor: pointer; }
.dc-dialog-close:hover { background: #1f1e1a; }
.dc-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 16px; }
.dc-facts div { background: #181815; border-radius: 8px; padding: 9px 10px; }
.dc-facts dt { font: 600 9.5px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.dc-facts dd { margin: 5px 0 0; font: 600 15px var(--mono); }
.dc-origin { font-size: 13px; line-height: 1.6; color: var(--muted); margin: 0 0 20px; }
.dc-dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 1060px) {
  .dc-hero { grid-template-columns: 1fr; }
  .dc-intro { max-width: 680px; }
  .dc-step { grid-template-columns: 1fr; }
  .dc-lab-grid { grid-template-columns: 1fr; }
  .dc-lab-stage canvas { height: clamp(360px, 62vh, 640px); }
  .dc-notes-grid { grid-template-columns: 1fr; }
  .dc-dialog-body { grid-template-columns: 1fr; height: auto; max-height: calc(100dvh - 32px); overflow-y: auto; }
  .dc-dialog-stage { height: 56dvh; }
  .dc-dialog-info { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
}

@media (max-width: 640px) {
  .dc-jump { display: none; }
  .dc-lede { font-size: 16.5px; }
  .dc-sheet-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); border-radius: 12px; }
  .dc-figure { padding: 12px; }
  .dc-fates { grid-template-columns: 1fr 1fr; }
  .dc-fates > div:first-child { grid-column: 1 / -1; }
  .dc-fates > div:first-child canvas { height: 90px; }
  .dc-fade::after { top: calc(clamp(280px, 34vw, 440px) - 120px); }
  .dc-field select, .dc-seed-input { width: 170px; }
  .dc-hint { flex-direction: column; }
  .dc-counters dd { font-size: 18px; }
  .dc-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .dc-dialog-actions .dc-button { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .dc * { transition: none !important; scroll-behavior: auto !important; }
}

/* The lab's loop diagram. Step 3 lights up with the latest verdict. */
.dc-loop { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; counter-reset: none; }
.dc-loop-step { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--panel); box-shadow: 0 0 0 1px #1d1c19; font-size: 14px; line-height: 1.55; color: var(--muted); transition: box-shadow 0.2s, background 0.2s; }
.dc-loop-step b { flex: 0 0 auto; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #23221d; color: var(--gold); font: 600 12px var(--mono); }
.dc-loop-step strong { color: var(--ink); font-weight: 600; }
.dc-loop-step:not(:last-child)::after { content: "\2192"; position: absolute; right: -5px; top: 50%; transform: translate(50%, -50%); color: var(--faint); font-size: 14px; z-index: 1; }
.dc-loop[data-state="improved"] .dc-loop-judge { background: #2a2410; box-shadow: 0 0 0 1.5px var(--gold); }
.dc-loop[data-state="kept"] .dc-loop-judge { box-shadow: 0 0 0 1.5px #6f8f6a; }
.dc-loop[data-state="rejected"] .dc-loop-judge { box-shadow: 0 0 0 1.5px #8a4b47; }
.dc-lab-note { max-width: 760px; font-size: 15px; line-height: 1.7; color: var(--muted); margin: 0 0 clamp(20px, 3vw, 32px); }
.dc-lab-note b { color: var(--ink); font-weight: 600; }
.dc-caption { margin: 8px 0 0; font-size: 12px; line-height: 1.5; color: var(--faint); }
@media (max-width: 760px) {
  .dc-loop { grid-template-columns: 1fr; }
  .dc-loop-step:not(:last-child)::after { content: "\2193"; right: 50%; top: auto; bottom: -5px; transform: translate(50%, 50%); }
}

/* New creature: the lab's main button, and the same action on the canvas
   once a run has finished. */
.dc-dice { flex: 0 0 auto; }
.dc-button .dc-dice { margin-left: -2px; }
.dc-new { width: 100%; min-height: 52px; font-size: 16px; gap: 10px; border-radius: 10px; box-shadow: 0 8px 24px rgba(242, 194, 27, 0.18); }
.dc-new:hover .dc-dice, .dc-lab-again:hover .dc-dice, .dc-cta .dc-button-primary:hover .dc-dice { transform: rotate(-18deg); }
.dc-dice { transition: transform 0.2s; }
.dc-lab-again { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); min-height: 48px; padding: 0 22px; font-size: 15px; gap: 9px; border-radius: 999px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 0 6px rgba(17, 17, 17, 0.6); }
.dc-lab-again[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  .dc-dice { transition: none; }
}
