:root {
  color-scheme: light;
  --bg: #eeebe5;
  --bg-glow: #f8f6f2;
  --panel: #ffffff;
  --panel-2: #f6f4f0;
  --text: #1f1d1a;
  --muted: #6f695f;
  --border: #e1dcd2;
  --accent: #3a72d8;
  --accent-soft: rgba(58, 114, 216, 0.12);
  --light-square: #efdab8;
  --dark-square: #b48762;
  --last-move: rgba(155, 199, 0, 0.42);
  /* The engine lines, best first: arrows and the marks beside the lines. */
  --pv-1: #1f6fe5;
  --pv-2: #0f9e8e;
  --pv-3: #9a4fd8;
  --eval-white: #f6f6f4;
  --eval-black: #3b3936;
  --eval-mid: rgba(214, 60, 46, 0.55);
  --draw: #a7a29a;
  --eval-good-white: #1f8a3b;
  --eval-good-black: #c23a2c;
  --title: #c98a1b;
  --live: #d6342a;
  --shadow: 0 1px 2px rgba(30, 25, 15, 0.06), 0 6px 20px rgba(30, 25, 15, 0.08);
  --board-shadow: 0 2px 6px rgba(30, 25, 15, 0.18), 0 14px 34px rgba(30, 25, 15, 0.16);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141311;
    --bg-glow: #1d1c19;
    --panel: #201f1c;
    --panel-2: #191816;
    --text: #e9e6e0;
    --muted: #9c968b;
    --border: #34322d;
    --accent: #78a6f5;
    --accent-soft: rgba(120, 166, 245, 0.14);
    --eval-white: #e8e6e1;
    --eval-black: #0d0c0b;
    --draw: #77736c;
    --eval-good-white: #5fcf7f;
    --eval-good-black: #f2796b;
            --title: #e8aa3c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
    --board-shadow: 0 2px 8px rgba(0, 0, 0, 0.45), 0 16px 40px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.invisible { visibility: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 30% -10%, var(--bg-glow), var(--bg)) fixed, var(--bg);
  color: var(--text);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
button { font: inherit; }

/* MARK: Header */

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 16px 4px;
}
.logo { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25)); }
.event { min-width: 0; flex: 1; }
#tour {
  display: block;
  /* On one line: a little smaller on a phone rather than cut off. */
  font-size: clamp(0.92rem, 4.1vw, 1.05rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tagline { font-size: 0.72rem; color: var(--muted); line-height: 1.3; }
/* A wide screen: title and tagline on one line ("WCC 2026 – Gukesh vs Sindarov – Live AI …"). */
@media (min-width: 821px) {
  .event > #tour, .event > .tagline { display: inline; }
  .event > .tagline { font-size: 1.05rem; font-weight: 400; line-height: 1.25; }
  .event > .tagline::before { content: " – "; }
}
/* A phone: the title gets the whole width, the badge sits beside the round. */
@media (max-width: 600px) {
  .top {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "logo title title" "logo tagline tagline" "logo sub badge";
    gap: 0 12px;
    align-items: center;
  }
  .top .logo { grid-area: logo; }
  .top .event { display: contents; }
  #tour { grid-area: title; }
  .top .tagline { grid-area: tagline; }
  .top .sub { grid-area: sub; }
  .top .badge { grid-area: badge; justify-self: end; }
}
.sub { display: flex; flex-wrap: wrap; gap: 0 10px; font-size: 0.85rem; color: var(--muted); }
#opening:not(:empty)::before { content: "·"; margin-right: 10px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  white-space: nowrap;
  flex: none;
}
.badge.live { color: #fff; background: var(--live); border-color: var(--live); letter-spacing: 0.06em; }
.badge.live::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.6s ease-in-out infinite;
}
.badge.error { color: var(--live); border-color: var(--live); }
@keyframes pulse { 50% { opacity: 0.25; } }

/* MARK: Match bar */

