/* ==========================================================================
   The Other Player — Game Theory & Decisions
   Visual identity: a dark card-table felt, cream chalk text, and fixed
   colour meanings: blue = row player / you, orange = column player / them,
   gold = equilibrium, green = cooperate, red = defect, cream dashed = average.
   ========================================================================== */

:root {
  --felt-deep: #08130f;
  --felt: #0b1a16;
  --felt-raised: #10241f;
  --card: #132b25;
  --card-2: #18352d;
  --canvas-bg: #0a1815;
  --line: #24443b;
  --line-soft: rgba(241, 234, 217, 0.1);

  --text: #f1ead9;
  --text-soft: #d3d9cc;
  --text-muted: #9cb0a4;
  --text-dim: #6f877b;

  --row: #62b0ea;
  --col: #f39a5d;
  --eq: #f4cd4c;
  --coop: #7fd496;
  --defect: #ee5d5d;
  --avg: #f1ead9;
  --chance: #b9b3a3;
  --lilac: #b79af2;

  --font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-sans: 'Source Sans 3', 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Consolas, 'Courier New', monospace;

  --sidebar-w: 284px;
  --content-max: 820px;
  --radius: 14px;
  --radius-sm: 9px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--felt);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 70% 45% at 55% -8%, rgba(244, 205, 76, 0.07), transparent 62%),
    radial-gradient(ellipse 55% 40% at 10% 105%, rgba(98, 176, 234, 0.05), transparent 60%),
    var(--felt);
  color: var(--text);
}

a { color: var(--eq); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--eq);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Reading progress ---------- */
.reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--row), var(--eq), var(--col));
  z-index: 1000;
}

/* ---------- Layout ---------- */
.book-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--felt-deep);
  border-right: 1px solid var(--line);
  padding: 1.4rem 1rem 2.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  z-index: 95;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.2rem 0.35rem 0.95rem;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.sidebar-brand:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.brand-title {
  display: block;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.12rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.brand-sub { display: block; font-size: 0.74rem; color: var(--text-muted); margin-top: 2px; letter-spacing: 0.02em; }

.course-progress-box {
  background: var(--felt-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
}
.course-progress-label { display: flex; justify-content: space-between; font-size: 0.76rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.course-progress-track { height: 6px; background: rgba(241, 234, 217, 0.08); border-radius: 99px; overflow: hidden; }
.course-progress-fill { height: 100%; background: linear-gradient(90deg, var(--coop), var(--eq)); border-radius: 99px; transition: width 0.3s ease; }

.toc-part-title {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-weight: 700;
  margin: 0.85rem 0 0.3rem 0.45rem;
}
.toc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.toc-link {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.42rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.3;
}
.toc-link:hover { background: rgba(241, 234, 217, 0.06); color: var(--text); text-decoration: none; }
.toc-link.active { background: rgba(244, 205, 76, 0.12); color: var(--eq); font-weight: 600; }
.toc-num { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-dim); width: 1.4rem; flex-shrink: 0; }
.toc-link.active .toc-num { color: var(--eq); }
.toc-check { margin-left: auto; font-size: 0.78rem; color: var(--coop); opacity: 0; }
.toc-link.completed .toc-check { opacity: 1; }

.mobile-topbar {
  display: none;
  position: sticky; top: 0; z-index: 90;
  background: rgba(8, 19, 15, 0.94);
  border-bottom: 1px solid var(--line);
  padding: 0.6rem 1rem;
  align-items: center; justify-content: space-between; gap: 1rem;
}
.mobile-menu-btn {
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius-sm); padding: 0.4rem 0.75rem;
  font: 600 0.9rem var(--font-sans); cursor: pointer;
}
.mobile-brand { font-family: var(--font-serif); font-weight: 600; color: var(--text); }
.sidebar-backdrop { display: none; }

.chapter-content {
  flex: 1;
  min-width: 0;
  max-width: calc(var(--content-max) + 7rem);
  margin: 0 auto;
  padding: 2.6rem clamp(1rem, 4vw, 3.5rem) 4.5rem;
}

/* ---------- Chapter header ---------- */
.chapter-header { margin-bottom: 2.3rem; padding-bottom: 1.6rem; border-bottom: 1px solid var(--line); }
.chapter-eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--eq);
  margin-bottom: 0.6rem;
}
.chapter-header h1, .hero h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(2rem, 4.6vw, 3.05rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 0.8rem;
  color: #fffaf0;
}
.chapter-subtitle { font-size: 1.14rem; color: var(--text-soft); margin: 0; max-width: 64ch; line-height: 1.6; }

