/* ══════════════════════════════════════════════════════
   ChessVibe — style.css
   Notion-Style Flat UI · Pure Black & White
═════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────── */
:root {
  /* Background */
  --bg:      #191919;    /* main page background — near black */
  --bg2:     #202020;    /* panel background — slightly lighter black */
  --panel:   #252525;    /* card/modal surface */
  --panel2:  #2f2f2f;    /* hover surface */

  /* Borders */
  --border:  rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.13);

  /* Accent — Notion uses NO accent color, use white/light gray only */
  --accent:     #ffffff;
  --accent-dim: #acacac;
  --accent-glow:  rgba(255,255,255,0.06);
  --accent-glow2: rgba(255,255,255,0.03);

  /* Text */
  --text:       #e8e8e6;     /* primary text */
  --text-dim:   #9b9b97;     /* secondary text */
  --text-muted: #5a5a57;     /* placeholder / label */

  /* Board squares — Wikipedia classic green/cream */
  --sq-light:   #ebecd0;     /* warm cream */
  --sq-dark:    #779556;     /* classic green */
  --sq-select:  rgba(155,199,0,0.60);
  --sq-legal:   rgba(20,85,30,0.28);
  --sq-lastmove:rgba(255,255,51,0.32);
  --sq-check:   rgba(220,53,53,0.55);
  --sq-drag:    rgba(255,255,255,0.12);
  --piece-dark: #161512;     /* wikipedia black pieces */
  --piece-light:#ffffff;     /* wikipedia white pieces */

  /* Status colors — keep muted */
  --danger:     #e55;
  --danger-dim: #c44;
  --warn:       #c8a84b;

  /* Fonts — Notion uses Inter exclusively */
  --font-display: 'Inter', sans-serif;
  --font-ui:      'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Radius — Notion uses very small radius */
  --radius:    4px;
  --radius-lg: 6px;
  --radius-xl: 8px;

  /* Shadows — flat, no color glow */
  --shadow-panel: 0 2px 8px rgba(0,0,0,0.35);
  --shadow-board: 0 4px 24px rgba(0,0,0,0.55);
  --transition:   150ms ease;
}

/* Light Mode Variables */
body.light-mode {
  --bg:      #ffffff;
  --bg2:     #f7f6f3;
  --panel:   #f1f0ee;
  --panel2:  #e9e8e4;
  --border:  rgba(55,53,47,0.09);
  --border2: rgba(55,53,47,0.16);
  --accent:     #37352f;
  --accent-dim: #6b6b6b;
  --accent-glow:  rgba(55,53,47,0.06);
  --accent-glow2: rgba(55,53,47,0.03);
  --text:       #37352f;
  --text-dim:   #6b6b6b;
  --text-muted: #9b9b97;
  --sq-light:   #f0ede6;
  --sq-dark:    #37352f;
  --sq-select:  rgba(55,53,47,0.25);
  --sq-legal:   rgba(55,53,47,0.18);
  --sq-lastmove:rgba(55,53,47,0.12);
  --danger:     #c0392b;
  --shadow-panel: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-board: 0 4px 24px rgba(0,0,0,0.15);
}

body.light-mode #navbar {
  background: #ffffff;
  border-bottom: 1px solid rgba(55,53,47,0.09);
}
body.light-mode .modal-box {
  background: #ffffff;
  border-color: rgba(55,53,47,0.16);
}
body.light-mode .form-select,
body.light-mode .form-input {
  background: #f7f6f3;
  border-color: rgba(55,53,47,0.16);
}
body.light-mode .btn-primary {
  background: #37352f;
  color: #ffffff;
}
body.light-mode .btn-primary:hover {
  background: #2b2a27;
}
body.light-mode .piece-w {
  color: #ffffff;
  text-shadow: 0 0 2px rgba(0,0,0,0.9), 0 0 6px rgba(0,0,0,0.55);
}
body.light-mode .piece-b {
  color: #161512;
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
button { cursor: pointer; font-family: var(--font-ui); border: none; background: none; }
input, select { font-family: var(--font-ui); }
a { color: var(--accent); }

/* ── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ── Particle Canvas ────────────────────────────────── */
#particle-canvas {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9999;
  display: none;
}

