/* Chess Wiki & Masterpieces - Premium Dark Theme Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-surface: #141e33;
  --bg-surface-elevated: #1b2742;
  --bg-surface-hover: #223254;
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(245, 158, 11, 0.5);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-gold: #f59e0b;
  --accent-gold-light: #fbbf24;
  --accent-gold-glow: rgba(245, 158, 11, 0.25);
  
  --accent-blue: #38bdf8;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  
  /* Board Themes */
  --sq-light: #ebecd0;
  --sq-dark: #779556;
  --sq-highlight-from: rgba(245, 158, 11, 0.5);
  --sq-highlight-to: rgba(245, 158, 11, 0.65);
  --sq-select: rgba(56, 189, 248, 0.6);
  --sq-check: radial-gradient(circle, rgba(244, 63, 94, 0.8) 0%, rgba(244, 63, 94, 0.2) 60%, transparent 100%);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 25px var(--accent-gold-glow);
}

/* Board Theme Presets */
body[data-board-theme="wood"] {
  --sq-light: #d6b88d;
  --sq-dark: #8b5a2b;
}

body[data-board-theme="emerald"] {
  --sq-light: #ebecd0;
  --sq-dark: #779556;
}

body[data-board-theme="midnight"] {
  --sq-light: #94a3b8;
  --sq-dark: #334155;
}

body[data-board-theme="cyber"] {
  --sq-light: #cbd5e1;
  --sq-dark: #0284c7;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* App Layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  background: radial-gradient(circle at 50% 10%, #151d30 0%, #090d16 80%);
}

/* Top Navigation Bar */
.top-header {
  height: 56px;
  min-height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 50;
}

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

.brand-icon {
  font-size: 24px;
  line-height: 1;
  filter: drop-shadow(0 0 8px var(--accent-gold));
}

.brand-title {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 40%, var(--accent-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.custom-select {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
}

.custom-select:hover, .custom-select:focus {
  border-color: var(--accent-gold);
}

.icon-btn {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.icon-btn.active {
  background: var(--accent-gold);
  color: #000;
  border-color: var(--accent-gold);
}

/* Main 3-Column Workspace */
.workspace {
  display: flex;
  flex: 1;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* LEFT SIDEBAR: Games Browser */
.sidebar-games {
  width: 340px;
  min-width: 320px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  border-right: 1px solid var(--border-subtle);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.search-input {
  width: 100%;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px 8px 34px;
  font-size: 13px;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px var(--accent-gold-glow);
}

.search-icon {
  position: absolute;
  left: 10px;
  font-size: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Era Filters */
.era-filters {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.era-filters::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-chip:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.filter-chip.active {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  font-weight: 600;
}

/* Tactic Filter Section */
.tactic-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  margin-bottom: 6px;
}

.tactic-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tactic-clear-btn {
  background: none;
  border: none;
  color: var(--accent-gold);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  transition: all 0.15s;
}

.tactic-clear-btn:hover {
  text-decoration: underline;
  color: #fff;
}

.tactic-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 88px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.tactic-filters::-webkit-scrollbar {
  width: 4px;
}

.tactic-filters::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.tactic-chip {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tactic-chip:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.tactic-chip.active {
  background: rgba(245, 158, 11, 0.22);
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  font-weight: 600;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.25);
}

.tactic-chip .chip-count {
  font-size: 10px;
  opacity: 0.75;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 4px;
  border-radius: 8px;
}

.tactic-chip.active .chip-count {
  background: rgba(245, 158, 11, 0.35);
  opacity: 1;
}

/* Tactic badges on cards and details */
.game-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  margin-bottom: 2px;
}

.tactic-tag-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-gold-light);
  border: 1px solid rgba(245, 158, 11, 0.25);
  white-space: nowrap;
}

.tactic-tag-badge.more {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border-color: var(--border-subtle);
}

.games-count-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.1);
}

.games-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.games-list::-webkit-scrollbar {
  width: 5px;
}
.games-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

/* Game Card */
.game-card {
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.game-card:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.game-card.active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(20, 30, 51, 0.95) 100%);
  border-color: var(--accent-gold);
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.15);
}

.game-card.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent-gold);
}

.game-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.game-card-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-gold);
}

.game-card-year {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.game-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.3;
}

