﻿:root {
  /* Light mode — aged-parchment warmth with deep espresso ink and gilt accents.
     Goal: reads like a fancy restaurant menu / vintage reference card. */
  --page-cream: #f5ead0;
  --page-sand: #e8d4a7;
  --page-ink: #2a1d12;
  --page-muted: #6b5a49;
  --panel-bg: rgba(253, 246, 229, 0.88);
  --panel-border: rgba(48, 32, 18, 0.14);
  --panel-shadow: 0 28px 80px rgba(50, 30, 10, 0.16);
  --navy: #1b2a44;
  --navy-soft: #2d3e5d;
  --teal: #2b756a;
  /* Saturated partisan hues that still land above 4.5:1 contrast on the warm
     cream page. Blue/red/green match the dark-mode intensity so neither theme
     feels flatter than the other. */
  --blue: #0f52c4;
  --red: #c91d25;
  --green: #128a3d;
  --amber: #b78a3d;
  --warm: #c4912f;
  --warm-deep: #8a4a22;
  --sea: #2b756a;
  --card-radius: 22px;
  --chip-radius: 999px;
  --transition: 200ms ease;
  --heading-font: "Fraunces", "Playfair Display", Georgia, serif;
  --body-font: "Space Grotesk", "Segoe UI Variable Text", system-ui, sans-serif;
  --mono-font: "JetBrains Mono", "Fira Code", Consolas, monospace;

  /* Board node gradient stops (referenced by SVG <defs>) */
  --node-top: #fffaea;
  --node-mid: #f5e2b3;
  --node-bottom: #c59a4b;
  --node-sel-top: #fff4c8;
  --node-sel-mid: #e0a93c;
  --node-sel-bottom: #8a5820;
  --node-gnd-top: #4a5d80;
  --node-gnd-mid: #1a2840;
  --node-gnd-bottom: #050c18;
  --node-shadow-color: #1a0f05;
  --board-bg: #f7eccc;
  --board-grid: rgba(50, 30, 12, 0.07);

  /* Ambient body-background glows */
  --body-glow-1: rgba(196, 145, 47, 0.28);
  --body-glow-2: rgba(43, 117, 106, 0.18);

  /* Panel hairlines for chips, dividers, grid lines */
  --ink-soft-1: rgba(42, 29, 18, 0.06);
  --ink-soft-2: rgba(42, 29, 18, 0.10);
  --ink-soft-3: rgba(42, 29, 18, 0.18);
}

:root.theme-dark {
  /* Rich midnight palette inspired by a vintage moviehouse: deep navy-black
     background with warm-amber and sea-green accent glows. Gold is the primary
     accent; partisan edges pop in saturated coastal hues. */
  --page-cream: #0d1724;
  --page-sand: #060d18;
  --page-ink: #eff4f9;
  --page-muted: #b6c2d2;
  --panel-bg: rgba(10, 20, 31, 0.78);
  --panel-border: rgba(255, 222, 145, 0.14);
  --panel-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
  /* --navy keeps enough blue saturation to read as text on dark panels AND to
     give buttons a solid shape with white text. The warm brass accents live on
     dedicated --warm / --warm-deep / --sea / --amber vars. */
  --navy: #6d8cce;
  --navy-soft: #9fb5e0;
  --teal: #5ed7cd;
  /* Near-primary partisan hues so edges read as saturated painted strokes, not
     dusty pastels, even on the warm brass nodes. The per-color glow filter
     below gives them an ambient halo on dark mode. */
  --blue: #2b7bff;
  --red: #ff2f3a;
  --green: #15d67a;
  --amber: #ffd04d;
  --warm: #ffd04d;
  --warm-deep: #ff7a45;
  --sea: #18a58b;

  /* Non-ground nodes are polished brass-parchment so they pop against the dark
     board. Ground keeps a bright rim on a deep core. */
  --node-top: #fff3c4;
  --node-mid: #e9bc63;
  --node-bottom: #8a5618;
  --node-sel-top: #ffeba3;
  --node-sel-mid: #ff9a3c;
  --node-sel-bottom: #6a3208;
  --node-gnd-top: #c2d1f0;
  --node-gnd-mid: #24375a;
  --node-gnd-bottom: #030811;
  --node-shadow-color: #000000;
  --board-bg: #0a1220;
  --board-grid: rgba(255, 220, 150, 0.07);

  /* Warm amber + sea-green backdrop glows (REF signature look). */
  --body-glow-1: rgba(255, 180, 85, 0.22);
  --body-glow-2: rgba(24, 165, 139, 0.20);

  --ink-soft-1: rgba(255, 220, 160, 0.08);
  --ink-soft-2: rgba(255, 220, 160, 0.14);
  --ink-soft-3: rgba(255, 220, 160, 0.26);

  --ground-path-color: rgba(255, 220, 160, 0.42);
  --ground-shadow-color: rgba(0, 0, 0, 0.72);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--body-font);
  color: var(--page-ink);
  letter-spacing: 0.005em;
  background:
    radial-gradient(circle at 18% 22%, var(--body-glow-1), transparent 28%),
    radial-gradient(circle at 82% 14%, var(--body-glow-2), transparent 24%),
    linear-gradient(180deg, var(--page-cream) 0%, var(--page-sand) 100%);
  min-height: 100vh;
}

/* Elegant heading voice: Fraunces with tight leading and refined tracking. */
h1, h2, h3, h4, h5 {
  font-family: var(--heading-font);
  letter-spacing: -0.015em;
  font-weight: 600;
}

code, pre, .mono {
  font-family: var(--mono-font);
  letter-spacing: -0.01em;
}

/* Small uppercase eyebrow-style labels everywhere (menu-card vibe). */
.eyebrow,
.group-label,
.metric-label,
.hero-badges span {
  font-family: var(--body-font);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
}

/* Drifting backdrop orbs — subtle depth, respects reduced motion. */
.site-shell {
  position: relative;
}

.site-shell::before,
.site-shell::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  filter: blur(80px);
  pointer-events: none;
  z-index: -1;
  animation: orb-drift 22s ease-in-out infinite;
}

.site-shell::before {
  top: 6rem;
  right: -10rem;
  width: 28rem;
  height: 28rem;
  background: radial-gradient(circle, var(--warm, #c4912f) 0%, transparent 72%);
  opacity: 0.22;
}

.site-shell::after {
  bottom: 8rem;
  left: -12rem;
  width: 26rem;
  height: 26rem;
  background: radial-gradient(circle, var(--sea, #2b756a) 0%, transparent 72%);
  opacity: 0.22;
  animation-delay: -9s;
}

:root.theme-dark .site-shell::before { opacity: 0.3; }
:root.theme-dark .site-shell::after { opacity: 0.28; }

@keyframes orb-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-30px, 20px) scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .site-shell::before,
  .site-shell::after { animation: none; }
}

button, input, textarea { font: inherit; }

/* Color coding */
.color-blue { color: var(--blue); font-weight: 700; }
.color-red { color: var(--red); font-weight: 700; }
.color-green { color: var(--green); font-weight: 700; }

/* Layout shell */
.site-shell {
  width: min(1500px, calc(100vw - 36px));
  margin: 20px auto 32px;
}

/* Hero */
.hero {
  margin-bottom: 20px;
  padding: 24px 28px;
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  background:
    linear-gradient(160deg, rgba(255, 252, 246, 0.78), rgba(248, 236, 213, 0.72)),
    linear-gradient(120deg, rgba(19, 33, 53, 0.05), rgba(255, 255, 255, 0));
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(12px);
  animation: rise-in 420ms ease;
}

:root.theme-dark .hero {
  background:
    linear-gradient(160deg, rgba(14, 25, 40, 0.88), rgba(10, 18, 30, 0.82)),
    radial-gradient(circle at 85% 20%, rgba(255, 208, 77, 0.10), transparent 55%);
  border-color: rgba(255, 222, 145, 0.18);
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.hero-copy { display: grid; gap: 6px; }

.eyebrow, .panel-kicker, .group-label, .status-label, .metric-label, .detail-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--page-muted);
  margin: 0;
}

.hero h1, .panel h2, .moves-panel h3 {
  margin: 0;
  font-family: var(--heading-font);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.hero h1 {
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1;
}

.hero-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.metric-card {
  flex: 1;
  min-width: 140px;
  display: grid;
  gap: 4px;
  padding: 14px 18px;
  border-radius: 18px;
  color: #f5f6f8;
  background: linear-gradient(150deg, var(--navy), var(--navy-soft));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Metric cards live on the dark navy gradient — every label inside needs to be
   legible on that surface regardless of theme. */
.metric-card .metric-label,
.metric-card .eyebrow {
  color: rgba(255, 240, 200, 0.82);
}

.metric-value {
  font-family: var(--heading-font);
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.metric-card-status { min-width: 100px; flex: 0.5; }

/* Mode toggle */
.hero-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 22px;
  border: 1px solid var(--panel-border);
  background: rgba(19, 33, 53, 0.06);
  color: var(--page-ink);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.theme-toggle:hover {
  background: rgba(19, 33, 53, 0.12);
}

:root.theme-dark .theme-toggle {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

:root.theme-dark .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
}

.theme-toggle-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--amber), #8c5a12 70%);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35) inset;
}

:root[data-theme="light"] .theme-toggle-icon {
  background: radial-gradient(circle at 35% 30%, #fff2c4, var(--amber));
}

:root[data-theme="dark"] .theme-toggle-icon {
  background: radial-gradient(circle at 70% 30%, #e5edff, #2a3d5d 70%);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15) inset;
}

.mode-toggle {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 22px;
  background: rgba(19, 33, 53, 0.06);
  position: relative;
}
.mode-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-radius: 18px;
  background: linear-gradient(160deg, var(--navy), var(--navy-soft));
  box-shadow: 0 4px 14px rgba(19, 33, 53, 0.2);
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1), width 0.26s, height 0.26s;
  pointer-events: none;
  z-index: 0;
}

:root.theme-dark .mode-toggle { background: rgba(255, 255, 255, 0.06); }

/* Small "NEW" badge — gilt-stamp pinned to top-right corner of a button or next
   to a section title. Warm amber gradient with a faint sheen animation. */
.new-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--body-font);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe08a 0%, #ff9a3c 50%, #c06c28 100%);
  background-size: 200% 200%;
  color: #2a1700;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow:
    0 2px 6px rgba(255, 154, 60, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  line-height: 1;
  pointer-events: none;
  animation: new-badge-sheen 3.2s ease-in-out infinite;
}

@keyframes new-badge-sheen {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .new-badge { animation: none; }
}

.has-new-badge {
  position: relative;
  padding-right: 42px;
}

.has-new-badge .new-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  transform: scale(0.95);
  transform-origin: top right;
}

.theme-toggle.has-new-badge {
  padding-right: 34px;
}

/* Inline badge next to a section label (e.g. Component Breakdown). */
.group-label .new-badge {
  margin-left: 10px;
  transform: translateY(-1px);
}