/* ═══════════════════════════════════════════════════
   LOADER
════════════════════════════════════════════════════ */
#loader {
  position: fixed; inset: 0;
  background: #191919;
  display: flex; align-items: center; justify-content: center;
  z-index: 10000;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-content {
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
  text-align: center;
}
.loader-logo {
  width: 120px; height: 120px;
  object-fit: contain;
  margin-bottom: 20px;
  filter: none;
  animation: logo-float 3s ease-in-out infinite;
}
@keyframes logo-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.loader-piece {
  font-size: 56px;
  animation: loader-bounce 1.2s ease-in-out infinite;
  filter: none;
  opacity: 0.9;
}
@keyframes loader-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}
.loader-brand {
  font-family: var(--font-ui);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.loader-tagline {
  font-size: 0.9rem;
  color: var(--text-muted);
}
.loader-bar-track {
  width: 180px; height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  margin-top: 12px;
  overflow: hidden;
}
.loader-bar-fill {
  height: 100%;
  background: rgba(255,255,255,0.5);
  border-radius: 99px;
  width: 0%;
  animation: loader-fill 1.6s ease forwards;
}
@keyframes loader-fill {
  0%   { width: 0%; }
  60%  { width: 70%; }
  100% { width: 100%; }
}

/* ═══════════════════════════════════════════════════
   NAVBAR
════════════════════════════════════════════════════ */
#navbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 48px;
  display: flex; align-items: center;
  padding: 0 20px;
  background: #191919;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  backdrop-filter: none;
  z-index: 100;
  gap: 12px;
}

.nav-logo {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}
.nav-logo-img {
  width: 32px; height: 32px;
  object-fit: contain;
  margin-right: 10px;
}
.logo-glyph {
  font-size: 1.3rem;
  filter: none;
  opacity: 0.85;
  line-height: 1;
}
.logo-name {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text);
}

.nav-center {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
}
#nav-game-mode {
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  font-weight: 500;
}

.nav-actions {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}

.nav-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.nav-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
  border-color: var(--border);
}
.nav-btn-accent {
  color: var(--text);
  border-color: var(--border);
  background: rgba(255,255,255,0.04);
}
.nav-btn-danger {
  color: var(--danger);
  border-color: transparent;
}
.nav-btn-danger:hover {
  background: rgba(220,53,53,0.1);
  border-color: rgba(220,53,53,0.3);
}
.nav-btn.hidden { display: none !important; }
.nav-select {
  display: none;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-ui);
}
.nav-select:focus {
  outline: none;
  border-color: var(--accent-dim);
  background: rgba(255,255,255,0.08);
}
.nav-select.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════
   SCREENS
════════════════════════════════════════════════════ */
.screen {
  display: none;
  min-height: 100vh;
  padding-top: 48px;
}
.screen.active { display: flex; flex-direction: column; }

/* ═══════════════════════════════════════════════════
   MODE SCREEN
════════════════════════════════════════════════════ */
#mode-screen {
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 80px 24px 40px;
  background: var(--bg);
}

.mode-hero { text-align: center; }
.hero-badge {
  display: inline-block;
  padding: 5px 16px;
  border: 1px solid var(--border2);
  border-radius: 99px;
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  font-weight: 500;
  margin-bottom: 20px;
  background: transparent;
}
.hero-title {
  font-family: var(--font-ui);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 14px;
  line-height: 1.05;
}
.hero-title em {
  font-style: normal;
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: var(--text);
  background-clip: unset;
  font-weight: 800;
}
.hero-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 400;
}

.mode-cards {
  display: flex; gap: 18px;
  flex-wrap: wrap; justify-content: center;
  max-width: 880px; width: 100%;
}

.mode-card {
  position: relative;
  width: 260px;
  padding: 28px 24px 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--transition), background var(--transition);
  display: flex; flex-direction: column; gap: 12px;
  opacity: 0;
  transform: translateY(24px);
  box-shadow: none;
}
.mode-card.animate-in {
  animation: card-rise 0.5s ease forwards;
}
@keyframes card-rise {
  to { opacity: 1; transform: translateY(0); }
}
.mode-card:hover {
  border-color: var(--border2);
  background: var(--panel2);
  transform: none;
  box-shadow: none;
}
.mode-card-glow { display: none; }
.mode-card-featured { background: var(--panel); border-color: var(--border2); }
.mode-card-featured:hover { background: var(--panel2); }

