﻿/* ==========================================================================
   ChessMIND Modern Grandmaster Design System v3.0
   Color Palette: Obsidian Dark + Imperial Gold + Emerald Accent
   Fully Responsive (Desktop, Tablet, Mobile)
   ========================================================================== */

:root {
  /* ==========================================================================
     Stitch "Grandmaster Tournament & Analysis Workstation" Design Tokens
     Source: stitch_chessmind_ai_grandmaster_platform/DESIGN.md
     Tone: flat industrial, structural hairlines, zero decorative glow
     ========================================================================== */

  /* Surface Architecture (Z-0..Z-3 planar layering) */
  --bg-primary: #0f131b;          /* Z-0 Base Plane */
  --bg-secondary: #1c2028;        /* Z-1 Panel Surfaces */
  --bg-card: #1c2028;             /* flat panel, 1px hairline */
  --bg-card-hover: #31353d;       /* Z-3 hover/popover */
  --bg-elevated: #262a32;         /* Z-2 active elements */
  --bg-recessed: #0a0e16;         /* recessed inputs / clock plate */

  /* Structural hairlines (replaces all glassy borders) */
  --border-color: #424939;
  --border-active: #9cd85c;
  --border-subtle: #181c24;
  --border-float: #8c9380;        /* Z-3 floating edge */

  /* Semantic & Analysis Chromatics */
  --accent-gold: #fcba5b;         /* Theoretical Amber: book moves / novelty */
  --accent-gold-glow: rgba(252, 186, 91, 0.22);
  --accent-emerald: #9cd85c;      /* Tournament Green: PV1 / confirmed moves */
  --accent-emerald-glow: rgba(156, 216, 92, 0.22);
  --accent-emerald-anchor: #68a02a;
  --accent-blue: #c2c9b4;         /* Subdued Slate: depth / thread metrics */
  --accent-rose: #ffb4ab;         /* Critical / blunder / clock distress */
  --accent-rose-glow: rgba(255, 180, 171, 0.25);

  /* Typography */
  --text-main: #dfe2ed;
  --text-muted: #c2c9b4;
  --text-dim: #8c9380;
  --font-ui: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Board Default: Tournament Green Chromatic Discipline */
  --sq-light: #eeeed2;
  --sq-dark: #769656;
  --sq-highlight: rgba(156, 216, 92, 0.5);
  --sq-lastmove: rgba(252, 186, 91, 0.4);
  --sq-check: rgba(255, 180, 171, 0.7);

  /* Industrial surgical corners */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;
}

/* Theme Variants — Tournament Green Chromatic Discipline (Stitch DESIGN.md) */
[data-theme="tournament"] {
  --sq-light: #eeeed2;
  --sq-dark: #769656;
  --arrow-rec: #facc15;
  --arrow-rec-outline: #0a0e16;
}

[data-theme="cyberpunk"] {
  --sq-light: #262a32;
  --sq-dark: #181c24;
  --arrow-rec: #0a0e16;
  --arrow-rec-outline: #ffffff;
}

[data-theme="nightwatch"] {
  --sq-light: #262a32;
  --sq-dark: #181c24;
  --sq-highlight: rgba(140, 147, 128, 0.5);
  --border-color: rgba(140, 147, 128, 0.25);
}

[data-theme="walnut"] {
  --sq-light: #e3c896;
  --sq-dark: #8b5a2b;
  --arrow-rec: #facc15;
  --arrow-rec-outline: #0a0e16;
}

[data-theme="ice"] {
  --sq-light: #dbeafe;
  --sq-dark: #2563eb;
  --arrow-rec: #facc15;
  --arrow-rec-outline: #0a0e16;
}

[data-theme="ruby"] {
  --sq-light: #ffe4e6;
  --sq-dark: #9f1239;
  --arrow-rec: #facc15;
  --arrow-rec-outline: #0a0e16;
}

/* Reset & Global */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Custom Sleek Dark Scrollbar (workstation hairline) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #424939;
  border-radius: 4px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: #8c9380;
}

/* ==========================================================================
   Header Navigation
   ========================================================================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--bg-recessed);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-emerald-anchor);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: none;
  color: #ffffff;
}

.logo-text h1 {
  font-family: var(--font-ui);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.logo-text .badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  background: rgba(252, 186, 91, 0.15);
  border: 1px solid rgba(252, 186, 91, 0.4);
  color: var(--accent-gold);
  border-radius: 2px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Center Mode Segmented Control */
