:root {
  --bg: #1a1713;
  --bg2: #211e1a;
  --surface: #2b2722;
  --surface2: #36322c;
  --surface3: #413d36;
  --border: #4a453d;
  --text: #d4cfc7;
  --text2: #9e9889;
  --white: #f0ece4;
  --accent: #7fad39;
  --accent2: #95c44d;
  --accent-bg: rgba(127, 173, 57, 0.12);
  --blunder: #e74c3c;
  --mistake: #e69f00;
  --inaccuracy: #56b4e9;
  --good: #7fad39;
  --ok: #9e9889;
  --wood: #8b6f47;
  --wood-light: #a68b5b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ═══════════════════════════════
   BUTTONS
   ═══════════════════════════════ */
.btn-primary {
  padding: 12px 28px;
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-ghost {
  padding: 12px 28px;
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--white); }

/* ═══════════════════════════════
   INPUT PAGE
   ═══════════════════════════════ */
.input-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.input-wrap {
  width: 100%;
  max-width: 480px;
}
.logo {
  font-size: 2rem;
  font-weight: 800;
  color: var(--white);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-icon { vertical-align: middle; flex-shrink: 0; }
.topbar-icon { vertical-align: -4px; }
.tagline {
  color: var(--text2);
  font-size: 1.05rem;
  margin-bottom: 24px;
}
.input-field {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
}
.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg);
}
textarea.input-field {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.85rem;
  resize: vertical;
}
.input-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  color: var(--text2);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.input-or::before, .input-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.input-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.status-text {
  margin-top: 12px;
  color: var(--mistake);
  font-size: 0.9rem;
}