.mode-icon {
  font-size: 2rem;
  line-height: 1;
  filter: none;
}
.mode-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.mode-desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
}
.mode-badge {
  display: inline-block;
  padding: 3px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  width: fit-content;
}
.mode-badge-accent {
  background: rgba(255,255,255,0.06);
  border-color: var(--border2);
  color: var(--text-dim);
}
.mode-arrow {
  position: absolute; right: 20px; bottom: 24px;
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: all 0.2s;
}
.mode-card:hover .mode-arrow {
  color: var(--text);
  transform: none;
}
.mode-footer {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.04em;
}

/* ═══════════════════════════════════════════════════
   GAME SCREEN LAYOUT
════════════════════════════════════════════════════ */
#game-screen {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 56px 12px 12px;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

.game-layout {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "player-top   board   side"
    "player-top   board   side"
    "player-bot   board   side";
  gap: 10px;
  
  height: 100%;
  max-width: 1300px;
  align-items: stretch;
}

/* ── Player Bars ──────────────────────────────────── */
.player-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.3s;
  
  max-width: 500px;
}
.player-bar-top { grid-area: player-top; align-self: end; }
.player-bar-bottom { grid-area: player-bot; }
.player-bar.active-turn {
  border-color: rgba(255,255,255,0.22);
  background: var(--panel2);
}

.player-avatar {
  font-size: 1.6rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
  flex-shrink: 0;
}

.player-info-col {
  display: flex; flex-direction: column; gap: 3px;
  flex: 1; min-width: 0;
}
.player-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.captured-strip {
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 1px;
  min-height: 18px;
  line-height: 1.3;
}
.material-adv {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
}

.timer-pill {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 12px;
  letter-spacing: 0.04em;
  transition: all 0.3s;
  flex-shrink: 0;
  min-width: 64px;
  text-align: center;
}
.timer-pill.timer-pill-active {
  color: var(--text);
  border-color: rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.07);
  box-shadow: none;
}
.timer-pill.timer-low {
  color: var(--danger);
  border-color: rgba(220,53,53,0.4);
  background: rgba(220,53,53,0.07);
  animation: timer-pulse 1s ease-in-out infinite;
}
@keyframes timer-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(220,53,53,0.3); }
  50% { box-shadow: 0 0 20px rgba(220,53,53,0.5); }
}

/* ── Board Area ───────────────────────────────────── */
.board-area {
  grid-area: board;
  display: flex; flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 0;
  min-width: 0;
  align-self: stretch;
  overflow: hidden;
}

/* ── Move Breadcrumb ───────────────────────────────── */
.breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-dim);
  width: min(64vw, 520px, 80vh - 120px);
  max-width: 500px;
  min-height: 32px;
}
.breadcrumb-moves {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.breadcrumb-moves::-webkit-scrollbar { display: none; }
.breadcrumb-move {
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.breadcrumb-move:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}
.breadcrumb-arrow {
  color: var(--accent);
  font-weight: 600;
}

.board-frame {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow-board);
  border: 1px solid rgba(255,255,255,0.1);
  width: 100%;
  max-width: min(100vw - 420px, calc(100vh - 180px), 900px);
  min-width: 0;
  flex-shrink: 1;
}
@media (max-width: 860px) {
  .board-frame {
    max-width: none;
    flex-shrink: 0;
  }
}
.board-frame.game-won {
  animation: none;
  border-color: rgba(255,255,255,0.25);
}

/* ── The Board Grid ───────────────────────────────── */
#board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  user-select: none;
  touch-action: none;
  transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── Squares ──────────────────────────────────────── */
.square {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  transition: background-color 0.1s;
  cursor: default;
}
.square.light { background-color: var(--sq-light); }
.square.dark  { background-color: var(--sq-dark); }

.square.selected        { background-color: var(--sq-select) !important; }
.square.last-move       { background-color: var(--sq-lastmove) !important; }
.square.in-check        { background-color: var(--sq-check) !important; animation: check-pulse 0.6s ease; }
.square.drag-over       { background-color: var(--sq-drag) !important; }
.square.legal-target    { cursor: pointer; }
.square.legal-target:hover { filter: brightness(1.1); }
.square.pre-move-from     { background-color: rgba(255, 255, 0, 0.4) !important; }
.square.pre-move-to       { background-color: rgba(255, 255, 0, 0.3) !important; }

@keyframes check-pulse {
  0% { box-shadow: inset 0 0 0 3px rgba(220,53,53,0.9); }
  100% { box-shadow: none; }
}