/* ---------- Prose ---------- */
.chapter-content h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.68rem;
  line-height: 1.22;
  color: #fffaf0;
  margin: 2.7rem 0 0.85rem;
  letter-spacing: -0.012em;
}
.chapter-content h3 { font-size: 1.12rem; color: var(--eq); margin: 1.8rem 0 0.5rem; font-weight: 700; }
.chapter-content p { margin: 0 0 1.15rem; color: var(--text-soft); max-width: 68ch; }
.chapter-content ul, .chapter-content ol { margin: 0 0 1.3rem; padding-left: 1.35rem; max-width: 66ch; color: var(--text-soft); }
.chapter-content li { margin-bottom: 0.45rem; }
.chapter-content strong { color: var(--text); }
.chapter-content em { color: var(--text); }

.c-row { color: var(--row); font-weight: 700; }
.c-col { color: var(--col); font-weight: 700; }
.c-eq { color: var(--eq); font-weight: 700; }
.c-coop { color: var(--coop); font-weight: 700; }
.c-def { color: var(--defect); font-weight: 700; }
.c-avg { color: var(--avg); font-weight: 700; border-bottom: 1px dashed rgba(241, 234, 217, 0.6); }
.c-chance { color: var(--chance); font-weight: 700; }
.c-lilac { color: var(--lilac); font-weight: 700; }

.formula {
  font-family: var(--font-mono);
  background: var(--felt-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.1rem;
  margin: 1.2rem 0 0.6rem;
  max-width: 68ch;
  color: var(--text);
  font-size: 0.98rem;
  overflow-x: auto;
}
.formula + .formula-read { margin-top: 0; font-size: 0.95rem; color: var(--text-muted); font-style: italic; }

/* ---------- Callouts ---------- */
.callout {
  background: var(--felt-raised);
  border: 1px solid var(--line);
  border-left: 4px solid var(--eq);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin: 1.6rem 0;
  max-width: 68ch;
}
.callout p { margin: 0; color: var(--text); }
.callout p + p { margin-top: 0.6rem; }
.callout-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--eq);
  margin-bottom: 0.35rem;
}
.callout.principle { background: linear-gradient(90deg, rgba(244, 205, 76, 0.08), var(--felt-raised) 45%); }
.callout.green { border-left-color: var(--coop); }
.callout.green .callout-title { color: var(--coop); }
.callout.red { border-left-color: var(--defect); }
.callout.red .callout-title { color: var(--defect); }
.callout.blue { border-left-color: var(--row); }
.callout.blue .callout-title { color: var(--row); }
.callout.history { border-left-color: var(--chance); }
.callout.history .callout-title { color: var(--chance); }

