/* ================================================================
   Board grid, cells, tiles, and premium squares
   ================================================================ */

/* ---- Board grid ---- */

.board {
  display: grid;
  grid-template-columns: repeat(15, var(--cell-size));
  grid-template-rows: repeat(15, var(--cell-size));
  gap: 1px;
  background: var(--grid-line);
  border-radius: 4px;
  padding: 1px;
  user-select: none;
}

.board--disabled {
  pointer-events: none;
  opacity: 0.85;
}

/* ---- Cells ---- */

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: var(--cell-empty);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: background 0.1s ease;
}

.cell:hover {
  filter: brightness(1.05);
}

.cell--drop-target {
  background: rgba(136, 204, 136, 0.3) !important;
}

/* ---- Premium squares ---- */

.cell--tw {
  background: var(--tw-color);
}

.cell--dw {
  background: var(--dw-color);
}

.cell--tl {
  background: var(--tl-color);
}

.cell--dl {
  background: var(--dl-color);
}

/* Labels */

.cell__label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  pointer-events: none;
  user-select: none;
}

.cell--tw .cell__label {
  color: rgba(255, 255, 255, 0.85);
}

.cell--dw .cell__label {
  color: rgba(120, 40, 60, 0.7);
}

.cell--tl .cell__label {
  color: rgba(255, 255, 255, 0.85);
}

.cell--dl .cell__label {
  color: rgba(30, 80, 110, 0.7);
}

/* Center star */

.cell--center .cell__star {
  position: absolute;
  font-size: 16px;
  color: rgba(120, 40, 60, 0.6);
  pointer-events: none;
  line-height: 1;
}

/* Hide star if label is also present (it's a DW square) */
.cell--center .cell__label + .cell__star {
  top: auto;
  bottom: 1px;
  font-size: 10px;
}

/* ---- Board tiles ---- */

.board-tile {
  width: var(--tile-size);
  height: var(--tile-size);
  background: var(--tile-face);
  border: 1px solid var(--tile-border);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  animation: tilePlaced 0.15s ease-out;
}

.board-tile--current-turn {
  border-color: var(--current-turn-border);
  border-width: 2px;
}

.board-tile--last-move {
  border-color: #E8A030;
  border-width: 2px;
  animation: lastMoveGlow 2s ease-out;
}

@keyframes lastMoveGlow {
  0% { box-shadow: 0 0 8px 3px rgba(232, 160, 48, 0.7); }
  100% { box-shadow: none; }
}

.board-tile__letter {
  font-size: 20px;
  font-weight: 700;
  color: var(--tile-letter);
  line-height: 1;
}

.board-tile__points {
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-size: 11px;
  font-weight: 400;
  color: var(--tile-points);
  line-height: 1;
}

@keyframes tilePlaced {
  from {
    transform: scale(1.1);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---- Rack tiles ---- */

.rack {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.rack--exchange-mode {
  background: rgba(255, 215, 0, 0.08);
  border-radius: 8px;
  padding: 8px;
}

.rack-tile {
  width: var(--rack-tile-size);
  height: var(--rack-tile-size);
  background: var(--tile-face);
  border: 2px solid var(--tile-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: grab;
  transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.15s ease;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  user-select: none;
}

.rack-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.25);
}

.rack-tile:focus-visible {
  outline: 2px solid var(--btn-primary);
  outline-offset: 2px;
}

.rack-tile--blank {
  background: var(--blank-face);
}

.rack-tile--selected {
  border-color: var(--selected-ring);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.4), 0 3px 6px rgba(0, 0, 0, 0.2);
  animation: selectedPulse 1.5s ease-in-out infinite;
}

.rack-tile--exchange-selected {
  border-color: var(--selected-ring);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.4), 0 3px 6px rgba(0, 0, 0, 0.2);
}

.rack-tile--dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.rack-tile--drop-target {
  border-color: var(--btn-primary);
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.4), 0 3px 6px rgba(0, 0, 0, 0.2);
  transform: translateY(-3px);
}

.rack-tile__letter {
  font-size: 20px;
  font-weight: 700;
  color: var(--tile-letter);
  line-height: 1;
}

.rack-tile__points {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 11px;
  font-weight: 400;
  color: var(--tile-points);
  line-height: 1;
}

.btn--exchange-confirm {
  background: var(--selected-ring);
  color: var(--text-dark);
  font-weight: 700;
}

.btn--exchange-cancel {
  background: var(--btn-secondary);
}

@keyframes selectedPulse {
  0%, 100% {
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.4), 0 3px 6px rgba(0, 0, 0, 0.2);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(255, 215, 0, 0.6), 0 3px 6px rgba(0, 0, 0, 0.2);
  }
}
