/* ════════════════════════════════════════════════════════════════
   CUSTOM CHESSBOARD IMPLEMENTATION
   Replacing chessboard.js for full control over click/drag events
   ════════════════════════════════════════════════════════════════ */

.custom-board {
  display: grid;
  /* Keep Grid */
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  background-size: 100% 100%;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  /* extra contrast */
}

.board-square {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Lichess Standard Colors */
.board-square.light {
  background-color: #f0d9b5;
}

.board-square.dark {
  background-color: #b58863;
}

/* Coordinates */
.coordinate {
  position: absolute;
  font-size: 10px;
  font-weight: bold;
  pointer-events: none;
  font-family: var(--font-main);
  z-index: 1;
}

.coordinate.rank {
  top: 2px;
  left: 2px;
}

.coordinate.file {
  bottom: 2px;
  right: 2px;
}

.coordinate.light {
  color: #b58863;
}

.coordinate.dark {
  color: #f0d9b5;
}

/* Pieces */
.piece {
  width: 100%;
  height: 100%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  cursor: grab;
  z-index: 10;
  transition: transform 0.1s;
}

.piece:active {
  cursor: grabbing;
}

.piece.dragging {
  opacity: 0.5;
  /* Visual feedback on original piece */
}

/* Dragging Ghost */
.drag-ghost {
  position: fixed;
  width: 80px;
  /* Adjust via JS based on square size */
  height: 80px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  z-index: 1000;
  opacity: 1;
  transform: translate(-50%, -50%);
  cursor: grabbing;
}

/* Highlights */
.board-square.highlight-selected {
  background-color: rgba(20, 85, 30, 0.5) !important;
}

.board-square.highlight-lastmove {
  background-color: rgba(205, 210, 106, 0.6) !important;
}

.board-square.highlight-check {
  background: radial-gradient(ellipse at center, rgba(255, 0, 0, 1) 0%, rgba(231, 0, 0, 1) 25%, rgba(169, 0, 0, 0) 89%, rgba(158, 0, 0, 0) 100%);
}

/* Legal Move Hints - Premium Green Style */
.legal-hint-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30%;
  height: 30%;
  background: rgba(20, 85, 30, 0.6);
  border-radius: 50%;
  pointer-events: none;
  z-index: 15;
}

.legal-hint-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border-radius: 50%;
  border: 6px solid rgba(20, 85, 30, 0.6);
  pointer-events: none;
  z-index: 15;
}

/* Premove Highlight */
.board-square.highlight-premove {
  background-color: rgba(244, 42, 50, 0.5) !important;
  box-shadow: inset 0 0 3px 3px rgba(244, 42, 50, 0.5);
}

/* Responsive Ghost Size */
@media (max-width: 600px) {
  .drag-ghost {
    width: 40px;
    height: 40px;
  }
}