@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root,
[data-theme="minimal"] {
  --bg: radial-gradient(circle at top, #0e1a12 0%, #06090a 70%);
  --panel: rgba(14, 22, 16, 0.88);
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.25);
  --text: #f4f4ff;
  --muted: #9ca3b1;
  --square-light: #f4f3ff;
  --square-dark: #363b63;
  --highlight-move: rgba(34, 197, 94, 0.45);
  --highlight-target: rgba(255, 190, 92, 0.65);
  --danger: #ff6b6b;
  --success: #5de58a;
  --glow: rgba(34, 197, 94, 0.3);
}

[data-theme="classic"] {
  --bg: radial-gradient(circle at top, #1a1508 0%, #09070a 70%);
  --panel: rgba(22, 18, 10, 0.88);
  --accent: #d4a017;
  --accent-soft: rgba(212, 160, 23, 0.25);
  --text: #f4f4ff;
  --muted: #9ca3b1;
  --square-light: #f4f3ff;
  --square-dark: #363b63;
  --highlight-move: rgba(212, 160, 23, 0.45);
  --highlight-target: rgba(255, 190, 92, 0.65);
  --danger: #ff6b6b;
  --success: #5de58a;
  --glow: rgba(212, 160, 23, 0.3);
}

[data-theme="navy"] {
  --bg: radial-gradient(circle at top, #0f172a 0%, #06080f 70%);
  --panel: rgba(14, 22, 40, 0.88);
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.25);
  --text: #f4f4ff;
  --muted: #94a3b8;
  --square-light: #f4f3ff;
  --square-dark: #363b63;
  --highlight-move: rgba(59, 130, 246, 0.45);
  --highlight-target: rgba(255, 190, 92, 0.65);
  --danger: #ff6b6b;
  --success: #5de58a;
  --glow: rgba(59, 130, 246, 0.3);
}

[data-theme="wood"] {
  --bg: radial-gradient(circle at top, #1f1008 0%, #080304 70%);
  --panel: rgba(24, 12, 10, 0.88);
  --accent: #e63946;
  --accent-soft: rgba(230, 57, 70, 0.25);
  --text: #f4f4ff;
  --muted: #9ca3b1;
  --square-light: #f4f3ff;
  --square-dark: #363b63;
  --highlight-move: rgba(230, 57, 70, 0.45);
  --highlight-target: rgba(255, 190, 92, 0.65);
  --danger: #ff6b6b;
  --success: #5de58a;
  --glow: rgba(230, 57, 70, 0.3);
}

body {
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  margin: 0;
  padding: 2rem 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.game-shell {
  width: min(1200px, 100%);
  background: var(--panel);
  border-radius: 32px;
  padding: clamp(1rem, 2vw, 2rem);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.player-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-radius: 20px;
  background: linear-gradient(120deg, var(--accent-soft), rgba(43, 45, 66, 0.5));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.player-banner.bottom {
  flex-direction: row-reverse;
}

.player-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.player-name {
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  font-weight: 600;
}

.player-status {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.player-clock {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 700;
}

.boards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.board-card {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 24px;
  padding: clamp(0.8rem, 1.5vw, 1.4rem);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  position: relative;
  overflow: hidden;
}

.board-card.primary::after,
.board-card.secondary::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.board-label {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.turn-indicator {
  font-size: 0.9rem;
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chessboard {
  width: 100%;
  aspect-ratio: 1/1;
  display: flex;
  flex-wrap: wrap;
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 25px 35px rgba(0, 0, 0, 0.35);
}

.chessboard.mini {
  opacity: 0.85;
  box-shadow: none;
}

.row {
  width: 100%;
  height: 12.5%;
  display: flex;
}

.square {
  width: 12.5%;
  height: 100%;
  position: relative;
  box-sizing: border-box;
  transition: background 0.2s ease;
}

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

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

.square.highlight,
.square.target,
.square.highlight2,
.square.highlight3 {
  position: relative;
}

.square.highlight::after,
.square.highlight2::after,
.square.target::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 12px;
  background: var(--highlight-move);
  opacity: 0.7;
}

.square.target::after {
  background: var(--highlight-target);
}

.square.highlight2::after {
  background: rgba(255, 107, 107, 0.7);
}

.square.highlight3::after {
  background: rgba(255, 0, 98, 0.65);
}

.square.last-move::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 3px solid var(--accent);
  border-radius: 6px;
  animation: pulse 1.5s infinite;
}

.square img {
  position: absolute;
  height: 85%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: transform 0.2s ease, filter 0.2s ease;
}

.square:hover img {
  transform: translate(-50%, -50%) scale(1.05);
}

.board-note {
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2rem;
}

.pool-panel {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  min-height: 48px;
}

.pool-panel.slim {
  opacity: 0.8;
}

.pool-chip {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.pool-chip.active,
.pool-chip:hover {
  background: var(--accent-soft);
}

.pool-chip span {
  font-weight: 600;
}

.promotion,
.overlay {
  display: flex;

  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
}

.overlay {
  background: rgba(6, 8, 20, 0.55);
  backdrop-filter: blur(6px);
}

.promotion-menu {
  background: var(--panel);
  padding: 1.5rem;
  border-radius: 18px;
  display: flex;
  gap: 1rem;
}

.promotion-menu input {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: none;
}

.action-row {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.action-row button {
  padding: 0.9rem 1.8rem;
  border-radius: 999px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.action-row button.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 15px 30px var(--glow);
}

.action-row button.ghost {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.action-row button:active {
  transform: translateY(2px);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: rgba(6, 6, 10, 0.85);
  padding: 0.8rem 1.4rem;
  border-radius: 999px;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: transform 0.4s ease;
  z-index: 30;
}

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

body.classic #secondary-card {
  display: none;
}

@media (max-width: 960px) {
  .game-shell {
    padding: 1.25rem;
  }
  .boards-grid {
    grid-template-columns: 1fr;
  }
  .board-card.secondary {
    order: 3;
  }
}

@media (max-width: 600px) {
  body {
    padding: 1rem 0.5rem;
  }
  .player-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }
  .action-row {
    flex-direction: column;
  }
  .action-row button {
    width: 100%;
  }
}

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

.overlay.hidden {
  display: none;
}