:root.theme-dark .new-badge {
  background: linear-gradient(135deg, #ffe08a 0%, #ff9a3c 50%, #a8551a 100%);
  background-size: 200% 200%;
  box-shadow:
    0 2px 10px rgba(255, 154, 60, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.mode-button {
  border: 0;
  border-radius: 18px;
  padding: 12px 22px;
  background: transparent;
  color: var(--page-muted);
  cursor: pointer;
  font-weight: 600;
  transition: all var(--transition);
  position: relative;
  z-index: 1;
}

.mode-button.is-active {
  color: #f7fbff;
}

.mode-button:hover:not(.is-active) {
  background: rgba(19, 33, 53, 0.1);
  color: var(--page-ink);
}

/* Header quick toggles (Play): pick your side + who moves first, right beside
   the mode buttons so starting a game never means digging through a panel. */
.quick-toggles {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.quick-group { display: flex; align-items: center; gap: 7px; }
.quick-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--page-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.quick-seg {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 16px;
  background: rgba(19, 33, 53, 0.06);
}
:root.theme-dark .quick-seg { background: rgba(255, 255, 255, 0.06); }
.quick-btn {
  border: 0;
  border-radius: 13px;
  padding: 6px 13px;
  background: transparent;
  color: var(--page-muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.82rem;
  transition: all var(--transition);
}
.quick-btn:hover:not(.is-active) { background: rgba(19, 33, 53, 0.1); color: var(--page-ink); }
.quick-btn.is-active[data-quick-side="left"] { color: #fff; background: var(--blue); }
.quick-btn.is-active[data-quick-side="right"] { color: #fff; background: var(--red); }
.quick-toggle-btn {
  border: 1px solid rgba(19, 33, 53, 0.18);
  border-radius: 14px;
  padding: 6px 14px;
  background: transparent;
  color: var(--page-muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.82rem;
  transition: all var(--transition);
}
:root.theme-dark .quick-toggle-btn { border-color: rgba(255, 255, 255, 0.2); }
.quick-toggle-btn.is-on {
  color: #f7fbff;
  background: linear-gradient(160deg, var(--navy), var(--navy-soft));
  border-color: transparent;
}

/* Persistent ink marks (Ink + Dust effect): a standalone SVG layer the board
   re-render never wipes. Same viewBox + inset:0 as the board, so puddle coords
   match board coords exactly. multiply/screen lets ink soak into the ground. */
.ink-mark-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 6;
  pointer-events: none;
  overflow: visible;
}
.ink-mark { mix-blend-mode: multiply; }
:root.theme-dark .ink-mark { mix-blend-mode: screen; }

/* Foldable effect / style controls — keep the toolbar compact by default; the
   "More effects" toggle reveals the full Cut FX / Shape-Locked / Visuals sets. */
.fx-hidden { display: none !important; }
.fx-ink-marks { display: flex; flex-direction: column; gap: 4px; }
.fx-fold-toggle { align-self: center; white-space: nowrap; }

/* Main stack */
.main-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Split view: board + mode panels on the left, the games bar on the right. The
   games bar is master (category titles + preview thumb) + detail (game cards).
   Folding shrinks it to a slim strip; the grid track animates so the board
   widens/narrows smoothly. One column in Auto and on narrow screens. */
.main-stack.has-library { grid-template-columns: minmax(0, 1fr) 478px; }
.main-stack.has-library.library-folded { grid-template-columns: minmax(0, 1fr) 54px; }
.main-column {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.library-bar {
  position: sticky;
  top: 16px;
  align-self: start;
  max-height: calc(100vh - 28px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.library-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.library-title { margin: 0; }
.lib-fold-btn {
  border: 0;
  background: rgba(19, 33, 53, 0.06);
  color: var(--page-muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  padding: 7px 11px;
  border-radius: 10px;
  transition: background var(--transition), color var(--transition);
}
.lib-fold-btn:hover { background: rgba(19, 33, 53, 0.12); color: var(--page-ink); }
:root.theme-dark .lib-fold-btn { background: rgba(255, 255, 255, 0.08); }
.lib-fold-icon { display: inline-block; transition: transform 0.25s ease; }
.main-stack.library-folded .lib-fold-icon { transform: rotate(180deg); }

.library-search-wrap { margin: 12px 0 6px; flex: 0 0 auto; }
.library-search {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(19, 33, 53, 0.16);
  background: rgba(255, 255, 255, 0.6);
  color: var(--page-ink);
  font: inherit;
}
.library-search:focus { outline: 2px solid rgba(31, 143, 135, 0.5); outline-offset: 1px; }
:root.theme-dark .library-search {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
  color: rgba(232, 238, 250, 0.96);
}

/* Master (category list) | detail (cards for the selected category). */
.library-body {
  display: grid;
  grid-template-columns: 122px minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  flex: 1 1 auto;
}
.lib-master {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  min-height: 0;
  padding-right: 2px;
}
.lib-cat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  border: 1px solid transparent;
  background: rgba(19, 33, 53, 0.04);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.lib-cat:hover { background: rgba(19, 33, 53, 0.08); }
.lib-cat.is-active { background: rgba(31, 143, 135, 0.12); border-color: rgba(31, 143, 135, 0.5); }
:root.theme-dark .lib-cat { background: rgba(255, 255, 255, 0.05); }
:root.theme-dark .lib-cat.is-active { background: rgba(64, 188, 178, 0.18); border-color: rgba(64, 188, 178, 0.6); }
.lib-cat-thumb {
  display: block;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(19, 33, 53, 0.05);
  aspect-ratio: 5 / 3;
}
.lib-cat-thumb svg { width: 100%; height: 100%; display: block; }
.lib-cat-text { display: flex; flex-direction: column; gap: 1px; }
.lib-cat-text strong { font-size: 0.82rem; line-height: 1.15; }
.lib-cat-count { font-size: 0.68rem; color: var(--page-muted); }

.lib-detail {
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}
.lib-detail-head { display: flex; align-items: baseline; gap: 8px; }
.lib-detail-head strong { font-family: var(--heading-font); font-size: 1rem; }
.lib-detail-count { font-size: 0.72rem; color: var(--page-muted); }
.library-hint {
  margin: 4px 0 8px;
  font-size: 0.8rem;
  color: var(--page-muted);
  line-height: 1.4;
}

/* Folded: slim strip — only the fold toggle shows. */
.main-stack.library-folded .library-search-wrap,
.main-stack.library-folded .library-body,
.main-stack.library-folded .library-title { display: none; }
.main-stack.library-folded .library-bar { padding-left: 8px; padding-right: 8px; }

@media (max-width: 1100px) {
  .main-stack.has-library,
  .main-stack.has-library.library-folded { grid-template-columns: minmax(0, 1fr); }
  .library-bar { position: static; max-height: none; }
  .main-stack.library-folded .library-search-wrap { display: block; }
  .main-stack.library-folded .library-body { display: grid; }
  .main-stack.library-folded .library-title { display: block; }
}

/* Panel base */
.panel {
  border: 1px solid var(--panel-border);
  border-radius: var(--card-radius);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(14px);
  animation: rise-in 520ms ease both;
  padding: 22px;
}

.panel-heading { display: grid; gap: 4px; }

/* Board panel */
.board-panel { padding: 18px; }

.board-frame {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  background:
    linear-gradient(0deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.28)),
    radial-gradient(circle at top, rgba(255, 248, 236, 0.9), rgba(230, 216, 187, 0.76));
  border: 1px solid rgba(19, 33, 53, 0.1);
}

:root.theme-dark .board-frame {
  background:
    linear-gradient(0deg, rgba(10, 20, 36, 0.45), rgba(10, 20, 36, 0.45)),
    radial-gradient(circle at top, #16253d, #0a1324);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Share toast — slides up from the bottom-right after Share Link click */
.share-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 240;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--panel-bg);
  border: 1px solid color-mix(in srgb, var(--green) 35%, var(--panel-border));
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(12px);
  display: grid;
  gap: 4px;
  max-width: min(420px, calc(100vw - 48px));
  font-size: 0.86rem;
  color: var(--page-ink);
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  transition: opacity 220ms ease, transform 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.share-toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.share-toast.is-error {
  border-color: color-mix(in srgb, var(--red) 50%, var(--panel-border));
}

.share-toast strong {
  font-family: var(--heading-font);
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--green);
}

.share-toast.is-error strong {
  color: var(--red);
}

.share-toast code {
  font-family: var(--mono-font);
  font-size: 0.78rem;
  color: var(--page-muted);
  word-break: break-all;
  line-height: 1.4;
}

/* Keyboard shortcuts modal */
.shortcuts-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 24, 0.55);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  animation: shortcut-fade-in 200ms ease;
}

@keyframes shortcut-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.shortcuts-modal {
  max-width: min(640px, 100%);
  width: 100%;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--card-radius);
  box-shadow: var(--panel-shadow);
  padding: 24px;
}

.shortcuts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.shortcuts-header h2 {
  margin: 0;
  font-family: var(--heading-font);
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.shortcuts-close {
  background: var(--ink-soft-1);
  border: 1px solid var(--panel-border);
  color: var(--page-ink);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition);
}

.shortcuts-close:hover { background: var(--ink-soft-2); }

.shortcut-section {
  margin-bottom: 16px;
}

.shortcut-section h3 {
  font-family: var(--body-font);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--teal);
  margin: 0 0 8px;
}

.shortcut-rows {
  display: grid;
  gap: 4px;
}

.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--ink-soft-1);
  border: 1px solid var(--panel-border);
  font-size: 0.86rem;
  gap: 12px;
}

.shortcut-keys {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex: 0 0 auto;
}

.shortcuts-modal kbd {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--page-cream);
  border: 1px solid var(--panel-border);
  border-bottom-width: 2px;
  font-family: var(--mono-font);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--page-ink);
  min-width: 22px;
  text-align: center;
}

.shortcut-label {
  flex: 1 1 auto;
  text-align: right;
  color: var(--page-ink);
}

.shortcuts-footer {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
  font-size: 0.78rem;
  color: var(--page-muted);
  text-align: center;
}

/* Seen-NEW badge fade — once user interacts, badge shrinks and dims so it
   doesn't keep shouting on every visit. */
.new-badge.is-seen {
  opacity: 0.45;
  transform: scale(0.78);
  animation: none;
  filter: saturate(0.7);
}

/* Compact heat viz inside the auto-mode toolbar */
.auto-heat-group {
  min-width: 220px;
}

.auto-heat-viz {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auto-heat-meter {
  position: relative;
  height: 28px;
  border-radius: 14px;
  background: var(--ink-soft-1);
  border: 1px solid var(--panel-border);
  overflow: hidden;
}

.auto-heat-bar {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 14px;
  transition: width 650ms cubic-bezier(0.22, 0.8, 0.25, 1);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.65), inset 0 -2px 3px rgba(0,0,0,0.16), 2px 0 8px rgba(255,255,255,0.18);
  opacity: 0.65;
}

.auto-heat-extras { display: flex; flex-direction: column; gap: 6px; }

.auto-heat-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.34), transparent 48%, rgba(0,0,0,0.12));
}

