/* ============================================
   Tablo — Chess Styles
   ============================================ */

.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px 20px;
  gap: 24px;
}

.game-wrapper::before {
  content: '';
  display: block;
  height: 12px;
  flex-shrink: 0;
}

.game-stats {
  display: flex;
  gap: 24px;
  padding: 16px 24px;
  background: var(--bg-surface, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: var(--radius-lg, 12px);
  flex-wrap: wrap;
  justify-content: center;
  max-width: 400px;
  margin: 0 auto;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent, #2dd4bf);
}

.captured-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  min-height: 32px;
  margin: 0 auto;
  max-width: 400px;
}

.captured-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  text-transform: uppercase;
}

.captured-pieces {
  font-size: 22px;
  letter-spacing: -2px;
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 50px);
  grid-template-rows: repeat(8, 50px);
  width: 400px;
  height: 400px;
  border: 3px solid #1e293b;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  margin: 0 auto;
  flex-shrink: 0;
}

.square {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background 0.1s ease;
  overflow: hidden;
  box-sizing: border-box;
}

.square.light { background: #e8e8e0; }
.square.dark { background: #5a7a5a; }
.square.selected { background: #ffd93d !important; }
.square.drag-over { background: rgba(45,212,191,0.3) !important; }
.square.valid-move::after {
  content: '';
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(45,212,191,0.5);
  pointer-events: none;
}
.square.capture-move {
  background: rgba(248,113,113,0.5) !important;
}
.square.in-check {
  background: rgba(248,113,113,0.4) !important;
  animation: check-pulse 1s ease infinite alternate;
}

@keyframes check-pulse {
  from { box-shadow: inset 0 0 0 rgba(248,113,113,0); }
  to { box-shadow: inset 0 0 20px rgba(248,113,113,0.5); }
}

.piece {
  font-size: 36px;
  user-select: none;
  -webkit-user-select: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  line-height: 1;
  cursor: grab;
}

.piece.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.white-piece { color: #ffffff; text-shadow: 0 0 1px #000, 0 1px 2px rgba(0,0,0,0.5); }
.black-piece { color: #1a1a1a; text-shadow: 0 1px 1px rgba(255,255,255,0.3); }

.game-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

.mode-select {
  background: var(--bg-input, #1e293b);
  color: var(--text-primary, #e2e8f0);
  border: 1px solid var(--border-color, #334155);
  border-radius: var(--radius-md, 8px);
  padding: 10px 16px;
  font-family: var(--font-primary, sans-serif);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.mode-select:hover { border-color: var(--accent, #2dd4bf); }

.game-btn {
  background: var(--bg-surface, #1e293b);
  border: 1px solid var(--border-color, #334155);
  color: var(--text-primary, #e2e8f0);
  padding: 10px 20px;
  border-radius: var(--radius-md, 8px);
  font-family: var(--font-primary, sans-serif);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition, 0.2s ease);
}
.game-btn:hover { background: #243044; border-color: var(--accent, #2dd4bf); color: var(--accent, #2dd4bf); }
.game-btn.primary { background: var(--accent, #2dd4bf); border-color: var(--accent, #2dd4bf); color: #0f1923; }
.game-btn.primary:hover { background: #5eead4; }

.winner-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
}
.winner-modal.visible { display: flex; }

.winner-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
}

.winner-content {
  position: relative;
  background: #1e293b;
  border: 2px solid #2dd4bf;
  border-radius: 12px;
  padding: 32px 24px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 16px 64px rgba(0,0,0,0.6);
}
.winner-icon { font-size: 48px; margin-bottom: 16px; }
.winner-title { font-size: 24px; font-weight: 700; margin-bottom: 12px; color: #e2e8f0; }
.winner-message { font-size: 16px; color: #94a3b8; margin-bottom: 24px; }

.promotion-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
}
.promotion-modal.visible { display: flex; }

.promo-content {
  position: relative;
  background: #1e293b;
  border: 2px solid #2dd4bf;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  z-index: 1;
}
.promo-content h3 { margin-bottom: 16px; font-size: 18px; color: #e2e8f0; }
.promo-options { display: flex; gap: 12px; justify-content: center; }
.promo-btn {
  width: 60px;
  height: 60px;
  font-size: 36px;
  background: #1e293b;
  border: 2px solid #334155;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.2s ease;
}
.promo-btn:hover { border-color: #2dd4bf; transform: scale(1.05); }

.tablo-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.tablo-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 768px) {
  .chess-board {
    grid-template-columns: repeat(8, 40px);
    grid-template-rows: repeat(8, 40px);
    width: 320px;
    height: 320px;
  }
  .square { width: 40px; height: 40px; }
  .piece { font-size: 28px; }
  .promo-btn { width: 50px; height: 50px; font-size: 30px; }
}

@media (max-width: 480px) {
  .chess-board {
    grid-template-columns: repeat(8, 35px);
    grid-template-rows: repeat(8, 35px);
    width: 280px;
    height: 280px;
  }
  .square { width: 35px; height: 35px; }
  .piece { font-size: 24px; }
  .game-stats { gap: 16px; padding: 12px 16px; }
  .game-controls { flex-direction: column; width: 100%; }
  .mode-select, .game-btn { width: 100%; justify-content: center; }
}