:root {
  --bg: #f3f0e8;
  --panel: #ffffff;
  --text: #1f1d1a;
  --muted: #6b665e;
  --border: #ddd6c8;
  --accent: #2f6f8f;
  --water: #9fc6d9;
  --lane: #ffffff;
  --coast: #3d5866;
  --hl: #ffd23f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171a1d;
    --panel: #22262a;
    --text: #e8e6e1;
    --muted: #9ea3a8;
    --border: #353a40;
    --accent: #5aa6c9;
    --water: #23485a;
    --lane: #a9cbe0;
    --coast: #0f2530;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
}
main { max-width: 1320px; margin: 0 auto; padding: 16px; }
h1 { font-size: 2.6rem; margin: 0 0 4px; letter-spacing: .02em; }
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; margin: 0; }
a { color: var(--accent); }

#home { text-align: center; padding-top: 14vh; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }

#game { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.map-col { flex: 3 1 560px; min-width: 0; }
aside {
  flex: 1 1 300px; min-width: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  display: flex; flex-direction: column; gap: 14px;
}

#map svg { display: block; width: 100%; height: auto; border-radius: 10px; user-select: none; }
.terr { cursor: pointer; }
.terr:hover { filter: brightness(1.08); }
.terr polygon { stroke-width: 1; }
.b-inner { stroke: rgba(0,0,0,.35); stroke-width: 1; fill: none; }
.b-region { stroke: rgba(0,0,0,.75); stroke-width: 2.4; fill: none; stroke-linecap: round; }
.b-coast { stroke: var(--coast); stroke-width: 2; fill: none; stroke-linecap: round; }
.lane { stroke: var(--lane); stroke-width: 1.6; stroke-dasharray: 4 4; opacity: .85; }
.outline { fill: none; stroke: none; stroke-width: 3.5; stroke-linecap: round; pointer-events: none; }
.outline.cand { stroke: var(--hl); stroke-dasharray: 5 4; stroke-width: 2.5; }
.outline.sel { stroke: #fff; }
.outline.target { stroke: var(--hl); }
.label { pointer-events: none; }
.tname { font-size: 8.5px; font-weight: 600; text-anchor: middle; fill: #1d1d1d; paint-order: stroke; stroke: rgba(255,255,255,.7); stroke-width: 2.5px; }
.badge circle { stroke: #fff; stroke-width: 1.5; }
.badge text { font-size: 10px; font-weight: 700; text-anchor: middle; fill: #fff; }

.regions { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: .85rem; color: var(--muted); }
.regions b { color: var(--text); }

.status { font-size: 1.1rem; font-weight: 650; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.actions:empty { display: none; }
.actions .hint { color: var(--muted); font-size: .9rem; margin: 0; }
button {
  font: inherit; padding: 7px 12px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: #c0392b; border-color: #c0392b; color: #fff; }
button.on { outline: 2px solid var(--accent); outline-offset: 1px; font-weight: 700; }
button:disabled { opacity: .45; cursor: default; }
input {
  font: inherit; padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg); color: var(--text); min-width: 0;
}
input[type=range] { padding: 0; flex: 1; }
.share input { flex: 1; }

.warn { color: #c0392b; font-size: .85rem; margin: 0; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.players li { display: flex; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 7px; border: 1px solid transparent; }
.players li.turn { border-color: var(--border); background: var(--bg); }
.players li.dead { opacity: .5; text-decoration: line-through; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.players .stats { margin-left: auto; color: var(--muted); font-size: .82rem; text-align: right; }
.off { color: var(--muted); font-size: .8rem; }

.cards { display: flex; gap: 6px; flex-wrap: wrap; }
.card { padding: 4px 9px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); font-size: .85rem; font-weight: 600; }

.battle { background: var(--bg); border-radius: 8px; padding: 10px; font-size: .9rem; }
.dice { display: flex; gap: 5px; margin: 4px 0; align-items: center; }
.die { width: 26px; height: 26px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.die.att { background: #c0392b; color: #fff; }
.die.def { background: #fff; color: #222; border: 1px solid #999; }

.log { margin: 0; padding-left: 0; list-style: none; max-height: 220px; overflow-y: auto; font-size: .85rem; color: var(--muted); }
.log li:last-child { color: var(--text); }
.rules { font-size: .88rem; }
.rules ul { padding-left: 1.2em; margin: 6px 0 0; }
.rules summary { cursor: pointer; font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: #222; color: #fff; padding: 9px 16px; border-radius: 8px; max-width: calc(100% - 32px);
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
}