.mode-switcher-nav {
  display: flex;
  align-items: center;
  background: var(--bg-recessed);
  border: 1px solid var(--border-color);
  padding: 0.25rem;
  border-radius: 4px;
  gap: 0.25rem;
}

.mode-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  background: transparent;
  border: none;
  border-radius: 2px;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.mode-tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-elevated);
}

.mode-tab-btn.active {
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-active);
  box-shadow: none;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.btn-action-ghost {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-action-ghost:hover {
  background: var(--bg-elevated);
  border-color: var(--border-color);
  color: var(--text-main);
  transform: none;
}

.engine-status-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  background: rgba(156, 216, 92, 0.08);
  border: 1px solid rgba(156, 216, 92, 0.3);
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #9cd85c;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9cd85c;
  box-shadow: 0 0 8px #9cd85c;
  animation: pulse-dot 2s infinite ease-in-out;
}

.status-dot.calculating {
  background: #fcba5b;
  box-shadow: 0 0 10px #fcba5b;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

/* ==========================================================================
   Main Workspace Layout: Board on Top, Settings & Controls Below (Split-Screen & Mobile Optimized)
   ========================================================================== */
.main-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.85rem;
  padding: 0.75rem 1rem 2.5rem;
  max-width: 540px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* ==========================================================================
   TOP SECTION: Chess Arena (Large, Crisp, Dominant)
   ========================================================================== */
.game-section {
  display: flex;
  gap: 0.65rem;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  max-width: 535px;
}

/* ==========================================================================
   Chess Arena Row: Board + Strictly Aligned Evaluation Bar (Lichess 1:1)
   ========================================================================== */
.board-arena-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
  position: relative;
}

/* Professional Vertical Evaluation Bar (Matches Board Height Exactly) */
.eval-bar-container {
  width: 16px;
  background: #262a32;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
  user-select: none;
}

.eval-bar-container.flipped {
  flex-direction: column-reverse;
}

/* Clear Slate Gray Black Bar (Eliminates blend into body background) */
.eval-black {
  background: #424939;
  width: 100%;
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Midpoint Equilibrium Indicator (50:50 / 0.0) */
.eval-notch {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.65);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
  transform: translateY(-50%);
  z-index: 2;
  pointer-events: none;
}

/* Crisp Pure White Bar */
.eval-white {
  background: linear-gradient(180deg, #ffffff, #dfe2ed);
  width: 100%;
  flex: 1;
}

/* High-Contrast Evaluation Score Badge */
.eval-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 800;
  color: #c2c9b4;
  background: rgba(15, 23, 42, 0.88);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid rgba(140, 147, 128, 0.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  white-space: nowrap;
  z-index: 3;
}

/* Board + Player Cards Wrap */
.board-container {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: min(500px, 90vw);
  max-width: 500px;
}

/* Player Cards */
.player-info-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.65rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  backdrop-filter: blur(12px);
  transition: border-color 0.25s, box-shadow 0.25s;
}

.player-info-card.active-turn {
  border-color: var(--accent-gold);
  box-shadow: 0 0 16px rgba(252, 186, 91, 0.25);
}

.player-meta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.player-avatar {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  border: 1px solid var(--border-subtle);
}

.avatar-black {
  background: #262a32;
  color: #dfe2ed;
}

.avatar-white {
  background: #dfe2ed;
  color: #181c24;
}

.player-details strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

.captured-pieces {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  min-height: 14px;
}

.captured-advantage {
  font-weight: 700;
  color: var(--accent-gold);
  font-size: 0.72rem;
  margin-left: 0.25rem;
}

/* Active Format Banner (Mode Display without ticking countdown) */
.active-format-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(252, 186, 91, 0.25);
  border-radius: 4px;
  padding: 0.25rem 0.65rem;
  backdrop-filter: blur(12px);
  margin-bottom: 0.15rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.65);
}

.format-pill-tag {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
}

.format-icon {
  font-size: 1rem;
}

.format-title {
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 0.02em;
}

.format-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.engine-badge-tag {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 700;
  color: #9cd85c;
  background: rgba(156, 216, 92, 0.12);
  border: 1px solid rgba(156, 216, 92, 0.3);
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  letter-spacing: 0.04em;
}

.engine-dot-live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9cd85c;
  box-shadow: 0 0 8px #9cd85c;
  animation: pulse-dot 1.5s infinite;
}

/* Modern Player Status Pill (Stress-free, No Countdown) */
.player-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: 'Hanken Grotesk', sans-serif;
  letter-spacing: 0.02em;
  transition: all 0.25s ease;
  user-select: none;
}

