/* ==========================================================================
   Classic English Draughts (Checkers) Stylesheet
   Warm Walnut & Maple Board, Tactile Pieces, Responsive CSS Grid
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-color: #1a1816;
  --panel-bg: rgba(36, 32, 29, 0.95);
  --panel-border: #4a3b32;
  --text-main: #f5ede0;
  --text-muted: #a69888;
  
  /* Wood Board Palette */
  --board-rim: #3d2514;
  --board-rim-border: #23150b;
  --board-inner-border: #5a3820;
  --square-light: #eed9b7;
  --square-dark: #8b5a2b;
  --square-dark-highlight: #aa733c;
  
  /* Piece Colors */
  --red-piece-from: #e53935;
  --red-piece-to: #8e1515;
  --red-piece-border: #5f0f0f;
  
  --black-piece-from: #3b3a39;
  --black-piece-to: #181716;
  --black-piece-border: #0d0c0c;

  --gold-accent: #f5b041;
  --gold-glow: rgba(245, 176, 65, 0.7);
  --move-dot-color: rgba(46, 204, 113, 0.85);
  --jump-dot-color: rgba(231, 76, 60, 0.9);
  
  /* Sizing */
  --board-max-size: min(88vw, 72vh, 560px);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  background-image: radial-gradient(circle at 50% 20%, #2a241f 0%, #151311 100%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
  overflow-x: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 680px;
  gap: 14px;
}

/* ==========================================================================
   Header & Action Controls
   ========================================================================== */

.game-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 10px;
}

.game-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-main);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn:hover {
  background: #3e332c;
  border-color: #635043;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: #b54a24;
  border-color: #8c3514;
  color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover {
  background: #cb562d;
  border-color: #a4401a;
}

.control-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.select-control {
  font-size: 0.84rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}

.select-control:hover, .select-control:focus {
  background: #3e332c;
  border-color: #8c3514;
}

.select-control option {
  background: #24201d;
  color: #f5ede0;
}

.btn-icon {
  padding: 7px 10px;
}

.icon {
  display: inline-block;
  vertical-align: middle;
}

.hidden {
  display: none !important;
}

@keyframes pulse-thinking {
  0% { opacity: 0.5; }
  50% { opacity: 1; text-shadow: 0 0 6px rgba(245, 176, 65, 0.6); }
  100% { opacity: 0.5; }
}

.turn-message.thinking {
  color: var(--gold-accent);
  font-weight: 700;
  animation: pulse-thinking 1.2s infinite ease-in-out;
}

/* ==========================================================================
   Scoreboard & Turn Status
   ========================================================================== */

.game-info-card {
  width: 100%;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.player-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.player-card.active-turn {
  border-color: var(--gold-accent);
  background: rgba(245, 176, 65, 0.12);
  box-shadow: 0 0 10px rgba(245, 176, 65, 0.2);
}

.player-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.piece-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
}

.red-avatar {
  background: radial-gradient(circle at 35% 35%, var(--red-piece-from), var(--red-piece-to));
  border: 1px solid var(--red-piece-border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.black-avatar {
  background: radial-gradient(circle at 35% 35%, var(--black-piece-from), var(--black-piece-to));
  border: 1px solid var(--black-piece-border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.player-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.player-stats {
  display: flex;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.crown-symbol {
  color: var(--gold-accent);
  font-size: 0.9rem;
}

.turn-status-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 140px;
}

.turn-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  font-weight: 700;
  font-size: 0.88rem;
}

.turn-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--red-piece-from);
  box-shadow: 0 0 6px var(--red-piece-from);
}

.turn-dot.black-turn {
  background-color: #888;
  box-shadow: 0 0 6px #888;
}

.turn-message {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  min-height: 1.2em;
}

.turn-message.alert {
  color: #ffb74d;
  font-weight: 600;
}

/* ==========================================================================
   Board & Squares
   ========================================================================== */

.board-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
}

.board {
  width: var(--board-max-size);
  height: var(--board-max-size);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  background-color: var(--board-rim);
  border: 10px solid var(--board-rim);
  outline: 2px solid var(--board-inner-border);
  border-radius: 8px;
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.6),
    0 2px 4px rgba(0, 0, 0, 0.4),
    inset 0 0 10px rgba(0, 0, 0, 0.5);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.board.flipped {
  transform: rotate(180deg);
}

.board.flipped .piece,
.board.flipped .square-notation {
  transform: rotate(180deg);
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.square-light {
  background-color: var(--square-light);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(0, 0, 0, 0.04) 100%);
}

.square-dark {
  background-color: var(--square-dark);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(0, 0, 0, 0.12) 100%);
  cursor: default;
}

.square-notation {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.45);
  pointer-events: none;
  display: none;
}

.show-notation .square-notation {
  display: block;
}

