/* ==========================================================================
   Dots & Boxes - game-specific styles
   base.css handles tokens, reset, body, .home-btn, .util-btns, .menu-logo,
   .menu-title, .icon, focus-visible, reduced-motion
   ========================================================================== */

html, body { height: 100%; overflow: hidden; }

body {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 16px;
}

.app {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.top {
  width: 100%;
  text-align: center;
  padding-left: 52px;
  padding-right: 52px;
}
.top h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  letter-spacing: -0.01em;
}

.panel {
  width: 100%;
  padding: 24px 22px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px; }

.hidden { display: none !important; }

/* Menu entrance (layout only; look comes from base.css) */
.menu-step:not(.hidden) > * { animation: menu-field-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both; }
.menu-step:not(.hidden) > *:nth-child(2) { animation-delay: 0.05s; }
.menu-step:not(.hidden) > *:nth-child(3) { animation-delay: 0.10s; }
.menu-step:not(.hidden) > *:nth-child(4) { animation-delay: 0.15s; }
.menu-step:not(.hidden) > *:nth-child(5) { animation-delay: 0.20s; }
@keyframes menu-field-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Game --- */
/* Turn + result are shown visually (active card, coloured edges). The status
   text is kept for screen readers only. */
.status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.board-wrap {
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1 / 1;
}
.board {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  --turn: var(--accent);
}

.board .dot { fill: var(--muted); }

.board .edge {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-linecap: round;
  transition: stroke 0.18s ease;
}
.board .edge.set {
  stroke: var(--pc);
}
.board .edge.last { animation: db-edge-in 0.28s ease; }
@keyframes db-edge-in {
  from { opacity: 0.2; }
  to   { opacity: 1; }
}

.board .hit {
  stroke: transparent;
  stroke-linecap: butt;
  pointer-events: stroke;
  cursor: pointer;
}
.board .hit.taken { pointer-events: none; cursor: default; }
.board.locked .hit { pointer-events: none; cursor: default; }

/* Hover preview in the current player's colour (pointer devices only) */
@media (hover: hover) {
  .board:not(.locked) .hit:not(.taken):hover + .edge {
    stroke: var(--turn);
    opacity: 0.45;
  }
}

.board .box {
  fill: var(--pc);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.board .box.set { opacity: 0.22; }

/* --- Scoreboard --- */
.scoreboard {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 10px;
  width: 100%;
}
.score {
  --pc: var(--accent);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.12s ease;
}
.score-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.score-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pc);
  flex-shrink: 0;
}
.score-value {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.score.active {
  border-color: var(--pc);
  background: rgba(255, 255, 255, 0.07);
}
.score.active .score-head { color: var(--text); }
.score.flash { animation: db-flash 0.7s ease; }
@keyframes db-flash {
  0%, 100% { transform: scale(1); }
  35%      { transform: scale(1.08); }
}

.result {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--text);
  text-align: center;
}
.result[hidden] { display: none; }

.game-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}
.game-actions > * { flex: 1; }

/* ==========================================================================
   ONLINE - create/join overlay (uses base.css .lb-overlay / .lb-card shell)
   ========================================================================== */
.online-card { position: relative; padding-top: 28px; }
.online-card h2 { font-family: var(--font-serif); font-weight: 400; font-size: 1.3rem; letter-spacing: 0; }
.online-setup, .online-config { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.online-setup.hidden, .online-config.hidden { display: none !important; }
.online-btn { width: 100%; }
.online-actions { display: flex; gap: 10px; }
.online-divider {
  display: flex;
  gap: 10px; }
.online-divider::before, .online-divider::after {
  content: ""; flex: 1; height: 1px; }
.online-join { display: flex; gap: 8px; }
.online-join input {
  flex: 1;
  min-width: 0;
}
.online-join input:focus { outline: none; }
.online-wait { display: flex; flex-direction: column; gap: 6px; }
.online-wait.hidden { display: none !important; }
.online-code { text-indent: 0.25em;
  cursor: pointer; user-select: all; }
.online-wait-sub {
  animation: online-wait-pulse 1.6s ease-in-out infinite; }
@keyframes online-wait-pulse { 0%,100%{opacity:0.55;} 50%{opacity:1;} }
.online-status[hidden] { display: none; }

@media (max-width: 600px) {
  body { padding: 16px 12px; }
  .panel { padding: 18px 14px 16px; }
  .seg-btn { padding: 9px 14px; min-height: 40px; }
  .score-value { font-size: 1.25rem; }
}