.player-status-pill.active {
  background: rgba(156, 216, 92, 0.18);
  border: 1px solid rgba(156, 216, 92, 0.55);
  color: #9cd85c;
  box-shadow: 0 0 14px rgba(156, 216, 92, 0.3);
}

.player-status-pill.active .status-pulse-dot {
  background: #9cd85c;
  box-shadow: 0 0 8px #9cd85c;
  animation: pulse-dot 1.2s infinite;
}

.player-status-pill.idle {
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
}

.player-status-pill.idle .status-pulse-dot {
  background: #8c9380;
  opacity: 0.6;
}

.status-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

/* Digital Chess Clock (Hidden fallback) */
.chess-clock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.25rem;
  font-weight: 800;
  padding: 0.3rem 0.75rem;
  background: #0a0e16;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: #dfe2ed;
  min-width: 82px;
  text-align: center;
  letter-spacing: 0.05em;
}

.chess-clock.low-time {
  color: #ffb4ab;
  border-color: rgba(255, 180, 171, 0.4);
  animation: clock-blink 1s infinite;
}

@keyframes clock-blink {
  50% { opacity: 0.55; }
}

/* 8x8 Chessboard */
.board-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 0;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border-color);
}

.chessboard {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.square.light {
  background-color: var(--sq-light);
}

.square.dark {
  background-color: var(--sq-dark);
}

.square.selected {
  background-color: var(--sq-highlight) !important;
}

.square.last-move {
  background-color: var(--sq-lastmove) !important;
}

.square.in-check {
  background-color: var(--sq-check) !important;
}

/* Board Coordinates (Grandmaster Tournament Style: Clean, Distinct, Perfectly Positioned) */
.square-coord,
.coord-rank,
.coord-file {
  position: absolute !important;
  font-family: 'JetBrains Mono', 'Hanken Grotesk', monospace, sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  z-index: 2;
}

.coord-rank {
  top: 4px;
  left: 5px;
}

.coord-file {
  bottom: 4px;
  right: 5px;
}

/* Sharp Dynamic Contrast on Light vs Dark Squares */
.square.light .square-coord,
.square.light .coord-rank,
.square.light .coord-file {
  color: #8c9380;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.4);
}

.square.dark .square-coord,
.square.dark .coord-rank,
.square.dark .coord-file {
  color: #1c2028;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

/* Legal Move Hints */
.legal-dot {
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(156, 216, 92, 0.75);
  box-shadow: none;
  pointer-events: none;
  animation: dot-pop 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.legal-ring {
  position: absolute;
  inset: 0;
  border: 4px solid rgba(255, 180, 171, 0.75);
  border-radius: 0;
  pointer-events: none;
}

@keyframes dot-pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* Chess Pieces */
.piece {
  width: 86%;
  height: 86%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1);
  position: relative;
}

.piece svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45));
}

.piece:hover {
  transform: scale(1.06);
}

.piece-just-moved {
  animation: piece-land 0.22s ease-out;
}

@keyframes piece-land {
  0% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.touch-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 99999;
  width: 58px;
  height: 58px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.65));
  opacity: 0.95;
}

/* Arrow Overlay */
.arrow-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Threat Alert Status Banner */
.threat-alert {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.85rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.threat-alert.danger {
  background: rgba(255, 180, 171, 0.15);
  border-color: rgba(255, 180, 171, 0.35);
  color: #ffb4ab;
}

.threat-alert.safe {
  background: rgba(156, 216, 92, 0.12);
  border-color: rgba(156, 216, 92, 0.3);
  color: #b7f575;
}

/* ==========================================================================
   BOTTOM SECTION: Dashboard, Assistant & Engine Controls
   ========================================================================== */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: min(500px, 90vw);
  max-width: 500px;
}

/* Mode Panels */
.mode-panel {
  display: none;
}

.mode-panel.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.95rem;
  backdrop-filter: none;
  box-shadow: none;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}

.panel-tag {
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent-gold);
}

.badge-live {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.2);
  color: #c2c9b4;
}

.badge-sandbox {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: rgba(156, 216, 92, 0.2);
  color: #9cd85c;
}

/* Assistant Hero Recommendation Card */
.assistant-card {
  background: linear-gradient(135deg, rgba(22, 28, 40, 0.95), rgba(16, 20, 30, 0.98));
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.95rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 16px rgba(252, 186, 91, 0.12);
}