.auto-heat-bar.heat-cold { background: linear-gradient(90deg, #4a90c4, #5cb6c4); }
.auto-heat-bar.heat-warm { background: linear-gradient(90deg, #c4912f, #d4a850); }
.auto-heat-bar.heat-hot { background: linear-gradient(90deg, #d4a850, #d44d49); }
.auto-heat-bar.heat-fuzzy { background: linear-gradient(90deg, #2c6b4a, #4a9b6a); }
.auto-heat-bar.heat-infinite { background: linear-gradient(90deg, #8b3da3, #d44d49); }

.auto-heat-meter-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-family: var(--body-font);
  font-size: 0.78rem;
  pointer-events: none;
}

.auto-heat-category {
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.72rem;
  text-shadow: 0 0 4px var(--panel-bg), 0 0 6px var(--panel-bg);
}

.auto-heat-category.heat-cold { color: #1c4e8c; }
.auto-heat-category.heat-warm { color: #8a5a18; }
.auto-heat-category.heat-hot { color: #a8221c; }
.auto-heat-category.heat-fuzzy { color: #1a6940; }
.auto-heat-category.heat-infinite { color: #6b1f88; }
:root.theme-dark .auto-heat-category.heat-cold { color: #7fb2ff; }
:root.theme-dark .auto-heat-category.heat-warm { color: #ffc97a; }
:root.theme-dark .auto-heat-category.heat-hot { color: #ff928c; }
:root.theme-dark .auto-heat-category.heat-fuzzy { color: #6dd49a; }
:root.theme-dark .auto-heat-category.heat-infinite { color: #d99cea; }

.auto-heat-detail {
  font-family: var(--mono-font);
  font-weight: 600;
  color: var(--page-ink);
  text-shadow: 0 0 4px var(--panel-bg);
}

.auto-thermo-flat {
  margin-top: 4px;
  padding: 6px 12px;
  font-size: 0.78rem;
  color: var(--page-muted);
  font-style: italic;
  background: var(--ink-soft-1);
  border-radius: 8px;
  border: 1px dashed var(--panel-border);
}

.auto-thermo-flat code {
  font-family: var(--mono-font);
  color: var(--page-ink);
  background: transparent;
  padding: 0;
}

/* Game rating chips — complexity stars + length + concept tags */
.rating-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.rating-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ink-soft-1);
  border: 1px solid var(--panel-border);
  font-size: 0.74rem;
}

.rating-label {
  font-family: var(--body-font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  font-size: 0.66rem;
  color: var(--page-muted);
}

.rating-stars {
  color: var(--amber);
  letter-spacing: 1px;
  font-size: 0.84rem;
  line-height: 1;
}

.rating-value {
  font-family: var(--mono-font);
  font-weight: 600;
  color: var(--page-ink);
}

.rating-concepts {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.rating-concept {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--teal) 14%, var(--ink-soft-1));
  border: 1px solid color-mix(in srgb, var(--teal) 32%, var(--panel-border));
  color: color-mix(in srgb, var(--teal) 75%, var(--page-ink));
  font-family: var(--body-font);
  font-size: 0.7rem;
  font-weight: 600;
}

.auto-heat-viz .thermograph-svg {
  width: 200px;
  height: 110px;
  background: transparent;
  padding: 0;
}

.auto-heat-viz .thermograph-status {
  display: none;
}

/* "Complex" value badge — verbose game forms render as a clickable button
   that scrolls to the interactive game tree below. The full label is in
   the title attribute as a fallback tooltip. */
/* Boss-tier "Solve position" gate — warm amber so it reads as a heavy,
   deliberate action distinct from the normal teal value chips. */
.solve-boss-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #f6b042, #e8702c);
  color: #fff;
  font-family: var(--body-font);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 6px 18px -6px rgba(232, 112, 44, 0.65);
  transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
}
.solve-boss-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 9px 22px -7px rgba(232, 112, 44, 0.75);
}
.solve-boss-btn:active { transform: translateY(0); }
.solve-boss-btn span { font-size: 1.1em; }

/* Live progress + cancel while a boss position solves on the worker thread. */
.boss-progress {
  font-family: var(--mono-font, ui-monospace, monospace);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--teal);
  margin-right: 12px;
}
.cancel-boss-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid color-mix(in srgb, #e8702c 55%, var(--panel-border));
  background: transparent;
  color: #e8702c;
  font-family: var(--body-font);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.cancel-boss-btn:hover { background: color-mix(in srgb, #e8702c 14%, transparent); transform: translateY(-1px); }
.cancel-boss-btn:active { transform: translateY(0); }

.value-complex-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: 999px;
  border: 1.5px solid color-mix(in srgb, var(--teal) 50%, var(--panel-border));
  background: linear-gradient(135deg, color-mix(in srgb, var(--teal) 18%, var(--ink-soft-1)), var(--ink-soft-1));
  color: var(--teal);
  font-family: var(--body-font);
  font-size: 0.62em;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  vertical-align: middle;
  transition: background var(--transition), transform var(--transition);
}

.value-complex-btn:hover {
  background: linear-gradient(135deg, color-mix(in srgb, var(--teal) 30%, var(--ink-soft-1)), var(--ink-soft-2));
  transform: translateY(-1px);
}

.value-complex-arrow {
  font-size: 1.1em;
  line-height: 1;
}

/* Move-history commentary — italic explanatory line under each move row */
.history-row-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-commentary {
  margin-top: 4px;
  margin-left: 30px;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--page-muted);
  line-height: 1.4;
}

.history-commentary.commentary-forced {
  color: color-mix(in srgb, var(--amber) 70%, var(--page-ink));
}

.history-commentary.commentary-optimal {
  color: color-mix(in srgb, var(--green) 70%, var(--page-ink));
}

.history-commentary.commentary-suboptimal {
  color: color-mix(in srgb, var(--red) 60%, var(--page-ink));
}

/* Auto-mode banner commentary — small italic appended to last-move strip */
.banner-commentary {
  margin-left: 8px;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--page-muted);
  opacity: 0.85;
}

/* Accessibility: visible focus outlines for keyboard nav */
:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--teal) 65%, transparent);
  outline-offset: 2px;
  border-radius: 4px;
}

button:focus-visible,
.tool-button:focus-visible,
.action-button:focus-visible {
  outline-offset: 4px;
}

/* Skip-to-main link — visually hidden until focused */
.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  padding: 10px 16px;
  background: var(--navy);
  color: #ffffff;
  text-decoration: none;
  border-radius: 0 0 12px 0;
  font-family: var(--body-font);
  font-weight: 600;
  z-index: 250;
  transform: translateY(-110%);
  transition: transform 180ms ease;
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
}

/* Animation mode categories — sub-headers above each row of buttons. */
.anim-mode-group {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.anim-mode-section {
  display: grid;
  gap: 4px;
}

.anim-mode-section-label {
  font-family: var(--body-font);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--page-muted);
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--ink-soft-1);
  border: 1px solid var(--panel-border);
  width: max-content;
}

.anim-mode-section-label.anim-section-latest {
  background: linear-gradient(135deg, color-mix(in srgb, var(--amber) 25%, var(--ink-soft-1)), var(--ink-soft-1));
  border-color: color-mix(in srgb, var(--amber) 45%, var(--panel-border));
  color: color-mix(in srgb, var(--amber) 70%, var(--page-ink));
}

.anim-mode-section-label.anim-section-artistic {
  background: linear-gradient(135deg, color-mix(in srgb, var(--teal) 22%, var(--ink-soft-1)), var(--ink-soft-1));
  border-color: color-mix(in srgb, var(--teal) 40%, var(--panel-border));
  color: color-mix(in srgb, var(--teal) 80%, var(--page-ink));
}

/* Sign-expansion display: row of +/- pills */
.sign-expansion-view {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--ink-soft-1);
  border: 1px solid var(--panel-border);
  min-height: 0;
}

.sign-expansion-view:empty {
  display: none;
}

.sign-expansion-label {
  font-family: var(--body-font);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--page-muted);
  flex: 0 0 auto;
}

.sign-expansion-pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 0;
}

.sign-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  font-family: var(--mono-font);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1;
}

.sign-pill.sign-plus {
  background: color-mix(in srgb, var(--blue) 22%, var(--ink-soft-1));
  color: var(--blue);
  border: 1px solid color-mix(in srgb, var(--blue) 38%, transparent);
}

.sign-pill.sign-minus {
  background: color-mix(in srgb, var(--red) 22%, var(--ink-soft-1));
  color: var(--red);
  border: 1px solid color-mix(in srgb, var(--red) 38%, transparent);
}

.sign-pill.sign-overflow {
  background: var(--ink-soft-2);
  color: var(--page-muted);
  border: 1px solid var(--panel-border);
}

.sign-expansion-meta {
  flex: 0 0 auto;
  font-family: var(--mono-font);
  font-size: 0.72rem;
  color: var(--page-muted);
  margin-left: auto;
}

/* Analysis anchors — jump links from the value headline to deep-analysis sections */
.analysis-anchors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.analysis-anchor {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: 999px;
  font-family: var(--body-font);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: color-mix(in srgb, var(--teal) 15%, var(--ink-soft-1));
  border: 1px solid color-mix(in srgb, var(--teal) 30%, var(--panel-border));
  color: var(--teal);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.analysis-anchor:hover {
  background: color-mix(in srgb, var(--teal) 28%, var(--ink-soft-1));
  color: var(--teal);
  transform: translateY(-1px);
}

/* Highlight pulse on the target section so users can see where they jumped */
.scroll-target-flash {
  animation: anchor-flash 1.4s ease;
}

@keyframes anchor-flash {
  0% { background-color: color-mix(in srgb, var(--amber) 30%, transparent); }
  100% { background-color: transparent; }
}

/* Roadmap panel */
.roadmap-panel {
  margin-top: 18px;
  padding: 22px 24px;
  position: relative;
}

.roadmap-panel .panel-heading {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.roadmap-panel .panel-subtitle {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: var(--page-muted);
  line-height: 1.5;
  max-width: 64ch;
}

.roadmap-toggle {
  position: absolute;
  top: 22px;
  right: 24px;
  font-size: 0.78rem;
  padding: 6px 14px;
}

.roadmap-body {
  display: grid;
  gap: 16px;
}

.roadmap-category {
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--ink-soft-1);
}

.roadmap-category-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--ink-soft-2);
}

.roadmap-category-badge {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
}

.roadmap-done .roadmap-category-badge {
  background: color-mix(in srgb, var(--green) 22%, transparent);
  color: var(--green);
  border: 1.5px solid color-mix(in srgb, var(--green) 55%, transparent);
}

.roadmap-partial .roadmap-category-badge {
  background: color-mix(in srgb, var(--amber) 22%, transparent);
  color: var(--amber);
  border: 1.5px solid color-mix(in srgb, var(--amber) 55%, transparent);
}

.roadmap-planned .roadmap-category-badge {
  background: color-mix(in srgb, var(--blue) 22%, transparent);
  color: var(--blue);
  border: 1.5px solid color-mix(in srgb, var(--blue) 55%, transparent);
}

.roadmap-out-of-scope .roadmap-category-badge {
  background: color-mix(in srgb, var(--red) 18%, transparent);
  color: var(--red);
  border: 1.5px solid color-mix(in srgb, var(--red) 50%, transparent);
}

.roadmap-category-title {
  flex: 1 1 auto;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.roadmap-category-title strong {
  font-family: var(--heading-font);
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--page-ink);
}

.roadmap-category-title span {
  font-size: 0.82rem;
  color: var(--page-muted);
  line-height: 1.45;
}

.roadmap-category-count {
  flex: 0 0 auto;
  font-family: var(--mono-font);
  font-size: 0.76rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ink-soft-1);
  border: 1px solid var(--panel-border);
  color: var(--page-muted);
  font-weight: 600;
}

.roadmap-list {
  list-style: none;
  padding: 8px 16px 16px;
  margin: 0;
  display: grid;
  gap: 6px;
}

.roadmap-item {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  display: grid;
  gap: 4px;
}

.roadmap-item strong {
  font-family: var(--body-font);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--page-ink);
}

.roadmap-item .roadmap-note {
  font-size: 0.83rem;
  color: var(--page-muted);
  line-height: 1.5;
}

/* Thermograph card */
.thermograph-card {
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: var(--ink-soft-1);
  display: grid;
  gap: 6px;
  justify-items: center;
}

.thermograph-svg {
  display: block;
  max-width: 100%;
  height: auto;
  background: var(--panel-bg);
  border-radius: 12px;
  padding: 4px;
}

.thermograph-status {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--page-muted);
  font-style: italic;
  text-align: center;
  max-width: 360px;
  line-height: 1.5;
}

/* Self-test panel — shown only when user clicks Run Self-Test. */
.self-test-panel {
  margin-top: 18px;
  padding: 20px 22px;
  border: 1px solid var(--panel-border);
  border-radius: var(--card-radius);
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  box-shadow: var(--panel-shadow);
  animation: rise-in 300ms ease;
}

.self-test-summary {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--ink-soft-1);
  border: 1px solid var(--panel-border);
}

.self-test-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--heading-font);
  font-size: 1.15rem;
}

.self-test-stats .all-pass {
  color: var(--green);
}

.self-test-stats .some-fail {
  color: var(--red);
}

.self-test-category {
  margin-top: 18px;
}

.self-test-category h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--heading-font);
  font-size: 1rem;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  color: var(--page-ink);
}

.self-test-category h3 .meta-chip {
  font-family: var(--body-font);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--ink-soft-1);
  font-weight: 600;
}

.self-test-category ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.self-test-row {
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--ink-soft-1);
}

.self-test-row.is-pass {
  border-color: color-mix(in srgb, var(--green) 32%, transparent);
  background: color-mix(in srgb, var(--green) 10%, var(--ink-soft-1));
}

.self-test-row.is-fail {
  border-color: color-mix(in srgb, var(--red) 32%, transparent);
  background: color-mix(in srgb, var(--red) 10%, var(--ink-soft-1));
}

.self-test-indicator {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-family: var(--body-font);
  font-size: 0.85rem;
  font-weight: 700;
}

.self-test-row.is-pass .self-test-indicator {
  background: var(--green);
  color: #041b10;
}

.self-test-row.is-fail .self-test-indicator {
  background: var(--red);
  color: #2a0606;
}

.self-test-body {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 3px;
}

.self-test-body strong {
  font-family: var(--body-font);
  font-size: 0.92rem;
  color: var(--page-ink);
}

.self-test-line {
  font-size: 0.82rem;
  color: var(--page-muted);
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.self-test-label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  min-width: 60px;
}

.self-test-line code {
  font-family: var(--mono-font);
  font-size: 0.82rem;
  color: var(--page-ink);
  background: var(--ink-soft-1);
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
}

.self-test-error {
  margin-top: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--red) 15%, transparent);
  color: var(--red);
  font-family: var(--mono-font);
  font-size: 0.78rem;
}

.self-test-meta {
  font-size: 0.68rem;
  color: var(--page-muted);
  letter-spacing: 0.08em;
}

/* Analyzing shimmer — subtle pulsing bar across the top of the board while the
   engine is crunching, so users know the app isn't locked up. */
.board-frame.is-analyzing::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--warm, #c4912f) 30%,
    var(--sea, #2b756a) 60%,
    transparent
  );
  background-size: 200% 100%;
  animation: analyzing-shimmer 1.4s linear infinite;
  z-index: 4;
  pointer-events: none;
}

@keyframes analyzing-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .board-frame.is-analyzing::after { animation: none; opacity: 0.7; }
}

.board-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--board-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--board-grid) 1px, transparent 1px);
  background-size: 56px 56px;
  pointer-events: none;
}

/* touch-action: none is required for touch drags. Without it the browser
   claims a vertical drag as a page pan and fires pointercancel, so the Create
   tools could never draw an edge on a phone. */
#boardSvg { display: block; width: 100%; height: auto; touch-action: none; }

.hint-copy {
  margin: 10px 0 0;
  color: var(--page-muted);
  line-height: 1.5;
  font-size: 0.9rem;
}

