/* ============================================================
   CHESS GAME STYLES
   ============================================================ */

#chess-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  user-select: none;
}

/* Board container */
#chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(480px, 90vw);
  height: min(480px, 90vw);
  border: 3px solid #5d4037;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

/* Square */
.chess-sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 1;
}

.sq-light { background-color: #f0d9b5; }
.sq-dark  { background-color: #b58863; }

.chess-sq:hover { filter: brightness(1.1); }

/* Highlights */
.sq-selected { background-color: #7fc97f !important; }
.sq-last     { background-color: #cdd26a !important; }
.sq-check    { background-color: #e74c3c !important; }

.sq-legal::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.sq-capture::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 4px solid rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  pointer-events: none;
}

/* Piece */
.piece {
  font-size: clamp(20px, 6vw, 46px);
  line-height: 1;
  pointer-events: none;
  z-index: 1;
}
.piece-w { color: #fff; text-shadow: 0 0 2px #333, 0 1px 3px rgba(0,0,0,0.7); }
.piece-b { color: #1a1a1a; text-shadow: 0 0 2px #ccc; }

/* Coordinate labels */
.rank-lbl {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: clamp(8px, 1.5vw, 12px);
  font-weight: bold;
  color: rgba(0,0,0,0.45);
  line-height: 1;
  pointer-events: none;
  z-index: 2;
}
.sq-dark .rank-lbl { color: rgba(255,255,255,0.45); }

.file-lbl {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: clamp(8px, 1.5vw, 12px);
  font-weight: bold;
  color: rgba(0,0,0,0.45);
  line-height: 1;
  pointer-events: none;
  z-index: 2;
}
.sq-dark .file-lbl { color: rgba(255,255,255,0.45); }

/* ============================================================
   CONTROLS PANEL
   ============================================================ */
#chess-controls {
  width: min(480px, 90vw);
  margin-top: 14px;
}

#game-status {
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  padding: 8px 12px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  margin-bottom: 12px;
  color: #333;
}

.ctrl-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.ctrl-label {
  font-size: 13px;
  color: #666;
  margin-bottom: 4px;
  display: block;
  text-align: center;
}

.ctrl-group {
  text-align: center;
}

/* Buttons */
.chess-btn {
  padding: 7px 16px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s;
}
.chess-btn:hover { background: #e9ecef; }
.chess-btn.active {
  background: #5d4037;
  color: #fff;
  border-color: #5d4037;
}

.diff-btn, .color-btn { min-width: 70px; }

.new-game-btn {
  background: #5d4037;
  color: #fff;
  border-color: #5d4037;
  font-weight: bold;
  padding: 8px 24px;
}
.new-game-btn:hover { background: #4e342e; }

/* ============================================================
   PROMOTION DIALOG
   ============================================================ */
#promo-dialog {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 999;
  align-items: center;
  justify-content: center;
}

#promo-box {
  background: #fff;
  border-radius: 12px;
  padding: 20px 30px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
#promo-box h5 {
  margin: 0 0 16px;
  font-size: 18px;
  color: #333;
}
#promo-opts {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.promo-btn {
  font-size: 40px;
  width: 64px;
  height: 64px;
  border: 2px solid #ccc;
  border-radius: 8px;
  background: #f8f9fa;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.promo-btn:hover {
  background: #e9ecef;
  transform: scale(1.08);
  border-color: #5d4037;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 520px) {
  #chess-board { width: 94vw; height: 94vw; }
  #chess-controls { width: 94vw; }
  .piece { font-size: 10vw; }
}
