/* ============================================
   REGICIDE CHESS — Volcanic Glass Design System
   ============================================ */

:root {
  --bg-deep:       #0f0f0f;
  --bg-surface:    #1a1a1a;
  --bg-raised:     #242424;
  --bg-card:       #2a2a2a;
  --border:        #333333;
  --border-bright: #444444;
  --ember:         #FF6B2B;
  --ember-soft:    #FFB088;
  --ember-glow:    rgba(255, 107, 43, 0.25);
  --ember-dim:     rgba(255, 107, 43, 0.08);
  --text-primary:  #F0EBE3;
  --text-secondary:#A09080;
  --text-muted:    #5A5040;
  --white-sq:      #C8B89A;
  --black-sq:      #3A2E22;
  --white-piece:   #F5EDD8;
  --black-piece:   #1A1208;
  --highlight:     rgba(255, 107, 43, 0.45);
  --legal-dot:     rgba(255, 107, 43, 0.6);
  --check-glow:    rgba(255, 60, 60, 0.6);
  --font-display:  'Clash Display', sans-serif;
  --font-body:     'Newsreader', serif;
  --radius-sm:     6px;
  --radius-md:     12px;
  --radius-lg:     20px;
  --transition:    0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  overflow-x: hidden;
}

/* ── Background Grid ── */
.bg-grid {
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(255,107,43,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,107,43,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

/* ── Ember Particles ── */
.ember-particles {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  overflow: hidden;
}
.particle {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--ember);
  opacity: 0;
  animation: float-up linear infinite;
}
@keyframes float-up {
  0%   { transform: translateY(0) scale(1); opacity: 0.7; }
  100% { transform: translateY(-100vh) scale(0); opacity: 0; }
}

/* ── Header ── */
.site-header {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 40px;
  border-bottom: 1px solid var(--border);
  background: rgba(15,15,15,0.85);
  backdrop-filter: blur(12px);
}
.logo {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-primary);
}
.logo-icon {
  font-size: 28px;
  color: var(--ember);
  filter: drop-shadow(0 0 8px var(--ember));
  animation: pulse-glow 3s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 8px var(--ember)); }
  50%       { filter: drop-shadow(0 0 18px var(--ember)) drop-shadow(0 0 32px var(--ember-soft)); }
}
.header-controls { display: flex; gap: 12px; }

/* ── Buttons ── */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-bright);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 12px; font-weight: 500;
  letter-spacing: 0.08em;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.btn-ghost:hover {
  border-color: var(--ember);
  color: var(--ember);
  background: var(--ember-dim);
}
.btn-primary {
  background: var(--ember);
  border: none;
  color: #fff;
  font-family: var(--font-display);
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.1em;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(255,107,43,0.3);
}
.btn-primary:hover {
  background: #ff7d42;
  box-shadow: 0 4px 28px rgba(255,107,43,0.5);
  transform: translateY(-1px);
}

/* ── Layout ── */
.game-layout {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 240px 1fr 240px;
  gap: 24px;
  padding: 24px 40px;
  min-height: calc(100vh - 65px);
  align-items: start;
}

/* ── Panels ── */
.panel {
  display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 24px;
}

/* ── Player Card ── */
.player-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
}
.player-card.active {
  border-color: var(--ember);
  box-shadow: 0 0 0 1px var(--ember), 0 4px 20px var(--ember-glow);
}
.player-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.white-avatar { background: var(--white-sq); color: var(--black-piece); }
.black-avatar { background: var(--black-sq); color: var(--white-piece); border: 1px solid var(--border-bright); }
.player-info { flex: 1; }
.player-name {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.1em;
}
.player-label {
  font-size: 11px; color: var(--text-muted);
  font-style: italic; margin-top: 2px;
}
.player-timer {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 500;
  color: var(--text-secondary);
}

/* ── Captured Pieces ── */
.captured-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  min-height: 56px;
}
.captured-label {
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  font-family: var(--font-display);
}
.captured-pieces {
  display: flex; flex-wrap: wrap; gap: 2px;
  font-size: 18px; line-height: 1;
}

/* ── Score ── */
.score-display {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.score-item { text-align: center; }
.score-num {
  display: block;
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
  color: var(--ember);
}
.score-lbl {
  font-size: 10px; color: var(--text-muted);
  letter-spacing: 0.08em;
  font-family: var(--font-display);
}
.score-divider { color: var(--border-bright); font-size: 18px; }

/* ── Status Card ── */
.status-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
}
.status-icon {
  font-size: 32px; margin-bottom: 8px;
  display: block;
  animation: pulse-glow 3s ease-in-out infinite;
}
.status-text {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 600;
  letter-spacing: 0.06em;
}
.status-sub {
  font-size: 12px; color: var(--text-muted);
  font-style: italic; margin-top: 4px;
}