.game-card-players {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

.player-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.player-dot.white {
  background: #f8fafc;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}
.player-dot.black {
  background: #334155;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.game-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.badge-eco {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-blue);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

.badge-result {
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}
.badge-result.white-win { color: #f8fafc; background: rgba(255, 255, 255, 0.12); }
.badge-result.black-win { color: var(--accent-gold-light); background: rgba(245, 158, 11, 0.12); }
.badge-result.draw { color: var(--accent-blue); }

/* CENTER: Chessboard & Match Controls */
.center-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  overflow-y: auto;
  position: relative;
}

/* Match Header Info */
.match-header {
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(20, 30, 51, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 10px;
}

.match-info-title {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.match-info-sub {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  transition: all 0.2s;
}

.mode-badge.replay {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.mode-badge.branch {
  background: rgba(245, 158, 11, 0.18);
  color: var(--accent-gold);
  border: 1px solid rgba(245, 158, 11, 0.4);
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(245, 158, 11, 0.2); }
  50% { box-shadow: 0 0 16px rgba(245, 158, 11, 0.5); }
}

/* Player Bar */
.player-bar {
  width: 100%;
  max-width: 580px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.player-details {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-name {
  font-weight: 600;
  color: var(--text-primary);
}

.player-elo {
  font-size: 12px;
  color: var(--text-muted);
}

.captured-pieces {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 22px;
}

.captured-icon {
  width: 18px;
  height: 18px;
}

.material-diff {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-left: 6px;
}

/* Board Outer Wrapper */
.board-outer {
  position: relative;
  padding: 12px;
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 35px rgba(0, 0, 0, 0.5);
}

/* Chessboard Area */
.board-container {
  width: min(520px, 80vw, calc(100vh - 280px));
  height: min(520px, 80vw, calc(100vh - 280px));
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: var(--radius-md);
  overflow: hidden;
  user-select: none;
  position: relative;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.4);
}

/* Board Square */
.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.square.light {
  background-color: var(--sq-light);
}

.square.dark {
  background-color: var(--sq-dark);
}

/* Coordinate Labels inside edge squares */
.coord-rank, .coord-file {
  position: absolute;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
  line-height: 1;
}

.coord-rank {
  top: 3px;
  left: 3px;
}

.coord-file {
  bottom: 3px;
  right: 3px;
}

.square.light .coord-rank, .square.light .coord-file {
  color: var(--sq-dark);
}

.square.dark .coord-rank, .square.dark .coord-file {
  color: var(--sq-light);
}

/* Last move highlights */
.square.highlight-from {
  background-color: var(--sq-highlight-from) !important;
}

.square.highlight-to {
  background-color: var(--sq-highlight-to) !important;
}

.square.selected {
  background-color: var(--sq-select) !important;
}

.square.in-check {
  background: var(--sq-check) !important;
}

/* Tactic Highlights on Chessboard */
.square.highlight-tactic-target {
  box-shadow: inset 0 0 0 3px #f43f5e, 0 0 14px rgba(244, 63, 94, 0.6) !important;
  position: relative;
}
.square.highlight-tactic-target::after {
  content: '🎯';
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 11px;
  pointer-events: none;
  z-index: 10;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.9));
}

.square.highlight-tactic-pin {
  box-shadow: inset 0 0 0 3px #38bdf8, 0 0 14px rgba(56, 189, 248, 0.6) !important;
  position: relative;
}
.square.highlight-tactic-pin::after {
  content: '📌';
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 11px;
  pointer-events: none;
  z-index: 10;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.9));
}

.square.highlight-tactic-source {
  box-shadow: inset 0 0 0 3px #eab308, 0 0 14px rgba(234, 179, 8, 0.6) !important;
}

/* Legal Move Hints */
.legal-dot {
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  pointer-events: none;
  animation: fadeIn 0.15s ease;
}

.legal-capture-ring {
  width: 86%;
  height: 86%;
  border-radius: 50%;
  border: 4px solid rgba(244, 63, 94, 0.7);
  pointer-events: none;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}

/* Pieces */
.piece {
  width: 90%;
  height: 90%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  cursor: grab;
  z-index: 10;
  transition: transform 0.1s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

.piece:active {
  cursor: grabbing;
  transform: scale(1.12);
  z-index: 20;
}

/* Floating Turn Indicator / Commentary Bar */
.turn-status-bar {
  width: 100%;
  max-width: 580px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(20, 30, 51, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-top: 8px;
  font-size: 13px;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ply-counter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-gold);
}

.turn-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}

.status-alert {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-rose);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Control Navigation Deck */
.board-controls {
  width: 100%;
  max-width: 580px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 8px 14px;
  margin-top: 8px;
  box-shadow: var(--shadow-md);
}

.nav-buttons-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-btn {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.nav-btn.primary {
  background: linear-gradient(135deg, var(--accent-gold) 0%, #d97706 100%);
  color: #000;
  border-color: var(--accent-gold);
  font-weight: 700;
}

.nav-btn.primary:hover:not(:disabled) {
  box-shadow: 0 0 15px var(--accent-gold-glow);
}

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

.speed-select {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

/* RIGHT PANEL: Game Lore & Moves List */
.sidebar-moves {
  width: 360px;
  min-width: 330px;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  border-left: 1px solid var(--border-subtle);
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
}

.tab-btn {
  flex: 1;
  padding: 14px 12px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.05);
}

.tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Play/Branch Banner */
.branch-banner {
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(30, 41, 59, 0.8) 100%);
  border-bottom: 1px solid var(--accent-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.branch-banner-text {
  font-weight: 600;
  color: var(--accent-gold-light);
}

.btn-small {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-small:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent-gold);
}

.btn-small.danger {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.4);
  color: var(--accent-rose);
}

/* Move List Table */
.moves-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.moves-scrollable::-webkit-scrollbar {
  width: 5px;
}
.moves-scrollable::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

.move-pair-row {
  display: grid;
  grid-template-columns: 40px 1fr 1fr;
  align-items: center;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
}

.move-pair-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.move-num {
  color: var(--text-muted);
  font-size: 12px;
}

.move-cell {
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-height: 28px;
}

.move-cell:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.move-cell.current-move {
  background: var(--accent-gold);
  color: #000;
  font-weight: 700;
  box-shadow: 0 0 10px var(--accent-gold-glow);
}

.move-cell.current-move .move-tactic-pill {
  background: rgba(0, 0, 0, 0.28);
  border-color: rgba(0, 0, 0, 0.4);
  color: #fff;
}

.move-tactic-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--accent-gold-light);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  line-height: 1.2;
  cursor: pointer;
  transition: all 0.15s ease;
}

.move-tactic-pill:hover {
  transform: scale(1.08);
  background: rgba(245, 158, 11, 0.35);
  color: #fff;
}

.move-tactic-pill .t-icon {
  font-size: 10px;
}

.move-tactic-pill .t-sq {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  opacity: 0.95;
}

/* Quick Tactics Jump Bar */
.tactics-jump-bar {
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tactics-jump-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tactics-count-badge {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-gold);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}

.tactics-jump-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 76px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.tactics-jump-list::-webkit-scrollbar {
  width: 4px;
}
.tactics-jump-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.tactic-jump-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tactic-jump-chip:hover {
  background: var(--bg-surface-hover);
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  transform: translateY(-1px);
}

.tactic-jump-chip.active {
  background: rgba(245, 158, 11, 0.25);
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.25);
}