/* Previous Move Highlight */
.square.last-move-from::before,
.square.last-move-to::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(245, 176, 65, 0.28);
  pointer-events: none;
}

/* Valid Move Destination */
.square.valid-dest {
  cursor: pointer;
}

.square.valid-dest::after {
  content: "";
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: var(--move-dot-color);
  box-shadow: 0 0 8px rgba(46, 204, 113, 0.7);
  z-index: 10;
  pointer-events: none;
  animation: pulse-dot 1.4s infinite ease-in-out;
}

.square.valid-dest.is-jump-dest::after {
  background: var(--jump-dot-color);
  box-shadow: 0 0 10px rgba(231, 76, 60, 0.8);
  width: 32%;
  height: 32%;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
}

/* ==========================================================================
   Tactile Checkers Pieces
   ========================================================================== */

.piece {
  width: 82%;
  height: 82%;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: manipulation;
  z-index: 5;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

/* Tactile ridges (concentric grooves on draughts pieces) */
.piece::before {
  content: "";
  position: absolute;
  width: 66%;
  height: 66%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* Red Piece */
.piece.red {
  background: radial-gradient(circle at 35% 35%, var(--red-piece-from) 0%, var(--red-piece-to) 80%, #6e1010 100%);
  border: 2px solid var(--red-piece-border);
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.5),
    inset 0 2px 4px rgba(255, 255, 255, 0.35),
    inset 0 -3px 4px rgba(0, 0, 0, 0.4);
}

/* Black Piece */
.piece.black {
  background: radial-gradient(circle at 35% 35%, var(--black-piece-from) 0%, var(--black-piece-to) 80%, #0a0909 100%);
  border: 2px solid var(--black-piece-border);
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.6),
    inset 0 2px 3px rgba(255, 255, 255, 0.22),
    inset 0 -3px 4px rgba(0, 0, 0, 0.6);
}

/* Selectable Piece (has legal moves) */
.piece.selectable {
  cursor: pointer;
  box-shadow:
    0 0 0 3px var(--gold-glow),
    0 4px 8px rgba(0, 0, 0, 0.5);
}

.piece.selectable:hover {
  transform: scale(1.05);
}

/* Active Selected Piece */
.piece.selected {
  transform: scale(1.1);
  box-shadow:
    0 0 0 4px var(--gold-accent),
    0 0 16px var(--gold-glow),
    0 8px 14px rgba(0, 0, 0, 0.6) !important;
  z-index: 20;
}

/* King Styling */
.crown-icon {
  width: 52%;
  height: 52%;
  fill: #ffd700;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7));
  z-index: 2;
  pointer-events: none;
}

/* Newly crowned piece bounce */
.piece.newly-crowned {
  animation: crown-pop 0.45s ease-out;
}

@keyframes crown-pop {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* ==========================================================================
   Game Over Modal
/* ==========================================================================
   Tactile & Animated Checkers Pieces
   ========================================================================== */

/* Multi-jump active piece pulse */
.piece.multi-jump-active {
  animation: multi-jump-pulse 0.9s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 25;
}

@keyframes multi-jump-pulse {
  0% {
    box-shadow: 0 0 0 3px #f5b041, 0 0 10px rgba(245, 176, 65, 0.5);
  }
  100% {
    box-shadow: 0 0 0 6px #e74c3c, 0 0 20px rgba(231, 76, 60, 0.9);
    transform: scale(1.08);
  }
}

/* Prey Target Highlighting (pieces about to be jumped) */
.piece.target-prey {
  animation: prey-pulse 0.9s infinite alternate ease-in-out;
}

@keyframes prey-pulse {
  0% {
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.6);
  }
  100% {
    box-shadow: 0 0 0 5px rgba(231, 76, 60, 1), 0 0 16px rgba(231, 76, 60, 0.9);
  }
}

.square.is-prey-square::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 2px dashed rgba(231, 76, 60, 0.85);
  border-radius: 50%;
  pointer-events: none;
  z-index: 4;
  animation: rotate-prey 4s linear infinite;
}

@keyframes rotate-prey {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Move & Jump Animations */
.piece.anim-sliding {
  transition: transform 200ms cubic-bezier(0.25, 1, 0.5, 1) !important;
  z-index: 30;
}

.piece.anim-hopping {
  animation: piece-hop 250ms cubic-bezier(0.22, 1, 0.36, 1) forwards !important;
  z-index: 35;
}

@keyframes piece-hop {
  0% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(calc(var(--move-dx, 0px) * 0.5), calc(var(--move-dy, 0px) * 0.5)) scale(1.25);
    box-shadow: 0 16px 26px rgba(0, 0, 0, 0.65), 0 0 14px var(--gold-glow);
  }
  100% {
    transform: translate(var(--move-dx, 0px), var(--move-dy, 0px)) scale(1);
  }
}

/* Capture Dissipation Animation */
.piece.anim-dissipating {
  animation: capture-dissipate 200ms ease-out forwards !important;
  pointer-events: none;
  z-index: 15;
}

@keyframes capture-dissipate {
  0% {
    transform: scale(1);
    opacity: 1;
    filter: brightness(1);
  }
  40% {
    transform: scale(1.15) rotate(12deg);
    opacity: 0.85;
    filter: brightness(1.3);
  }
  100% {
    transform: scale(0) rotate(-25deg);
    opacity: 0;
    filter: brightness(0.2);
  }
}

/* Dynamic Multi-Jump Callout Banner */
.multijump-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: var(--board-max-size);
  padding: 8px 14px;
  background: rgba(192, 57, 43, 0.22);
  border: 1px solid rgba(231, 76, 60, 0.6);
  border-radius: 8px;
  color: #ffcdd2;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  animation: fade-in 0.2s ease;
}