/* ── Difficulty & Mode ── */
.difficulty-section, .mode-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.section-label {
  font-family: var(--font-display);
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.difficulty-buttons, .mode-buttons {
  display: flex; gap: 6px;
}
.diff-btn, .mode-btn {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.06em;
  padding: 7px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.diff-btn:hover, .mode-btn:hover {
  border-color: var(--ember-soft);
  color: var(--ember-soft);
}
.diff-btn.active, .mode-btn.active {
  background: var(--ember-dim);
  border-color: var(--ember);
  color: var(--ember);
}

/* ── Move History ── */
.move-history-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  flex: 1;
}
.move-history {
  max-height: 220px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.move-history::-webkit-scrollbar { width: 4px; }
.move-history::-webkit-scrollbar-track { background: transparent; }
.move-history::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.move-row {
  display: grid; grid-template-columns: 28px 1fr 1fr;
  gap: 4px; align-items: center;
  padding: 3px 4px;
  border-radius: 4px;
  font-size: 12px;
}
.move-row:hover { background: var(--bg-raised); }
.move-num {
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 10px;
}
.move-white, .move-black {
  font-family: var(--font-display);
  font-size: 12px; font-weight: 500;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  transition: var(--transition);
}
.move-white { color: var(--text-primary); }
.move-black { color: var(--text-secondary); }
.move-white:hover, .move-black:hover { color: var(--ember); }

/* ── Board Section ── */
.board-section {
  display: flex; align-items: center; justify-content: center;
}
.board-wrapper {
  display: grid;
  grid-template-areas:
    ". board ."
    ". files .";
  grid-template-columns: 24px 1fr 24px;
  grid-template-rows: 1fr 24px;
  gap: 0;
  width: min(calc(100vh - 130px), 600px);
  max-width: 600px;
}
.rank-labels {
  grid-area: board;
  display: flex; flex-direction: column;
  justify-content: space-around;
  padding: 4px 0;
  grid-column: 1;
  grid-row: 1;
}
.rank-label, .file-label {
  font-family: var(--font-display);
  font-size: 11px; font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  line-height: 1;
}
.file-labels {
  grid-area: files;
  display: flex; justify-content: space-around;
  padding: 4px 0;
  grid-column: 2;
  grid-row: 2;
}
.board-container {
  grid-column: 2; grid-row: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow:
    0 0 0 2px var(--border),
    0 0 0 4px var(--bg-deep),
    0 0 0 6px var(--border),
    0 20px 60px rgba(0,0,0,0.8),
    0 0 80px rgba(255,107,43,0.06);
}
.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%; aspect-ratio: 1;
  user-select: none;
}

/* ── Squares ── */
.square {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--transition);
}
.square.light { background: var(--white-sq); }
.square.dark  { background: var(--black-sq); }

.square.selected {
  background: var(--ember) !important;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.2);
}
.square.last-move-from { background: rgba(255,107,43,0.3) !important; }
.square.last-move-to   { background: rgba(255,107,43,0.45) !important; }
.square.in-check       { background: rgba(220,50,50,0.55) !important; box-shadow: inset 0 0 20px rgba(255,0,0,0.4); }
.square.hover-highlight:hover { filter: brightness(1.15); }

/* Legal move dots */
.square.legal-move::after {
  content: '';
  position: absolute;
  width: 30%; height: 30%;
  border-radius: 50%;
  background: var(--legal-dot);
  pointer-events: none;
  animation: dot-appear 0.15s ease-out;
}
.square.legal-capture::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 0;
  background: transparent;
  border: 4px solid var(--ember);
  opacity: 0.7;
  pointer-events: none;
  animation: dot-appear 0.15s ease-out;
}
@keyframes dot-appear {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── Pieces ── */
.piece {
  font-size: clamp(24px, 5.5vw, 44px);
  line-height: 1;
  cursor: grab;
  transition: transform 0.12s ease, filter 0.12s ease;
  position: relative; z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
}
.piece:active { cursor: grabbing; }
.piece.white-piece {
  color: var(--white-piece);
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.8)) drop-shadow(0 0 1px rgba(0,0,0,0.9));
}
.piece.black-piece {
  color: var(--black-piece);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4)) drop-shadow(0 0 8px rgba(255,176,136,0.15));
}
.square:hover .piece { transform: scale(1.08); }
.square.selected .piece { transform: scale(1.12); }

/* Piece move animation */
@keyframes piece-land {
  0%   { transform: scale(1.2) translateY(-4px); }
  60%  { transform: scale(0.95) translateY(1px); }
  100% { transform: scale(1) translateY(0); }
}
.piece.just-moved { animation: piece-land 0.25s ease-out; }

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8), 0 0 0 1px var(--ember-glow);
  animation: modal-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modal-in {
  from { transform: scale(0.85) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.modal-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 600;
  letter-spacing: 0.08em;
  margin-bottom: 20px;
  color: var(--ember);
}
.promo-choices {
  display: flex; gap: 12px; justify-content: center;
}
.promo-piece {
  width: 64px; height: 64px;
  background: var(--bg-raised);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  cursor: pointer;
  transition: var(--transition);
}
.promo-piece:hover {
  border-color: var(--ember);
  background: var(--ember-dim);
  transform: scale(1.1);
}

/* Game Over Modal */
.gameover-modal { min-width: 280px; }
.gameover-icon {
  font-size: 56px; margin-bottom: 12px;
  display: block;
  animation: pulse-glow 2s ease-in-out infinite;
}
.gameover-title {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ember);
  margin-bottom: 6px;
}
.gameover-sub {
  font-size: 14px; color: var(--text-secondary);
  font-style: italic; margin-bottom: 24px;
}

/* ── Thinking Indicator ── */
.thinking-dots {
  display: inline-flex; gap: 4px; align-items: center;
}
.thinking-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ember);
  animation: thinking 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinking {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1); opacity: 1; }
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .game-layout {
    grid-template-columns: 200px 1fr 200px;
    padding: 16px 20px;
    gap: 16px;
  }
}
@media (max-width: 860px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .panel { position: static; flex-direction: row; flex-wrap: wrap; }
  .panel > * { flex: 1 1 160px; }
  .board-wrapper { width: min(90vw, 480px); margin: 0 auto; }
  .site-header { padding: 14px 20px; }
}