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

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

/* Board container: holds board + overlay */
#board-container {
  position: relative;
  width: min(480px, 94vw);
}

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

/* PC: larger board */
@media (min-width: 600px) {
  #board-container { width: min(640px, 94vw); }
  #chess-board { width: min(640px, 94vw); height: min(640px, 94vw); }
  #chess-footer { width: min(640px, 94vw); }
}

/* 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); }

/* ============================================================
   OPTIONS OVERLAY
   ============================================================ */
#options-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  z-index: 10;
}

#options-panel {
  background: #fdf6e3;
  border: 2px solid #8d6e63;
  border-radius: 10px;
  padding: 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 240px;
  max-width: 90%;
}

.options-title {
  font-size: 17px;
  font-weight: bold;
  color: #3e2723;
  text-align: center;
}

/* ============================================================
   FOOTER
   ============================================================ */
#chess-footer {
  width: min(480px, 94vw);
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#game-status {
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  padding: 8px 12px;
  background: #fdf6e3;
  border: 1px solid #8d6e63;
  border-radius: 6px;
  width: 100%;
  box-sizing: border-box;
  color: #3e2723;
}

#footer-actions {
  display: flex;
  gap: 8px;
  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 #8d6e63;
  border-radius: 5px;
  background: #fdf6e3;
  cursor: pointer;
  font-size: 14px;
  color: #3e2723;
  transition: background 0.15s, border-color 0.15s;
}
.chess-btn:hover { background: #e8d5b0; }
.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 28px;
}
.new-game-btn:hover { background: #4e342e; }

.settings-btn {
  font-size: 13px;
  padding: 5px 14px;
}

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

/* Hint text */
.hint-text {
  font-size: 12px;
  color: #999;
  text-align: center;
  margin: 0;
  line-height: 1.6;
}

/* ============================================================
   PIECE FLOATER (animation)
   ============================================================ */
.piece-floater {
  /* position/size/transition set inline by JS */
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: left, top;
}

/* ============================================================
   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; }
  #board-container { width: 94vw; }
  #chess-footer { width: 94vw; }
  .piece { font-size: 10vw; }
}
