/* ============================================================
   Board — Royal Game of Ur
   ============================================================ */

/* ============================================================
   Board wrapper & layout
   ============================================================ */

#board-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  z-index: 40;
}

/* Path direction labels */
.path-label {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.path-label.p1-label {
  align-self: flex-start;
  margin-top: 3px;
}
.path-label.p2-label {
  align-self: flex-start;
  margin-top: 2px;
}
.path-arrow {
  font-size: 0.7rem;
  opacity: 0.7;
}

/* ============================================================
   The 3×8 CSS Grid board
   ============================================================ */

#board {
  display: grid;
  grid-template-columns: repeat(8, var(--tile-size, 64px));
  grid-template-rows: repeat(3, var(--tile-size, 64px));
  gap: var(--tile-gap, 4px);
  padding: 10px;
  background: var(--panel-bg);
  border: 2px solid var(--border);
  border-radius: 16px;
  box-shadow:
    0 4px 32px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  position: relative;
}

/* ============================================================
   Individual tiles
   ============================================================ */

.tile {
  position: relative;
  width: var(--tile-size, 64px);
  height: var(--tile-size, 64px);
  background: var(--tile-bg);
  border: 1.5px solid var(--tile-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.2s, border-color 0.2s, background 0.2s;
  overflow: hidden;
  cursor: default;
}

/* Shared lane (row 1) */
.tile.shared {
  background: var(--tile-shared);
  border-color: var(--tile-shared-border);
}

/* Empty non-playable tiles — just a gap */
.tile.empty {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
  cursor: default;
}

/* ============================================================
   Rosette tiles
   ============================================================ */

.tile.rosette {
  background: var(--rosette-bg);
  border-color: var(--rosette-accent);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.3);
}

/* Rosette flower / star symbol via ::before */
.tile.rosette::before {
  content: '✦';
  font-size: 1.5rem;
  color: var(--rosette-accent);
  opacity: 0.55;
  pointer-events: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  line-height: 1;
  animation: rosette-spin 18s linear infinite;
}

/* Extra decorative petals via ::after */
.tile.rosette::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: radial-gradient(
    circle at center,
    var(--rosette-accent) 0%,
    transparent 65%
  );
  opacity: 0.12;
  pointer-events: none;
}

/* ============================================================
   Valid-move highlight
   ============================================================ */

.tile.valid-move {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent),
    0 0 16px var(--accent-glow);
  cursor: pointer;
  animation: valid-pulse 1.1s ease-in-out infinite;
  z-index: 5;
}

.tile.valid-move:hover {
  box-shadow:
    0 0 0 3px var(--accent),
    0 0 22px var(--accent-glow);
  filter: brightness(1.12);
}

/* Empty tiles should never receive valid-move */
.tile.empty.valid-move {
  border-color: transparent;
  box-shadow: none;
  cursor: default;
  animation: none;
}

/* ============================================================
   Last-move highlight (brief flash after a piece moves)
   ============================================================ */

.tile.last-move {
  animation: last-move-flash 0.88s ease-out forwards;
}

@keyframes last-move-flash {
  0%   { box-shadow: 0 0 0 3px var(--accent), 0 0 24px var(--accent-glow); }
  100% { box-shadow: none; }
}

/* ============================================================
   "Enter" target (piece about to enter from home)
   ============================================================ */

.tile.entry-target {
  border-color: var(--p1-color);
  box-shadow: 0 0 12px var(--p1-glow);
}
.tile.entry-target.p2 {
  border-color: var(--p2-color);
  box-shadow: 0 0 12px var(--p2-glow);
}

/* ============================================================
   Home & scored piece areas (beside the board)
   ============================================================ */

.home-pieces,
.scored-pieces {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  min-height: 20px;
}

.home-pieces { gap: 3px; }
.scored-pieces { gap: 3px; }

/* Labels */
.piece-area-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-right: 4px;
}

/* ============================================================
   Board edge connector bars
   Thin coloured strips flanking the board to show P1/P2 lanes
   ============================================================ */

#board::before,
#board::after {
  content: '';
  position: absolute;
  left: -6px;
  right: -6px;
  height: 3px;
  border-radius: 3px;
  pointer-events: none;
}

#board::before {
  top: -3px;
  background: linear-gradient(90deg, transparent 33%, var(--p1-color) 33%, var(--p1-color) 50%, transparent 50%);
  opacity: 0.6;
}

#board::after {
  bottom: -3px;
  background: linear-gradient(90deg, transparent 33%, var(--p2-color) 33%, var(--p2-color) 50%, transparent 50%);
  opacity: 0.6;
}

/* ============================================================
   Shared lane visual divider lines
   ============================================================ */

.tile.shared:first-child {
  border-top-left-radius: 8px;
}

/* Subtle top/bottom border on shared row to delineate it */
.tile[data-row="1"] {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* ============================================================
   Tile number hint (dev helper — hidden in production)
   ============================================================ */

.tile[data-pos-label]::after {
  content: attr(data-pos-label);
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.55rem;
  color: var(--text-secondary);
  opacity: 0.35;
  pointer-events: none;
  line-height: 1;
}

/* ============================================================
   Keyframe animations
   ============================================================ */

@keyframes valid-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 2px var(--accent),
      0 0 10px var(--accent-glow);
  }
  50% {
    box-shadow:
      0 0 0 2px var(--accent),
      0 0 22px var(--accent-glow);
    filter: brightness(1.08);
  }
}

@keyframes rosette-spin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to   { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ============================================================
   Responsive — smaller tiles on narrow viewports
   ============================================================ */

@media (max-width: 768px) {
  :root {
    --tile-size: 48px;
    --tile-gap: 3px;
  }
  #board { padding: 7px; border-radius: 12px; }
  .tile { border-radius: 6px; }
  .tile.rosette::before { font-size: 1.1rem; }
  .path-label { font-size: 0.55rem; }
}

@media (max-width: 480px) {
  :root {
    --tile-size: 38px;
    --tile-gap: 2px;
  }
  #board { padding: 5px; border-radius: 10px; }
  .tile { border-radius: 5px; }
  .tile.rosette::before { font-size: 0.9rem; }
}

/* Very small screens — squeeze further */
@media (max-width: 360px) {
  :root {
    --tile-size: 32px;
    --tile-gap: 2px;
  }
}