.multijump-pill {
  background: #c0392b;
  color: #fff;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.multijump-text {
  flex: 1;
  text-align: left;
}

/* Floating Re-open Recap Pill */
.reopen-modal-pill {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 80;
  background: #b54a24;
  color: #fff;
  border: 1px solid var(--gold-accent);
  border-radius: 24px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55), 0 0 12px rgba(245, 176, 65, 0.4);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.reopen-modal-pill:hover {
  transform: translateY(-2px) scale(1.03);
  background: #cb562d;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 18px rgba(245, 176, 65, 0.6);
}

/* Keyboard Shortcuts Legend */
.keyboard-legend {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 4px 8px;
  user-select: none;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

kbd {
  background: #2b2521;
  border: 1px solid #4d3d34;
  border-bottom: 2px solid #362a22;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Game Over Modal
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fade-in 0.25s ease;
}

.modal-card {
  background: #25201c;
  border: 2px solid var(--gold-accent);
  border-radius: 14px;
  padding: 26px 32px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), 0 0 28px rgba(245, 176, 65, 0.35);
  animation: scale-up 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.modal-trophy {
  font-size: 3rem;
  margin-bottom: 6px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
  animation: trophy-bounce 0.6s ease;
}

@keyframes trophy-bounce {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); }
}

.modal-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold-accent);
  margin-bottom: 6px;
}

.modal-reason-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
  background: rgba(245, 176, 65, 0.18);
  border: 1px solid var(--gold-accent);
  color: var(--gold-accent);
}

.modal-message {
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 16px;
  line-height: 1.4;
}

/* Modal Stats Recap Grid */
.modal-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 22px;
  text-align: left;
}