.match-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 16px 0;
}
.match-bar .step {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.match-bar .step:disabled { opacity: 0.35; cursor: default; }
.chips {
  display: flex;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  padding: 2px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 42px;
  padding: 3px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
a.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip-number { font-weight: 750; font-size: 0.85rem; }
.chip-result { font-size: 0.68rem; color: var(--muted); white-space: nowrap; }
.chip.future { opacity: 0.45; background: transparent; }
.chip.next { border-style: dashed; border-color: var(--accent); }
.chip.pending .chip-result::after { content: " ·"; color: var(--accent); }
.chip.live { border-color: var(--live); }
.chip.live .chip-result { color: var(--live); font-weight: 700; text-transform: uppercase; }
.chip.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.current .chip-result { color: rgba(255, 255, 255, 0.85); }
.match-score {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .match-bar { flex-wrap: wrap; }
  .chips { flex: 1; }
  .match-score { width: 100%; justify-content: center; order: 3; font-size: 0.9rem; }
}

/* MARK: Teaser */

.teaser {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}
.teaser-hero { text-align: center; padding: 22px 16px; }
.kicker {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.countdown {
  display: flex;
  justify-content: center;
  gap: clamp(10px, 4vw, 28px);
  margin: 10px 0 4px;
  font-variant-numeric: tabular-nums;
}
.countdown .unit { display: flex; flex-direction: column; align-items: center; min-width: 2.2em; }
.countdown b { font-size: clamp(2.2rem, 9vw, 3.6rem); font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.countdown small { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.countdown-note { font-size: 1.4rem; font-weight: 700; }
.teaser-when { color: var(--text); font-size: 0.95rem; }
.teaser-when .muted { color: var(--muted); }
.pairing {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  max-width: 640px;
  margin: 18px auto 0;
}
.pairing-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 12px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  min-width: 0;
}
.pairing-color {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.pairing .swatch { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.35); }
.pairing .swatch.white { background: #f8f8f6; }
.pairing .swatch.black { background: #232220; }
.pairing-name { font-weight: 700; margin-top: 4px; overflow-wrap: anywhere; }
.pairing-name .title {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0 4px;
  margin-right: 6px;
  border-radius: 4px;
  color: var(--title);
  border: 1px solid currentColor;
  vertical-align: 2px;
}
.pairing-extra {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.photo.medium {
  width: 96px;
  height: 96px;
  margin-bottom: 8px;
  box-shadow: 0 0 0 3px var(--panel), 0 0 0 4px var(--border), 0 4px 14px rgba(0, 0, 0, 0.2);
}
@media (max-width: 480px) {
  .photo.medium { width: 72px; height: 72px; }
}
.pairing-score { display: flex; flex-direction: column; align-items: center; }
.pairing-score small { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.pairing-score b { font-size: 1.3rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 480px) {
  .pairing { grid-template-columns: 1fr; }
}

.insights {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 12px;
}
.insight {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.insight h3 { margin: 0; font-size: 1rem; }
/* Drawn from what people say (headlines, opinions, bets): marked as such. */
.insight.talk { border-style: dashed; }
.insight-tag {
  align-self: flex-start;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.insight-tags { display: flex; flex-wrap: wrap; gap: 6px; }
/* Added from a later source. */
.insight-tag.new { border-style: solid; border-color: var(--accent); color: var(--accent); }
.insight p { margin: 0; line-height: 1.5; }
.insight-source { margin-top: auto; font-size: 0.78rem; color: var(--muted); overflow-wrap: anywhere; }
.insight-source summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.insight-source summary::-webkit-details-marker { display: none; }
.insight-source summary::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.15s;
}
.insight-source[open] summary::after { transform: translateY(1px) rotate(-135deg); }
.insight-source summary:hover { color: var(--text); }
.insight-source[open] summary { margin-bottom: 4px; }
.insight-source div + div { margin-top: 2px; }
.insights .placeholder { color: var(--muted); }

.teaser-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) {
  .teaser-columns { grid-template-columns: minmax(0, 1fr); }
}
.so-far, .news { list-style: none; margin: 0; padding: 0; }
.so-far li, .news li { padding: 8px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.so-far li:last-child, .news li:last-child { border-bottom: none; }
.so-far-game { display: flex; gap: 10px; align-items: baseline; color: var(--text); }
.so-far-round { font-weight: 700; color: var(--accent); white-space: nowrap; }
.so-far-players { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.so-far-result { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.so-far-details, .news-meta { font-size: 0.8rem; color: var(--muted); }
.news a { overflow-wrap: anywhere; }

/* MARK: About */

.about {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 16px 32px;
  line-height: 1.6;
}
.about h1 { margin: 0 0 8px; font-size: 1.4rem; line-height: 1.3; }
.about h2 { margin-bottom: 8px; }
.about p { margin: 0 0 10px; }
.about p:last-child { margin-bottom: 0; }
.about ul { margin: 0; padding-left: 20px; }
.about li + li { margin-top: 8px; }
.about code { font-size: 0.9em; padding: 1px 5px; border-radius: 4px; background: var(--panel-2); }
.about .contact { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; }
.about .contact li + li { margin-top: 0; }
a.badge:hover { text-decoration: none; border-color: var(--accent); }

/* MARK: Footer */

.ai-note { margin: 10px 0 0; font-size: 0.72rem; color: var(--muted); }

.footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 24px;
  font-size: 0.78rem;
  color: var(--muted);
}

/* MARK: Layout */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 660px) minmax(300px, 1fr);
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}

.board-area { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.board-row { display: flex; gap: 10px; }

/* MARK: Players */

.player {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding-left: 28px;
  min-width: 0;
}
.player .swatch {
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.35);
}
.player .swatch.white { background: #f8f8f6; }
.player .swatch.black { background: #232220; }
/* The players' photos and flags. */
.photo { flex: none; border-radius: 50%; object-fit: cover; background: var(--panel-2); }
.photo.small { width: 32px; height: 32px; box-shadow: 0 0 0 2px var(--panel), 0 1px 4px rgba(0, 0, 0, 0.25); }
.flag {
  flex: none;
  height: 14px;
  width: auto;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
  vertical-align: -2px;
}
.player .title {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--title);
  border: 1px solid currentColor;
}
.player .name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .elo { color: var(--muted); font-variant-numeric: tabular-nums; }
.player .material { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.player .result {
  font-weight: 800;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.player .clock {
  margin-left: auto;
  font-size: 1.25rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  padding: 3px 14px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  box-shadow: var(--shadow);
  min-width: 5.2em;
  text-align: center;
}
.player .clock.to-move { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.player .clock.running { background: var(--accent); border-color: var(--accent); color: #fff; }
.player .clock.low.running { background: var(--live); border-color: var(--live); }

/* MARK: Eval bar */

.eval-bar {
  position: relative;
  width: 18px;
  flex: none;
  background: var(--eval-black);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--board-shadow);
}
.eval-bar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: var(--eval-mid);
  z-index: 1;
}
.eval-white {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50%;
  background: var(--eval-white);
  transition: height 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.eval-bar.flipped .eval-white { top: 0; bottom: auto; }
.eval-label {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  font-size: 9px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.eval-label.at-bottom { bottom: 4px; color: #333; }
.eval-label.at-top { top: 4px; color: #ddd; }

/* MARK: Board */

.board-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  aspect-ratio: 1;
  border-radius: 6px;
  box-shadow: var(--board-shadow);
}
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
  border-radius: 6px;
  overflow: hidden;
  user-select: none;
}
.square { position: relative; }
.square.light { background: var(--light-square); }
.square.dark { background: var(--dark-square); }
.square.last::after { content: ""; position: absolute; inset: 0; background: var(--last-move); }
.square.check {
  background-image: radial-gradient(circle, rgba(255, 0, 0, 0.85) 0%, rgba(231, 0, 0, 0.5) 30%, rgba(169, 0, 0, 0) 70%);
}
.square img { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.square .coord {
  position: absolute;
  font-size: clamp(8px, 1.5vw, 11px);
  font-weight: 700;
  z-index: 2;
  line-height: 1;
}
.square .coord.rank { top: 3px; left: 3px; }
.square .coord.file { bottom: 3px; right: 4px; }
.square.light .coord { color: var(--dark-square); }
.square.dark .coord { color: var(--light-square); }

.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.arrow { stroke: rgba(255, 255, 255, 0.35); stroke-width: 0.025; stroke-linejoin: round; }
.arrow.pv-1 { fill: var(--pv-1); opacity: 0.85; }
.arrow.pv-2 { fill: var(--pv-2); opacity: 0.72; }
.arrow.pv-3 { fill: var(--pv-3); opacity: 0.65; }

.no-game {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  border-radius: 6px;
  background: rgba(10, 10, 10, 0.6);
  backdrop-filter: blur(2px);
  color: #fff;
  font-size: 1.1rem;
}

/* MARK: Controls */

.controls { display: flex; gap: 6px; padding-left: 28px; }
.controls button {
  flex: 1;
  padding: 8px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.15s, transform 0.05s;
}
.controls button:hover:not(:disabled) { background: var(--panel-2); }
.controls button:active:not(:disabled) { transform: translateY(1px); }
.controls button:disabled { opacity: 0.4; cursor: default; }
.controls #live { font-weight: 700; }
.controls #live.active { background: var(--live); border-color: var(--live); color: #fff; }

/* MARK: Panels */

.side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.stats { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.hint { margin: 10px 0 0; font-size: 0.82rem; color: var(--muted); }

/* Engine */

.engine-head { display: flex; align-items: center; gap: 14px; }
.big-eval {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  min-width: 3.6em;
}
/* A tablebase win: "White wins", "tablebase" below. */
.big-eval.tb { font-size: 1.2rem; letter-spacing: 0; }
.big-eval.tb small { display: block; margin-top: 3px; font-size: 0.6em; font-weight: 600; color: var(--muted); }
.engine-panel.still .big-eval.tb { font-size: 1.1rem; }
.engine-meta { min-width: 0; }
/* The engine's name links to its repository: it looks like a link. */
.engine-name { display: inline-block; font-weight: 700; color: var(--accent); }
.engine-name::after { content: " ↗"; font-weight: 400; font-size: 0.85em; }
.engine-name:hover { text-decoration: underline; text-underline-offset: 2px; }
/* A finished or earlier game: one row, no win/draw/loss bar. */
.engine-panel.still { padding-top: 12px; padding-bottom: 10px; }
.engine-panel.still .big-eval { font-size: 1.6rem; }
.engine-panel.still .lines { margin-top: 10px; }
.engine-panel.still .lines li { min-height: 0; padding: 6px 0 0; }
.engine-meta .stats { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wdl { margin-top: 12px; }
.wdl-bar {
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.wdl-bar span { transition: flex-grow 0.6s ease; flex-basis: 0; }
.wdl-w { background: var(--eval-white); }
.wdl-d { background: var(--draw); }
.wdl-l { background: var(--eval-black); }
.wdl-text {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.lines {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}
.lines li {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  min-height: 2.6em;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.lines li:last-child { border-bottom: none; padding-bottom: 0; }
.lines .pv-mark { flex: none; align-self: stretch; width: 4px; border-radius: 2px; }
.pv-mark.pv-1 { background: var(--pv-1); }
.pv-mark.pv-2 { background: var(--pv-2); }
.pv-mark.pv-3 { background: var(--pv-3); }
.pv-mark.pv-4 { background: var(--border); }
.lines .score {
  flex: none;
  min-width: 4.4em;
  padding: 2px 0;
  border-radius: 6px;
  text-align: center;
  font-weight: 750;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.score.for-white { background: var(--eval-white); color: #222; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.score.for-black { background: var(--eval-black); color: #eee; }
.score.even { background: var(--panel-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.lines .pv { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lines .pv b { font-weight: 700; }
.lines .depth { flex: none; margin-left: auto; font-size: 0.72rem; color: var(--muted); }
.lines li.placeholder { color: var(--muted); justify-content: center; }

/* Commentary */

.commentary-panel .panel-head { margin-bottom: 6px; }
/* Room for a typical comment, so the panel rarely changes height as
   comments come and go; more comments on a move scroll, the latest shown. */
.commentary {
  position: relative;  /* the entries' offsetTop, to scroll to them */
  min-height: calc(1.5em * 5);
  max-height: calc(1.5em * 14);
  overflow-y: auto;
  overscroll-behavior: contain;
  line-height: 1.5;
}
.commentary.empty { color: var(--muted); }
/* The whole game, the move shown marked (and the others a click away). */
.commentary .entry {
  margin: 0;
  padding: 6px 8px 6px 10px;
  border-left: 3px solid transparent;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
}
.commentary .entry + .entry { margin-top: 2px; }
.commentary .entry:not(.current):hover { background: var(--accent-soft); }
.commentary .entry.current { border-left-color: var(--accent); background: var(--accent-soft); cursor: default; }
/* The intro and the summary, a little apart from the moves'. */
.commentary .entry.intro, .commentary .entry.result {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 8px;
  border-left: 0;
  background: var(--panel-2);
  box-shadow: inset 0 0 0 1px var(--border);
}
.commentary .entry.intro:first-child { margin-top: 0; }
.commentary .entry.result:last-child { margin-bottom: 0; }
.commentary .entry.intro.current, .commentary .entry.result.current { box-shadow: inset 0 0 0 2px var(--accent); }
.commentary .entry.intro .comment-label, .commentary .entry.result .comment-label {
  display: block;
  margin-bottom: 2px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.commentary .comment-label { font-weight: 650; color: var(--muted); margin-right: 6px; }
/* A move's quick first word (no model), before the commentator's own. */
.commentary .quick-word { color: var(--muted); }
.commentary .comment-move {
  font: inherit;
  font-weight: 650;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  margin-right: 6px;
  cursor: pointer;
}
.commentary .comment-move:disabled { color: var(--text); cursor: default; }
/* The move shown has no comment yet: its line says it is being written. */
.commentary .entry.pending { color: var(--muted); }
.commentary .writing { color: var(--muted); font-style: italic; white-space: nowrap; }
/* The AI's words, one shown: all in one place, as wide as the longest. */
.ai-text { display: inline-grid; }
.ai-text > span { grid-area: 1 / 1; }
.ai-text > span:not(.shown) { visibility: hidden; }
.commentary .writing::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 0.1em;
  animation: pulse 1.6s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .commentary .writing::before { animation: none; }
}
.engine-link { color: inherit; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 2px; }

/* Moves */

.moves-status { margin-left: auto; }
.moves-panel { flex: 1; display: flex; flex-direction: column; min-height: 220px; container-type: inline-size; }

.moves {
  display: grid;
  grid-template-columns: 2.4em 1fr 1fr;
  align-content: start;
  position: relative;
  overflow-y: auto;
  /* Stacked, the list fits on screen whole, and scrolling it never hands
     off to the page once it reaches its top or bottom. */
  max-height: min(430px, 60vh);
  max-height: min(430px, 60dvh);
  overscroll-behavior: contain;
  font-variant-numeric: tabular-nums;
}
.moves .number {
  color: var(--muted);
  padding: 4px 0 4px 4px;
  font-size: 0.85rem;
  background: var(--panel-2);
  border-radius: 6px 0 0 6px;
  margin: 1px 0;
}
.moves .move {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 8px;
  margin: 1px 0 1px 2px;
  border-radius: 6px;
  cursor: pointer;
  min-width: 0;
}
.moves .move:hover { background: var(--accent-soft); }
.moves .move.current { background: var(--accent); color: #fff; }
.moves .move .san { font-weight: 650; }
.moves .move .ev {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 700;
}
.moves .move .ev.white { color: var(--eval-good-white); }
.moves .move .ev.black { color: var(--eval-good-black); }
.moves .move .ev.level { color: var(--muted); }
.moves .move .clk { font-size: 0.72rem; opacity: 0.65; min-width: 3.6em; text-align: right; }
.moves .move.current .ev, .moves .move.current .clk { color: #fff; opacity: 0.9; }
.moves .empty { grid-column: 1 / -1; color: var(--muted); padding: 8px 0; }
.moves .game-end {
  grid-column: 1 / -1;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  text-align: center;
}
.moves .game-end b { color: var(--text); }
/* Too narrow for the clocks beside each move. */
@container (max-width: 420px) {
  .moves .move .clk { display: none; }
}

/* Side by side: the side column is exactly as tall as the board column
   (contain: size keeps its content from growing the row), and the move
   list scrolls within it, so both end level. */
@media (min-width: 901px) {
  .side { contain: size; }
  /* The move list keeps room for about eight moves; the commentary gives
     way first and scrolls within what is left. */
  .moves-panel { flex: 1 0 300px; min-height: 0; }
  .moves { flex: 1; min-height: 0; max-height: none; }
  .commentary-panel { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .commentary { flex: 1 1 auto; min-height: calc(1.5em * 3); }
}

@media (max-width: 480px) {
  #opening { display: none; }
  .player, .controls { padding-left: 0; }
  /* Room for the name beside the photo and flag. */
  .player .elo, .player .title, .player .swatch { display: none; }
  .eval-bar { width: 12px; }
  .eval-label { display: none; }
  .big-eval { font-size: 1.6rem; }
}