.role-toggle-group {
  display: flex;
  gap: 0.35rem;
  background: rgba(10, 12, 18, 0.75);
  padding: 0.2rem;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.role-btn {
  padding: 0.25rem 0.65rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.role-btn.active {
  background: var(--accent-gold);
  color: #181c24;
}

.rec-display-box {
  background: rgba(10, 14, 22, 0.85);
  border: 1px solid rgba(156, 216, 92, 0.3);
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  text-align: center;
  margin: 0.5rem 0;
  position: relative;
  overflow: hidden;
}

.rec-display-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #9cd85c, transparent);
}

.rec-status-line {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.rec-move-hero {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(1.4rem, 2.2vw, 1.95rem);
  font-weight: 800;
  color: #9cd85c;
  letter-spacing: 0.03em;
  text-shadow: 0 0 16px rgba(156, 216, 92, 0.45);
  line-height: 1.1;
  margin: 0.15rem 0;
}

.rec-subtext {
  font-size: 0.74rem;
  color: #c2c9b4;
}

.rec-actions-row {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.btn-apply-rec {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: linear-gradient(135deg, #9cd85c, #68a02a);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.5rem 0.8rem;
  box-shadow: none;
}

.kbd-badge {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  padding: 0.12rem 0.45rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 700;
  color: #b7f575;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.65);
}

.btn-full-width {
  width: 100%;
}

/* Clear Visual Divider for Termination Claims (Error Prevention Heuristic) */
.section-divider-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.75rem 0 0.35rem;
  position: relative;
}

.section-divider-tag::before,
.section-divider-tag::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.section-divider-tag span {
  padding: 0 0.55rem;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.btn-apply-rec:hover:not(:disabled) {
  background: linear-gradient(135deg, #9cd85c, #9cd85c);
  transform: translateY(-1px);
}

.btn-copy-rec {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 0.5rem 0.8rem;
}

.assistant-hint {
  font-size: 0.7rem;
  color: var(--text-dim);
  line-height: 1.35;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 0.45rem;
}

/* Play AI Card */
.play-ai-card .setting-row {
  margin-bottom: 0.85rem;
}

.play-ai-actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 1rem;
}

.play-ai-actions .btn {
  flex: 1;
  padding: 0.65rem;
}

/* Analysis Card */
.panel-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 0.85rem;
}

.analysis-status-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(10, 14, 22, 0.85);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.eval-hero {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.35rem;
  font-weight: 800;
  color: #c2c9b4;
}

/* ==========================================================================
   ZONE 2: Quick Action Bar & Termination Action Grid
   ========================================================================== */
.quick-action-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

/* Termination & Result Action Grid (Resign, Timeout, Forfeit) */
.termination-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.btn-term {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.55rem;
  border-radius: 4px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  user-select: none;
}

.btn-term .term-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.btn-term-gold, .btn-opponent-resign {
  background: rgba(252, 186, 91, 0.14);
  border-color: rgba(252, 186, 91, 0.45);
  color: var(--accent-gold);
}

.btn-term-gold:hover, .btn-opponent-resign:hover {
  background: rgba(252, 186, 91, 0.28);
  border-color: var(--accent-gold);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: none;
}

.btn-term-cyan {
  background: rgba(140, 147, 128, 0.14);
  border-color: rgba(140, 147, 128, 0.45);
  color: #8c9380;
}

.btn-term-cyan:hover {
  background: rgba(140, 147, 128, 0.28);
  border-color: #8c9380;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(140, 147, 128, 0.35);
}

.btn-term-rose {
  background: rgba(255, 180, 171, 0.12);
  border-color: rgba(255, 180, 171, 0.35);
  color: #ffb4ab;
}

.btn-term-rose:hover {
  background: rgba(255, 180, 171, 0.25);
  border-color: #ffb4ab;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(255, 180, 171, 0.35);
}

.btn-term-amber {
  background: rgba(252, 186, 91, 0.12);
  border-color: rgba(252, 186, 91, 0.35);
  color: #fcba5b;
}

.btn-term-amber:hover {
  background: rgba(252, 186, 91, 0.25);
  border-color: #fcba5b;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 0.85rem;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-gold), #fcba5b);
  color: #181c24;
  box-shadow: 0 4px 12px var(--accent-gold-glow);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #fcba5b, var(--accent-gold));
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(22, 28, 40, 0.85);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(32, 40, 56, 0.95);
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(255, 180, 171, 0.15);
  border: 1px solid rgba(255, 180, 171, 0.4);
  color: #ffb4ab;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(255, 180, 171, 0.25);
  color: #fff;
}

/* ==========================================================================
   ZONE 3: Tabbed Workspace
   ========================================================================== */
.workspace-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.65);
}

.sidebar-tabs-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(14, 18, 26, 0.95);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.3rem;
  gap: 0.25rem;
}

