/* ─── Chess Board ─── */
.board-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
}

.board-wrap {
  position: relative;
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(92vw, 92vh, 520px);
  height: min(92vw, 92vh, 520px);
  max-width: 520px;
  max-height: 520px;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  touch-action: none;
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: background-color 0.1s;
}

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

.square.selected {
  background: #829769 !important;
}

.square.last-move-from,
.square.last-move-to {
  background: rgba(155, 199, 0, 0.41) !important;
}

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

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

.square.in-check {
  background: radial-gradient(circle at center, #ff4444 0%, #b22222 60%, transparent 100%) !important;
}

/* Coordinate labels */
.square .coord-rank {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: clamp(8px, 1.5vw, 11px);
  font-weight: 600;
  line-height: 1;
  opacity: 0.7;
}

.square .coord-file {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: clamp(8px, 1.5vw, 11px);
  font-weight: 600;
  line-height: 1;
  opacity: 0.7;
}

.square.light .coord-rank,
.square.light .coord-file { color: #b58863; }
.square.dark  .coord-rank,
.square.dark  .coord-file  { color: #f0d9b5; }

/* Pieces */
.piece {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(24px, 9vw, 56px);
  line-height: 1;
  font-family: "Noto Sans Symbols 2", "DejaVu Sans", "Segoe UI Symbol", sans-serif;
  cursor: grab;
  z-index: 2;
  pointer-events: none; /* handled by square */
  text-shadow:
    0 1px 3px rgba(0,0,0,0.6),
    0 0 8px rgba(0,0,0,0.2);
  /*
   * Unicode chess glyph metrics are often baseline-heavy in default fonts.
   * Small upward nudge keeps pieces visually centered in each square.
   */
  transform: translateY(-2%);
  transition: transform 0.05s;
}

/* White pieces rendered lighter */
.piece.white-piece {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.8));
}

/* Floating drag piece */
.piece-drag {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  font-size: clamp(28px, 11vw, 62px);
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.6));
  opacity: 0.9;
}

/* Promotion modal pieces */
.promo-piece {
  line-height: 1;
}
