/* ═══════════════════════════════════════════
   CHESS MASTER — Premium Dark Theme
   ═══════════════════════════════════════════ */

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #1e2a3a;
  --bg-nav: #0f1626;
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0b0;
  --accent: #e2a832;
  --accent-hover: #f0b840;
  --board-light: #ecd8b0;
  --board-dark: #b48863;
  --highlight-selected: rgba(226, 168, 50, 0.55);
  --highlight-move: rgba(130, 180, 80, 0.5);
  --highlight-capture: rgba(220, 60, 60, 0.45);
  --highlight-last: rgba(180, 180, 50, 0.35);
  --highlight-check: rgba(255, 0, 0, 0.55);
  --shadow: 0 8px 32px rgba(0,0,0,0.35);
  --radius: 12px;
  --transition: all 0.2s ease;
}

[data-theme="light"] {
  --bg-primary: #f0f0f0;
  --bg-secondary: #e0e0e0;
  --bg-card: #ffffff;
  --bg-nav: #2c2c3e;
  --text-primary: #1a1a2e;
  --text-secondary: #555;
  --shadow: 0 8px 32px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* NAVBAR */
.bg-dark-nav {
  background: var(--bg-nav) !important;
  box-shadow: 0 2px 16px rgba(0,0,0,0.3);
}

.text-accent { color: var(--accent) !important; }

.btn-accent {
  background: var(--accent);
  color: #1a1a2e;
  font-weight: 600;
  border: none;
  transition: var(--transition);
}
.btn-accent:hover {
  background: var(--accent-hover);
  color: #1a1a2e;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(226,168,50,0.3);
}

/* CARD / PANEL */
.bg-card {
  background: var(--bg-card) !important;
  color: var(--text-primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel .card-body { padding: 1.25rem; }

/* PLAYER INFO */
.player-info {
  background: rgba(255,255,255,0.04);
  transition: var(--transition);
}
.player-info.active-turn {
  background: rgba(226,168,50,0.12);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.player-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
}
.player-clock {
  font-family: 'Courier New', monospace;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 4px 12px;
  background: rgba(0,0,0,0.35);
  border-radius: 8px;
  min-width: 70px;
  text-align: center;
}
.player-clock.warning { color: #ff6b6b; animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.captured-pieces {
  font-size: 1rem;
  letter-spacing: 1px;
  min-height: 1.4em;
  opacity: 0.85;
}

/* MOVE HISTORY */
.move-history {
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
}
.move-history::-webkit-scrollbar { width: 6px; }
.move-history::-webkit-scrollbar-track { background: transparent; }
.move-history::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

.move-number { color: var(--text-secondary); }
.move-white { color: var(--text-primary); padding: 1px 4px; border-radius: 3px; cursor: pointer; }
.move-black { color: var(--text-secondary); padding: 1px 4px; border-radius: 3px; cursor: pointer; }
.move-white:hover, .move-black:hover { background: rgba(226,168,50,0.2); }
.move-last { background: rgba(226,168,50,0.2); font-weight: bold; }

/* BOARD WRAPPER */
.board-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* COORDINATES */
.coords {
  display: flex;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.coords-top, .coords-bottom {
  justify-content: space-around;
  padding: 0 0;
  width: 100%;
}
.coords-left, .coords-right {
  flex-direction: column;
  justify-content: space-around;
  padding: 0 4px;
  font-size: 0.7rem;
}
.coord-item {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

/* CHESS BOARD */
.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(85vw, 520px);
  height: min(85vw, 520px);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
  user-select: none;
  position: relative;
}

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

.square-light { background: var(--board-light); }
.square-dark { background: var(--board-dark); }

/* Piece styling */
.piece {
  font-size: clamp(1.8rem, 6vw, 3.4rem);
  line-height: 1;
  cursor: grab;
  z-index: 2;
  transition: transform 0.15s ease;
  filter: drop-shadow(1px 2px 2px rgba(0,0,0,0.4));
}
.piece:hover { transform: scale(1.08); }
.piece.dragging { cursor: grabbing; opacity: 0.7; transform: scale(1.15); }

/* Highlights */
.square.selected { background: var(--highlight-selected) !important; }
.square.selected::after {
  content: '';
  position: absolute;
  inset: 2px;
  border: 2px solid var(--accent);
  border-radius: 4px;
  animation: glow 1.5s ease-in-out infinite alternate;
}

@keyframes glow {
  from { box-shadow: 0 0 6px rgba(226,168,50,0.4); }
  to { box-shadow: 0 0 14px rgba(226,168,50,0.7); }
}

.square.last-move { background-color: var(--highlight-last) !important; }
.square.check { background: var(--highlight-check) !important; animation: checkPulse 0.8s ease infinite; }

@keyframes checkPulse {
  0%, 100% { box-shadow: inset 0 0 12px rgba(255,0,0,0.5); }
  50% { box-shadow: inset 0 0 24px rgba(255,0,0,0.8); }
}

/* Possible move dots */
.square.possible-move::before {
  content: '';
  position: absolute;
  width: 28%;
  height: 28%;
  background: rgba(0,0,0,0.2);
  border-radius: 50%;
  z-index: 1;
}

.square.possible-capture::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 3px solid rgba(0,0,0,0.25);
  border-radius: 50%;
  z-index: 1;
}

/* Piece animation */
.piece-animate {
  position: absolute;
  z-index: 10;
  transition: top 0.25s ease, left 0.25s ease;
}

/* GAME STATUS */
.game-status {
  font-weight: 600;
  font-size: 0.9rem;
  min-height: 1.5em;
}

/* EVAL BAR */
.eval-bar-container {
  width: 100%;
  height: 16px;
  background: #333;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}
.eval-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, #e8e8e8, #f5f5f5);
  transition: height 0.5s ease;
  border-radius: 0 0 8px 8px;
}

/* INFO ROWS */
.info-row span:last-child { color: var(--text-primary); }

/* TOAST */
.toast { border-radius: var(--radius); }

/* MODAL */
.modal-content { border-radius: var(--radius); box-shadow: var(--shadow); }
.promotion-piece {
  width: 60px; height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  cursor: pointer;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  transition: var(--transition);
  filter: drop-shadow(1px 2px 2px rgba(0,0,0,0.4));
}
.promotion-piece:hover {
  background: rgba(226,168,50,0.3);
  transform: scale(1.1);
}

/* FORM ELEMENTS */
.form-select { border-radius: 8px; }

/* RESPONSIVE */
@media (max-width: 991px) {
  .chess-board {
    width: min(90vw, 480px);
    height: min(90vw, 480px);
  }
  .panel { margin-top: 0.5rem; }
}

@media (max-width: 576px) {
  .chess-board {
    width: 96vw;
    height: 96vw;
  }
  .piece { font-size: clamp(1.5rem, 10vw, 2.8rem); }
  .player-clock { font-size: 1rem; padding: 2px 8px; }
  .navbar-brand span { display: none; }
  .coords-left, .coords-right { font-size: 0.55rem; padding: 0 2px; }
}

/* FADE ANIMATION */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* SCROLLBAR GLOBAL */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; }
