/* =========================
 * Global Layout
 * ========================= */

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: #202225;
  color: white;
}

#app {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
  padding: 40px;
}

/* =========================
 * Board Wrapper
 * ========================= */

#board-container {
  padding: 12px;
  background: #111;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* =========================
 * Board Grid
 * ========================= */

#board {
  display: grid;
  grid-template-columns: repeat(8, 64px);
  grid-template-rows: repeat(8, 64px);
  border-radius: 8px;
  overflow: hidden;
}

/* =========================
 * Square
 * ========================= */

.square {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

/* Chess.com like colors */
.light {
  background: #eeeed2;
}

.dark {
  background: #769656;
}

/* hover effect */
.square:hover {
  filter: brightness(1.08);
}

/* selected piece */
.square.selected {
  outline: 3px solid #f6f669;
}

/* legal move highlight */
.square.highlight {
  position: relative;
}

/* dot indicator like Chess.com */
.square.highlight::after {
  content: "";
  width: 18px;
  height: 18px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 50%;
  position: absolute;
}

/* capture highlight (optional future use) */
.square.capture::after {
  width: 100%;
  height: 100%;
  border: 3px solid rgba(0,0,0,0.25);
  background: transparent;
}

/* =========================
 * Side Panel
 * ========================= */

#info {
  width: 260px;
  background: #2a2d31;
  padding: 16px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

#info h4 {
  margin-top: 16px;
  margin-bottom: 8px;
}

#turn {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
}

/* =========================
 * Buttons
 * ========================= */

button {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: #3a3f44;
  color: white;
  cursor: pointer;
  margin-top: 10px;
  transition: 0.2s;
}

button:hover {
  background: #4a5158;
}

/* =========================
 * Move History
 * ========================= */

#history {
  font-size: 14px;
  line-height: 1.4;
  max-height: 300px;
  overflow-y: auto;
}

/* =========================
 * Pieces
 * ========================= */

.piece {
  font-size: 42px;
  line-height: 1;
  pointer-events: none;
}

/* White pieces */
.white-piece {
  color: #ffffff;
  text-shadow:
    -1px -1px 0 #222,
     1px -1px 0 #222,
    -1px  1px 0 #222,
     1px  1px 0 #222,
     0px  2px 3px rgba(0,0,0,0.35);
}

/* Black pieces */
.black-piece {
  color: #111111;
  text-shadow:
    0px 1px 2px rgba(255,255,255,0.15);
}

/* =========================
 * Game Over Overlay
 * ========================= */

#game-over {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

#game-over.hidden {
  display: none;
}

.game-over-box {
  background: #2a2d31;
  padding: 24px;
  border-radius: 12px;
  text-align: center;
  width: 280px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.game-over-box h2 {
  margin: 0 0 10px 0;
}

.game-over-box p {
  font-size: 14px;
  opacity: 0.85;
  margin-bottom: 16px;
}

.game-over-box button {
  width: 100%;
}

/* =========================
 * Move History Panel
 * ========================= */

#history {
  font-size: 13px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 6px;
}

/* each move row */
.history-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: default;
}

/* hover effect like Chess.com */
.history-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* move number */
.move-number {
  opacity: 0.6;
  text-align: right;
  padding-right: 6px;
}

/* moves */
.move {
  padding-left: 6px;
  font-family: monospace;
}

/* white vs black styling */
.white-move {
  color: #ffffff;
}

.black-move {
  color: #cfcfcf;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 8px;

  white-space: nowrap;
}

.history-row span {
  white-space: nowrap;
}

#history {
  overflow-x: auto;
}

#history {
  max-height: 300px;
  overflow-y: auto;
  font-family: system-ui, sans-serif;
  font-size: 14px;
}

/* =========================
 * Promotion Overlay
 * ========================= */

#promotion-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

#promotion-modal.hidden {
  display: none;
}

.promotion-box {
  background: #2b2b2b;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  color: white;
  min-width: 220px;
}

.promotion-options {
  display: flex;
  justify-content: space-around;
  margin-top: 12px;
}

.promotion-options button {
  font-size: 28px;
  background: #3a3a3a;
  border: none;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: 0.15s;
}

.promotion-options button:hover {
  background: #555;
  transform: scale(1.1);
}