/* ==========================================================================
   BATTLE CHESS — MODERN GLASSMORPHIC MEDIEVAL THEME
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;900&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #080c16;
  --bg-secondary: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.75);
  --border-card: rgba(255, 255, 255, 0.1);
  --border-glow: rgba(56, 189, 248, 0.4);

  --accent-gold: #fbbf24;
  --accent-gold-glow: rgba(251, 191, 36, 0.35);
  --accent-cyan: #38bdf8;
  --accent-crimson: #ef4444;

  --sq-light: #d8c39e;
  --sq-dark: #785a44;
  --sq-selected: rgba(251, 191, 36, 0.65);
  --sq-last-move: rgba(56, 189, 248, 0.4);
  --sq-check: rgba(239, 68, 68, 0.7);

  --font-display: 'Cinzel', serif;
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font-body);
  background: radial-gradient(circle at 50% 10%, #1e1b4b 0%, #0a0d1a 60%, #05070d 100%);
  color: #f1f5f9;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Battleground Banner */
.battleground-banner {
  background: linear-gradient(90deg, #1e1b4b, #3b0764 50%, #1e1b4b);
  border-bottom: 1px solid rgba(251, 191, 36, 0.35);
  text-align: center;
  padding: 0.45rem 1rem;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent-gold);
  text-shadow: 0 0 12px var(--accent-gold-glow);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  z-index: 60;
}

/* Header & Title */
header {
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-card);
  background: rgba(8, 12, 22, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 2.2rem;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 12px var(--accent-gold-glow));
}

.logo-text h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(90deg, #ffffff, #e2e8f0 70%, #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text p {
  font-size: 0.75rem;
  color: #94a3b8;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Mode Selection Tabs */
.mode-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.9);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-card);
}

.mode-tab {
  padding: 0.5rem 1rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: #94a3b8;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-tab:hover {
  color: #ffffff;
}