.sidebar-subtab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.5rem;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-subtab-btn:hover {
  color: var(--text-main);
}

.sidebar-subtab-btn.active {
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-active);
}

.sidebar-subtab-pane {
  display: none;
}

.sidebar-subtab-pane.active {
  display: block;
}

.subtab-content {
  padding: 1rem;
}

.subtab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.subtab-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-count, .badge-engine-type {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

/* Notation Table */
.history-container {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: var(--bg-primary);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.history-table th {
  padding: 0.35rem 0.55rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  font-size: 0.7rem;
  text-align: left;
}

.history-table td {
  padding: 0.35rem 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  cursor: pointer;
}

.history-table td:hover {
  background: var(--bg-elevated);
}

.history-table td.move-active {
  background: var(--bg-elevated);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--border-active);
}

.history-table .move-num {
  width: 38px;
  color: var(--text-dim);
  font-size: 0.72rem;
}

/* Telemetry Grid */
.telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.telemetry-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 0.55rem 0.75rem;
}

.telemetry-box.highlight {
  border-color: rgba(252, 186, 91, 0.35);
}

.telemetry-box .label {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-bottom: 0.15rem;
}

.telemetry-box .value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.pv-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.pv-box {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 0.55rem;
  word-break: break-all;
  min-height: 38px;
}

/* Settings Form Controls */
.settings-scroll {
  max-height: 280px;
  overflow-y: auto;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* UI Framework: Mode Category Ribbon (Segmented Pills) */
/* Lichess Quick Pairing Grid Component (1:1 Lichess.org Tile Layout) */
.setting-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.active-badge-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-gold);
  background: rgba(252, 186, 91, 0.15);
  border: 1px solid rgba(252, 186, 91, 0.35);
  padding: 0.12rem 0.5rem;
  border-radius: 2px;
}

.lichess-format-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin: 0.35rem 0 0.75rem;
}

.format-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.4rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  user-select: none;
}

.format-tile:hover {
  background: var(--bg-elevated);
  border-color: var(--border-color);
  transform: none;
}

.format-tile.selected {
  background: var(--bg-elevated);
  border: 1px solid var(--border-active);
  box-shadow: none;
}

.tile-tc {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.format-tile.selected .tile-tc {
  color: var(--border-active);
}

.tile-label {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: capitalize;
  margin-top: 0.15rem;
}

.format-tile.selected .tile-label {
  color: var(--text-muted);
}

.setting-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.setting-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.mode-category-ribbon {
  display: flex;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 0.25rem;
  gap: 0.25rem;
  overflow-x: auto;
}

.cat-pill {
  flex: 1;
  padding: 0.38rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-align: center;
}

.cat-pill:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.cat-pill.active {
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-active);
  box-shadow: none;
}

/* UI Framework: Modern Select Component (Replaces native select) */
.ui-select-wrapper {
  position: relative;
  width: 100%;
}

.ui-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.ui-select-trigger:hover,
.ui-select-wrapper.open .ui-select-trigger {
  border-color: var(--accent-gold);
  background: rgba(20, 28, 48, 0.95);
  box-shadow: 0 0 0 2px rgba(252, 186, 91, 0.2);
}

.ui-select-value {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ui-select-chevron {
  font-size: 0.7rem;
  color: var(--text-dim);
  transition: transform 0.2s ease;
}

.ui-select-wrapper.open .ui-select-chevron {
  transform: rotate(180deg);
}

.ui-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #181c24;
  border: 1px solid rgba(252, 186, 91, 0.35);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.65);
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
  display: none;
  backdrop-filter: blur(20px);
  padding: 0.35rem;
}

.ui-select-wrapper.open .ui-select-dropdown,
.ui-select-dropdown.open {
  display: block;
  animation: dropdown-fade-in 0.15s ease-out;
}

@keyframes dropdown-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.ui-select-group {
  margin-bottom: 0.35rem;
}

.ui-select-group-header {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent-gold);
  padding: 0.35rem 0.5rem 0.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 0.2rem;
}

.ui-select-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ui-select-option:hover {
  background: rgba(252, 186, 91, 0.15);
  color: #fff;
}

.ui-select-option.selected {
  background: rgba(252, 186, 91, 0.25);
  color: var(--accent-gold);
  font-weight: 700;
}

.opt-text {
  display: flex;
  flex-direction: column;
}

.opt-title {
  font-size: 0.78rem;
}