/* Toolbar panel (horizontal) */
.toolbar-panel { padding: 16px 20px; }

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
}

.toolbar-group {
  display: grid;
  gap: 8px;
}

.toolbar-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.toolbar-buttons.anim-mode-group {
  max-width: 100%;
}

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

/* Buttons */
.tool-button, .action-button, .preset-button {
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  background: rgba(19, 33, 53, 0.06);
  color: var(--page-ink);
  cursor: pointer;
  font-size: 0.88rem;
  transition: transform var(--transition), background var(--transition), color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.tool-button:hover, .action-button:hover, .preset-button:hover, .move-play-button:hover {
  transform: translateY(-1px);
  background: rgba(19, 33, 53, 0.12);
}

.tool-button:disabled, .action-button:disabled, .preset-button:disabled,
.move-play-button:disabled, .color-chip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.tool-button.is-active, .action-button.is-active {
  color: #f7fbff;
  background: linear-gradient(160deg, var(--navy), var(--navy-soft));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.muted-action { background: rgba(19, 33, 53, 0.08); }

/* Color chips */
.color-chip {
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  color: white;
  font-size: 0.88rem;
  transition: transform var(--transition), box-shadow var(--transition), outline-color var(--transition);
}

.color-chip:hover { transform: translateY(-1px); }

.color-chip.is-active {
  outline: 3px solid rgba(19, 33, 53, 0.16);
  box-shadow: 0 8px 20px rgba(19, 33, 53, 0.16);
}

.blue-chip { background: linear-gradient(145deg, #448cf5, #1d6ef0); }
.red-chip { background: linear-gradient(145deg, #e16a64, #d44d49); }
.green-chip { background: linear-gradient(145deg, #33bc7a, #23a767); }

/* Toggle row */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(19, 33, 53, 0.05);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

/* Analysis panel */
.analysis-headline {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.analysis-headline strong {
  font-family: var(--heading-font);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1;
}

.analysis-copy {
  margin: 12px 0 0;
  color: var(--page-muted);
  line-height: 1.6;
  max-width: 90ch;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.meta-chip, .relation-chip, .move-chip, .warning-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 7px 11px;
  border-radius: var(--chip-radius);
  background: rgba(19, 33, 53, 0.07);
  color: var(--page-ink);
  font-size: 0.85rem;
}

.warning-chip {
  background: rgba(201, 135, 23, 0.14);
  color: #724706;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.detail-card {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(19, 33, 53, 0.05);
}

.detail-value {
  overflow-wrap: anywhere;
  font-size: 0.95rem;
  color: var(--navy);
}

.warning-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

/* Best Replies / Moves */
.recommendation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.recommendation-card, .move-card, .preset-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(19, 33, 53, 0.05);
}

.recommendation-card strong, .move-card strong, .preset-card strong {
  font-family: var(--heading-font);
}

.move-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.moves-panel h3 { font-size: 1rem; margin-bottom: 10px; }

.move-list { display: grid; gap: 10px; }

.move-card.is-featured, .recommendation-card.is-featured {
  background:
    linear-gradient(160deg, rgba(31, 143, 135, 0.12), rgba(19, 33, 53, 0.08)),
    rgba(19, 33, 53, 0.05);
  border: 1px solid rgba(31, 143, 135, 0.24);
}

.move-header, .preset-header, .recommendation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.move-play-button {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  color: white;
  font-size: 0.85rem;
  background: linear-gradient(150deg, var(--navy), var(--navy-soft));
  transition: transform var(--transition), box-shadow var(--transition);
}

.recommendation-copy, .preset-copy, .move-copy {
  margin: 0;
  color: var(--page-muted);
  line-height: 1.4;
  font-size: 0.88rem;
}

.preset-copy strong { color: var(--page-ink); }

/* Preset list: vertical stack of categories. Each category-header takes a
   full row so it's clearly distinct from its entries. The cards INSIDE a
   category still wrap horizontally via .category-items. */
.preset-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}

/* JSON editor */
.json-panel { padding: 18px 22px; }

.json-editor {
  width: 100%;
  min-height: 140px;
  margin-top: 10px;
  border: 1px solid rgba(19, 33, 53, 0.12);
  border-radius: 16px;
  padding: 14px;
  resize: vertical;
  background: rgba(255, 255, 255, 0.55);
  color: var(--navy);
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 0.85rem;
}

.json-editor:focus { outline: 2px solid rgba(31, 143, 135, 0.28); }

/* Play banner */
.play-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 20px;
  border-radius: 18px;
  margin-bottom: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
}

.banner-winning {
  background: linear-gradient(140deg, rgba(35, 167, 103, 0.18), rgba(35, 167, 103, 0.08));
  color: #145a3a;
  border: 1px solid rgba(35, 167, 103, 0.25);
}

.banner-losing {
  background: linear-gradient(140deg, rgba(212, 77, 73, 0.15), rgba(212, 77, 73, 0.06));
  color: #7a2320;
  border: 1px solid rgba(212, 77, 73, 0.2);
}

.banner-opponent {
  background: rgba(19, 33, 53, 0.07);
  color: var(--page-muted);
  border: 1px solid var(--panel-border);
}

.banner-win {
  background: linear-gradient(140deg, rgba(35, 167, 103, 0.25), rgba(35, 167, 103, 0.1));
  color: #0d4a2c;
  border: 1px solid rgba(35, 167, 103, 0.3);
}

.banner-lose {
  background: linear-gradient(140deg, rgba(212, 77, 73, 0.2), rgba(212, 77, 73, 0.08));
  color: #6a1c1a;
  border: 1px solid rgba(212, 77, 73, 0.25);
}

.banner-turn-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-blue { background: var(--blue); }
.dot-red { background: var(--red); }

.banner-text { flex: 1; }

.banner-best {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(19, 33, 53, 0.08);
  font-size: 0.88rem;
}

.banner-best strong { color: var(--teal); }

.banner-status {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(19, 33, 53, 0.06);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.banner-last-move {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(100%, 420px);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  font-size: 0.82rem;
}

.banner-arrow {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.banner-arrow-blue { color: var(--blue); }
.banner-arrow-red { color: var(--red); }

.banner-last-move-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.banner-icon { font-size: 1.5rem; }

/* Suggestion panel (play mode) */
.suggestion-panel { padding: 16px 20px; }

.suggestion-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.suggestion-main {
  flex: 1;
  min-width: 200px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.suggestion-main strong { color: var(--teal); }

/* Play status panel */
.play-status-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* SVG edges */
.edge-main {
  fill: none;
  stroke-linecap: round;
  stroke-width: 10;
  cursor: pointer;
  pointer-events: stroke;
  transition: opacity var(--transition), stroke-width var(--transition), filter var(--transition);
}

.edge-blue { stroke: var(--blue); }
.edge-red { stroke: var(--red); }
.edge-green { stroke: var(--green); }
.edge-stable { stroke-dasharray: 16 12; }

/* ── Edge style variants (set via :root[data-edge-style="X"]) ──
   "solid" is the default. The variants below override stroke-width / filters
   without changing the SVG DOM, so toggling is instant and cheap. */

/* "glow": heavy luminous halo around each edge color. */
:root[data-edge-style="glow"] .edge-main.edge-blue {
  filter: drop-shadow(0 0 8px rgba(43, 123, 255, 0.7)) drop-shadow(0 0 14px rgba(43, 123, 255, 0.35));
}
:root[data-edge-style="glow"] .edge-main.edge-red {
  filter: drop-shadow(0 0 8px rgba(255, 47, 58, 0.7)) drop-shadow(0 0 14px rgba(255, 47, 58, 0.35));
}
:root[data-edge-style="glow"] .edge-main.edge-green {
  filter: drop-shadow(0 0 8px rgba(21, 214, 122, 0.7)) drop-shadow(0 0 14px rgba(21, 214, 122, 0.35));
}

/* "chunky": thicker rope-like strokes for a bold, hand-drawn-poster feel. */
:root[data-edge-style="chunky"] .edge-main {
  stroke-width: 14;
  stroke-linejoin: round;
}
:root[data-edge-style="chunky"] .edge-stable {
  stroke-dasharray: 22 14;
}

/* "spiral": each edge ends in a curling spiral on both sides — vine /
   art-nouveau feel. Markers are defined once in the SVG defs and inherit the
   edge's stroke color via `context-stroke`. */
:root[data-edge-style="spiral"] .edge-main {
  marker-start: url(#edge-spiral-curl);
  marker-end: url(#edge-spiral-curl);
  stroke-width: 8;
}

/* "spiral-soft": same idea but tighter / subtler curl — reads as decorative
   accent rather than full vine. */
:root[data-edge-style="spiral-soft"] .edge-main {
  marker-start: url(#edge-spiral-tight);
  marker-end: url(#edge-spiral-tight);
  stroke-width: 9;
}

/* "hand-drawn": narrower stroke + slight blur, lower opacity, double-shadow —
   reads as a soft pencil/marker sketch instead of a printed line. */
:root[data-edge-style="hand-drawn"] .edge-main {
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.88;
  filter: blur(0.4px) drop-shadow(0.6px 1px 0 rgba(19, 33, 53, 0.18));
}
:root[data-edge-style="hand-drawn"] .edge-main.edge-blue {
  filter: blur(0.4px) drop-shadow(0.6px 1px 0 rgba(36, 105, 210, 0.32));
}
:root[data-edge-style="hand-drawn"] .edge-main.edge-red {
  filter: blur(0.4px) drop-shadow(0.6px 1px 0 rgba(218, 60, 64, 0.32));
}
:root[data-edge-style="hand-drawn"] .edge-main.edge-green {
  filter: blur(0.4px) drop-shadow(0.6px 1px 0 rgba(31, 143, 90, 0.32));
}

/* Dark-mode halo: each partisan color gets a subtle drop-shadow in its own hue
   so the strokes glow off the deep navy board instead of reading as dusty. */
:root.theme-dark .edge-blue {
  filter: drop-shadow(0 0 4px rgba(43, 123, 255, 0.55));
}
:root.theme-dark .edge-red {
  filter: drop-shadow(0 0 4px rgba(255, 47, 58, 0.55));
}
:root.theme-dark .edge-green {
  filter: drop-shadow(0 0 4px rgba(21, 214, 122, 0.55));
}

.edge-glow {
  stroke-linecap: round;
  fill: none;
  pointer-events: none;
}

.edge-recommended {
  opacity: 0.98;
  stroke-width: 12.5;
  filter: drop-shadow(0 0 10px rgba(31, 143, 135, 0.2));
}

.edge-suggestion-glow {
  stroke: rgba(31, 143, 135, 0.92);
  opacity: 0.58;
  stroke-width: 30;
  filter: drop-shadow(0 0 12px rgba(31, 143, 135, 0.58));
}

.edge-hover-friendly {
  stroke: rgba(35, 167, 103, 0.88);
  opacity: 0.22;
  stroke-width: 21;
  filter: drop-shadow(0 0 6px rgba(35, 167, 103, 0.28));
}

.edge-hover-opponent {
  stroke: rgba(212, 77, 73, 0.86);
  opacity: 0.22;
  stroke-width: 21;
  filter: drop-shadow(0 0 6px rgba(212, 77, 73, 0.28));
}

.edge-illegal {
  filter: drop-shadow(0 0 10px rgba(190, 92, 255, 0.45));
}

.edge-illegal-glow {
  stroke: rgba(182, 72, 255, 0.98);
  opacity: 0.9;
  stroke-width: 34;
  filter: drop-shadow(0 0 14px rgba(182, 72, 255, 0.95));
  animation: illegal-edge-glow 0.72s ease-in-out infinite alternate;
}

@keyframes illegal-edge-glow {
  from { opacity: 0.62; stroke-width: 28; }
  to { opacity: 1; stroke-width: 38; }
}

.edge-hovered { opacity: 0.86; stroke-width: 10.75; }
.edge-selected { opacity: 0.92; stroke-width: 11.5; }
.edge-dimmed { opacity: 0.3 !important; }

.edge-pulse {
  animation: edge-pulse-anim 1.4s ease-in-out infinite;
}

@keyframes edge-pulse-anim {
  0%, 100% { stroke-width: 12.5; filter: drop-shadow(0 0 10px rgba(31, 143, 135, 0.2)); }
  50% { stroke-width: 15; filter: drop-shadow(0 0 18px rgba(31, 143, 135, 0.5)); }
}

.edge-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  fill: rgba(19, 33, 53, 0.72);
  pointer-events: none;
}

/* ── Move-value overlay: small badge near each edge showing the resulting
   game value if that edge is cut. Toggle in toolbar (edit + play modes). ── */
.move-value-badge {
  pointer-events: none;
}
.move-value-badge rect {
  fill: rgba(255, 255, 255, 0.92);
  stroke: rgba(19, 33, 53, 0.32);
  stroke-width: 1;
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.18));
}
.move-value-badge text {
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 700;
  fill: rgba(19, 33, 53, 0.9);
  text-anchor: start;
  dominant-baseline: middle;
}

/* Color-coded by relation-to-zero of the resulting position */
.move-value-badge.mv-blue-favors rect {
  fill: rgba(36, 105, 210, 0.16);
  stroke: rgba(36, 105, 210, 0.65);
}
.move-value-badge.mv-blue-favors text {
  fill: rgb(28, 80, 165);
}
.move-value-badge.mv-red-favors rect {
  fill: rgba(218, 60, 64, 0.16);
  stroke: rgba(218, 60, 64, 0.65);
}
.move-value-badge.mv-red-favors text {
  fill: rgb(166, 38, 42);
}
.move-value-badge.mv-balanced rect {
  fill: rgba(31, 143, 135, 0.16);
  stroke: rgba(31, 143, 135, 0.6);
}
.move-value-badge.mv-balanced text {
  fill: rgb(20, 96, 91);
}
.move-value-badge.mv-fuzzy rect {
  fill: rgba(220, 158, 36, 0.18);
  stroke: rgba(220, 158, 36, 0.7);
}
.move-value-badge.mv-fuzzy text {
  fill: rgb(140, 92, 12);
}

:root.theme-dark .move-value-badge rect {
  fill: rgba(20, 28, 46, 0.86);
  stroke: rgba(225, 232, 245, 0.32);
}
:root.theme-dark .move-value-badge text {
  fill: rgba(232, 238, 250, 0.92);
}
:root.theme-dark .move-value-badge.mv-blue-favors rect {
  fill: rgba(76, 142, 232, 0.22);
  stroke: rgba(120, 175, 245, 0.7);
}
:root.theme-dark .move-value-badge.mv-blue-favors text {
  fill: rgb(165, 200, 250);
}
:root.theme-dark .move-value-badge.mv-red-favors rect {
  fill: rgba(232, 88, 92, 0.22);
  stroke: rgba(245, 132, 136, 0.72);
}
:root.theme-dark .move-value-badge.mv-red-favors text {
  fill: rgb(248, 168, 172);
}
:root.theme-dark .move-value-badge.mv-balanced rect {
  fill: rgba(64, 188, 178, 0.22);
  stroke: rgba(120, 220, 212, 0.7);
}
:root.theme-dark .move-value-badge.mv-balanced text {
  fill: rgb(150, 230, 222);
}
:root.theme-dark .move-value-badge.mv-fuzzy rect {
  fill: rgba(244, 188, 88, 0.22);
  stroke: rgba(248, 208, 132, 0.72);
}
:root.theme-dark .move-value-badge.mv-fuzzy text {
  fill: rgb(248, 218, 158);
}

.ghost-line {
  stroke: rgba(19, 33, 53, 0.4);
  stroke-dasharray: 12 10;
  stroke-width: 6;
  fill: none;
  pointer-events: none;
}

.ground-path {
  fill: none;
  stroke: var(--ground-path-color, rgba(22, 32, 45, 0.55));
  stroke-width: 7;
  stroke-linecap: round;
}

.ground-shadow {
  fill: none;
  stroke: var(--ground-shadow-color, rgba(255, 255, 255, 0.5));
  stroke-width: 16;
  stroke-linecap: round;
  opacity: 0.5;
}

/* Hit layer on top of nodes */
.edge-hit-layer { pointer-events: auto; }

.edge-hit {
  fill: none;
  stroke: transparent;
  stroke-linecap: round;
  stroke-width: 40;
  cursor: pointer;
  pointer-events: stroke;
}

/* Nodes */
.node-body {
  fill: url(#node-fill);
  stroke: rgba(19, 33, 53, 0.32);
  stroke-width: 2.4;
  cursor: grab;
  filter: url(#node-shadow);
  transition: transform var(--transition), stroke var(--transition), stroke-width var(--transition), fill 240ms ease;
}

/* ── Node style variants (set via :root[data-node-style="X"]) ──
   "sphere" is the default (radial gradient + drop-shadow above). */

/* "flat": 2D solid look — no gradient, no shadow. Easier to read in dense
   positions and renders much faster on weak hardware. */
:root[data-node-style="flat"] .node-body {
  fill: var(--node-mid, #cba37a);
  filter: none;
  stroke: rgba(19, 33, 53, 0.55);
  stroke-width: 2;
}
:root[data-node-style="flat"] .node-body.is-ground {
  fill: var(--node-gnd-mid, #2a3a5c);
}
:root[data-node-style="flat"] .node-body.is-selected {
  fill: var(--node-sel-mid, #6dd0c8);
}

/* "outlined": minimalist — thick outline, transparent fill. Great for
   architectural diagrams or when the user wants the edges to dominate. */
:root[data-node-style="outlined"] .node-body {
  fill: rgba(255, 255, 255, 0.05);
  filter: none;
  stroke: var(--page-text, #132135);
  stroke-width: 3.2;
}
:root[data-node-style="outlined"] .node-body.is-ground {
  stroke: var(--accent, #1f8f87);
  stroke-width: 4;
}
:root[data-node-style="outlined"] .node-body.is-selected {
  stroke: var(--accent, #1f8f87);
  stroke-width: 4.2;
}
:root.theme-dark[data-node-style="outlined"] .node-body {
  stroke: rgba(232, 238, 250, 0.92);
  fill: rgba(20, 28, 46, 0.4);
}

/* "halo": sphere + soft outer glow ring — premium 3D look. */
:root[data-node-style="halo"] .node-body {
  filter: url(#node-shadow) drop-shadow(0 0 6px rgba(255, 220, 140, 0.45));
}
:root[data-node-style="halo"] .node-body.is-ground {
  filter: url(#node-shadow) drop-shadow(0 0 7px rgba(120, 200, 255, 0.55));
}
:root[data-node-style="halo"] .node-body.is-selected {
  filter: url(#node-shadow) drop-shadow(0 0 8px rgba(31, 143, 135, 0.7));
}
:root.theme-dark[data-node-style="halo"] .node-body {
  filter: url(#node-shadow) drop-shadow(0 0 8px rgba(255, 220, 140, 0.55));
}

.node-body.is-selected {
  fill: url(#node-fill-selected);
  stroke: rgba(31, 143, 135, 0.82);
  stroke-width: 3;
}

.node-body.is-ground {
  fill: url(#node-fill-ground);
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 2;
}

/* Floating non-ground node: no incident edges, so the solver prunes it. Keep
   the visual but render it faded with a dashed outline so the user sees it as
   "staged" rather than believing it's part of the position. */
.node-body.is-floating {
  fill: transparent;
  stroke: var(--page-muted);
  stroke-width: 1.8;
  stroke-dasharray: 4 3;
  filter: none;
  opacity: 0.55;
}

.node-label.is-floating {
  fill: var(--page-muted) !important;
  opacity: 1; /* always show the label so user can identify the dangling node */
  font-style: italic;
}

.node-label {
  fill: var(--node-label-color, rgba(42, 29, 18, 0.88));
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-anchor: middle;
  pointer-events: none;
  /* Default: hidden. Show on group hover so board stays clean with dense
     positions (e.g. post-infinite-cut stalks of ~50 intermediate nodes). */
  opacity: 0;
  transition: opacity 140ms ease;
}

.node-label.is-ground {
  fill: rgba(255, 255, 255, 0.95);
  opacity: 1; /* Ground labels always visible so you can find anchors */
}

/* Selected node always shows its label. */
.node-body.is-selected + .node-label { opacity: 1; }

/* Hovering an SVG group reveals its label. */
#boardSvg g:hover .node-label { opacity: 1; }

:root.theme-dark .node-label {
  /* Non-ground nodes in dark mode are bright brass gradients → need dark ink. */
  fill: rgba(30, 18, 6, 0.92);
}

:root.theme-dark .node-label.is-ground {
  /* Ground nodes in dark mode are deep blue gradients → need light ink. */
  fill: rgba(255, 248, 225, 0.95);
}
:root.theme-dark .component-thumb {
  background: rgba(22, 34, 54, 0.55);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 1px 2px rgba(0, 0, 0, 0.45);
}

/* Edge tooltip — lives in the viewport (not inside #boardFrame) so it can
   render OUTSIDE the main board panel, with a dashed connector line drawn
   from the hovered edge. Fades + flies in from the relevant side. */
.edge-tooltip {
  position: fixed;
  z-index: 60;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(19, 33, 53, 0.94);
  color: #f5f6f8;
  font-size: 0.85rem;
  line-height: 1.5;
  width: 280px;
  max-width: 280px;
  pointer-events: none;
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.32);
  /* Hidden by default; made visible by adding .is-visible. The fly-in
     direction is controlled by data-side so the tooltip swoops in from the
     correct side of the board. */
  opacity: 0;
  transform: translateX(-14px);
  transition: opacity 220ms cubic-bezier(0.2, 0.7, 0.4, 1),
              transform 220ms cubic-bezier(0.2, 0.7, 0.4, 1);
}
.edge-tooltip[data-side="left"] {
  transform: translateX(14px);
}
.edge-tooltip[data-side="below"] {
  transform: translateY(-14px);
}
.edge-tooltip[data-side="above"] {
  transform: translateY(14px);
}
.edge-tooltip[data-side="inside"] {
  transform: translateY(8px);
}
.edge-tooltip.is-visible {
  opacity: 1;
  transform: translate(0, 0);
}
.edge-tooltip.is-measuring {
  /* Visible to layout engine for offsetWidth/Height but invisible to user */
  opacity: 0 !important;
  transform: none !important;
  transition: none !important;
}

/* Dashed connector line from hovered edge to tooltip — fixed-position SVG
   covering the viewport, only made visible while the tooltip is shown. */
.tooltip-connector {
  position: fixed;
  inset: 0;
  z-index: 55;
  pointer-events: none;
  width: 100vw;
  height: 100vh;
  opacity: 0;
  transition: opacity 200ms cubic-bezier(0.2, 0.7, 0.4, 1);
}
.tooltip-connector.is-visible {
  opacity: 1;
}
.tooltip-connector-line {
  stroke: var(--accent, #1f8f87);
  stroke-width: 1.6;
  stroke-dasharray: 5 5;
  /* Animate the dash offset on entry so the line "draws toward" the tooltip */
  animation: tooltip-line-draw 380ms cubic-bezier(0.3, 0.6, 0.4, 1) both;
}
.tooltip-connector-dot {
  fill: var(--accent, #1f8f87);
  opacity: 0.8;
}
.tooltip-connector-head {
  fill: var(--accent, #1f8f87);
  opacity: 0.85;
}
@keyframes tooltip-line-draw {
  from { stroke-dashoffset: 60; opacity: 0; }
  to   { stroke-dashoffset: 0;  opacity: 1; }
}

:root.theme-dark .tooltip-connector-line {
  stroke: rgba(120, 220, 212, 0.95);
}
:root.theme-dark .tooltip-connector-dot,
:root.theme-dark .tooltip-connector-head {
  fill: rgba(120, 220, 212, 0.95);
}

@media (prefers-reduced-motion: reduce) {
  .edge-tooltip,
  .tooltip-connector,
  .tooltip-connector-line {
    transition: none !important;
    animation: none !important;
  }
}

.edge-tooltip strong { font-family: var(--heading-font); font-size: 0.92rem; }

.edge-tooltip .move-chip {
  background: rgba(255, 255, 255, 0.15);
  color: #f5f6f8;
  font-size: 0.75rem;
  padding: 3px 7px;
}

.tooltip-detail {
  margin-top: 5px;
  color: rgba(245, 246, 248, 0.82);
  font-size: 0.8rem;
}

.tooltip-detail code { color: #8be9c0; font-weight: 600; }

/* Theory panel */
.construction-steps {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  /* Cap height so a long surreal construction path (e.g. deep dyadic
     fractions with 30+ days) doesn't push every panel below it off-screen.
     User can scroll within the section when the path is long. */
  max-height: 280px;
  overflow-y: auto;
  border-radius: 12px;
  /* Visually hint at scrollability: subtle inset shadow at top/bottom. */
  background:
    linear-gradient(var(--panel-bg) 30%, transparent),
    linear-gradient(transparent, var(--panel-bg) 70%) bottom,
    radial-gradient(ellipse at top, var(--ink-soft-2), transparent 70%),
    radial-gradient(ellipse at bottom, var(--ink-soft-2), transparent 70%) bottom;
  background-repeat: no-repeat;
  background-size: 100% 24px, 100% 24px, 100% 14px, 100% 14px;
  background-attachment: local, local, scroll, scroll;
  padding: 4px 6px;
}

.construction-steps::-webkit-scrollbar { width: 8px; }
.construction-steps::-webkit-scrollbar-thumb {
  background: var(--ink-soft-3);
  border-radius: 999px;
}
.construction-steps::-webkit-scrollbar-track { background: transparent; }

.construction-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 8px;
  margin-bottom: 4px;
}

.construction-meta-count {
  font-family: var(--mono-font);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--page-muted);
}

.construction-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--ink-soft-1);
  border: 1px solid var(--panel-border);
}

.step-day {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--teal);
  min-width: 52px;
  flex: 0 0 auto;
}

.step-value {
  font-family: var(--mono-font);
  font-size: 0.84rem;
  color: var(--page-ink);
  /* Allow long descriptions (e.g. ω+constructions with deep nesting) to wrap
     instead of overflowing horizontally. */
  word-break: break-word;
  flex: 1 1 auto;
  min-width: 0;
}

.component-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.component-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(19, 33, 53, 0.05);
  border: 1px solid rgba(19, 33, 53, 0.06);
}

.component-card-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.component-card strong { font-family: var(--heading-font); font-size: 0.88rem; }

.component-thumb {
  flex: 0 0 auto;
  display: block;
  background: rgba(255, 250, 236, 0.6);
  border-radius: 10px;
  border: 1px solid rgba(19, 33, 53, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 1px 2px rgba(12, 22, 38, 0.08);
}

.game-tree { margin-top: 10px; font-size: 0.85rem; }

.tree-node { padding: 3px 0; }
.tree-node code { color: var(--navy); font-weight: 600; }

.tree-branches {
  border-left: 2px solid rgba(19, 33, 53, 0.12);
  padding-left: 10px;
}

.tree-side { margin: 3px 0; }

.tree-side-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--page-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-right: 4px;
}

.trace-log {
  margin-top: 10px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(19, 33, 53, 0.04);
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 0.78rem;
  line-height: 1.7;
  max-height: 300px;
  overflow-y: auto;
}

.trace-line { color: var(--navy); white-space: pre-wrap; }

/* Move history */
.history-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.replay-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.replay-btn {
  font-family: var(--body-font);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--ink-soft-1);
  color: var(--page-ink);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.replay-btn:hover:not(:disabled) {
  background: var(--ink-soft-2);
  border-color: var(--ink-soft-3);
}

.replay-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.replay-btn.replay-live {
  background: linear-gradient(135deg, color-mix(in srgb, var(--green) 22%, var(--ink-soft-1)), var(--ink-soft-1));
  border-color: color-mix(in srgb, var(--green) 30%, var(--panel-border));
}

.replay-btn.replay-live:hover:not(:disabled) {
  background: linear-gradient(135deg, color-mix(in srgb, var(--green) 35%, var(--ink-soft-1)), var(--ink-soft-2));
}

.replay-status {
  font-family: var(--mono-font);
  font-size: 0.78rem;
  color: var(--page-muted);
  letter-spacing: 0.04em;
  min-width: 100px;
  text-align: center;
}

.history-list {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.history-list.is-scrubbing {
  outline: 2px dashed color-mix(in srgb, var(--amber) 50%, transparent);
  outline-offset: 4px;
  border-radius: 12px;
  padding: 4px 0;
}

.history-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 10px;
  background: var(--ink-soft-1);
  font-size: 0.84rem;
  cursor: pointer;
  transition: background var(--transition), border var(--transition);
  border: 1px solid transparent;
}

.history-entry:hover { background: var(--ink-soft-2); }

/* Whose move: our moves stay bright with a side-coloured edge; the opponent's
   moves recede (dimmed) so the timeline reads as a back-and-forth at a glance. */
.history-entry.is-ours { background: var(--ink-soft-2); }
.history-entry.is-ours.accent-blue { box-shadow: inset 3px 0 0 var(--blue); }
.history-entry.is-ours.accent-red { box-shadow: inset 3px 0 0 var(--red); }
.history-entry.is-theirs { opacity: 0.5; background: color-mix(in srgb, var(--ink-soft-1) 55%, transparent); }
.history-entry.is-theirs:hover { opacity: 0.82; }

.history-entry.is-current {
  background: color-mix(in srgb, var(--amber) 22%, var(--ink-soft-1));
  border: 1px solid color-mix(in srgb, var(--amber) 55%, transparent);
  opacity: 1;
}

.history-entry.history-start em {
  color: var(--page-muted);
  font-size: 0.82rem;
}

.history-num {
  font-weight: 700;
  color: var(--page-muted);
  min-width: 22px;
}

.history-player {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.anim-mode-note {
  margin: 2px 0 8px;
  color: var(--page-muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

/* ── Board styles (set via :root[data-board-style="X"]) ────────────────────────
   Whole-board treatments rather than per-element tweaks. Each borrows a
   painter's SPATIAL logic — how the picture organises light and void — not
   their subject matter, and each stays behind the game: the board is furniture
   for the position, so nothing here competes with the edges for attention.
   All decoration is drawn with gradients on a ::before layer, so no extra DOM
   and nothing to clean up. */

/* Dedicated art layer. It deliberately does NOT reuse .board-frame::before,
   which already draws the measuring grid — painting over that pseudo-element
   would silently delete the grid on the plain board. */
.board-art {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 600ms ease;
  z-index: 0;
}
/* Only the board establishes flow height. Ink, cut effects, and the finish
   overlay keep their absolute positioning and their independent stacking. */
.board-frame > #boardSvg { position: relative; z-index: 1; }

/* Kandinsky — floating circles and a couple of long diagonals, the "musical"
   scatter of Composition-era work. Warm ground, primaries kept translucent so
   they read as accompaniment. */
:root[data-board-style="kandinsky"] .board-frame {
  background: radial-gradient(circle at 30% 20%, #fffaf0, #f0e6d2 70%);
}
:root[data-board-style="kandinsky"] .board-art {
  opacity: 1;
  background:
    radial-gradient(circle at 18% 26%, color-mix(in srgb, var(--blue) 26%, transparent) 0 5%, transparent 5.4%),
    radial-gradient(circle at 18% 26%, transparent 0 8.5%, color-mix(in srgb, var(--red) 20%, transparent) 8.5% 9.6%, transparent 10%),
    radial-gradient(circle at 79% 70%, color-mix(in srgb, var(--amber) 30%, transparent) 0 7%, transparent 7.4%),
    radial-gradient(circle at 62% 18%, transparent 0 3.4%, color-mix(in srgb, var(--teal) 34%, transparent) 3.4% 4.2%, transparent 4.6%),
    linear-gradient(66deg, transparent 47.6%, rgba(19, 33, 53, 0.16) 47.6% 48%, transparent 48%),
    linear-gradient(-38deg, transparent 61%, color-mix(in srgb, var(--red) 22%, transparent) 61% 61.5%, transparent 61.5%);
  animation: board-drift 54s ease-in-out infinite alternate;
}

/* Malevich — suprematist void. No gradient, no glow, no texture: a flat field,
   one tilted black bar and one red, and a great deal of nothing. The restraint
   IS the style, so this one removes more than it adds. */
:root[data-board-style="malevich"] .board-frame {
  background: #f2efe9;
  border-color: rgba(19, 33, 53, 0.18);
}
:root.theme-dark[data-board-style="malevich"] .board-frame { background: #10151c; }
:root[data-board-style="malevich"] .board-art {
  opacity: 1;
  background:
    linear-gradient(24deg, transparent 12%, rgba(19, 33, 53, 0.14) 12% 15.4%, transparent 15.4%),
    linear-gradient(-14deg, transparent 78%, color-mix(in srgb, var(--red) 26%, transparent) 78% 80.2%, transparent 80.2%);
}
:root.theme-dark[data-board-style="malevich"] .board-art {
  background:
    linear-gradient(24deg, transparent 12%, rgba(255, 255, 255, 0.12) 12% 15.4%, transparent 15.4%),
    linear-gradient(-14deg, transparent 78%, color-mix(in srgb, var(--red) 34%, transparent) 78% 80.2%, transparent 80.2%);
}
/* Flatten everything: suprematism has no light source. The per-colour selectors
   are needed to out-specify the dark-theme glow, which also uses !important. */
:root[data-board-style="malevich"] .edge-main,
:root[data-board-style="malevich"] .edge-main.edge-blue,
:root[data-board-style="malevich"] .edge-main.edge-red,
:root[data-board-style="malevich"] .edge-main.edge-green,
:root[data-board-style="malevich"] .node-body { filter: none !important; }

/* Chirico — metaphysical late afternoon. A low sun, a hard horizon, and the
   long raking shadows that make his squares feel abandoned. The shadow
   direction is constant across the whole board, which is what sells the light
   as a single source rather than a per-object effect. */
:root[data-board-style="chirico"] .board-frame {
  background:
    linear-gradient(178deg, #f6dfb4 0%, #eec98d 38%, #d9a468 52%, #b9825a 52.6%, #9d6a4c 100%);
}
:root.theme-dark[data-board-style="chirico"] .board-frame {
  background:
    linear-gradient(178deg, #3d2f42 0%, #6b4a4a 36%, #a9694a 51%, #4a3040 51.6%, #241a2b 100%);
}
:root[data-board-style="chirico"] .board-art {
  opacity: 1;
  background:
    radial-gradient(ellipse at 78% 44%, rgba(255, 236, 190, 0.55), transparent 42%),
    linear-gradient(96deg, transparent 63%, rgba(58, 38, 60, 0.18) 63% 71%, transparent 71%);
}
/* Per-colour selectors so the raking light survives whichever edge style is
   active — the glow and hand-drawn variants also set filter at .edge-main.edge-X
   specificity, and a single light source has to beat all of them. */
:root[data-board-style="chirico"] .edge-main,
:root[data-board-style="chirico"] .edge-main.edge-blue,
:root[data-board-style="chirico"] .edge-main.edge-red,
:root[data-board-style="chirico"] .edge-main.edge-green {
  filter: drop-shadow(-13px 7px 2px rgba(46, 28, 48, 0.34)) !important;
}
:root[data-board-style="chirico"] .node-body {
  filter: drop-shadow(-9px 5px 1.5px rgba(46, 28, 48, 0.4));
}

/* A very slow parallax so the abstract fields feel inhabited rather than
   printed. Long enough that you notice it only if you look for it. */
@keyframes board-drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-1.4%, 1%, 0) scale(1.035); }
}
@media (prefers-reduced-motion: reduce) {
  .board-art { animation: none !important; }
}

/* ── Rigor colour coding ──────────────────────────────────────────────────────
   How much weight an answer can carry, colour-coded so a pattern-matched or
   unsimplified result never looks as confident as a solved one. Green proved,
   teal exact, amber not-simplified, red heuristic. Hover for the reason. */
.rigor-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  font-family: var(--body-font);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  vertical-align: middle;
  cursor: help;
  border: 1px solid transparent;
}
.rigor-proved {
  background: color-mix(in srgb, var(--green) 20%, transparent);
  border-color: color-mix(in srgb, var(--green) 55%, transparent);
  color: color-mix(in srgb, var(--green) 72%, var(--page-ink));
}
.rigor-exact {
  background: color-mix(in srgb, var(--teal) 16%, transparent);
  border-color: color-mix(in srgb, var(--teal) 45%, transparent);
  color: color-mix(in srgb, var(--teal) 76%, var(--page-ink));
}
.rigor-unreduced {
  background: color-mix(in srgb, var(--amber) 22%, transparent);
  border-color: color-mix(in srgb, var(--amber) 62%, transparent);
  color: color-mix(in srgb, var(--amber) 60%, var(--page-ink));
}
.rigor-heuristic {
  background: color-mix(in srgb, var(--red) 16%, transparent);
  border-color: color-mix(in srgb, var(--red) 52%, transparent);
  color: color-mix(in srgb, var(--red) 70%, var(--page-ink));
}

/* ── Fusion Principle reduction ───────────────────────────────────────────── */
.fusion-view { margin-bottom: 18px; }
.fusion-lede {
  margin: 4px 0 10px;
  color: var(--page-muted);
  font-size: 0.84rem;
  line-height: 1.55;
}
.fusion-view .reason-step { border-left-color: color-mix(in srgb, var(--green) 60%, transparent); }
.fusion-result {
  margin: 10px 0 0;
  padding: 9px 13px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--green) 14%, var(--ink-soft-1));
  border-left: 3px solid var(--green);
  font-size: 0.95rem;
}
.fusion-result strong { font-family: var(--mono-font); font-size: 1.1rem; }

/* ── Nim-sum bit grid ─────────────────────────────────────────────────────────
   Sprague-Grundy made visible: one row per branch, one column per bit, and the
   answer read off as column parity. */
.nim-grid {
  display: grid;
  gap: 4px;
  margin: 8px 0 6px;
  font-family: var(--mono-font);
}
.nim-row {
  display: grid;
  grid-template-columns: minmax(74px, auto) 34px repeat(var(--nim-bits), 1fr);
  gap: 5px;
  align-items: center;
}
.nim-row-label { font-size: 0.72rem; color: var(--page-muted); }
.nim-row-value { font-size: 0.82rem; text-align: right; }
.nim-bit-head { font-size: 0.62rem; color: var(--page-muted); text-align: center; }
.nim-cell {
  height: 20px;
  border-radius: 5px;
  background: var(--ink-soft-2);
  border: 1px solid transparent;
}
.nim-cell.is-on { background: var(--teal); }
.nim-row.is-total { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--panel-border); }
.nim-row.is-total .nim-row-label,
.nim-row.is-total .nim-row-value { font-weight: 700; color: var(--page-ink); }
/* Odd columns survive the cancellation; even ones vanish. */
.nim-row.is-total .nim-cell.is-odd { background: var(--amber); border-color: var(--amber); }
.nim-row.is-total .nim-cell.is-even { background: transparent; border-color: var(--panel-border); }
.nim-caption { margin: 4px 0 0; font-size: 0.78rem; color: var(--page-muted); line-height: 1.5; }
.nim-grid-label { margin-top: 16px; }

/* ── Cooling sweep ────────────────────────────────────────────────────────── */
.cool-controls { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.cool-slider { flex: 1; }
.cool-caption { margin: 6px 0 0; font-size: 0.78rem; color: var(--page-muted); line-height: 1.5; }

/* ── Fusion reduction played on the board ─────────────────────────────────── */
.fusion-play-btn { margin-left: 10px; font-size: 0.72rem; padding: 4px 10px; }
.fusion-caption {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 7px 15px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel-bg) 88%, transparent);
  border: 1px solid var(--panel-border);
  color: var(--page-ink);
  font-family: var(--body-font);
  font-size: 0.82rem;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}

/* ── Misère play ──────────────────────────────────────────────────────────── */
.misere-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 8px 0 10px;
}
.misere-card {
  display: grid;
  gap: 3px;
  padding: 10px 13px;
  border-radius: 12px;
  background: var(--ink-soft-1);
  border-left: 3px solid var(--panel-border);
}
.misere-card.is-normal { border-left-color: var(--teal); }
.misere-card.is-misere { border-left-color: var(--purple, var(--amber)); }
.misere-card-title {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--page-muted);
}
.misere-card-value { font-family: var(--mono-font); font-size: 1.25rem; }
.misere-card-winner { font-size: 0.78rem; color: var(--page-muted); }

.misere-verdict {
  margin: 0 0 8px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.5;
}
/* Amber when the two conventions disagree — that is the finding, not a warning. */
.misere-verdict.is-different {
  background: color-mix(in srgb, var(--amber) 15%, transparent);
  border-left: 3px solid var(--amber);
}
.misere-verdict.is-same {
  background: var(--ink-soft-1);
  border-left: 3px solid var(--panel-border);
  color: var(--page-muted);
}
.misere-caveat {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--page-muted);
  border-left: 3px solid color-mix(in srgb, var(--red) 45%, transparent);
  padding-left: 10px;
}

/* ── Extra analysis: chord diagrams ───────────────────────────────────────── */
.extra-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin-bottom: 14px;
}

.chord-view { margin-top: 6px; }
.chord-svg {
  display: block;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  height: auto;
  overflow: visible;
}

.chord-band {
  stroke: var(--panel-bg);
  stroke-width: 0.75;
  transition: opacity var(--transition);
}
.chord-ribbon {
  fill-opacity: 0.42;
  stroke: none;
  transition: fill-opacity var(--transition);
}
/* Hovering a ribbon lifts just that flow out of the weave. */
.chord-svg:hover .chord-ribbon { fill-opacity: 0.16; }
.chord-svg .chord-ribbon:hover { fill-opacity: 0.86; }
.chord-label {
  font-family: var(--mono-font);
  font-size: 9.5px;
  fill: var(--page-muted);
}
.chord-empty { fill: var(--page-muted); font-size: 13px; }

/* ── Extra analysis: the stepped reasoning walk ───────────────────────────── */
.reasoning-view { margin-top: 18px; }
.reason-steps {
  list-style: none;
  margin: 8px 0 0;
  padding: 0 0 0 4px;
  display: grid;
  gap: 10px;
}

.reason-step {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border-left: 3px solid color-mix(in srgb, var(--teal) 55%, transparent);
  background: var(--ink-soft-1);
}
.reason-step.is-result {
  border-left-color: var(--amber);
  background: color-mix(in srgb, var(--amber) 13%, var(--ink-soft-1));
}
.reason-step.is-revealing { animation: reason-in 0.44s both ease-out; }
@keyframes reason-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .reason-step.is-revealing { animation: none; }
}

.reason-index {
  flex-shrink: 0;
  min-width: 62px;
  font-family: var(--body-font);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--teal);
  padding-top: 2px;
}
.reason-headline { margin: 0; font-weight: 600; font-size: 0.92rem; }
.reason-detail { margin: 3px 0 0; color: var(--page-muted); font-size: 0.8rem; line-height: 1.5; }
.reason-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.reason-chip {
  font-family: var(--mono-font);
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--ink-soft-2);
  color: var(--page-ink);
}

/* The classification ladder: rejected rungs recede, the taken one stands out. */
.ladder { margin-top: 9px; display: grid; gap: 5px; }
.ladder-rung { display: flex; gap: 9px; align-items: flex-start; }
.ladder-rung.is-rejected { opacity: 0.42; }
.ladder-rung.is-unreached { opacity: 0.22; }
.ladder-mark {
  flex-shrink: 0;
  width: 17px; height: 17px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.66rem; font-weight: 700;
  background: var(--ink-soft-2);
  color: var(--page-muted);
  margin-top: 1px;
}
.ladder-rung.is-taken .ladder-mark { background: var(--teal); color: #fff; }
.ladder-q { margin: 0; font-size: 0.81rem; }
.ladder-rung.is-taken .ladder-q { font-weight: 600; }
.ladder-a { margin: 2px 0 0; font-size: 0.85rem; font-weight: 700; color: var(--teal); }
.ladder-detail { margin: 2px 0 0; font-size: 0.78rem; color: var(--page-muted); line-height: 1.5; }

/* Branch fan: one hop of options, Blue left and Red right. */
.branch-fan { display: block; width: 100%; max-width: 460px; height: auto; margin: 10px 0 2px; }
.fan-root { fill: var(--ink-soft-3); stroke: var(--panel-border); }
.fan-root-label { font-family: var(--mono-font); font-size: 13px; font-weight: 700; fill: var(--page-ink); }
.fan-label { font-family: var(--mono-font); font-size: 10px; fill: var(--page-ink); }
.fan-side { font-family: var(--body-font); font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.fan-side-blue { fill: var(--blue); }
.fan-side-red { fill: var(--red); }
.fan-none { font-family: var(--body-font); font-size: 11px; fill: var(--page-muted); }

/* Where the value came from, derived from this position's own options. */
.analysis-derivation {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--teal);
  border-radius: 0;
  background: color-mix(in srgb, var(--teal) 9%, transparent);
  color: var(--page-ink);
  font-size: 0.86rem;
  line-height: 1.55;
}

/* The shortcut that makes a Paper Tiger easy, named on its library card. */
.preset-tell {
  margin: 6px 0 0;
  padding: 6px 10px;
  border-left: 3px solid var(--amber);
  border-radius: 0;
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  color: var(--page-ink);
  font-size: 0.78rem;
  line-height: 1.45;
}

.history-move { font-weight: 600; }
.history-value { color: var(--teal); font-size: 0.8rem; }

/* Branch fall-off: when a move discards the old future, those entries darken,
   tip, and drop away before the list truncates. */
.history-entry.is-falling {
  pointer-events: none;
  animation: history-fall 460ms cubic-bezier(0.45, 0, 0.7, 0.1) forwards;
  transform-origin: 16% center;
  will-change: transform, opacity, filter;
}
@keyframes history-fall {
  0%   { opacity: 1; transform: translateY(0) rotate(0deg); filter: brightness(1); }
  22%  { filter: brightness(0.5); }
  100% { opacity: 0; transform: translateY(34px) rotate(7deg); filter: brightness(0.3); }
}
@media (prefers-reduced-motion: reduce) {
  .history-entry.is-falling { animation: none; opacity: 0.3; }
}

/* Empty state */
.empty-state {
  padding: 16px;
  border-radius: 14px;
  background: rgba(19, 33, 53, 0.05);
  color: var(--page-muted);
}

/* Responsive */
@media (max-width: 900px) {
  .hero-top { flex-direction: column; align-items: flex-start; }
  .hero-metrics { flex-direction: column; }
  .toolbar-row { flex-direction: column; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .move-columns { grid-template-columns: minmax(0, 1fr); }
  .recommendation-grid { grid-template-columns: minmax(0, 1fr); }
  .preset-grid { grid-template-columns: minmax(0, 1fr); }
  .play-status-panel { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .site-shell { width: min(100vw - 16px, 100%); margin: 8px auto 16px; }
  .hero, .panel { padding: 16px; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Heat meter */
.heat-meter {
  margin-top: 16px;
}

.heat-bar-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(19, 33, 53, 0.06);
}

.heat-bar {
  height: 18px;
  border-radius: 10px;
  transition: width 650ms cubic-bezier(0.22, 0.8, 0.25, 1);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.6), inset 0 -2px 3px rgba(0,0,0,0.2);
  min-width: 4px;
}

.heat-cold { background: linear-gradient(90deg, #93c5fd, #3b82f6); }
.heat-warm { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.heat-hot { background: linear-gradient(90deg, #f87171, #dc2626); }
.heat-fuzzy { background: linear-gradient(90deg, #a78bfa, #7c3aed); }
.heat-infinite { background: linear-gradient(90deg, #f87171, #991b1b); }

.heat-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--page-muted);
  white-space: nowrap;
}

/* Grouped presets — categories are full-width section bands, never
   side-by-side with each other or with their entries. */
.preset-category {
  display: block;
  margin: 0;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 18px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(31, 143, 135, 0.12), rgba(31, 143, 135, 0.04) 60%, transparent);
  border-left: 4px solid var(--accent, #1f8f87);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
  /* Make the header visually a "row divider" — bigger and bolder than entries. */
  font-size: 1rem;
}

.category-header:hover {
  background: linear-gradient(90deg, rgba(31, 143, 135, 0.18), rgba(31, 143, 135, 0.06) 60%, transparent);
}

.category-header strong {
  font-family: var(--heading-font);
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: var(--page-text, #132135);
}

.category-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 12px;
  background: rgba(31, 143, 135, 0.22);
  color: var(--accent, #1f8f87);
  font-size: 0.78rem;
  font-weight: 800;
}

.category-desc {
  flex: 1;
  font-size: 0.82rem;
  color: var(--page-muted);
  font-style: italic;
}

.category-arrow {
  font-size: 0.85rem;
  color: var(--page-muted);
  transition: transform var(--transition);
}

:root.theme-dark .category-header {
  background: linear-gradient(90deg, rgba(64, 188, 178, 0.16), rgba(64, 188, 178, 0.04) 60%, transparent);
  border-left-color: rgba(120, 220, 212, 0.85);
}
:root.theme-dark .category-header:hover {
  background: linear-gradient(90deg, rgba(64, 188, 178, 0.24), rgba(64, 188, 178, 0.06) 60%, transparent);
}
:root.theme-dark .category-header strong {
  color: rgba(232, 238, 250, 0.96);
}
:root.theme-dark .category-count {
  background: rgba(64, 188, 178, 0.28);
  color: rgb(150, 230, 222);
}

.category-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
  margin-top: 8px;
  transition: max-height 300ms ease;
}

.category-items.collapsed {
  display: none;
}

/* Preset cards with thumbnails */
.preset-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.preset-thumb-wrap {
  flex-shrink: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(19, 33, 53, 0.08);
  overflow: hidden;
}

.preset-thumb {
  display: block;
}

.abstract-thumb {
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(244,248,252,0.88));
}

.abstract-thumb text {
  font-family: var(--heading-font);
  letter-spacing: 0.01em;
}

.preset-info {
  flex: 1;
  min-width: 0;
}

.reference-figure-panel {
  border-radius: 20px;
  border: 1px solid rgba(19, 33, 53, 0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(246,250,255,0.92));
  padding: 10px;
  overflow: hidden;
}

.reference-figure-panel svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Unsupported preset cards (reddish) */
.preset-unsupported {
  background: rgba(212, 77, 73, 0.06) !important;
  border: 1px solid rgba(212, 77, 73, 0.15);
}

.preset-unsupported-badge {
  background: rgba(212, 77, 73, 0.12) !important;
  color: #7a2320 !important;
}

/* Infinite edge SVG styles */
.inf-marker {
  font-size: 22px;
  font-weight: 800;
  text-anchor: middle;
  pointer-events: none;
  animation: inf-marker-pulse 2.4s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
  paint-order: stroke;
  stroke: var(--page-cream);
  stroke-width: 3;
}

:root.theme-dark .inf-marker {
  /* On dark backgrounds, contrast with a deep stroke */
  stroke: rgba(8, 14, 30, 0.92);
}

@keyframes inf-marker-pulse {
  0%, 100% { opacity: 0.92; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.12); }
}

.inf-vapor-trail {
  opacity: 0.55;
  animation: inf-vapor-fade 2.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes inf-vapor-fade {
  0%, 100% { opacity: 0.35; stroke-dashoffset: 0; }
  50% { opacity: 0.7; stroke-dashoffset: -12; }
}

.inf-overlay {
  animation: inf-march 1.8s linear infinite;
}

.inf-overlay-grass {
  animation-duration: 2.6s;
}

.inf-overlay-flower {
  animation-duration: 2s;
}

.inf-overlay-tower {
  animation-duration: 1.4s;
}

@keyframes inf-march {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -24; }
}

@media (prefers-reduced-motion: reduce) {
  .inf-marker,
  .inf-overlay {
    animation: none;
  }
}

/* Infinite edge slider popup */
.inf-slider-popup {
  position: fixed;
  z-index: 9999;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: var(--panel-shadow);
  padding: 12px 16px;
  min-width: 240px;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: auto;
}
.inf-slider-popup.inf-slider-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.inf-slider-popup.inf-slider-hiding {
  opacity: 0;
  transform: translateY(6px) scale(0.97);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}
.inf-slider-header {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--page-ink);
  margin-bottom: 8px;
}
.inf-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.inf-slider-range {
  flex: 1;
  height: 22px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  --fill: 7%;
}
.inf-slider-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--navy) 0 var(--fill), rgba(19, 33, 53, 0.14) var(--fill) 100%);
}
.inf-slider-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--navy);
  box-shadow: 0 1px 5px rgba(19, 33, 53, 0.32);
  transition: transform 0.12s ease;
}
.inf-slider-range:hover::-webkit-slider-thumb { transform: scale(1.14); }
.inf-slider-range:active::-webkit-slider-thumb { transform: scale(0.95); }
.inf-slider-range::-moz-range-track { height: 6px; border-radius: 999px; background: rgba(19, 33, 53, 0.14); }
.inf-slider-range::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--navy); }
.inf-slider-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 3px solid var(--navy);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 5px rgba(19, 33, 53, 0.32);
}
:root.theme-dark .inf-slider-range::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, var(--navy-soft) 0 var(--fill), rgba(255, 255, 255, 0.16) var(--fill) 100%);
}
:root.theme-dark .inf-slider-range::-moz-range-track { background: rgba(255, 255, 255, 0.16); }
:root.theme-dark .inf-slider-range::-moz-range-progress { background: var(--navy-soft); }

/* Themed thin scrollbars across the app (fit the overall style). */
* { scrollbar-width: thin; scrollbar-color: rgba(31, 143, 135, 0.45) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(19, 33, 53, 0.26);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(31, 143, 135, 0.62); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
:root.theme-dark * { scrollbar-color: rgba(64, 188, 178, 0.5) transparent; }
:root.theme-dark ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); background-clip: padding-box; }
:root.theme-dark ::-webkit-scrollbar-thumb:hover { background: rgba(64, 188, 178, 0.6); background-clip: padding-box; }

/* ── Dark-mode contrast fixes ── */
/* Category master: titles were inheriting the button default (black) on the
   dark panel; give them a real color and brighten the preview boxes so the
   small category views stand out. */
.lib-cat { color: var(--page-ink); }
/* Side names are color-coded; inside the dark metric cards they must be bright
   enough to read in BOTH themes (the card is dark navy in light, slate in dark).
   This is the "side: Blue is too close to the background" fix. */
.metric-card .color-blue { color: #6ea2ff; }
.metric-card .color-red { color: #ff8275; }
.metric-card .color-green { color: #7ed27e; }

/* Quick-wins polish: shortcuts button + page footer. */
.shortcuts-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: rgba(19, 33, 53, 0.06);
  color: var(--page-muted);
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: all var(--transition);
}
.shortcuts-btn:hover { background: rgba(19, 33, 53, 0.12); color: var(--page-ink); }
:root.theme-dark .shortcuts-btn { background: rgba(255, 255, 255, 0.07); border-color: rgba(255, 255, 255, 0.12); }
.site-footer {
  margin-top: 22px;
  padding: 16px 6px 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 1px solid var(--panel-border);
  color: var(--page-muted);
  font-size: 0.85rem;
}
.site-footer-links { display: inline-flex; gap: 8px; align-items: center; }
.site-footer-links a { color: var(--teal); text-decoration: none; }
.site-footer-links a:hover { text-decoration: underline; }

/* Rules legend under the board. */
.rules-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--page-muted);
}
.rules-item { display: inline-flex; align-items: center; gap: 6px; }
.rules-swatch { width: 13px; height: 13px; border-radius: 4px; }
.rules-blue { background: var(--blue); }
.rules-red { background: var(--red); }
.rules-green { background: var(--green); }
.rules-note { font-style: italic; opacity: 0.85; }
:root.theme-dark .lib-cat { background: rgba(255, 255, 255, 0.07); border-color: rgba(255, 255, 255, 0.1); }
:root.theme-dark .lib-cat:hover { background: rgba(255, 255, 255, 0.12); }
:root.theme-dark .lib-cat-thumb {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}
/* "Selected/filled" surfaces use a light lavender (var(--navy)) in dark mode, so
   their white text was low-contrast (metric cards, the active mode pill, active
   tool buttons, the on quick-toggle, the slider Cut button). Give them a
   saturated blue fill in dark mode — light mode is untouched — so the white
   text reads cleanly. */
/* Metric cards hold color-coded side text (blue/red), so a deep slate fill
   keeps BOTH the white values and the colored side names legible. */
:root.theme-dark .metric-card {
  background: linear-gradient(150deg, #1b2c4a, #273f66);
}
/* Active controls carry only white text, so a saturated blue lets them pop. */
:root.theme-dark .mode-indicator,
:root.theme-dark .tool-button.is-active,
:root.theme-dark .action-button.is-active,
:root.theme-dark .quick-toggle-btn.is-on {
  background: linear-gradient(160deg, #2c52bd, #4a6fd0);
}
:root.theme-dark .inf-slider-confirm { background: #2c52bd; border-color: #2c52bd; }
:root.theme-dark .inf-slider-confirm:hover { background: #4a6fd0; }
.inf-slider-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 30px;
  text-align: center;
  color: var(--navy);
}
.inf-slider-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 10px;
}
.inf-slider-btn {
  font-size: 0.78rem;
  padding: 4px 14px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.12s;
}
.inf-slider-btn:hover { background: rgba(0,0,0,0.05); }
.inf-slider-confirm {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.inf-slider-confirm:hover { background: var(--navy-soft); }

/* Tooltip infinite hints */
.tooltip-detail.inf-hint {
  font-size: 0.72rem;
  color: var(--page-muted);
  font-style: italic;
}

/* Start Match glow */
@keyframes start-glow {
  0%, 100% { box-shadow: 0 0 8px 2px rgba(218,165,32,0.35); }
  50% { box-shadow: 0 0 20px 6px rgba(255,200,0,0.65); }
}
.start-glow {
  animation: start-glow 1.8s ease-in-out infinite;
  border-color: #daa520 !important;
}

/* Cut animation overlay */
.anim-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

/* Auto mode turn tints */
.board-frame.auto-blue-turn { background: linear-gradient(135deg, rgba(50,120,230,0.06), transparent 60%); }
.board-frame.auto-red-turn { background: linear-gradient(135deg, rgba(230,60,50,0.06), transparent 60%); }

/* Auto celebration overlay */
.auto-celebration {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  animation: celebrate-in 0.5s cubic-bezier(0.34,1.56,0.64,1);
}

.celebration-inner {
  max-width: min(420px, calc(100% - 40px));
  padding: 24px 28px;
  border-radius: 28px;
  text-align: center;
  background: var(--panel-bg);
  color: var(--page-ink);
  border: 1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
}

.celebration-inner.is-fast {
  max-width: min(460px, 72vw);
  padding: 0;
  border-radius: 0;
  text-align: right;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.auto-result-title {
  font-size: 1.4rem;
  font-weight: 700;
}

.auto-result-subtitle {
  margin-top: 6px;
  font-size: 0.96rem;
  color: var(--page-muted);
}

.auto-result-note {
  margin-top: 10px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.auto-celebration.is-fast {
  inset: auto 16px 16px auto;
  align-items: flex-end;
  justify-content: flex-end;
  background: transparent;
  backdrop-filter: none;
  animation: none;
  pointer-events: none;
}
@keyframes celebrate-in {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}
.auto-celebration h2 {
  font-size: 2rem;
  margin: 0 0 12px;
}
.auto-celebration .auto-score {
  font-size: 1rem;
  color: var(--page-muted);
}
.auto-shape {
  width: 60px;
  height: 60px;
  margin-bottom: 16px;
  animation: shape-bounce 0.6s ease infinite alternate;
}
@keyframes shape-bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-14px); }
}
.auto-shape-blue {
  background: var(--blue);
  border-radius: 6px;
}
.auto-shape-red {
  width: 0; height: 0;
  background: none;
  border-left: 30px solid transparent;
  border-right: 30px solid transparent;
  border-bottom: 60px solid var(--red);
}

/* Auto panels — grid layout that fills the void left by the tall Cut FX
   group. Cut FX takes the full right column; Heat viz expands across the
   left to use its meter+thermograph as visual ballast. */
.auto-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(320px, 2fr);
  grid-template-areas:
    "controls speed cutfx"
    "heat     heat  cutfx"
    "shape    score cutfx";
  gap: 14px 20px;
  align-items: start;
}

.auto-toolbar > .toolbar-group:nth-child(1) { grid-area: controls; }
.auto-toolbar > .toolbar-group:nth-child(2) { grid-area: speed; }
.auto-toolbar > .toolbar-group:nth-child(3) { grid-area: cutfx; }
.auto-toolbar > .toolbar-group:nth-child(4) { grid-area: shape; }
.auto-toolbar > .toolbar-group:nth-child(5) { grid-area: score; }
.auto-toolbar > .toolbar-group:nth-child(6) { grid-area: heat; }

.auto-toolbar .toolbar-buttons { gap: 6px; }
.auto-toolbar .toolbar-group { min-width: 0; }
.auto-toolbar .auto-heat-group { min-width: 0; max-width: 100%; }
.auto-toolbar .auto-heat-viz { width: 100%; max-width: 480px; }
.auto-toolbar .auto-heat-viz .thermograph-svg {
  width: 100%;
  height: auto;
  max-width: 380px;
}

/* Auto toolbar narrow: collapse the grid to single column only when actually
   too narrow (~700px). Above that, the 3-column grid stays put even on
   tablets so the heat viz keeps filling the void next to Cut FX. */
@media (max-width: 700px) {
  .auto-toolbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "controls"
      "speed"
      "cutfx"
      "shape"
      "score"
      "heat";
  }
}
.auto-speed-select {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  font-size: 0.82rem;
  font-weight: 600;
}
.auto-score-display {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: 8px;
  align-items: center;
}
.auto-score-display .score-blue { color: var(--blue); }
.auto-score-display .score-red { color: var(--red); }

.game-introduction { margin: 12px 0 18px; max-width: 88ch; color: var(--page-muted); font-size: .92rem; line-height: 1.6; }
.game-introduction > p { margin: 0 0 10px; }
.game-introduction strong { color: var(--page-ink); }
.game-readpath { padding: 10px 14px; border: 1px solid var(--panel-border); border-radius: 14px; background: var(--panel-bg); }
.game-readpath summary { cursor: pointer; color: var(--page-ink); font-weight: 600; font-size: .86rem; }
.game-readpath ol { padding-left: 20px; margin: 12px 0; }
.game-readpath li + li { margin-top: 7px; }
.game-readpath p { margin: 10px 0 2px; font-size: .85rem; }
.game-readpath a { color: var(--blue); text-underline-offset: 3px; }
.game-readpath summary:focus-visible, .game-readpath a:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .auto-heat-bar, .heat-bar { transition: none; }
}