.mode-tab.active {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

/* Action Buttons */
.btn-action {
  background: rgba(30, 41, 59, 0.7);
  color: #e2e8f0;
  border: 1px solid var(--border-card);
  padding: 0.5rem 1rem;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn-action:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: var(--accent-cyan);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-action.muted {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

/* Main Layout Grid */
main {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr auto 340px;
  gap: 2rem;
  align-items: start;
}

/* Left Panel: Graveyards & Showcase */
.left-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 1.25rem;
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.card-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent-gold);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Graveyard Trays */
.graveyard-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 0.75rem;
  min-height: 50px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.graveyard-piece {
  font-size: 1.6rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

.score-tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
}

.score-white {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.score-black {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.score-even {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

/* Demo Animations Showcase Box */
.demo-buttons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.test-anim-btn {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  padding: 0.6rem 0.5rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.test-anim-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-cyan);
  color: #ffffff;
  transform: translateX(2px);
}

.test-anim-btn span {
  font-size: 1.1rem;
}

/* Center Stage: Chess Board */
.center-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.board-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 580px;
  padding: 0.5rem 1rem;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 12px;
  border: 1px solid var(--border-card);
}

.turn-badge {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.turn-w {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
}

.turn-b {
  background: #020617;
  color: #e2e8f0;
  border: 1px solid #475569;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.8);
}

.room-badge {
  display: none;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

/* THE CHESS BOARD */
.board-container {
  padding: 14px;
  background: linear-gradient(145deg, #2b1f14, #120c06);
  border-radius: 18px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(251, 191, 36, 0.15);
  border: 2px solid rgba(251, 191, 36, 0.3);
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 68px);
  grid-template-rows: repeat(8, 68px);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}

.chess-square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.square-light {
  background-color: var(--sq-light);
  background-image: radial-gradient(circle at 30% 30%, #e8d7b8, #cbb48c);
}

.square-dark {
  background-color: var(--sq-dark);
  background-image: radial-gradient(circle at 30% 30%, #87654d, #5a4231);
}

.square-selected {
  background: var(--sq-selected) !important;
  box-shadow: inset 0 0 14px rgba(251, 191, 36, 0.8);
}

.square-last-move {
  background: var(--sq-last-move) !important;
}

.square-in-check {
  background: var(--sq-check) !important;
  animation: pulseCheck 1s infinite alternate;
}

@keyframes pulseCheck {
  0% { box-shadow: inset 0 0 8px rgba(239, 68, 68, 0.6); }
  100% { box-shadow: inset 0 0 24px rgba(239, 68, 68, 1); }
}

/* Legal Move Indicators */
.square-legal-move::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(30, 41, 59, 0.35);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.square-legal-capture::after {
  content: '';
  position: absolute;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 4px solid rgba(239, 68, 68, 0.7);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.5);
  pointer-events: none;
}

/* Chess Pieces */
.chess-piece {
  font-size: 3.2rem;
  line-height: 1;
  cursor: grab;
  transition: transform 0.12s ease;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
  z-index: 2;
}

.chess-piece:hover {
  transform: scale(1.12);
}

.piece-w-p, .piece-w-r, .piece-w-n, .piece-w-b, .piece-w-q, .piece-w-k {
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9), 0 0 2px #ffffff;
}

.piece-b-p, .piece-b-r, .piece-b-n, .piece-b-b, .piece-b-q, .piece-b-k {
  color: #111827;
  text-shadow: 0 0 2px #ffffff, 0 2px 8px rgba(0, 0, 0, 1);
}

/* Coordinate Labels */
.coord-rank {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  opacity: 0.6;
  pointer-events: none;
}

.coord-file {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  opacity: 0.6;
  pointer-events: none;
}

/* Right Panel: Move Log & Chat */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.move-history-container {
  height: 380px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 0.5rem;
}

.history-row {
  display: grid;
  grid-template-columns: 35px 1fr 1fr;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  font-size: 0.85rem;
}

.history-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

.history-num {
  color: #64748b;
  font-weight: 600;
}

.history-san {
  color: #e2e8f0;
  font-family: monospace;
}

.history-san.has-capture {
  color: #f87171;
  font-weight: 700;
}

/* ==========================================================================
   CINEMATIC BATTLE CAM MODAL & THEATER
   ========================================================================== */

.battle-modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.92);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.battle-modal.active {
  opacity: 1;
  pointer-events: all;
}

.battle-theater {
  position: relative;
  width: 90vw;
  max-width: 960px;
  background: #090d16;
  border-radius: 20px;
  border: 2px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.9), 0 0 40px rgba(56, 189, 248, 0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.battle-canvas {
  width: 100%;
  height: 480px;
  display: block;
}

/* Overlay Banners */
.battle-overlay {
  position: absolute;
  top: 1.25rem;
  left: 1.5rem;
  right: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}

.battle-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.battle-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: var(--accent-cyan);
  color: #0b0f19;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.6);
}

.badge-pawn { background: #eab308; color: #1e1b4b; }
.badge-escort { background: #d946ef; color: #ffffff; box-shadow: 0 0 20px rgba(217, 70, 239, 0.8); }
.badge-rook { background: #0284c7; color: #ffffff; }
.badge-knight { background: #f97316; color: #ffffff; }
.badge-bishop { background: #38bdf8; color: #020617; box-shadow: 0 0 25px rgba(56, 189, 248, 0.9); }
.badge-king { background: #dc2626; color: #ffffff; box-shadow: 0 0 25px rgba(220, 38, 38, 0.8); }
.badge-queen { background: #9333ea; color: #ffffff; }

.battle-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #ffffff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}

.battle-subtitle {
  font-size: 0.95rem;
  color: #94a3b8;
  max-width: 600px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.battle-skip-btn {
  pointer-events: all;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #cbd5e1;
  padding: 0.5rem 1.25rem;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}

.battle-skip-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

/* Screen Shake Effect */
.screen-shake {
  animation: shake 0.35s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-3px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* Generic Modals (Promotion & Online Matchmaking) */
.dialog-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.dialog-modal.active {
  opacity: 1;
  pointer-events: all;
}

.dialog-box {
  background: #0f172a;
  border: 1px solid var(--border-glow);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
  border-radius: 18px;
  padding: 2rem;
  max-width: 440px;
  width: 90%;
  text-align: center;
}

.promo-piece-options {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.promo-piece-btn {
  font-size: 3rem;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  color: #ffffff;
  transition: all 0.2s ease;
}

.promo-piece-btn:hover {
  background: var(--accent-cyan);
  color: #0b0f19;
  transform: scale(1.1);
}

.input-field {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #1e293b;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  color: #ffffff;
  font-size: 1rem;
  margin: 1rem 0;
  text-align: center;
  font-weight: 600;
  letter-spacing: 2px;
}

.input-field:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px var(--border-glow);
}

/* Responsiveness */
@media (max-width: 1100px) {
  main {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .left-panel, .right-panel {
    width: 100%;
    max-width: 580px;
  }
}

/* Site Footer */
.app-footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  font-size: 0.85rem;
  color: #94a3b8;
  letter-spacing: 0.5px;
  border-top: 1px solid var(--border-card);
  background: rgba(8, 12, 22, 0.7);
  backdrop-filter: blur(8px);
  margin-top: 2rem;
}

.app-footer p {
  color: #94a3b8;
  font-weight: 500;
}