/* ── Legal Move Dots ──────────────────────────────── */
.legal-dot {
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  pointer-events: none;
  z-index: 1;
  animation: dot-pop 0.15s ease;
}
.legal-dot.capture-ring {
  width: 85%;
  height: 85%;
  background: transparent;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-radius: 50%;
}
@keyframes dot-pop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── Coordinate Labels ────────────────────────────── */
.coord-rank {
  position: absolute;
  top: 2px; left: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  z-index: 2;
  font-family: var(--font-mono);
  opacity: 0.4;
}
.coord-file {
  position: absolute;
  bottom: 2px; right: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  z-index: 2;
  font-family: var(--font-mono);
  opacity: 0.4;
}
.square.light .coord-rank, .square.light .coord-file { color: #779556; }
.square.dark .coord-rank, .square.dark .coord-file { color: #ebecd0; }

/* ── Pieces ───────────────────────────────────────── */
.piece {
  
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  position: relative;
  z-index: 10;
  transition: transform 0.1s var(--transition);
  font-size: clamp(2rem, 8vmin, 100px);
  line-height: 1;
  font-weight: 400;
  text-shadow: none;
  filter: none;
}
.piece:active { cursor: grabbing; transform: scale(1.08); }

.piece-img {
  width: 88%;
  height: 88%;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
  transition: transform 0.15s ease;
  pointer-events: none;
}

.piece-w {
  color: var(--piece-light);
  text-shadow:
    0 0 2px rgba(0,0,0,0.9),
    0 0 6px rgba(0,0,0,0.55);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.75));
}

.piece-b {
  color: var(--piece-dark);
  text-shadow: 0 0 1px rgba(255,255,255,0.15);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

.square.selected .piece {
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.9));
  transform: scale(1.06);
}

.piece-just-moved {
  animation: piece-land 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes piece-land {
  0% { transform: scale(1.3); filter: brightness(1.5); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* ── GitHub Repo Button (navbar) ─────────────────── */
.nav-btn-repo {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: var(--text, #fff);
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}
.nav-btn-repo:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* ── GitHub Repo Link (mode screen) ──────────────── */
.mode-github-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 18px auto 0;
  padding: 10px 22px;
  color: var(--text-dim);
  font-size: 0.9rem;
  text-decoration: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.mode-github-link:hover {
  color: #fff;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.05);
}

.drag-ghost {
  position: fixed;
  width: 60px; height: 60px;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.9;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center;
}
.drag-ghost img {
  width: 100%; height: 100%;
  filter: drop-shadow(0 12px 24px rgba(0,0,0,0.5)) brightness(1.1);
}

/* ── Bot Thinking Bar ─────────────────────────────── */
.bot-thinking-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(25,25,25,0.92);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 10px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.bot-thinking-bar.visible { opacity: 1; pointer-events: all; }

.bt-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: bt-bounce 1s ease-in-out infinite;
}
.bt-dot:nth-child(2) { animation-delay: 0.2s; }
.bt-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bt-bounce {
  0%, 100% { transform: scale(0.6); opacity: 0.4; }
  50% { transform: scale(1); opacity: 1; }
}
.bt-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.04em;
}

/* ── Side Panel ───────────────────────────────────── */
.side-panel {
  grid-area: side;
  display: flex; flex-direction: column;
  gap: 10px;
  height: 100%;
  width: 220px;
  align-self: stretch;
}

.panel-toprow {
  display: flex; align-items: center; justify-content: space-between;
}

.turn-indicator {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; font-weight: 600; color: var(--text-dim);
  padding: 7px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.3s;
  
}
.turn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.3s;
  flex-shrink: 0;
}
.turn-dot.white-turn { background: #f0f0f0; box-shadow: none; }
.turn-dot.black-turn { background: #2a2a2a; border: 1px solid rgba(255,255,255,0.2); }

/* ── History Panel ────────────────────────────────── */
.history-panel {
  flex: 1;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
}
.history-header {
  padding: 10px 14px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  text-transform: uppercase;
}
.move-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
}
.move-list-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
}
.move-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr;
  gap: 2px;
  align-items: center;
}
.move-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: right;
  padding-right: 4px;
}
.move-san {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-dim);
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}
.move-san:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.move-san.active {
  background: rgba(255,255,255,0.09);
  color: var(--text);
  border: 1px solid var(--border2);
}