.opt-desc {
  font-size: 0.68rem;
  color: var(--text-dim);
}

.theme-circle {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.theme-dot-midnight { background: #0f131b; }
.theme-dot-emerald  { background: #2c5000; }
.theme-dot-cyberpunk{ background: #701a75; }
.theme-dot-walnut   { background: #78350f; }
.theme-dot-ice      { background: #0284c7; }
.theme-dot-ruby     { background: #881337; }

/* Segmented Role Control in Play AI */
.segmented-role-control {
  display: flex;
  gap: 0.35rem;
  background: rgba(10, 14, 22, 0.8);
  padding: 0.25rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.seg-role-btn {
  flex: 1;
  padding: 0.45rem 0.5rem;
  font-size: 0.76rem;
  font-weight: 700;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.seg-role-btn.active {
  background: var(--accent-gold);
  color: #0f131b;
  box-shadow: none;
}

.custom-select {
  background: rgba(10, 14, 22, 0.95);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-main);
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  outline: none;
}

.custom-select:focus {
  border-color: var(--accent-gold);
}

.slider-setting-col {
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.slider-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge-time-optimal {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--accent-gold);
  font-weight: 700;
}

.time-range-input {
  width: 100%;
  accent-color: var(--accent-gold);
  cursor: pointer;
}

.slider-sublabels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-dim);
}

.clock-controls-bar {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.btn-clock {
  flex: 1;
  font-size: 0.72rem;
  padding: 0.35rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.fen-control-group {
  margin-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 0.75rem;
}

.fen-header-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.fen-input-row {
  display: flex;
  gap: 0.35rem;
}

.fen-input-field {
  flex: 1;
  background: rgba(10, 14, 22, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 0.35rem 0.55rem;
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  outline: none;
}

.btn-load-fen, .btn-copy-fen {
  padding: 0.35rem 0.65rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: 4px;
  font-size: 0.74rem;
  cursor: pointer;
}

.fen-copy-hint {
  color: #9cd85c;
  display: none;
}

.fen-error-msg {
  font-size: 0.7rem;
  color: #ffb4ab;
  margin-top: 0.25rem;
}

/* ==========================================================================
   Modals (Correction, Promotion, Game Over, History)
   ========================================================================== */
.correction-overlay, .game-over-overlay, .history-modal-overlay, .promo-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.correction-overlay.active, .game-over-overlay.active, .history-modal-overlay.active, .promo-modal.active {
  opacity: 1;
  pointer-events: all;
}

.correction-dialog, .history-modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  max-width: 820px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.65);
}

.correction-badge {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.btn-close-corr {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.correction-desc, .history-modal-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0.45rem 0 1rem;
  line-height: 1.4;
}

.correction-body {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}

.correction-board-wrap {
  width: 320px;
  height: 320px;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.65);
  flex-shrink: 0;
}

.correction-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.piece-palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.35rem;
}

.palette-item {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
}

.palette-item.active {
  background: rgba(252, 186, 91, 0.25);
  border-color: var(--accent-gold);
}

.btn-turn {
  padding: 0.35rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: 6px;
  font-size: 0.76rem;
  cursor: pointer;
}

.btn-turn.active {
  background: var(--accent-gold);
  color: #181c24;
  font-weight: 700;
}

.castling-checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.correction-actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 0.55rem;
}

.btn-save-corr {
  flex: 1;
}

/* Promotion Modal */
.promo-dialog {
  display: flex;
  gap: 0.75rem;
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.promo-piece {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.promo-piece:hover {
  background: rgba(252, 186, 91, 0.25);
  transform: scale(1.1);
}

/* Game Over Modal */
.game-over-modal {
  background: linear-gradient(135deg, rgba(22, 28, 42, 0.98), rgba(14, 18, 28, 0.99));
  border: 1px solid var(--border-active);
  border-radius: var(--radius-xl);
  padding: 2.25rem 2rem;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.65);
}

.game-over-icon {
  font-size: 4rem;
  margin-bottom: 0.5rem;
}

.game-over-title {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent-gold);
  margin-bottom: 0.25rem;
}

.game-over-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.game-over-details {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
}

.game-over-actions {
  display: flex;
  gap: 0.65rem;
}

.game-over-actions .btn {
  flex: 1;
}

/* History Modal */
.history-stats-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: rgba(10, 14, 22, 0.75);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

.history-games-table-wrap {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}

.history-games-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.history-games-table th, .history-games-table td {
  padding: 0.45rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.history-games-table th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  font-size: 0.72rem;
}

/* ==========================================================================
   WINDOWS SPLIT SCREEN & RESPONSIVE BREAKPOINTS
   Board-on-top, Settings & Controls Below layout across all screen widths
   ========================================================================== */

/* Split Screen & Desktop Standard Viewports */
@media (max-width: 1100px) {
  .main-wrapper {
    flex-direction: column;
    align-items: center;
    max-width: 540px;
    padding: 0.5rem 0.75rem 2rem;
    gap: 0.75rem;
  }

  .game-section {
    width: 100%;
    max-width: 520px;
  }

  .board-container {
    width: min(480px, 92vw);
    max-width: 480px;
  }

  .sidebar {
    width: min(480px, 92vw);
    max-width: 480px;
  }

  .app-header {
    padding: 0.35rem 0.75rem;
    gap: 0.5rem;
  }

  .logo-badge {
    display: none;
  }

  .logo-text {
    font-size: 1rem;
  }

  .mode-tab-btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.76rem;
  }

  .btn-action-ghost {
    padding: 0.35rem 0.6rem;
    font-size: 0.74rem;
  }

  .card, .assistant-card {
    padding: 0.65rem 0.75rem;
  }

  .rec-display-box {
    padding: 0.5rem 0.65rem;
    margin: 0.4rem 0;
  }

  .rec-move-hero {
    font-size: 1.65rem;
  }

  .btn-term {
    padding: 0.38rem 0.45rem;
    font-size: 0.72rem;
  }

  .history-container {
    max-height: 140px;
  }
}

/* Height-constrained laptops (<= 780px viewport height) */
@media (max-height: 780px) {
  .app-header {
    padding: 0.25rem 0.75rem;
  }

  .main-wrapper {
    padding: 0.35rem 0.75rem 1.5rem;
    gap: 0.55rem;
  }

  .active-format-bar {
    padding: 0.18rem 0.5rem;
    margin-bottom: 0.1rem;
  }

  .player-info-card {
    padding: 0.25rem 0.5rem;
  }

  .rec-display-box {
    padding: 0.45rem 0.6rem;
    margin: 0.35rem 0;
  }

  .rec-move-hero {
    font-size: 1.55rem;
    margin: 0.1rem 0;
  }

  .card, .assistant-card {
    padding: 0.6rem 0.75rem;
  }

  .history-container {
    max-height: 120px;
  }
}

/* Narrow Viewports & Mobile (<= 720px) */
@media (max-width: 720px) {
  .app-header {
    flex-wrap: wrap;
    padding: 0.45rem 0.65rem;
    gap: 0.45rem;
  }

  .logo-badge {
    display: none;
  }

  .mode-switcher-nav {
    order: 3;
    width: 100%;
    justify-content: stretch;
  }

  .mode-tab-btn {
    flex: 1;
    justify-content: center;
    padding: 0.4rem 0.25rem;
    font-size: 0.75rem;
  }

  .main-wrapper {
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    gap: 0.75rem;
  }

  .game-section {
    width: 100%;
    justify-content: center;
  }

  .board-container {
    width: min(100%, calc(100vw - 32px), 420px);
  }

  .eval-bar-container {
    width: 13px;
  }

  .sidebar {
    width: min(100%, calc(100vw - 32px), 420px);
  }

  .correction-body {
    flex-direction: column;
    align-items: center;
  }

  .correction-board-wrap {
    width: 260px;
    height: 260px;
  }
}

@media (max-width: 480px) {
  .board-container {
    width: calc(100vw - 28px);
  }

  .eval-bar-container {
    width: 11px;
  }

  .player-info-card {
    padding: 0.3rem 0.45rem;
  }

  .engine-status-pill {
    display: none;
  }
}

/* ==========================================================================
   Stitch Workstation Shell (Analysis / Sparring / Repertoire)
   Source: stitch_chessmind_ai_grandmaster_platform screens
   ========================================================================== */
.app-rail { position: fixed; left: 0; top: 0; bottom: 0; width: 56px; background: #0a0e16; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; z-index: 110; border-right: 1px solid #424939; }
.rail-brand { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: #1c2028; color: #9cd85c; border-radius: 2px; margin-bottom: 8px; }
.rail-btn { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: transparent; border: none; border-left: 2px solid transparent; color: #8c9380; cursor: pointer; transition: background 0.15s ease, color 0.15s ease; }
.rail-btn:hover { background: #262a32; color: #dfe2ed; }
.rail-btn.active { background: #31353d; color: #9cd85c; border-left-color: #9cd85c; }
.rail-btn .material-symbols-outlined, .header-actions .material-symbols-outlined { font-size: 20px; }
.brand-accent { color: #9cd85c; font-weight: 700; }
.app-header { margin-left: 56px; }
.mode-tab-btn { border: none; background: transparent; font-weight: 600; letter-spacing: 0.01em; }
.mode-tab-btn.active { border: none; border-bottom: 2px solid #9cd85c; border-radius: 0; background: transparent; color: #dfe2ed; }
.mode-switcher-nav { background: transparent; border: none; }
.mode-tab-btn .mode-text { font-size: 14px; }
.btn-action-ghost { background: #1c2028; border: 1px solid #424939; color: #c2c9b4; border-radius: 2px; padding: 6px 10px; }
.btn-action-ghost:hover { background: #262a32; color: #dfe2ed; }
.btn-action-ghost .material-symbols-outlined { font-size: 16px; }


[data-theme="midnight"] {
  --sq-light: #262a32;
  --sq-dark: #181c24;
  --arrow-rec: #0a0e16;
  --arrow-rec-outline: #ffffff;
}

[data-theme="emerald"] {
  --sq-light: #e3d5b0;
  --sq-dark: #5b8a3c;
  --arrow-rec: #facc15;
  --arrow-rec-outline: #0a0e16;
}

/* Stitch Analysis Arena - right column (Top Engine Line / stats / Notation Tree / Candidates) */
.main-wrapper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 500px;
  align-items: start;
  gap: 1rem;
  max-width: none;
  margin: 0 0 0 56px;
  padding: 1rem;
  background: #0f131b;
  width: auto;
}
.game-section { max-width: none; justify-content: center; }
.main-wrapper > .game-section { grid-column: 1; grid-row: 1; }
.main-wrapper > .sidebar { grid-column: 2; grid-row: 1; width: 500px; max-width: 500px; min-width: 500px; background: #0f131b; gap: 0; }
@media (max-width: 1100px) {
  .main-wrapper { grid-template-columns: minmax(0, 1fr); margin-left: 56px; }
  .main-wrapper > .sidebar { grid-column: 1; grid-row: 2; width: 100%; max-width: none; min-width: 0; }
}
@media (max-width: 720px) { .main-wrapper { margin-left: 0; } .app-rail { display: none; } .app-header { margin-left: 0; } }
.workspace-card { background: #1c2028; border: 1px solid #424939; border-radius: 2px; box-shadow: none; }
.sidebar-tabs-nav { background: #181c24; border-bottom: 1px solid #424939; }
.sidebar-subtab-btn { font-family: 'Hanken Grotesk', sans-serif; font-size: 12px; letter-spacing: 0.03em; text-transform: uppercase; color: #8c9380; }
.sidebar-subtab-btn.active { color: #9cd85c; border-bottom-color: #9cd85c; }
.history-table td, .history-table th { font-family: 'JetBrains Mono', monospace; font-size: 13px; }
.history-table th { color: #8c9380; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.history-table td.move-active { background: #31353d; color: #9cd85c; }
.telemetry-grid { grid-template-columns: repeat(4, 1fr); gap: 1px; background: #424939; border: 1px solid #424939; }
.telemetry-grid .telemetry-box { background: #0a0e16; border: none; border-radius: 0; text-align: center; padding: 6px 4px; }
.telemetry-grid .telemetry-box .label { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: #8c9380; text-transform: uppercase; }
.telemetry-grid .telemetry-box .value { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; color: #dfe2ed; }


/* Stitch right-column components */
.stitch-engine-line { background: #181c24; border: 1px solid #424939; padding: 6px 8px; margin-bottom: 6px; }
.stitch-engine-line-head { display: flex; justify-content: space-between; align-items: center; }
.stitch-section-title { font-family: 'Hanken Grotesk', sans-serif; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: #dfe2ed; }
.stitch-eval-badge { font-family: 'JetBrains Mono', monospace; font-size: 16px; font-weight: 700; color: #9cd85c; }
.stitch-depth-tag { font-size: 11px; font-weight: 400; color: #8c9380; margin-left: 4px; }
.stitch-telemetry-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: #424939; border: 1px solid #424939; margin-bottom: 6px; }
.stitch-tele-cell { background: #0a0e16; display: flex; flex-direction: column; align-items: center; padding: 6px 4px; }
.stitch-tele-label { font-family: 'JetBrains Mono', monospace; font-size: 10px; text-transform: uppercase; color: #8c9380; }
.stitch-tele-value { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; color: #dfe2ed; }

