/* Board CSS for Scrabble Game */

.game-board-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0px 0;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(17, 1fr); /* Changed to 17 for (N+1)x(N+1) */
  grid-template-rows: repeat(17, 1fr);
  gap: 2px;
  background-color: var(--board-border-color);
  padding: 10px;
  border-radius: 5px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 680px; /* Adjusted for larger grid */
  aspect-ratio: 1/1;
}

.board-cell {
  background-color: var(--regular-cell-color);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.7rem;
  font-weight: bold;
  color: #555;
  position: relative;
  cursor: pointer;
  border-radius: 2px;
}

.transparent-cell {
  background-color: transparent;
  border: none;
  cursor: pointer;
}

/* Special cells styling */
.double-letter {
  background-color: var(--dl-cell-color);
}

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

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

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

.center-star {
  background-color: var(--dw-cell-color);
  position: relative;
}

.center-star::after {
  content: "★";
  font-size: 1.2rem;
  color: #8b4513;
  position: absolute;
  z-index: 1; /* Place star behind tile */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Tile styling */
.tile {
  width: 90%;
  height: 90%;
  background-color: var(--tile-color);
  border-radius: 3px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 2;  /* Ensure tile is above star */
  font-family: 'Arial', sans-serif;
  font-size: 1rem;
  font-weight: bold;
  color: var(--tile-text-color);
}

.rack-tile .tile-letter,
.rack-tile .tile-value {
    user-select: none; /* Prevent text selection without blocking drag */
}

.tile-letter {
  font-size: 1rem;
  font-weight: bold;
  color: var(--tile-text-color);
}

.tile-value {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 0.6rem;
  font-weight: normal;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .game-board {
    max-width: 100%;
  }
  
  .tile-letter {
    font-size: 0.8rem;
  }
  
  .tile-value {
    font-size: 0.5rem;
  }
}

/* Hover and active states */
.board-cell:hover {
  opacity: 0.9;
}

.board-cell.valid-placement {
  box-shadow: inset 0 0 5px rgba(0, 255, 0, 0.5);
  background-color: rgba(0, 255, 0, 0.2); /* Green highlight */
}

.board-cell.invalid-placement {
  box-shadow: inset 0 0 5px rgba(255, 0, 0, 0.5);
  background-color: rgba(255, 0, 0, 0.2); /* Red highlight */
}

/* Rack tile styling */
.rack-tile {
  width: 40px; /* Fixed size to match board tiles (680px / 17 ≈ 40px) */
  height: 40px; /* Fixed size to match board tiles */
  background-color: var(--tile-color);
  border-radius: 3px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  cursor: grab;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1;
  font-family: 'Arial', sans-serif;
  font-size: 1rem;
  font-weight: bold;
  color: var(--tile-text-color);
}

.rack-tile:active {
  /* opacity: 0.1 !important; Translucent during drag */
  cursor: grabbing;
}

.rack-tile .tile-letter {
  font-size: 1rem;
  font-weight: bold;
}

.rack-tile .tile-value {
  font-size: 0.6rem;
  bottom: 2px;
  right: 2px;
}

.rack-tile.dragging {
  transform: scale(0.5);
  transform-origin: center;
  background-color: var(--tile-color);
}

.tile-rack {
  width: 360px; /* Fixed width */
  height: 60px; /* Fixed height */
  background-color: var(--rack-bg-color);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  justify-content: flex-start; /* Left-justify tiles */
  gap: 10px;
  position: relative;
  align-items: center;
}

/* Optional: Add a pseudo-element to reinforce rack background */
.tile-rack::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--rack-bg-color);
  z-index: 0;
}