:root {
  --bg: #f6f4f1;
  --paper: #fffdf9;
  --ink: #161310;
  --muted: #5c534c;
  --line: #d9d0c6;
  --accent: #893100;
  --focus: #2c0c00;
  --header: #e4e5eb;
  --board-mid: #893100;
  --board-dark: #401400;
  --board-darker: #2c0c00;
  --board-light: #983800;
  --chip: #ffe6ce;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

* { box-sizing: border-box; }
html, body { margin: 0; max-width: 100%; overflow-x: hidden; }
body { background: var(--bg); color: var(--ink); }

.wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

h1 {
  font-size: 1.85rem;
  line-height: 1.2;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.25rem;
  margin: 2.25rem 0 0.75rem;
}

.lede, p, li { font-size: 1rem; }
.muted { color: var(--muted); }
.stamp { font-size: 0.95rem; color: var(--muted); margin: 0 0 12px; }

.fan-note {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 12px 14px;
  margin: 0 0 20px;
  font-size: 0.95rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0 8px;
}
.metric {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 12px;
}
.metric b { display: block; font-size: 1.5rem; line-height: 1.2; }
.metric span { display: block; color: var(--muted); font-size: 0.85rem; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: flex-end;
  margin: 12px 0 14px;
}
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 160px; }
.field label { font-size: 0.85rem; color: var(--muted); }
.field input, .field select, .btn {
  min-height: 40px;
  font: inherit;
  font-size: 1rem;
  padding: 8px 10px;
  border: 1px solid #c9bfb4;
  background: #fff;
  color: var(--ink);
  border-radius: 0;
}
.btn { cursor: pointer; background: #fff; padding: 8px 14px; }
.btn:hover, .field input:focus, .field select:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.seg {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid #c9bfb4;
}
.seg button {
  min-height: 40px;
  border: 0;
  background: #fff;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}
.seg button[aria-pressed="true"] { background: #2c0c00; color: #fff; }

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 12px 0;
  font-size: 0.95rem;
}
.toggle input { width: 18px; height: 18px; }

.board-shell {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  background-color: var(--board-mid);
  background-image:
    linear-gradient(152deg, transparent 42%, #401400 42.2%, #401400 64%, transparent 64.2%),
    linear-gradient(28deg, #2c0c00 0%, #521d00 26%, #893100 52%, #983800 100%);
  padding: 28px 16px 24px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}
.swatch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #2c0c00;
  background: var(--chip);
  color: #000;
  font-family: ui-monospace, "Cascadia Mono", "DejaVu Sans Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  padding: 4px 8px;
  cursor: pointer;
}
.swatch i {
  width: 12px;
  height: 12px;
  border: 1px solid #2c0c00;
  flex: 0 0 12px;
  display: block;
}

.card {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  min-width: 0;
  overflow: hidden;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4.2rem 4.6rem 3.4rem;
  column-gap: 8px;
  padding: 0 12px;
  align-items: center;
  min-width: 0;
  width: 100%;
  font-family: ui-monospace, "Cascadia Mono", "DejaVu Sans Mono", monospace;
  font-size: 15px;
  line-height: 28px;
  font-weight: 700;
  color: #000;
  box-sizing: border-box;
}
.row.head {
  background: var(--header);
  border-bottom: 2px solid #000;
  min-height: 36px;
  font-size: 14px;
}
.row .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .num { text-align: right; }
.list {
  max-height: 640px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}

.table-wrap { width: 100%; overflow-x: auto; margin: 8px 0 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th:nth-child(1), td:nth-child(1),
th.num, td.num { text-align: right; }
th { font-weight: 600; }
table a { color: #6b2a00; }

.chart-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 12px;
  overflow-x: auto;
}
.chart-wrap svg { display: block; width: 100%; height: auto; }
.legend-note { font-size: 0.9rem; color: var(--muted); margin: 8px 0 0; }

.changes { list-style: none; padding: 0; margin: 0; }
.changes li {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.changes strong { display: block; }
.changes .meta { font-size: 0.85rem; color: var(--muted); }

.sources { display: grid; gap: 8px; }
.sources a {
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 12px 14px;
  color: inherit;
  text-decoration: none;
}
.sources a:hover { border-color: var(--accent); }
.sources small { display: block; color: var(--muted); }

.footer { margin-top: 2.5rem; font-size: 0.85rem; color: var(--muted); }
.footer a, .fan-note a, .rp-top .fan a { color: #6b2a00; text-decoration: underline; text-underline-offset: 2px; }
.footer a:hover, .fan-note a:hover, .rp-top .fan a:hover { color: var(--accent); }
.err { color: #8a1f1f; padding: 12px 0; }

@media (max-width: 640px) {
  .wrap { padding: 12px 12px 48px; }
  h1 { font-size: 1.45rem; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .controls { flex-direction: column; align-items: stretch; }
  .field { flex: 1 1 auto; }
  .field input, .field select, .btn, .seg button { min-height: 44px; font-size: 16px; }
  .desktop-only { display: none !important; }
  .board-shell { padding: 16px 8px; }
  .swatches { gap: 6px; margin-bottom: 12px; }
  .swatch { font-size: 12px; line-height: 18px; padding: 10px 12px; min-height: 44px; }
  .card { max-width: 100%; }
  .row {
    grid-template-columns: minmax(0, 1fr) 2.25rem 2.85rem 2.15rem;
    column-gap: 4px;
    padding: 0 8px;
    font-size: 13px;
    line-height: 24px;
  }
  .row.head { min-height: 32px; font-size: 12px; }
  .list { max-height: 420px; }
}

@media (min-width: 641px) {
  .mobile-only { display: none !important; }
}

.series-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}
.series-nav[hidden],
#app[hidden],
#about-root[hidden] {
  display: none !important;
}
body.view-about .series-nav {
  display: none !important;
}
.series-nav button {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  padding: 8px 14px;
  cursor: pointer;
}
.series-nav button[aria-selected="true"] {
  background: #2c0c00;
  color: #fff8f0;
  border-color: #2c0c00;
}

.support {
  margin-top: 2.75rem;
  padding: 18px 16px;
  background: #2c0c00;
  color: #ffe6ce;
  border: 1px solid #521d00;
}
.support p { margin: 0 0 12px; font-size: 0.98rem; }
.support-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 18px;
  background: #ffda5f;
  color: #2c0c00;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid #2c0c00;
}
.support-btn:hover { background: #ffff79; }
.support-soon {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  background: #401400;
  color: #ffe6ce;
  border: 1px dashed #ffda5f;
  font-weight: 700;
}

@media (max-width: 640px) {
  .series-nav button { min-height: 44px; }
  .support { margin-left: -12px; margin-right: -12px; padding: 18px 12px; }
}
.changes span { display: block; }

.view-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}
.view-nav button {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  padding: 8px 16px;
  cursor: pointer;
}
.view-nav button[aria-selected="true"] {
  background: #2c0c00;
  color: #fff8f0;
  border-color: #2c0c00;
}

.about-intro { max-width: 42rem; }
.about-section { margin: 1.75rem 0 0; }
.about-section h2 { margin-top: 0; }
.about-lede { color: var(--muted); margin: 0 0 12px; }
.cards { display: grid; gap: 12px; }
.card-note {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid #893100;
  padding: 14px 16px;
}
.card-note h3 { margin: 0 0 8px; font-size: 1.05rem; }
.card-note p { margin: 0 0 8px; }
.card-note .cites { font-size: 0.85rem; color: var(--muted); }
.card-note .cites a { color: #6b2a00; }
.source-list { list-style: none; padding: 0; margin: 0; }
.source-list li {
  border-top: 1px solid var(--line);
  padding: 10px 0;
  font-size: 0.92rem;
}
.source-list a { color: #6b2a00; }
.source-list small { display: block; color: var(--muted); }

@media (max-width: 640px) {
  .view-nav button { min-height: 44px; }
}

/* Board rows link to per-run pages (runs/<slug>.html) */
a.row-link { color: #000; text-decoration: none; }
a.row-link:hover, a.row-link:focus-visible { outline: 2px solid #2c0c00; outline-offset: -2px; filter: brightness(1.04); }
