:root {
  --bg: #06060f;
  --panel: #0d0d1e;
  --panel-2: #09091a;
  --border: #1e1e42;
  --cyan: #22d3ee;
  --red: #ff2d55;
  --magenta: #ec4899;
  --yellow: #fbbf24;
  --text: #d0e4ff;
  --muted: rgba(208, 228, 255, 0.58);
}

* { box-sizing: border-box; }

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

.scanlines,
.grid-bg {
  pointer-events: none;
  position: fixed;
  inset: 0;
}

.scanlines {
  z-index: 30;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 0, 0, 0.16) 2px, rgba(0, 0, 0, 0.16) 4px);
}

.grid-bg {
  z-index: 0;
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.04) 1px, transparent 1px);
  background-size: 42px 42px;
}

.page-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 6, 15, 0.9);
}

.back-home,
.game-btn {
  font-family: 'Orbitron', monospace;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.back-home {
  color: var(--cyan);
  border: 1px solid rgba(34, 211, 238, 0.35);
  padding: 8px 12px;
  text-decoration: none;
  font-size: 11px;
}

.back-games {
  color: var(--magenta);
  border-color: rgba(236, 72, 153, 0.4);
}

.brand {
  margin-left: auto;
  font-family: 'Orbitron', monospace;
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 900;
  letter-spacing: 3px;
}

.brand span,
.status,
.turn-card strong,
.win-card h2 {
  color: var(--yellow);
  text-shadow: 0 0 16px rgba(251, 191, 36, 0.45);
}

.status {
  font-family: 'Share Tech Mono', monospace;
  letter-spacing: 2px;
}

.game-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.board-panel,
.side-panel,
.win-card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(13, 13, 30, 0.96), rgba(8, 8, 22, 0.98));
  box-shadow: 0 0 28px rgba(34, 211, 238, 0.08);
  padding: 18px;
}

.board-panel,
.side-panel {
  min-width: 0;
}

.panel-label,
.tiny-label {
  font-family: 'Share Tech Mono', monospace;
  color: var(--muted);
  letter-spacing: 3px;
  font-size: 11px;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(42px, 1fr));
  width: min(680px, 100%);
  margin: 18px auto 0;
  border: 2px solid rgba(34, 211, 238, 0.35);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.cell.is-light {
  background: #111126;
}

.cell.is-dark {
  background: #050816;
}

.cell.is-move::after {
  content: "";
  width: 34%;
  height: 34%;
  border-radius: 50%;
  background: rgba(251, 191, 36, 0.55);
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.35);
}

.cell.is-capture::after {
  background: rgba(255, 45, 85, 0.72);
  box-shadow: 0 0 18px rgba(255, 45, 85, 0.45);
}

.cell.is-selected {
  outline: 3px solid var(--yellow);
  outline-offset: -3px;
}

.piece {
  position: relative;
  display: grid;
  place-items: center;
  width: 72%;
  height: 72%;
  border: 3px solid #0a0a0a;
  border-radius: 50%;
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.16), 0 0 16px rgba(0, 0, 0, 0.45);
}

.piece.red {
  background: var(--red);
}

.piece.cyan {
  background: var(--cyan);
}

.piece.king {
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.2), 0 0 20px rgba(251, 191, 36, 0.45);
}

.piece span {
  color: #050816;
  font-family: 'Orbitron', monospace;
  font-size: clamp(13px, 2vw, 20px);
  font-weight: 900;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.turn-card,
.pieces-card,
.rules-card {
  border: 1px solid rgba(34, 211, 238, 0.16);
  background: rgba(5, 8, 22, 0.64);
  padding: 14px;
}

.turn-card strong {
  display: block;
  margin-top: 8px;
  font-family: 'Orbitron', monospace;
  font-size: 24px;
}

.turn-card p,
.rules-card p {
  min-height: 48px;
  margin: 12px 0 0;
  color: var(--muted);
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
}

.piece-counts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.piece-counts div {
  border: 1px solid rgba(251, 191, 36, 0.16);
  background: rgba(251, 191, 36, 0.05);
  padding: 10px;
  text-align: center;
}

.piece-counts span {
  display: block;
  color: var(--muted);
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
}

.piece-counts strong {
  color: var(--yellow);
  font-family: 'Orbitron', monospace;
  font-size: 24px;
}

.game-btn {
  min-height: 42px;
  border: 1px solid var(--cyan);
  background: rgba(34, 211, 238, 0.1);
  color: var(--cyan);
  padding: 11px 14px;
  cursor: pointer;
  font-size: 12px;
}

.win-overlay[hidden],
[hidden] {
  display: none !important;
}

.win-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.78);
}

.win-card {
  width: min(430px, 100%);
  text-align: center;
  border-color: var(--yellow);
}

.win-card h2 {
  font-family: 'Orbitron', monospace;
}

.win-card p {
  color: var(--muted);
  font-family: 'Share Tech Mono', monospace;
}

@media (max-width: 880px) {
  .game-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .page-header {
    flex-wrap: wrap;
  }

  .brand {
    width: 100%;
    order: 3;
  }

  .game-shell {
    padding: 12px;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }
}