/* Story / Lore Tab */
.lore-container {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lore-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.lore-title {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lore-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.meta-item {
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.meta-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.meta-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Engine / Bot Options in Play Mode */
.bot-config-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.bot-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.bot-options-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Pawn Promotion Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.active {
  display: flex;
}

.promotion-box {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: modalPop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.promotion-title {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-gold);
}

.promotion-pieces {
  display: flex;
  gap: 12px;
}

.promo-piece-btn {
  width: 60px;
  height: 60px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.promo-piece-btn:hover {
  background: var(--accent-gold-glow);
  border-color: var(--accent-gold);
  transform: translateY(-3px);
}

.promo-piece-btn img {
  width: 48px;
  height: 48px;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(20, 30, 51, 0.95);
  border: 1px solid var(--accent-gold);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 20px var(--accent-gold-glow);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Responsive adjustments */
@media (max-width: 1080px) {
  .sidebar-games {
    width: 280px;
    min-width: 260px;
  }
  .sidebar-moves {
    width: 300px;
    min-width: 280px;
  }
}

@media (max-width: 860px) {
  .workspace {
    flex-direction: column;
    overflow-y: auto;
  }
  .sidebar-games {
    width: 100%;
    max-width: 100%;
    height: 250px;
  }
  .sidebar-moves {
    width: 100%;
    max-width: 100%;
    height: 300px;
  }
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
  body { padding: 12px !important; }
  .top-header { flex-direction: column !important; align-items: flex-start !important; gap: 12px !important; }
  .brand-title { font-size: 1.2rem !important; }
  .workspace { flex-direction: column !important; }
  .sidebar-games, .center-workspace { width: 100% !important; min-width: unset !important; }
  .match-header { flex-direction: column !important; gap: 8px !important; }
  .theme-selector { width: 100% !important; }
  .theme-selector select { width: 100% !important; min-height: 44px !important; }
  .header-actions { width: 100% !important; flex-wrap: wrap !important; }
  .icon-btn { min-width: 44px !important; min-height: 44px !important; }
  .search-input { min-height: 44px !important; font-size: 1rem !important; }
  .custom-select { min-height: 44px !important; }
  .era-filters, .tactic-filters { flex-wrap: wrap !important; }
  .games-list { max-height: 40vh !important; }
  .app-container { overflow-x: auto !important; }
  .games-count-bar { font-size: 0.75rem !important; }
}
@media (max-width: 480px) {
  body { padding: 8px !important; }
  .brand-title { font-size: 1rem !important; }
  .brand-badge { font-size: 0.7rem !important; }
  .match-info-title { font-size: 0.9rem !important; }
  .match-info-sub { font-size: 0.75rem !important; }
}
@media (pointer: coarse) {
  button, .icon-btn, select, input[type="checkbox"], input[type="radio"] {
    min-height: 44px !important;
    min-width: 44px !important;
  }
}

/* Touch-friendly tap targets */
@media (pointer: coarse) {
  button, .icon-btn, select, input[type="checkbox"], input[type="radio"], .filter-chip, .tactic-clear-btn {
    min-height: 44px !important;
    min-width: 44px !important;
  }
  a { min-height: 44px !important; display: inline-flex !important; align-items: center !important; }
  .custom-select { min-height: 44px !important; }
}
