:root {
  --paper: #f3ecdf;
  --card: #fffaf3;
  --ink: #241e18;
  --muted: #6d6256;
  --line: #e4d8c6;
  --move: #14635c;
  --move-soft: #1d8a80;
  --yield: #b8431f;
  --shadow: 0 16px 40px rgba(36, 30, 24, 0.06);
  --sans: "Segoe UI", "Helvetica Neue", sans-serif;
  --serif: "Palatino Linotype", Palatino, Georgia, serif;
  --mono: "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 0% -10%, #fff 0%, transparent 55%),
    var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.55;
}

main {
  width: min(880px, calc(100% - 32px));
  margin: 36px auto 72px;
}

.kicker {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--yield);
}

h1 {
  margin: 0 0 16px;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h2 {
  margin: 0 0 10px;
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

p { margin: 0 0 14px; }

.lead { font-size: 1.2rem; }

blockquote {
  margin: 0 0 28px;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ink);
  border-radius: 0 12px 12px 0;
  font-family: var(--mono);
  font-size: 0.95rem;
  line-height: 1.7;
  overflow-x: auto;
}

.token { white-space: nowrap; }

section {
  margin: 0 0 34px;
}

.mark {
  font-family: var(--sans);
  font-weight: 700;
}

.mark.move { color: var(--move); }
.mark.yield { color: var(--yield); }

.player {
  padding: 18px 18px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

button,
select {
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink);
}

button {
  border: 1px solid #cbbba6;
  background: #fff;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}

button.primary {
  background: var(--move);
  border-color: var(--move);
  color: #fffaf3;
}

button:hover { border-color: var(--ink); }

button.primary:hover { filter: brightness(1.08); }

button:disabled {
  opacity: 0.38;
  cursor: default;
  filter: none;
}

button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--move);
  outline-offset: 2px;
}

.speed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--muted);
}

select {
  border: 1px solid #cbbba6;
  background: #fff;
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
}

.scheme {
  margin: 0 0 6px;
  font-family: var(--sans);
  font-size: 1.28rem;
  line-height: 1.85;
  font-variant-numeric: tabular-nums;
}

.scheme .group.is-active {
  background: rgba(20, 99, 92, 0.08);
  border-radius: 8px;
}

.scheme .num {
  display: inline-block;
  min-width: 1.15em;
  text-align: center;
  padding: 0 0.18em;
  border-radius: 999px;
}

.scheme .num.here {
  background: var(--move);
  color: #fffaf3;
}

.scheme .arrow {
  color: #b3a89a;
  padding: 0 0.08em;
}

.scheme .arrow.done.move,
.scheme .arrow.active.move { color: var(--move); }

.scheme .arrow.done.yield,
.scheme .arrow.active.yield {
  color: var(--yield);
  font-weight: 700;
}

.scheme .arrow.active { text-decoration: underline; text-underline-offset: 0.18em; }

.scheme .comma { color: var(--muted); }

.counter,
.cycle-label,
.join-caption {
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--muted);
}

.figure-scroll,
.table-scroll {
  overflow-x: auto;
  margin: 8px 0 12px;
}

.figure-scroll {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbf7f1;
}

svg {
  display: block;
  width: 100%;
  min-width: 680px;
  height: auto;
  font-family: var(--sans);
}

.axis-line {
  stroke: #c9bba8;
  stroke-width: 2;
}

.tick-label {
  fill: var(--ink);
  font-size: 14px;
  text-anchor: middle;
}

.tick-label.anchor { font-weight: 700; }

.tick-label.here { fill: var(--move); }

.point {
  fill: var(--card);
  stroke: var(--ink);
  stroke-width: 2;
}

.point.anchor { fill: var(--ink); }

.arc { fill: none; stroke-linecap: round; }

.arc.out {
  stroke: var(--move);
  stroke-width: 2.5;
}

.arc.back {
  stroke: var(--move-soft);
  stroke-width: 2;
  stroke-dasharray: 5 4;
}

.arc.yield {
  stroke: var(--yield);
  stroke-width: 3;
}

.arc.active { stroke-width: 4; }

.yield-tag {
  fill: var(--yield);
  font-size: 16px;
  font-weight: 700;
  text-anchor: middle;
}

#walker { transition: transform 0.32s cubic-bezier(0.2, 0.7, 0.2, 1); }

svg.instant #walker { transition: none; }

svg.is-yield .halo { fill: rgba(184, 67, 31, 0.16); }
svg.is-yield .core { fill: var(--yield); }

.halo { fill: rgba(20, 99, 92, 0.16); }
.core { fill: var(--move); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--muted);
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--card);
  display: inline-block;
}

.dot.anchor { background: var(--ink); }

.swatch {
  width: 22px;
  height: 0;
  border-top: 3px solid var(--move);
  display: inline-block;
}

.swatch.back { border-top-style: dashed; border-top-color: var(--move-soft); }
.swatch.yield { border-top-color: var(--yield); }

.narration {
  min-height: 3.2em;
  margin: 4px 0 10px;
  font-size: 1.15rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--muted);
}

.chip b {
  font-weight: 700;
  margin-right: 6px;
}

.chip.done { border-color: var(--move); color: var(--move); }
.chip.yield.done { border-color: var(--yield); color: var(--yield); }
.chip.active { box-shadow: inset 0 0 0 1px currentColor; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  font-variant-numeric: tabular-nums;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

thead th {
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.band th {
  background: #f4ecdf;
  font-family: var(--sans);
  font-size: 0.92rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  font-weight: 650;
}

.yield-row td,
.yield-cell {
  color: var(--yield);
  font-weight: 700;
}

.equation {
  font-family: var(--mono);
  font-size: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.join {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 6px 0 8px;
}

.seg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  color: #fffaf3;
  font-family: var(--sans);
  font-weight: 700;
  border-radius: 8px;
}

.seg.a { width: 4.2rem; background: var(--move); }
.seg.b { width: 8.4rem; background: var(--move-soft); }
.seg.c { width: 12.6rem; background: var(--yield); }

.eq {
  font-family: var(--sans);
  font-size: 1.4rem;
  color: var(--muted);
}

.formula {
  font-family: var(--mono);
  font-size: 1.05rem;
  background: var(--ink);
  color: #f6f1e7;
  border-radius: 12px;
  padding: 14px 16px;
}

.subs {
  margin: 0 0 14px;
  padding-left: 1.2rem;
}

.subs li { margin: 4px 0; }

@media (max-width: 640px) {
  body { font-size: 1.05rem; }
  .player { padding: 14px; }
  .scheme { font-size: 1.05rem; }
  .seg.a { width: 3rem; }
  .seg.b { width: 6rem; }
  .seg.c { width: 9rem; }
}

@media (prefers-reduced-motion: reduce) {
  #walker { transition: none; }
}
