/* Detour: dark table, matte black board, blue walls, blue and pink balls (after the physical game). */
:root {
  --bg: #0f1013;
  --bg2: #16171c;
  --panel: #1b1d23;
  --panel2: #23252d;
  --text: #e8ebf2;
  --muted: #8f97a8;
  --line: #2c2f38;
  --blue: #3aa6ff;
  --blue-deep: #1a7fd8;
  --pink: #ff5fa8;
  --wall: #2f96e8;
  --bad: #ff5c5c;
}

* { box-sizing: border-box; }

html { background: var(--bg); color-scheme: dark; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2030 0%, var(--bg) 60%);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- header ---------- */
header.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { margin: 0; font-size: 1.25rem; font-weight: 900; letter-spacing: .18em; text-transform: uppercase; }
.brand .mark {
  width: 30px; height: 30px;
  fill: none; stroke: var(--blue); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(58, 166, 255, .5));
}
.top-actions { display: flex; gap: 8px; }

button {
  font: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
button:hover { background: #2b2e38; border-color: #3a3e4a; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; transform: none; }
button.primary { background: var(--blue-deep); border-color: var(--blue); }
button.primary:hover { background: #2590ea; }

/* ---------- player strips ---------- */
.player {
  --pc: var(--blue);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: border-color .2s, box-shadow .2s;
}
.player.p1 { --pc: var(--pink); }
.player.active { border-color: var(--pc); box-shadow: 0 0 0 1px var(--pc) inset, 0 0 22px -8px var(--pc); }
.player.winner { border-color: var(--pc); background: #1d2430; }
.player .ball {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .55) 0, var(--pc) 35%, rgba(0, 0, 0, .35) 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .55);
}
.player .pname { font-weight: 700; }
.player .who { color: var(--muted); font-size: .9em; }
.player .spacer { flex: 1; }
.player .walls { display: flex; gap: 3px; }
.player .walls i { display: block; width: 6px; height: 18px; border-radius: 2px; background: var(--wall); box-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.player .walls i.used { background: #2a2d36; box-shadow: none; }
.player .wcount { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9em; min-width: 4.2em; text-align: right; }

/* ---------- board ---------- */
.board-wrap { width: min(100%, calc(100vh - 300px)); min-width: 260px; margin: 0 auto; }
svg.board { display: block; width: 100%; height: auto; touch-action: manipulation; user-select: none; }

.rim { fill: #1a6fbf; }
.base { fill: #17181d; }
.goal { opacity: .55; }
.goal.g0 { fill: var(--blue); }
.goal.g1 { fill: var(--pink); }
.cell { fill: #2a2c33; stroke: #363943; stroke-width: 1; }

.wall { fill: url(#wallGrad); filter: drop-shadow(0 2px 1.5px rgba(0, 0, 0, .65)); }
.wall.new { animation: drop .22s ease-out; }
@keyframes drop {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.ghost { fill: #ffffff; opacity: .5; pointer-events: none; }
.ghost.bad { fill: var(--bad); opacity: .6; }
.ghost.pending { fill: #ffe27a; opacity: .8; }

.pawn { transition: transform .3s cubic-bezier(.25, .9, .3, 1.15); }
.pawn .shadow { fill: #000; opacity: .45; }

.target { fill: #fff; opacity: 0; pointer-events: none; transition: opacity .15s; }
.target.on { opacity: .3; pointer-events: all; cursor: pointer; }
.target.on:hover { opacity: .65; }
.targets.p0 .target { fill: var(--blue); }
.targets.p1 .target { fill: var(--pink); }

.hit { fill: none; pointer-events: all; cursor: pointer; }
.board.locked .hit, .board.locked .target { pointer-events: none; cursor: default; }

/* ---------- status + controls ---------- */
.status { text-align: center; margin: 0; min-height: 1.5em; color: var(--text); }
.status.muted { color: var(--muted); }
.status.bad { color: var(--bad); }
.controls { display: flex; gap: 8px; justify-content: center; }
.hint { text-align: center; color: var(--muted); font-size: .85em; margin: 0; }

/* ---------- dialogs ---------- */
dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 24px;
  width: min(92vw, 520px);
  max-height: 90vh;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .65);
}
dialog::backdrop { background: rgba(5, 6, 10, .7); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 12px; font-size: 1.3rem; }
dialog h3 { margin: 16px 0 6px; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
dialog p { margin: 8px 0; }

.choices { display: grid; gap: 6px; }
.choices.row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.choice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg2);
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--blue); background: #1a2433; }
.choice input { margin: 3px 0 0; }
.choice small { display: block; color: var(--muted); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }

.rules ul { padding-left: 20px; margin: 6px 0; }
.rules li { margin: 6px 0; }
.swatch { display: inline-block; width: .8em; height: .8em; border-radius: 50%; vertical-align: -1px; }
.swatch.blue { background: var(--blue); }
.swatch.pink { background: var(--pink); }
.over h2 { font-size: 1.6rem; }

@media (max-width: 480px) {
  .app { padding: 8px 10px 20px; gap: 8px; }
  .player { padding: 6px 10px; gap: 8px; }
  .player .walls i { width: 5px; height: 15px; }
  .player .who { display: none; }
  .brand h1 { font-size: 1.05rem; }
  button { padding: 7px 11px; }
  .board-wrap { width: 100%; }
}