/* ── Replay Bar ───────────────────────────── */
.replay-bar {
  display: flex; gap: 4px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: center;
}
.replay-btn {
  flex: 1;
  padding: 7px 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: all var(--transition);
  letter-spacing: 0.03em;
}
.replay-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.07);
  border-color: var(--border);
}
.replay-sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; flex-shrink: 0; }
.replay-exit-btn {
  flex: 1.4;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  background: rgba(255,255,255,0.06);
  border-color: var(--border2);
}
.replay-exit-btn:hover { background: rgba(255,255,255,0.09); }

/* ── Action Row ───────────────────────────── */
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.action-btn {
  flex: 1;
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
}
.action-btn:hover {
  color: var(--text);
  border-color: var(--border2);
  background: var(--panel2);
  transform: none;
  box-shadow: none;
}

/* ═══════════════════════════════════════════════════
   MODALS
════════════════════════════════════════════════════ */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
  z-index: 500;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s ease;
}
#modal-overlay.active { opacity: 1; pointer-events: all; }

.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.active { opacity: 1; pointer-events: all; transform: translate(-50%, -50%) scale(1); }

.modal-box {
  background: #252525;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-xl);
  padding: 0;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  min-width: min(340px, 92vw);
  max-width: min(440px, 92vw);
  width: 90vw;
}

.modal-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.modal-close {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: transparent;
  border: none;
  transition: all var(--transition);
}
.modal-close:hover { color: var(--text); background: rgba(255,255,255,0.07); }

.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 20px; }
.modal-ftr { padding: 16px 24px 20px; display: flex; gap: 10px; }

/* ── Form Elements ────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-lbl {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.form-select {
  width: 100%; padding: 10px 14px;
  background: #1a1a1a;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.88rem;
  font-family: var(--font-ui);
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.form-select:focus { border-color: rgba(255,255,255,0.3); box-shadow: none; }
.form-select:disabled { opacity: 0.4; cursor: not-allowed; }

.form-checkbox { margin-right: 8px; accent-color: var(--accent); }

.form-input {
  width: 100%; padding: 10px 14px;
  background: #1a1a1a;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.88rem;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color var(--transition);
}
.form-input:focus { border-color: rgba(255,255,255,0.3); box-shadow: none; }

.code-input {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
}

/* ── Color Picker ─────────────────────────── */
.color-picker { display: flex; gap: 8px; }
.color-choice { flex: 1; cursor: pointer; }
.color-choice input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.color-tile {
  display: flex; align-items: center; justify-content: center;
  padding: 10px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  border: 2px solid var(--border);
  transition: all var(--transition);
  cursor: pointer;
  text-align: center;
  gap: 6px;
}
.white-tile { background: rgba(240,216,181,0.08); color: var(--sq-light); }
.black-tile { background: rgba(181,136,99,0.08); color: var(--sq-dark); }
.random-tile { background: rgba(255,255,255,0.04); color: var(--text-dim); }
.color-choice input:checked + .color-tile {
  border-color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.07);
  color: var(--text);
}

/* ── Difficulty Slider ──────────────────────── */
.difficulty-row { display: flex; flex-direction: column; gap: 6px; }
.diff-slider {
  
  -webkit-appearance: none;
  height: 4px;
  border-radius: 99px;
  background: var(--border2);
  outline: none;
  cursor: pointer;
}
.diff-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: none;
  cursor: pointer;
}
.diff-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: none;
  cursor: pointer;
}
.diff-labels {
  display: flex; justify-content: space-between;
  font-size: 0.68rem; color: var(--text-muted);
}
.diff-display {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-weight: 600;
  font-family: var(--font-mono);
  text-align: center;
}

/* ── Toggle Switch ────────────────────────── */
.timer-row { display: flex; align-items: center; gap: 12px; }
.toggle-wrap { display: flex; align-items: center; cursor: pointer; }
.toggle-input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track {
  width: 38px; height: 22px;
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: all 0.2s;
}
.toggle-input:checked + .toggle-track { background: rgba(255,255,255,0.4); }
.toggle-input:checked + .toggle-track .toggle-thumb { left: 19px; background: #fff; }

/* ── Buttons ──────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px;
  background: #ffffff;
  color: #191919;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0;
}
.btn-primary:hover {
  background: #efefef;
  box-shadow: none;
  transform: none;
}
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px;
  background: rgba(255,255,255,0.05);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-ghost:hover { background: rgba(255,255,255,0.09); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.w-full { width: 100%; }

/* ── Online Tabs ──────────────────────────── */
.online-tabs {
  display: flex;
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
}
.otab {
  flex: 1; padding: 8px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  transition: all var(--transition);
}
.otab.otab-active { background: var(--panel2); color: var(--text); border: 1px solid var(--border2); }
.otab:hover:not(.otab-active) { color: var(--text); }

.tab-pane { display: flex; flex-direction: column; gap: 14px; }
.tab-pane.hidden { display: none; }
.tab-hint { font-size: 0.82rem; color: var(--text-dim); line-height: 1.5; }

/* Spectator Mode Styles */
.spectator-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.spectator-mode .action-btn,
.spectator-mode .nav-btn-danger,
.spectator-mode #btn-new-game {
  pointer-events: none;
  opacity: 0.4;
}
.spectator-mode .board-area {
  cursor: default;
}

