/* ===== CHESS BOARD ===== */
.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  direction: ltr; /* board always left-to-right: a=left, h=right */
  width: var(--board-size);
  height: var(--board-size);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25), 0 0 0 4px var(--yellow-dark);
  user-select: none;
  position: relative;
}

.chess-board.shaking { animation: shake 0.4s ease; }

/* ===== SQUARES ===== */
.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: background-color 0.15s;
}

/* Hardcoded — never let dark mode or variable overrides change them */
.square.light { background-color: #F0D9B5 !important; }
.square.dark  { background-color: #B58863 !important; }

.square:hover { opacity: 0.9; }

/* Square labels (rank/file) */
.square[data-col="0"]::before {
  content: attr(data-rank);
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  opacity: 0.6;
  line-height: 1;
  color: var(--square-dark);
}
.square.dark[data-col="0"]::before { color: var(--square-light); }

.square[data-row="7"]::after {
  content: attr(data-file);
  position: absolute;
  bottom: 2px;
  left: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  opacity: 0.6;
  line-height: 1;
  color: var(--square-dark);
}
.square.dark[data-row="7"]::after { color: var(--square-light); }

/* ===== PIECES ===== */
.piece {
  width: 88%;
  height: 88%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: transform 0.15s ease;
  border-radius: 50%;
}

.piece:hover { transform: scale(1.08); }

.piece svg,
.piece img {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}

/* Distinct halos so white vs black always reads clearly,
   even if the OS applies any image tinting */
.piece-w img { filter: drop-shadow(0 0 2px rgba(0,0,0,0.55))    drop-shadow(0 2px 3px rgba(0,0,0,0.3)); }
.piece-b img { filter: drop-shadow(0 0 2px rgba(255,255,255,0.45)) drop-shadow(0 2px 3px rgba(0,0,0,0.3)); }

/* Piece selected state */
.piece.selected {
  animation: piece-select-glow 0.8s ease infinite;
  border-radius: 4px;
  z-index: 5;
}

/* ===== MOVE HIGHLIGHTS ===== */
.move-dot {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 3;
}

.move-dot::after {
  content: '';
  display: block;
  border-radius: 50%;
  background: var(--highlight-move);
}

/* Normal dot (no piece to capture) */
.square.highlight-move .move-dot::after {
  width: 32%;
  height: 32%;
  animation: pulse-dot 1.2s ease-in-out infinite;
}

/* Capture ring (there's a piece to capture) */
.square.highlight-capture .move-dot::after {
  width: 90%;
  height: 90%;
  background: transparent;
  border: 4px solid var(--highlight-cap);
  border-radius: 50%;
  animation: pulse-dot 1.2s ease-in-out infinite;
}

/* Teach mode highlight: bigger for ages 5-7 */
.age-5-7 .square.highlight-move .move-dot::after {
  width: 42%;
  height: 42%;
  animation: pulse-dot-big 1s ease-in-out infinite;
}

.age-5-7 .square.highlight-capture .move-dot::after {
  border-width: 6px;
  animation: pulse-dot-big 1s ease-in-out infinite;
}

/* Teaching mode capture indicators (diagonal for pawn) */
.square.highlight-teach-cap .move-dot::after {
  width: 38%;
  height: 38%;
  background: var(--highlight-cap);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.age-5-7 .square.highlight-teach-cap .move-dot::after {
  width: 48%;
  height: 48%;
  animation: pulse-dot-big 1s ease-in-out infinite;
}

/* Clickable highlight squares */
.square.highlight-move,
.square.highlight-capture,
.square.highlight-teach-move,
.square.highlight-teach-cap {
  cursor: pointer;
}

.square.highlight-move:hover,
.square.highlight-teach-move:hover { background-color: rgba(127,201,127,0.3) !important; }
.square.highlight-capture:hover,
.square.highlight-teach-cap:hover { background-color: rgba(255,107,107,0.25) !important; }

/* Teaching move - green dot */
.square.highlight-teach-move .move-dot::after {
  width: 32%;
  height: 32%;
  background: var(--highlight-move);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.age-5-7 .square.highlight-teach-move .move-dot::after {
  width: 44%;
  height: 44%;
  animation: pulse-dot-big 1s ease-in-out infinite;
}

/* Selected square background */
.square.selected-square {
  background: var(--highlight-sel) !important;
}

/* Last move highlight */
.square.last-move-from,
.square.last-move-to {
  background: rgba(255,215,0,0.4) !important;
}

/* ===== FLYING PIECE (animation) ===== */
.flying-piece {
  position: fixed;
  pointer-events: none;
  z-index: 50;
  transition: none;
  border-radius: 4px;
}

.flying-piece svg,
.flying-piece img {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4));
}