/* ---------- Interactive figures ---------- */
.figure {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 1.9rem 0 2.1rem;
  overflow: hidden;
  box-shadow: 0 18px 40px -26px rgba(0, 0, 0, 0.8);
}
.figure-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 0.35rem 1rem;
  padding: 0.85rem 1.1rem 0.7rem;
  border-bottom: 1px solid var(--line);
}
.figure-title { font-weight: 700; color: var(--text); font-size: 1.02rem; display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.figure-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1b1405;
  background: var(--eq);
  border-radius: 5px;
  padding: 0.12rem 0.45rem;
}
.figure-hint { font-size: 0.86rem; color: var(--text-muted); font-style: italic; }
.canvas-wrap { background: var(--canvas-bg); padding: 0; position: relative; }
.canvas-wrap canvas { display: block; width: 100%; height: 300px; }
.figure-controls {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  gap: 0.8rem 1.2rem;
  padding: 0.9rem 1.1rem;
  border-top: 1px solid var(--line);
  background: var(--felt-raised);
}
.ctrl { display: flex; flex-direction: column; gap: 0.25rem; min-width: 170px; flex: 1 1 170px; }
.ctrl.narrow { flex: 0 1 140px; min-width: 120px; }
.ctrl label, .ctrl .ctrl-label {
  display: flex; justify-content: space-between; gap: 0.6rem;
  font-size: 0.82rem; font-weight: 600; color: var(--text-soft);
}
.ctrl output, .ctrl .val { font-family: var(--font-mono); color: var(--eq); font-weight: 600; font-size: 0.82rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.btn-row .btn-row-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; margin-right: 0.15rem; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 26px; background: transparent; cursor: pointer; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 5px; background: rgba(241, 234, 217, 0.16); border-radius: 99px; }
input[type="range"]::-moz-range-track { height: 5px; background: rgba(241, 234, 217, 0.16); border-radius: 99px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--eq); border: 2px solid #1b1405; margin-top: -6.5px;
}
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--eq); border: 2px solid #1b1405; }
input[type="range"]:focus-visible { outline: 2px solid var(--eq); outline-offset: 2px; }

input[type="number"], select {
  background: var(--felt-deep);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 7px;
  padding: 0.3rem 0.4rem;
  font: 600 0.92rem var(--font-mono);
  width: 4.2rem;
}
select { width: auto; font-family: var(--font-sans); }