.room-code-box {
  display: flex; align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
}
.room-code-box.hidden { display: none; }
.rc-label { font-size: 0.72rem; color: var(--text-dim); font-weight: 600; flex-shrink: 0; }
.rc-value {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.2em;
  flex: 1;
  text-align: center;
}

.join-row { display: flex; gap: 8px; align-items: stretch; }
.join-row .form-input { flex: 1; }
.join-row .btn-primary { flex-shrink: 0; white-space: nowrap; }

/* ── Timer Options ────────────────────────── */
.timer-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
}
.time-option {
  padding: 12px 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.time-option:hover { border-color: var(--border2); color: var(--text); }
.time-option.selected {
  border-color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.07);
  color: var(--text);
  box-shadow: none;
}
.time-option.custom { grid-column: span 2; }

.custom-time-group { margin-top: 16px; }
.custom-time-inputs { display: flex; align-items: center; gap: 8px; }
.time-input {
  width: 70px;
  text-align: center;
  font-size: 0.9rem;
  font-family: var(--font-mono);
}
.time-separator { font-size: 0.8rem; color: var(--text-dim); font-weight: 500; }

.form-desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.4;
  margin-top: 4px;
}

.online-status {
  min-height: 20px;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  padding: 4px 0;
}
.online-status.status-ok { color: #5a5a57; }
.online-status.status-err { color: var(--danger); }

/* ── Promotion Modal ──────────────────────── */
.promo-box { min-width: 300px; }
.promo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}
.promo-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  padding: 20px 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  border-right: 1px solid var(--border);
}
.promo-btn:last-child { border-right: none; }
.promo-btn:hover { background: rgba(255,255,255,0.07); }
.promo-glyph {
  font-size: 2.4rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
}
.promo-glyph.color-w { color: #f0f0f0; -webkit-text-stroke: 1px #111; }
.promo-glyph.color-b { color: #111; -webkit-text-stroke: 1px #666; }
.promo-name { font-size: 0.72rem; color: var(--text-dim); font-weight: 500; }

/* ── Result Modal ─────────────────────────── */
.result-box { text-align: center; padding-bottom: 4px; }
.result-glyph {
  font-size: 3rem;
  padding: 24px 0 8px;
  display: block;
}
.result-title {
  font-family: var(--font-ui);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  padding: 0 24px;
}
.result-reason {
  font-size: 0.9rem;
  color: var(--text-dim);
  padding: 6px 24px 0;
  font-weight: 500;
}
.result-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 10px 24px 0;
  font-family: var(--font-mono);
}
.result-ftr { justify-content: center; flex-wrap: wrap; }
.draw-ftr { justify-content: space-between; }

/* ── Context Menu ──────────────────────────── */
.context-menu {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 0;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 120px;
}
.context-menu.hidden { display: none; }
.context-item {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-dim);
  transition: all var(--transition);
}
.context-item:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════ */
@media (max-width: 860px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    grid-template-areas:
      "player-top"
      "board"
      "player-bot"
      "side";
    gap: 16px;
    
    padding: 0;
  }
  .side-panel {
    
    max-width: min(100%, 500px);
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
  .history-panel {
    
    max-height: 250px;
  }
  .player-bar {
    
    max-width: min(96vw, 560px);
    margin: 0 auto;
    padding: 6px 10px;
    gap: 8px;
  }
  .timer-pill {
    min-width: 58px;
    padding: 4px 10px;
    font-size: 0.85rem;
  }
  .captured-strip { min-height: 15px; }
  #board {
    width: min(96vw, calc(100dvh - 250px));
    height: min(96vw, calc(100dvh - 250px));
  }
  #game-screen {
    padding: 52px 6px 8px;
    height: 100dvh;
  }
  .eval-bar {
    display: none !important;
  }
  .breadcrumb-bar {
    display: none !important;
  }
  .side-panel {
    max-width: 100%;
    overflow-x: hidden;
  }
  .action-row {
    justify-content: center;
  }
  .action-btn {
    flex: 1 1 30%;
    min-width: 90px;
    font-size: 0.72rem;
    white-space: nowrap;
  }
}

