/* ===== RESET ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ===== BODY ===== */
body {
  background: #1a1a2e;
  color: #eee;
  font-family: Georgia, serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

/* ===== TITLE ===== */
#title {
  font-size: 32px;
  color: #d4af37;
  letter-spacing: 6px;
  margin-bottom: 10px;
  text-shadow: 0 0 20px rgba(212,175,55,0.5);
}

/* ===== TURN DISPLAY ===== */
#turn-display {
  font-size: 16px;
  letter-spacing: 3px;
  color: #aaa;
  margin-bottom: 6px;
  padding: 6px 20px;
  border: 1px solid #444;
  border-radius: 20px;
}

#turn-display.white-turn {
  color: #d4af37;
  border-color: #d4af37;
  background: rgba(212,175,55,0.08);
}

#turn-display.black-turn {
  color: #fff;
  border-color: #888;
  background: rgba(255,255,255,0.05);
}

/* ===== STATUS BAR ===== */
#status-bar {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.status-check {
  color: #ff8888;
  font-size: 15px;
  font-weight: bold;
  padding: 6px 20px;
  border: 1px solid #ff5555;
  border-radius: 20px;
  background: rgba(255,80,80,0.1);
}

.status-win {
  color: #d4af37;
  font-size: 16px;
  font-weight: bold;
  padding: 8px 24px;
  border: 1px solid #d4af37;
  border-radius: 20px;
  background: rgba(212,175,55,0.12);
}

.status-draw {
  color: #aaaaff;
  font-size: 15px;
  font-weight: bold;
  padding: 6px 20px;
  border: 1px solid #8888cc;
  border-radius: 20px;
  background: rgba(150,150,255,0.1);
}

/* ===== GAME CONTAINER ===== */
#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* ===== PLAYER PANELS ===== */
.player-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border: 1px solid #333;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  min-width: 400px;
}

.player-label {
  font-size: 13px;
  letter-spacing: 2px;
  color: #888;
  min-width: 80px;
}

#captured-white,
#captured-black {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  font-size: 18px;
}

/* ===== BOARD WRAPPER ===== */
#board-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== COORDINATE LABELS ===== */
.rank-labels {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  height: 480px;
}

.rank-labels span {
  width: 18px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #666;
}

.file-labels {
  display: flex;
}

.file-labels span {
  width: 60px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #666;
}

/* ===== BOARD ===== */
#board {
  display: grid;
  grid-template-columns: repeat(8, 60px);
  grid-template-rows: repeat(8, 60px);
  border: 3px solid #d4af37;
  box-shadow: 0 0 30px rgba(212,175,55,0.3);
}

/* ===== SQUARES ===== */
.square {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  font-size: 38px;
  line-height: 1;
  user-select: none;
}

.square.light { background: #f0d9b5; }
.square.dark  { background: #b58863; }

/* Last move highlight */
.square.last-from.light,
.square.last-to.light   { background: #cdd16f; }
.square.last-from.dark,
.square.last-to.dark    { background: #aaa23a; }

/* Selected square */
.square.selected { background: #7fc97f !important; }

/* King in check */
.square.in-check { background: #e05555 !important; }

/* Legal move dot */
.square.can-move::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 50%;
  pointer-events: none;
}

/* Legal capture ring */
.square.can-capture::after {
  content: '';
  position: absolute;
  width: 88%;
  height: 88%;
  border: 5px solid rgba(0, 0, 0, 0.22);
  border-radius: 50%;
  pointer-events: none;
}

/* Piece hover */
.square:hover { opacity: 0.88; }
.square.selected { opacity: 1; }

/* ===== CONTROLS ===== */
#controls {
  margin-top: 12px;
}

#new-game-btn {
  padding: 10px 30px;
  font-size: 14px;
  font-family: Georgia, serif;
  font-weight: bold;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #d4af37, #b8962e);
  color: #1a1a2e;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(212,175,55,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}

#new-game-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(212,175,55,0.5);
}

#new-game-btn:active {
  transform: translateY(0);
}

/* ===== MOVE HISTORY ===== */
#history-container {
  margin-top: 10px;
  max-height: 60px;
  overflow-y: auto;
  width: 100%;
  max-width: 480px;
}

#history {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

#history span {
  font-size: 11px;
  color: #666;
  background: rgba(255,255,255,0.04);
  padding: 2px 7px;
  border-radius: 4px;
}

/* ===== PROMOTION MODAL ===== */
#promo-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

#promo-overlay.open {
  display: flex;
}

#promo-box {
  background: #12122a;
  border: 2px solid #d4af37;
  border-radius: 16px;
  padding: 30px 36px;
  text-align: center;
  box-shadow: 0 0 50px rgba(212,175,55,0.3);
}

#promo-title {
  color: #d4af37;
  font-size: 16px;
  letter-spacing: 3px;
  margin-bottom: 18px;
}

#promo-choices {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.promo-btn {
  width: 66px;
  height: 66px;
  font-size: 40px;
  background: rgba(255,255,255,0.04);
  border: 2px solid #d4af37;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  line-height: 1;
}

.promo-btn:hover {
  background: rgba(212,175,55,0.2);
  transform: scale(1.1);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }


/* ===== PIECE COLORS (UPDATED) ===== */

/* Ensure pieces inherit styles properly */
.square span {
  display: inline-block;
  font-size: 38px;
  line-height: 1;
}

.white-piece {
  color: #ffffff;
  text-shadow: 0 0 2px #000;
}

.black-piece {
  color: #000000;
}