.modal-stat-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-card-wide {
  grid-column: span 2;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-value {
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--panel-border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: #6d5b4e;
}

.btn-large {
  font-size: 0.95rem;
  padding: 9px 20px;
  flex: 1;
}

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

@keyframes scale-up {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Touch & Mobile Optimizations */
html, body, .board, .square, .piece, .btn, .select-control {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 520px) {
  .game-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .game-info-card {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .turn-status-container {
    order: -1;
  }

  .player-card {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .btn-text {
    display: none;
  }

  .btn-icon {
    padding: 8px;
  }

  .btn-primary .btn-text,
  .btn-primary {
    display: inline-flex;
  }

  .modal-actions {
    flex-direction: column;
  }

  .keyboard-legend {
    display: none;
  }

  .main-layout-container {
    flex-direction: column;
  }
}

/* ==========================================================================
   AI Arena & WebLLM Features Styles
   ========================================================================== */

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.arena-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: linear-gradient(135deg, rgba(230, 81, 0, 0.3), rgba(245, 124, 0, 0.4));
  border: 1px solid rgba(255, 179, 0, 0.45);
  color: #ffca28;
  padding: 3px 8px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* WebLLM Download Progress Container */
.webllm-progress-container {
  background: rgba(22, 17, 13, 0.95);
  border: 1px solid rgba(255, 179, 0, 0.4);
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.progress-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-main);
  margin-bottom: 6px;
}

.progress-percent {
  font-weight: 700;
  color: #ffb300;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f57c00, #ffb300);
  border-radius: 999px;
  transition: width 200ms ease-out;
}

/* Spectator Controls Toolbar */
.spectator-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(26, 20, 16, 0.95);
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: 10px;
  padding: 8px 14px;
  margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

.spectator-badge {
  font-size: 0.82rem;
  font-weight: 700;
  color: #ffd54f;
  display: flex;
  align-items: center;
  gap: 6px;
}

.spectator-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spectator-speed-group {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}

.speed-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.select-sm {
  padding: 4px 8px;
  font-size: 0.78rem;
}

/* Speech Bubbles on Player Cards */
.player-card {
  position: relative;
}

.speech-bubble {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #2a2019;
  border: 1px solid rgba(255, 215, 0, 0.4);
  color: #fff8e7;
  font-size: 0.76rem;
  line-height: 1.35;
  padding: 6px 12px;
  border-radius: 10px;
  white-space: normal;
  max-width: 200px;
  min-width: 130px;
  text-align: center;
  z-index: 50;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  animation: pop-bubble 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.speech-bubble::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 6px 6px 6px;
  border-style: solid;
  border-color: transparent transparent #2a2019 transparent;
}

@keyframes pop-bubble {
  from { opacity: 0; transform: translateX(-50%) scale(0.85); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}

/* Arena Layout: Dual Column */
.main-layout-container {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
}

.arena-feed-section {
  flex: 0 0 280px;
  max-width: 320px;
  height: 540px;
  background: rgba(22, 17, 13, 0.95);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.arena-feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(36, 28, 22, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.feed-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.arena-feed-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.3px;
}

.btn-xs {
  font-size: 0.7rem;
  padding: 2px 7px;
}

.btn-subtle {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
}

.btn-subtle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.arena-feed-list {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.arena-msg {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.4;
  border-left: 3px solid rgba(255, 255, 255, 0.2);
  animation: fade-in 0.25s ease-out;
}

.arena-msg.msg-red {
  border-left-color: #e74c3c;
  background: rgba(231, 76, 60, 0.08);
}

.arena-msg.msg-black {
  border-left-color: #34495e;
  background: rgba(52, 73, 94, 0.18);
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.msg-avatar {
  font-size: 0.9rem;
}

.msg-author {
  font-weight: 700;
  color: #ffecb3;
}

.msg-move {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-left: auto;
  background: rgba(0, 0, 0, 0.25);
  padding: 1px 5px;
  border-radius: 4px;
}

.msg-body {
  color: var(--text-main);
}

.arena-welcome-msg {
  border-left-color: #f39c12;
  font-style: italic;
  color: var(--text-muted);
}

/* Arena Setup Modal */
.modal-card-wide {
  max-width: 620px;
  width: 90vw;
  text-align: left;
}

.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 580px) {
  .setup-grid {
    grid-template-columns: 1fr;
  }
}

.setup-panel {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px;
}

.panel-red {
  border-top: 3px solid #e74c3c;
}

.panel-black {
  border-top: 3px solid #7f8c8d;
}

.panel-heading {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-red {
  background: #e74c3c;
}

.dot-black {
  background: #2c3e50;
  border: 1px solid #7f8c8d;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.form-group label {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.full-width {
  width: 100%;
}

.setup-global-settings {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 16px;
}

/* ==========================================================================
   LLM Dashboard Styles
   ========================================================================== */

.modal-dashboard-card {
  max-width: 680px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  text-align: left;
  padding: 24px;
}

.modal-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
  margin-bottom: 18px;
}

.modal-header-row .modal-title {
  margin: 0;
  font-size: 1.3rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 640px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.dashboard-card {
  background: rgba(22, 19, 16, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dashboard-card-wide {
  grid-column: 1 / -1;
}

.dashboard-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 8px;
}

.card-icon {
  font-size: 1.1rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  flex-grow: 1;
}

.status-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.status-badge-success {
  background: rgba(46, 204, 113, 0.2);
  color: #2ecc71;
  border: 1px solid rgba(46, 204, 113, 0.4);
}

.status-badge-danger {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
  border: 1px solid rgba(231, 76, 60, 0.4);
}

.status-badge-pending {
  background: rgba(241, 196, 15, 0.2);
  color: #f1c40f;
  border: 1px solid rgba(241, 196, 15, 0.4);
}

.dashboard-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.82rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.info-label {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.info-val {
  color: var(--text-main);
  font-size: 0.8rem;
  word-break: break-word;
  text-align: right;
}

.font-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.info-notes {
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.35;
  margin: 0;
}

.model-meta-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.meta-badge {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.72rem;
  color: var(--gold-accent);
}

.model-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.dashboard-progress-container {
  margin-top: 6px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
}

.testbench-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.testbench-metrics {
  font-size: 0.74rem;
  color: var(--gold-accent);
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.console-box {
  background: #110f0d;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 10px;
  min-height: 90px;
  max-height: 180px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  color: #d1c7bd;
  white-space: pre-wrap;
  word-break: break-word;
}

.console-output {
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  white-space: pre-wrap;
}

.console-log-box {
  min-height: 100px;
  max-height: 160px;
}

.log-entry {
  padding: 2px 0;
  line-height: 1.35;
}

.log-entry-info .log-time {
  color: #3498db;
}

.log-entry-warn {
  color: #f39c12;
}

.log-entry-warn .log-time {
  color: #f39c12;
}

.log-entry-error {
  color: #e74c3c;
}

.log-entry-error .log-time {
  color: #e74c3c;
}