@media (max-width: 600px) {
  .hero-title { font-size: 1.8rem; }
  .mode-cards { gap: 12px; }
  .mode-card { padding: 20px; width: 100%; }
  .nav-logo-img { width: 28px; height: 28px; }
  .logo-name { font-size: 0.85rem; }
  .nav-btn { padding: 4px 8px; font-size: 0.75rem; }
  .modal-box { width: 95vw; padding: 12px; }
  .modal-body { padding: 16px 12px; }
  .modal-ftr { padding: 12px; }
  /* Result footer holds 4 buttons — let them wrap into 2 neat rows on phones */
  .result-ftr { padding: 12px; gap: 8px; }
  .result-ftr > button { flex: 1 1 44%; }
  .form-lbl { font-size: 0.65rem; }
  .color-tile { padding: 8px; font-size: 0.75rem; }
  .piece { font-size: calc(min(96vw, calc(100dvh - 250px)) / 8 * 0.94); }
}

/* ── Mobile navbar: keep every top-bar control on screen ─────────────
   Measured (in-game, 7 controls visible): with text labels the actions row
   needs ≥660px and overflows below that; at 390px the last two controls sat
   entirely off-screen (btn-new-game left 400.3, GitHub left 510.9) while
   btn-resign was clipped by 2.3px. Below 720px the labels are dropped (icons
   stay) and spacing tightened so every control fits, down to 320px. */
@media (max-width: 720px) {
  #navbar { padding: 0 12px; gap: 8px; }
  .nav-center { min-width: 0; }
  #nav-game-mode { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-actions { gap: 4px; }
  .nav-btn {
    padding: 5px;
    gap: 0;
    min-width: 30px;
    min-height: 34px;
    justify-content: center;
    touch-action: manipulation;
  }
  .nav-btn .btn-label { display: none; }
  .spectator-badge { gap: 0; padding: 5px; }
  .spectator-badge .badge-label { display: none; }
}

/* Phones: the wordmark and the centre mode label no longer fit, so they hand
   their room to the controls, which grow back to a comfortable tap size. */
@media (max-width: 560px) {
  .logo-name { display: none; }
  #nav-game-mode { display: none; }
  .spectator-count { display: none; }
  .nav-actions { gap: 6px; }
  .nav-btn { padding: 6px; min-width: 34px; min-height: 40px; }
  /* Resign / New Game are disabled while spectating — free their space. */
  body.spectator-mode #btn-resign,
  body.spectator-mode #btn-new-game { display: none; }
}

/* Tiny phones (320px class) */
@media (max-width: 340px) {
  .nav-actions { gap: 4px; }
  .nav-btn { padding: 5px; min-width: 30px; min-height: 36px; }
}

@media (max-width: 400px) {
  .hero-title { font-size: 1.5rem; }
  .timer-pill { min-width: 55px; padding: 4px 8px; font-size: 0.8rem; }
  .player-avatar { font-size: 1.2rem; }
  .player-name { font-size: 0.8rem; }
}

/* ═══════════════════════════════════════════════════
   PROPER FULL-SCREEN MODE
═══════════════════════════════════════════════════ */
body.fullscreen-mode #navbar,
body.fullscreen-mode .eval-bar,
body.fullscreen-mode .breadcrumb-bar,
body.fullscreen-mode .session-stats-bar,
body.fullscreen-mode .captured-strip {
  display: none !important;
}
body.fullscreen-mode #game-screen {
  padding: 0 !important;
  height: 100dvh;
  background: #121212;
}
body.fullscreen-mode .side-panel,
body.fullscreen-mode .action-row,
body.fullscreen-mode .history-panel,
body.fullscreen-mode #opening-name,
body.fullscreen-mode #btn-coords,
body.fullscreen-mode .chat-panel {
  display: none !important;
}
body.fullscreen-mode .game-layout {
  max-width: none;
  width: 100%;
  height: 100%;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "player-top"
    "board"
    "player-bot";
}
body.fullscreen-mode .board-area {
  justify-content: center;
  align-items: center;
  height: 100%;
}
body.fullscreen-mode .board-frame {
  max-width: none;
  min-width: 0;
}
body.fullscreen-mode #board {
  width: min(100vw, 100dvh - 120px);
  height: min(100vw, 100dvh - 120px);
}
body.fullscreen-mode .piece {
  font-size: calc(min(100vw, 100dvh - 120px) / 8 * 0.94);
}
body.fullscreen-mode .player-bar {
  background: transparent;
  border: none;
  box-shadow: none;
  max-width: none;
  justify-content: center;
}
body.fullscreen-mode .player-bar-top { align-self: end; }
body.fullscreen-mode .player-bar-bottom { align-self: start; }
@media (max-width: 860px) {
  body.fullscreen-mode #board {
    width: min(100vw, 100dvh - 120px);
    height: min(100vw, 100dvh - 120px);
  }
  body.fullscreen-mode .piece {
    font-size: calc(min(100vw, 100dvh - 120px) / 8 * 0.94);
  }
}