/* ── Input tabs ── */
.input-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 18px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.input-tab {
  flex: 1;
  padding: 10px 16px;
  background: var(--surface);
  color: var(--text2);
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.input-tab:hover { color: var(--white); }
.input-tab.active {
  background: var(--accent);
  color: #1a1a1a;
}

/* ── Platform toggle ── */
.platform-toggle {
  display: flex;
  gap: 0;
  margin-top: 12px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.platform-btn {
  flex: 1;
  padding: 10px 16px;
  background: var(--surface);
  color: var(--text2);
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.platform-btn:hover { color: var(--white); }
.platform-btn.active {
  background: var(--wood);
  color: var(--white);
}

/* ── Scout options ── */
.scout-options {
  display: flex;
  gap: 16px;
  margin-top: 14px;
}
.scout-option-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.scout-option-label {
  font-size: 0.78rem;
  color: var(--text2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.option-toggle {
  display: flex;
  gap: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.option-btn {
  flex: 1;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text2);
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.option-btn:hover { color: var(--white); }
.option-btn.active {
  background: var(--wood);
  color: var(--white);
}

/* ═══════════════════════════════
   ANALYSIS PAGE
   ═══════════════════════════════ */
.analysis-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 2px solid var(--wood);
}
.topbar-btn {
  padding: 8px 18px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.topbar-btn:hover { background: var(--surface3); color: var(--white); }
.topbar-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--white);
}
.topbar-opening {
  color: var(--wood-light);
  font-size: 0.9rem;
  font-weight: 500;
  margin-left: auto;
}

/* ── Progress bar ── */
.progress-bar {
  position: relative;
  height: 28px;
  background: var(--surface);
  overflow: hidden;
}
.progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.4s ease;
}
.progress-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--white);
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  z-index: 1;
}

/* ── Analysis grid ── */
.analysis-grid {
  display: grid;
  grid-template-columns: 36px 1fr 340px;
  gap: 0;
  flex: 1;
  min-height: 0;
  padding: 12px 16px;
}

/* ── Eval bar (vertical) ── */
.eval-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
}
.eval-track {
  width: 26px;
  height: 100%;
  max-height: 520px;
  background: #333;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}
.eval-white {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50%;
  background: linear-gradient(to top, #f0ece4, #d8d3c8);
  transition: height 0.4s ease;
}
.eval-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
}

/* ── Board column ── */
.board-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}
.the-board {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1;
}
.board-controls {
  display: flex;
  gap: 6px;
}
.ctrl-btn {
  width: 48px;
  height: 40px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ctrl-btn:hover {
  background: var(--surface3);
  color: var(--white);
  border-color: var(--wood);
}
.ctrl-btn:active { transform: scale(0.95); }

/* ── Right column ── */
.right-col {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  max-height: calc(100vh - 100px);
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
}

/* ── Summary strip ── */
.summary-strip {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.summary-strip:empty { display: none; }
.sum-side {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}
.sum-side:first-child { border-right: 1px solid var(--border); }
.sum-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--white);
}
.sum-acc {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.sum-badges {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: capitalize;
}
.badge-blunder { background: rgba(231,76,60,0.2); color: var(--blunder); }
.badge-mistake { background: rgba(230,159,0,0.2); color: var(--mistake); }
.badge-inaccuracy { background: rgba(86,180,233,0.2); color: var(--inaccuracy); }
.badge-good { background: rgba(127,173,57,0.2); color: var(--good); }
.badge-ok { background: rgba(158,152,137,0.15); color: var(--ok); }

/* ── Coach panel (above moves, always visible) ── */
.coach {
  padding: 14px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  line-height: 1.55;
  flex-shrink: 0;
}
.coach-empty {
  color: var(--text2);
  font-style: italic;
  padding: 8px 0;
}
.coach-move-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.coach-move-san {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--white);
}
.coach-eval {
  font-size: 0.82rem;
  color: var(--text2);
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.coach-best {
  font-size: 0.88rem;
  color: var(--accent);
  margin-bottom: 4px;
}
.coach-best strong { color: var(--accent2); }
.coach-pv {
  font-size: 0.78rem;
  color: var(--text2);
  font-family: "SF Mono", "Fira Code", monospace;
  margin-bottom: 8px;
  word-break: break-all;
}
.coach-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.coach-summary {
  color: var(--white);
  font-size: 0.92rem;
  line-height: 1.5;
}
.coach-whybad {
  color: var(--blunder);
  font-size: 0.88rem;
  padding: 6px 10px;
  background: rgba(231,76,60,0.08);
  border-radius: 4px;
  border-left: 3px solid var(--blunder);
}
.coach-better {
  color: var(--accent);
  font-size: 0.88rem;
  padding: 6px 10px;
  background: var(--accent-bg);
  border-radius: 4px;
  border-left: 3px solid var(--accent);
}
.coach-tip {
  color: var(--wood-light);
  font-size: 0.85rem;
  padding: 6px 10px;
  background: rgba(139,111,71,0.1);
  border-radius: 4px;
  border-left: 3px solid var(--wood);
}

/* ── Filter row ── */
.filter-row {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.filter-btn {
  flex: 1;
  padding: 9px 12px;
  background: transparent;
  color: var(--text2);
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.filter-btn:hover { color: var(--white); background: var(--surface2); }
.filter-btn.active {
  color: var(--accent);
  background: var(--accent-bg);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* ── Move list ── */
.moves-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  min-height: 0;
}
.move-row {
  display: grid;
  grid-template-columns: 36px 1fr 1fr;
  align-items: center;
  padding: 0 4px;
}
.move-row:hover { background: var(--surface2); }
.move-num {
  font-size: 0.78rem;
  color: var(--text2);
  text-align: right;
  padding-right: 8px;
  font-variant-numeric: tabular-nums;
}
.move-cell {
  padding: 6px 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.move-cell:hover { background: var(--surface3); }
.move-cell.empty { cursor: default; }
.move-cell.active-move {
  background: var(--accent-bg);
  color: var(--white);
  font-weight: 700;
}
.move-cell.move-blunder { color: var(--blunder); }
.move-cell.move-mistake { color: var(--mistake); }
.move-cell.move-inaccuracy { color: var(--inaccuracy); }

/* ── Move icons ── */
.move-icon {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1;
}
.move-icon.blunder { background: var(--blunder); color: #fff; }
.move-icon.mistake { background: var(--mistake); color: #1a1a1a; }
.move-icon.inaccuracy { background: var(--inaccuracy); color: #1a1a1a; }
.move-icon.good { background: var(--good); color: #1a1a1a; }

/* ── Arrow overlay ── */
.arrow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* ── Arrow tooltips ── */
.arrow-tooltip {
  position: absolute;
  z-index: 20;
  max-width: 260px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.45;
  font-weight: 500;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  animation: tooltipFadeIn 0.15s ease;
}
.arrow-tooltip-played {
  background: rgba(40, 20, 20, 0.95);
  color: #f0c8c8;
  border: 1px solid var(--blunder);
}
.arrow-tooltip-best {
  background: rgba(20, 40, 20, 0.95);
  color: #c8f0c8;
  border: 1px solid var(--accent);
}
@keyframes tooltipFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.arrow-tooltip-fading {
  opacity: 0 !important;
  transition: opacity 0.5s ease;
}

/* Hint in coach panel */
.coach-arrow-hint {
  font-size: 0.78rem;
  color: var(--text2);
  font-style: italic;
  margin-top: 4px;
}

/* ── Scrollbar styling ── */
.moves-scroll::-webkit-scrollbar {
  width: 6px;
}
.moves-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.moves-scroll::-webkit-scrollbar-thumb {
  background: var(--surface3);
  border-radius: 3px;
}
.moves-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--border);
}

/* ═══════════════════════════════
   SCOUT LOADING OVERLAY
   ═══════════════════════════════ */
.scout-loading {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(26, 23, 19, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: scoutOverlayIn 0.25s ease;
}
@keyframes scoutOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.scout-loading-inner {
  text-align: center;
  max-width: 340px;
  padding: 40px 32px;
}
.scout-loading-knight {
  margin-bottom: 6px;
  animation: knightBounce 1.2s ease-in-out infinite;
  filter: drop-shadow(0 4px 20px rgba(127, 173, 57, 0.3));
  color: var(--accent);
}
@keyframes knightBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  30% { transform: translateY(-18px) rotate(-8deg); }
  60% { transform: translateY(-6px) rotate(4deg); }
}
.scout-loading-pct {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}
.scout-loading-text {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 16px;
}
.scout-loading-bar {
  width: 100%;
  height: 6px;
  background: var(--surface3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}
.scout-loading-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 3px;
  transition: width 0.15s linear;
}

/* ═══════════════════════════════
   SCOUT PAGE
   ═══════════════════════════════ */
.scout-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.scout-content {
  flex: 1;
  padding: 20px 24px 40px;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

/* Scout filters bar */
.scout-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.btn-sm {
  padding: 8px 18px;
  font-size: 0.85rem;
  margin-left: auto;
}
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.share-btn { background: var(--accent); color: #1a1a1a; border-color: var(--accent); font-weight: 700; }
.share-btn:hover { background: var(--accent2); }

/* ── Hero card ── */
.scout-hero {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  display: flex;
  align-items: center;
  gap: 28px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.scout-hero::before {
  content: '';
  position: absolute;
  right: -10px;
  top: -10px;
  width: 140px;
  height: 140px;
  opacity: 0.04;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23f0ece4' d='M19 22H5v-2h14v2M17.16 8.26A4.96 4.96 0 0 0 19 4c0-.55-.45-1-1-1s-1 .45-1 1a3 3 0 0 1-3 3h-4a3 3 0 0 1-3-3c0-.55-.45-1-1-1s-1 .45-1 1a4.96 4.96 0 0 0 1.84 4.26C5.15 10.5 4 13.07 4 16v2h16v-2c0-2.93-1.15-5.5-2.84-7.74z'/%3E%3C/svg%3E") no-repeat center;
  background-size: contain;
}
.scout-hero-ring {
  flex-shrink: 0;
  position: relative;
  width: 110px;
  height: 110px;
}
.scout-hero-ring svg { width: 110px; height: 110px; transform: rotate(-90deg); }
.scout-hero-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.scout-hero-wr {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--white);
  line-height: 1;
}
.scout-hero-wr-sub {
  font-size: 0.68rem;
  color: var(--text2);
  margin-top: 2px;
}
.scout-hero-info { flex: 1; min-width: 0; }
.scout-hero-name {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--white);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.scout-hero-rating {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--accent-bg);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}
.scout-hero-meta {
  font-size: 0.88rem;
  color: var(--text2);
  margin-top: 6px;
}
.scout-hero-wld {
  display: flex;
  gap: 16px;
  margin-top: 10px;
}
.scout-hero-wld-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.88rem;
  font-weight: 700;
}
.scout-hero-wld-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.dot-win { background: var(--accent); }
.dot-draw { background: var(--text2); }
.dot-loss { background: var(--blunder); }

/* ── WLD bar ── */
.scout-wld-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 20px;
}
.scout-wld-bar .wld-win { background: var(--accent); }
.scout-wld-bar .wld-draw { background: var(--text2); }
.scout-wld-bar .wld-loss { background: var(--blunder); }

/* ── Stats row ── */
.scout-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.scout-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 12px;
  text-align: center;
}
.scout-stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.scout-stat-label {
  font-size: 0.75rem;
  color: var(--text2);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ── Rival cards (Nemesis / Victim) ── */
.scout-rivals {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.scout-rival-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.scout-rival-card.nemesis { border-left: 3px solid var(--blunder); }
.scout-rival-card.victim { border-left: 3px solid var(--accent); }
.scout-rival-card.nemesis .rival-icon { color: var(--blunder); }
.scout-rival-card.victim .rival-icon { color: var(--accent); }
.rival-icon { flex-shrink: 0; line-height: 1; }
.rival-info { flex: 1; min-width: 0; }
.rival-label {
  font-size: 0.72rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.rival-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rival-record {
  font-size: 0.78rem;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
}

/* ── Two-column layout ── */
.scout-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

/* ── Opening table ── */
.scout-openings {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.scout-openings h3 {
  font-size: 0.82rem;
  color: var(--wood-light);
  margin-bottom: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.scout-opening-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 4px;
  font-size: 0.82rem;
  align-items: center;
}
.scout-opening-row:nth-child(even) { background: var(--bg2); }
.scout-opening-name { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scout-opening-record { color: var(--text2); text-align: center; font-variant-numeric: tabular-nums; font-size: 0.78rem; }
.scout-opening-wr { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 38px; }
.scout-opening-wr.good { color: var(--accent); }
.scout-opening-wr.bad { color: var(--blunder); }
.scout-opening-wr.mid { color: var(--mistake); }

/* ── Breakdown cards ── */
.scout-breakdown-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.scout-breakdown-col h4 {
  font-size: 0.82rem;
  color: var(--text2);
  margin-bottom: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.scout-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.82rem;
}
.scout-bar-label { color: var(--text2); width: 72px; font-weight: 500; }
.scout-bar-track {
  flex: 1;
  height: 8px;
  background: var(--surface3);
  border-radius: 4px;
  overflow: hidden;
}
.scout-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.scout-bar-num { color: var(--text); width: 24px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── AI Report sections ── */
.scout-report {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}
.scout-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
}
.scout-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--wood-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.scout-section-body {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.55;
}

/* ── Watermark for share ── */
.scout-watermark {
  text-align: center;
  padding: 16px 0 4px;
  font-size: 0.82rem;
  color: var(--text2);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.scout-watermark span { color: var(--accent); }

/* ── Color stats row ── */
.scout-color-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.scout-color-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.scout-color-piece {
  font-size: 2rem;
  line-height: 1;
}
.scout-color-info { flex: 1; }
.scout-color-label {
  font-size: 0.75rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}
.scout-color-wr {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}
.scout-color-record {
  font-size: 0.78rem;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
}

/* ── AI Report button loading state ── */
.ai-btn-generating {
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--wood-light), var(--accent));
  background-size: 300% 100%;
  animation: aiGradientShift 2s ease infinite;
  pointer-events: none;
}
@keyframes aiGradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.ai-sparkle-spin {
  display: inline-flex;
  animation: sparkleSpin 1.6s linear infinite;
}
@keyframes sparkleSpin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}
.ai-btn-loading { display: inline-flex; align-items: center; gap: 0; }
.dot-pulse::after {
  content: '...';
  display: inline-block;
  width: 1em;
  overflow: hidden;
  animation: dotClip 1.2s steps(4) infinite;
  vertical-align: bottom;
}
@keyframes dotClip {
  0% { width: 0; }
  33% { width: 0.4em; }
  66% { width: 0.7em; }
  100% { width: 1em; }
}

@media (max-width: 640px) {
  .scout-hero { flex-direction: column; text-align: center; gap: 16px; padding: 20px; }
  .scout-hero-wld { justify-content: center; }
  .scout-two-col { grid-template-columns: 1fr; }
  .scout-color-row { flex-direction: column; }
  .scout-rivals { flex-direction: column; }
  .scout-content { padding: 14px 12px 30px; }
}

/* ═══════════════════════════════
   RESPONSIVE
   ═══════════════════════════════ */
@media (max-width: 1100px) {
  .analysis-grid {
    grid-template-columns: 30px 1fr 280px;
    padding: 10px 10px;
  }
}

@media (max-width: 860px) {
  .analysis-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 10px;
    padding: 10px;
  }
  .eval-col {
    flex-direction: row;
    justify-content: center;
    order: -1;
  }
  .eval-track {
    width: 100%;
    height: 20px;
    max-height: none;
  }
  .eval-white {
    bottom: auto;
    left: 0;
    top: 0;
    width: 50%;
    height: 100%;
    transition: width 0.4s ease;
  }
  .board-col {
    padding: 0;
  }
  .the-board {
    max-width: 100%;
  }
  .right-col {
    max-height: 50vh;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }
  .topbar-opening {
    margin-left: 0;
    width: 100%;
    font-size: 0.82rem;
  }
}

@media (max-width: 480px) {
  .input-wrap { padding: 0 8px; }
  .input-actions { flex-direction: column; }
  .btn-primary, .btn-ghost { width: 100%; }
  .ctrl-btn { width: 40px; height: 36px; font-size: 0.95rem; }
}

/* ═══════════════════════════════
   TRAINING PAGE
   ═══════════════════════════════ */

/* ── Train tab input ── */
.train-search-wrap {
  position: relative;
}
.train-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  max-height: 240px;
  overflow-y: auto;
}
.search-result-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 14px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.search-result-btn:hover { background: var(--surface2); }
.search-result-eco {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--wood-light);
  min-width: 32px;
}
.search-result-name { flex: 1; }

.train-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  align-items: center;
}
.train-presets-label {
  font-size: 0.78rem;
  color: var(--text2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}
.train-preset {
  padding: 5px 12px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.train-preset:hover { border-color: var(--accent); color: var(--white); }

/* ── Training page layout ── */
.train-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.train-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  flex: 1;
  padding: 16px 20px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}
.train-board-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.train-board-col .the-board {
  width: 100%;
  max-width: 520px;
}

/* ── Feedback bar ── */
.train-feedback {
  min-height: 44px;
  width: 100%;
  max-width: 520px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}
.train-feedback:empty { display: none; }
.train-feedback.correct {
  background: rgba(127, 173, 57, 0.15);
  color: var(--accent);
}
.train-feedback.wrong {
  background: rgba(231, 76, 60, 0.15);
  color: var(--blunder);
}
.train-feedback.info {
  background: rgba(139, 111, 71, 0.12);
  color: var(--wood-light);
}
.train-feedback.complete {
  background: rgba(127, 173, 57, 0.15);
  color: var(--accent);
}
.train-feedback.demo {
  background: rgba(100, 149, 237, 0.15);
  color: #6495ed;
}

/* ── Train action buttons ── */
.train-controls {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 520px;
  justify-content: center;
}
.train-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.train-action-btn:hover {
  border-color: var(--accent);
  color: var(--white);
  background: var(--surface2);
}
.train-action-btn.watch {
  border-color: #6495ed;
  color: #6495ed;
}
.train-action-btn.watch:hover {
  background: rgba(100, 149, 237, 0.12);
  color: #7eaaff;
}
.train-action-btn.retry {
  border-color: var(--accent);
  color: var(--accent);
}
.train-action-btn.retry:hover {
  background: rgba(127, 173, 57, 0.12);
}

/* ── Right column ── */
.train-right-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  max-height: calc(100vh - 100px);
}

/* ── Info panel ── */
.train-info-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.train-description {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.5;
}

/* ── Demo move list ── */
.demo-move-list {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 5px;
  align-items: baseline;
  font-size: 0.88rem;
  line-height: 1.6;
}
.demo-move-num {
  color: var(--text2);
  font-size: 0.78rem;
  font-weight: 700;
  margin-left: 4px;
}
.demo-move {
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
.demo-move.played {
  color: var(--text);
  background: rgba(127, 173, 57, 0.1);
}
.demo-move.current {
  color: var(--white);
  background: var(--accent);
  font-weight: 700;
}
.demo-move.upcoming {
  color: var(--text2);
  opacity: 0.4;
}
.demo-move-label {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 4px;
}

/* ── Line selector ── */
.train-line-selector {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  max-height: 180px;
  overflow-y: auto;
}
.train-line-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}
.train-line-btn:hover { background: var(--surface2); }
.train-line-btn.active { background: var(--accent-bg); border-color: var(--accent); color: var(--white); font-weight: 700; }
.train-line-btn .line-status {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.line-status.pending { background: var(--surface3); color: var(--text2); }
.line-status.in-progress { background: rgba(230, 159, 0, 0.2); color: var(--mistake); }
.line-status.complete { background: rgba(127, 173, 57, 0.2); color: var(--accent); }

/* ── Progress panel ── */
.train-progress-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}
.train-progress-panel:empty { display: none; }
.train-progress-bar {
  height: 8px;
  background: var(--surface3);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}
.train-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.train-progress-text {
  font-size: 0.78rem;
  color: var(--text2);
  font-weight: 600;
}

/* ── Chat panel in training ── */
.train-chat-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.train-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.train-chat-msg {
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 92%;
  word-wrap: break-word;
}
.train-chat-msg.coach {
  background: var(--surface);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}
.train-chat-msg.coach.typing {
  color: var(--text2);
  font-style: italic;
}
.train-chat-msg.user {
  background: var(--accent-bg);
  color: var(--white);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.train-chat-input-row {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.train-chat-field {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}
.train-chat-field:focus {
  border-color: var(--accent);
}
.train-chat-send {
  padding: 6px 12px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.train-chat-send:hover {
  background: var(--accent-hover, #6a9a30);
}

/* ── Training responsive ── */
@media (max-width: 860px) {
  .train-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }
  .train-right-col { max-height: none; }
}
