/* Dots and Boxes — own styles, theme variables only. Player 1 = accent, player 2 = --gm-db-p2 (teal fallback). */

.db {
  --db-p1: var(--gm-accent, #c0392b);
  --db-p2: var(--gm-db-p2, #1f9e89);
  width: 100%;
  max-width: 640px;
}

.db-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.db-stat {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--gm-surface, #1b2740);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.db-stat.is-turn {
  border-color: var(--gm-accent-line, rgba(192, 57, 43, 0.42));
  box-shadow: 0 0 0 3px var(--gm-accent-soft, rgba(192, 57, 43, 0.3));
}

.db-stat.is-p2.is-turn {
  border-color: var(--db-p2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--db-p2) 25%, transparent);
}

.db-swatch {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.db-stat.is-p1 .db-swatch { background: var(--db-p1); }
.db-stat.is-p2 .db-swatch { background: var(--db-p2); }

.db-who {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gm-muted, rgba(242, 238, 230, 0.66));
}

.db-stat b {
  font: 500 1.4rem/1.1 var(--gm-display, "Fraunces", Georgia, serif);
  font-variant-numeric: tabular-nums;
}

.db-board-wrap {
  padding: 6px;
  background: var(--gm-surface, #1b2740);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
  border-radius: var(--gm-radius, 12px);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.5);
}

.db-board {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.db-dot {
  fill: var(--gm-text, #f2eee6);
  pointer-events: none;
}

.db-box {
  fill: transparent;
  transition: fill 0.25s ease;
}

.db-box.is-p1 { fill: var(--db-p1); fill-opacity: 0.22; }
.db-box.is-p2 { fill: var(--db-p2); fill-opacity: 0.22; }
.db-box.is-new { animation: db-claim 0.35s ease-out; }

.db-mark {
  font: 600 40px var(--gm-display, "Fraunces", Georgia, serif);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.db-mark.is-p1 { fill: var(--db-p1); opacity: 0.85; }
.db-mark.is-p2 { fill: var(--db-p2); opacity: 0.85; }

.db-edge { outline: none; }

.db-hit {
  fill: transparent;
  stroke: none;
  cursor: pointer;
}

.db-glow,
.db-line {
  pointer-events: none;
  stroke-linecap: round;
}

.db-line {
  stroke: var(--gm-line-2, rgba(255, 255, 255, 0.16));
  stroke-width: 3;
  opacity: 0.7;
  transition: stroke-width 0.12s ease, opacity 0.12s ease;
}

.db-glow {
  stroke: transparent;
  stroke-width: 22;
  opacity: 0.3;
}

.db-edge.is-on .db-line { stroke-width: 10; opacity: 1; }
.db-edge.is-on.is-p1 .db-line { stroke: var(--db-p1); }
.db-edge.is-on.is-p2 .db-line { stroke: var(--db-p2); }
.db-edge.is-on.is-last.is-p1 .db-glow { stroke: var(--db-p1); }
.db-edge.is-on.is-last.is-p2 .db-glow { stroke: var(--db-p2); }
.db-edge.is-on .db-hit { cursor: default; }

/* hover / focus preview in the mover's colour */
.db-board:not(.is-locked) .db-edge:not(.is-on):hover .db-line,
.db-board:not(.is-locked) .db-edge:not(.is-on):focus-visible .db-line {
  stroke-width: 10;
  opacity: 0.5;
}
.db-board.is-turn-1:not(.is-locked) .db-edge:not(.is-on):hover .db-line,
.db-board.is-turn-1:not(.is-locked) .db-edge:not(.is-on):focus-visible .db-line { stroke: var(--db-p1); }
.db-board.is-turn-2:not(.is-locked) .db-edge:not(.is-on):hover .db-line,
.db-board.is-turn-2:not(.is-locked) .db-edge:not(.is-on):focus-visible .db-line { stroke: var(--db-p2); }

.db-edge:focus-visible .db-hit {
  fill: var(--gm-accent-soft, rgba(192, 57, 43, 0.3));
  stroke: var(--gm-accent-bright, #e0584a);
  stroke-width: 3;
  stroke-linejoin: round;
}

.db-board.is-locked .db-hit { cursor: default; }

#gm-dots-and-boxes .gm-status { margin-top: 12px; }

@keyframes db-claim {
  0% { fill-opacity: 0.6; }
  100% { fill-opacity: 0.22; }
}

@media (hover: none) {
  .db-board .db-edge:not(.is-on):hover .db-line { stroke-width: 3; opacity: 0.7; stroke: var(--gm-line-2, rgba(255, 255, 255, 0.16)); }
}

@media (max-width: 480px) {
  .db-bar { gap: 6px; }
  .db-stat { padding: 8px 10px; gap: 8px; }
  .db-who { font-size: 0.7rem; letter-spacing: 0.04em; }
  .db-stat b { font-size: 1.2rem; }
  .db-board-wrap { padding: 2px; }
  .gm-actions .gm-btn { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .db-box, .db-mark, .db-line, .db-stat { transition: none; }
  .db-box.is-new { animation: none; }
}

.gm-seg button, .gm-actions .gm-btn { min-height: 44px; }