/* ── Hint Canvas ───────────────────────────── */
#hint-canvas {
  position: absolute;
  top: 0;
  left: 0;
  
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

/* ── Evaluation Bar ───────────────────────── */
.eval-bar {
  width: 20px;
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-left: 8px;
}
#eval-fill {
  position: absolute;
  bottom: 0;
  
  background: #4a90e2;
  transition: height 0.3s ease;
}
#eval-text {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text);
  z-index: 1;
  text-align: center;
}

/* ── Opening Tag ──────────────────────────── */
.opening-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 0;
  min-height: 18px;
  transition: opacity 0.3s;
  letter-spacing: 0.02em;
}

/* ── Bullet Mode ──────────────────────────── */
.timer-pill.bullet-mode {
  border-color: rgba(220,53,53,0.5);
  color: #ff6b6b;
  background: rgba(220,53,53,0.08);
  font-weight: 700;
}
@keyframes bullet-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.bullet-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e55;
  display: inline-block;
  margin-right: 6px;
  animation: bullet-blink 1s infinite;
}

/* ── Blindfold Banner ─────────────────────── */
.blindfold-banner {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: none;
}
.blindfold-banner.visible {
  display: block;
}
.blindfold-mode .piece {
  opacity: 0 !important;
}

/* ── Chat Panel ───────────────────────────── */
.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  max-height: 180px;
}
.chat-header {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  min-height: 0;
}
.chat-msg {
  color: var(--text-dim);
  line-height: 1.4;
  word-break: break-word;
}
.chat-msg-self {
  color: var(--text);
}
.chat-name {
  font-weight: 600;
  margin-right: 4px;
  color: var(--text-muted);
}
.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 0.78rem;
  background: #1a1a1a;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
}

/* ── Session Stats Bar ────────────────────── */
.session-stats-bar {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 0;
  letter-spacing: 0.04em;
}

/* ── Move Time Badge ──────────────────────── */
.move-time-badge {
  font-size: 0.64rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-left: 3px;
  opacity: 0.7;
}
.move-time-badge.slow {
  color: var(--danger);
  opacity: 0.9;
}

/* ── Gauntlet Stages ──────────────────────── */
.gauntlet-desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 16px;
}
.gauntlet-stages {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gauntlet-stage {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}
.gauntlet-stage:hover:not(.locked) {
  border-color: var(--border2);
  background: var(--panel2);
}
.gauntlet-stage.locked {
  opacity: 0.5;
  cursor: not-allowed;
}
.stage-num {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-muted);
}

/* ── Invite URL Row ───────────────────────── */
.invite-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.invite-url-text {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  word-break: break-all;
  flex: 1;
  background: #1a1a1a;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ── Spectator Count ──────────────────────── */
.spectator-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 99px;
  margin-left: 8px;
}
.spectator-count.hidden {
  display: none !important;
}

/* ── Accuracy Bar ─────────────────────────── */
.accuracy-bar-track {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  margin-top: 4px;
}
.accuracy-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: #ffffff;
  transition: width 0.4s ease;
}

/* ── Piece Animation on Move ──────────────── */
@keyframes piece-move {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.piece-just-moved { animation: piece-move 0.2s ease; }

/* ── Win Glow Effect ──────────────────────── */
@keyframes win-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(255,255,255,0.3); }
  50%       { box-shadow: 0 0 60px rgba(255,255,255,0.6); }
}
.board-frame.game-won { animation: win-glow 1.5s ease-in-out 3; }