.btn {
  font: 600 0.88rem var(--font-sans);
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  line-height: 1.25;
  transition: background 0.15s ease, border-color 0.15s ease;
  display: inline-flex; align-items: center; gap: 0.35rem;
}
.btn:hover { background: #1f4238; border-color: #3a6357; text-decoration: none; }
.btn.active { background: rgba(244, 205, 76, 0.16); border-color: var(--eq); color: var(--eq); }
.btn.primary { background: var(--eq); color: #1b1405; border-color: var(--eq); }
.btn.primary:hover { background: #ffdb6a; }
.btn.done { background: rgba(127, 212, 150, 0.16); border-color: var(--coop); color: var(--coop); }
.btn.coop { border-color: rgba(127, 212, 150, 0.6); color: var(--coop); }
.btn.defect { border-color: rgba(238, 93, 93, 0.6); color: var(--defect); }
.btn.big { padding: 0.65rem 1.2rem; font-size: 1rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.readout {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--felt-deep);
  border-top: 1px solid var(--line);
  padding: 0.7rem 1.1rem;
  line-height: 1.55;
}
.readout b { color: var(--eq); font-weight: 700; }
.readout .m { font-family: var(--font-mono); font-size: 0.88rem; }
.readout .r { color: var(--row); }
.readout .c { color: var(--col); }
.readout .g { color: var(--coop); }
.readout .d { color: var(--defect); }
.figure-caption {
  padding: 0.8rem 1.1rem 0.95rem;
  font-size: 0.93rem;
  color: var(--text-muted);
  border-top: 1px solid var(--line);
  line-height: 1.6;
}
.figure-caption strong { color: var(--text); }
.legend { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; padding: 0.55rem 1.1rem; font-size: 0.8rem; color: var(--text-muted); border-bottom: 1px solid var(--line); }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.line { height: 3px; border-radius: 2px; width: 16px; }
.swatch.dash { height: 0; border-top: 2px dashed var(--avg); width: 16px; border-radius: 0; }

/* payoff editor */
.payoff-editor { display: grid; grid-template-columns: auto 1fr 1fr; gap: 0.4rem 0.6rem; align-items: center; font-size: 0.82rem; }
.payoff-editor .pe-h { color: var(--col); font-weight: 700; text-align: center; }
.payoff-editor .pe-r { color: var(--row); font-weight: 700; }
.payoff-editor .pe-cell { display: flex; gap: 0.3rem; justify-content: center; }
.payoff-editor input.in-row { border-color: rgba(98, 176, 234, 0.6); color: var(--row); }
.payoff-editor input.in-col { border-color: rgba(243, 154, 93, 0.6); color: var(--col); }

/* small data tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.data-table th, .data-table td { padding: 0.38rem 0.55rem; text-align: left; border-bottom: 1px solid var(--line); }
.data-table th { color: var(--text-muted); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.06em; }
.data-table td.num, .data-table th.num { text-align: right; font-family: var(--font-mono); }
.data-table td.wtl { white-space: nowrap; }
canvas.kbd:focus-visible { outline: 2px solid var(--eq); outline-offset: -2px; }
.table-scroll { overflow-x: auto; padding: 0.4rem 1.1rem 0.8rem; background: var(--felt-raised); border-top: 1px solid var(--line); }

/* roster (tournament) */
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 0.45rem 0.9rem; padding: 0.9rem 1.1rem; background: var(--felt-raised); border-top: 1px solid var(--line); }
.roster-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.86rem; }
.roster-item .nm { flex: 1; min-width: 0; color: var(--text-soft); }
.roster-item .cnt { font-family: var(--font-mono); width: 1.6rem; text-align: center; color: var(--text); font-weight: 600; }
.roster-item button { width: 1.8rem; height: 1.8rem; padding: 0; justify-content: center; }

/* ---------- Quiz ---------- */
.quiz {
  background: var(--felt-raised);
  border: 1px solid var(--line);
  border-top: 3px solid var(--row);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem 1.1rem;
  margin: 2.2rem 0;
}
.quiz h3 { margin: 0 0 0.5rem; color: var(--row); font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.13em; text-transform: uppercase; }
.quiz .quiz-q { color: var(--text); margin-bottom: 0.9rem; }
.quiz-options { display: flex; flex-direction: column; gap: 0.5rem; }
.quiz-option {
  text-align: left;
  font: 500 0.97rem var(--font-sans);
  color: var(--text-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  line-height: 1.45;
}
.quiz-option:hover { border-color: #3a6357; color: var(--text); }
.quiz-option.correct { border-color: var(--coop); background: rgba(127, 212, 150, 0.1); color: var(--text); }
.quiz-option.wrong { border-color: var(--defect); background: rgba(238, 93, 93, 0.08); }
.quiz-feedback { margin-top: 0.8rem; font-size: 0.95rem; color: var(--text-soft); min-height: 1.2em; }
.quiz-feedback.ok strong { color: var(--coop); }
.quiz-feedback.no strong { color: var(--defect); }

/* ---------- Connections & recap ---------- */
.connections {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 2.2rem 0 1.4rem;
  max-width: 68ch;
}
.connections h3 { margin-top: 0; color: var(--chance); font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.13em; text-transform: uppercase; }
.connections p { margin: 0; font-size: 0.97rem; }
.connections p + p { margin-top: 0.5rem; }
.recap {
  background: linear-gradient(135deg, rgba(244, 205, 76, 0.08), rgba(98, 176, 234, 0.05));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem 0.6rem;
  margin: 2rem 0;
}
.recap h2 { margin-top: 0 !important; font-size: 1.35rem !important; }
.recap li { color: var(--text); }

/* ---------- Chapter footer ---------- */
.chapter-footer { margin-top: 3rem; padding-top: 1.6rem; border-top: 1px solid var(--line); }
.complete-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.8rem;
  background: var(--felt-raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.95rem 1.2rem; margin-bottom: 1.1rem;
}
.complete-bar p { margin: 0 !important; font-size: 0.95rem; }
.chapter-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.nav-card {
  display: flex; flex-direction: column; gap: 0.2rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem 1.1rem; color: var(--text);
}
.nav-card:hover { border-color: var(--eq); text-decoration: none; }
.nav-card.next { text-align: right; }
.nav-dir { font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.nav-title { font-weight: 600; }

/* ---------- Home ---------- */
.hero { padding: 0.6rem 0 1.6rem; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 2rem; align-items: center; }
.hero-lead { font-size: 1.13rem; color: var(--text-soft); max-width: 52ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.2rem; }
.hero-toy { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.hero-toy .canvas-wrap canvas { height: 300px; }
.progress-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.4rem;
  background: var(--felt-raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin: 1.4rem 0 1rem;
}
.progress-banner .pb-text { flex: 1 1 200px; }
.progress-banner strong { color: var(--text); }
.progress-banner .pb-sub { font-size: 0.88rem; color: var(--text-muted); }
.progress-banner .pb-track { flex: 2 1 200px; height: 8px; background: rgba(241, 234, 217, 0.08); border-radius: 99px; overflow: hidden; }
.progress-banner .pb-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--coop), var(--eq)); border-radius: 99px; }
.legend-strip { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; font-size: 0.86rem; color: var(--text-muted); margin: 0.4rem 0 0; }
.legend-strip span { display: inline-flex; align-items: center; gap: 0.4rem; }
.part-heading { display: flex; align-items: baseline; gap: 0.8rem; margin: 2.4rem 0 0.9rem; flex-wrap: wrap; }
.part-badge { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.14em; color: var(--eq); border: 1px solid rgba(244, 205, 76, 0.5); border-radius: 6px; padding: 0.15rem 0.5rem; }
.part-heading h2 { margin: 0 !important; font-size: 1.5rem !important; }
.chapter-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0.9rem; }
.chapter-card {
  display: flex; flex-direction: column; gap: 0.35rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.chapter-card:hover { border-color: var(--eq); text-decoration: none; transform: translateY(-2px); }
.chapter-card-top { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); letter-spacing: 0.08em; }
.chapter-card-status { color: var(--coop); }
.chapter-card h3 { margin: 0.1rem 0 0 !important; color: #fffaf0 !important; font-family: var(--font-serif); font-weight: 600; font-size: 1.12rem !important; line-height: 1.3; }
.chapter-card p { margin: 0 !important; font-size: 0.92rem; color: var(--text-muted); }
.chapter-card .card-sims { margin-top: auto; padding-top: 0.4rem; font-size: 0.8rem; color: var(--eq); font-family: var(--font-mono); line-height: 1.45; }
.site-footer { margin-top: 3rem; padding-top: 1.2rem; border-top: 1px solid var(--line); font-size: 0.86rem; color: var(--text-dim); }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .mobile-topbar { display: flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-105%);
    visibility: hidden; /* keeps the closed drawer's links out of the tab order */
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
  }
  .sidebar.open { transform: translateX(0); visibility: visible; transition: transform 0.25s ease, visibility 0s; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 94; }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
  .hero-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  html { font-size: 16px; }
  .chapter-content { padding: 1.6rem 0.8rem 3.5rem; }
  .figure { margin-left: -0.3rem; margin-right: -0.3rem; border-radius: 10px; }
  .figure-head, .figure-controls, .readout, .figure-caption, .legend { padding-left: 0.8rem; padding-right: 0.8rem; }
  .ctrl { min-width: 100%; }
  .ctrl.narrow { min-width: 45%; }
  .chapter-nav { grid-template-columns: 1fr; }
  .nav-card.next { text-align: left; }
  .chapter-header h1 { font-size: 1.95rem; }
  .chapter-content h2 { font-size: 1.42rem; }
  .roster { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media (max-width: 420px) {
  .payoff-editor input[type="number"] { width: 3.3rem; }
  .payoff-editor { gap: 0.35rem 0.4rem; }
}
