:root {
  --bg: #14171c;
  --panel: #1e232b;
  --line: #2e3540;
  --text: #e9ecf1;
  --muted: #8b95a5;
  --red: #d9333f;
  --blue: #2f6fd6;
  --accent: #f2c14e;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.hidden { display: none !important; }
button {
  font: inherit; color: var(--text); background: #2b323d; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 14px; cursor: pointer;
}
button:hover { background: #353e4b; }
button.primary { background: var(--red); border-color: var(--red); font-weight: 600; }
button.primary:hover { background: #e84652; }
button.on { outline: 2px solid var(--accent); }
input {
  font: inherit; color: var(--text); background: #12151a; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
input[type=range] { padding: 0; accent-color: var(--accent); }

.screen { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px; width: min(420px, 100%); display: grid; gap: 14px;
}
.card h1 { margin: 0; font-size: 34px; display: flex; align-items: center; gap: 12px; }
.card h2 { margin: 0; }
.cross {
  background: var(--red); color: #fff; width: 42px; height: 42px; border-radius: 6px;
  display: grid; place-items: center; font-size: 40px; font-weight: 900; line-height: 1;
}
.sub, .muted { color: var(--muted); margin: 0; }
label { display: grid; gap: 6px; color: var(--muted); }
.join { display: flex; gap: 8px; }
.join input { flex: 1; text-transform: uppercase; }

#game { display: grid; grid-template-columns: 1fr 330px; height: 100vh; }
#board { position: relative; display: grid; place-items: center; padding: 12px; min-width: 0; overflow: auto; }
#map, #battle { width: 100%; height: 100%; max-height: calc(100vh - 24px); }
#side {
  background: var(--panel); border-left: 1px solid var(--line); padding: 12px;
  display: flex; flex-direction: column; gap: 10px; overflow-y: auto;
}
.panel { background: #171b21; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.panel:empty { display: none; }
.panel h3 { margin: 0 0 6px; font-size: 15px; }
.panel p { margin: 4px 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.row button { flex: 1; }

#players { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.player { border-radius: 10px; padding: 8px 10px; border: 2px solid transparent; background: #171b21; }
.player.turn { border-color: var(--accent); }
.player .nm { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.player .dot { width: 10px; height: 10px; border-radius: 50%; }
.player .st { color: var(--muted); font-size: 13px; }
.off { color: var(--muted); font-size: 11px; font-weight: 400; }

.log { font-size: 13px; color: var(--muted); flex: 1; min-height: 120px; overflow-y: auto; }
.log div { padding: 2px 0; border-bottom: 1px solid #222831; }
.log div:last-child { color: var(--text); }
#regions summary { cursor: pointer; font-weight: 600; }
#regions .rg { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }

/* Karte */
.terr { stroke: #10141a; stroke-width: 0.8; cursor: pointer; transition: fill .15s; }
.terr:hover { filter: brightness(1.15); }
.terr.sel { stroke: var(--accent); stroke-width: 3; }
.terr.target { stroke: #fff; stroke-width: 2; stroke-dasharray: 5 3; animation: dash 1s linear infinite; }
.terr.choice { stroke: var(--accent); stroke-width: 2.5; }
@keyframes dash { to { stroke-dashoffset: -16; } }
.lake { fill: #6fa3d8; stroke: #4a7fb5; stroke-width: .5; pointer-events: none; }
.lbl { pointer-events: none; font-weight: 700; }
.lbl circle { stroke: #fff; stroke-width: 1.5; }
.lbl .n { fill: #fff; font-size: 13px; text-anchor: middle; dominant-baseline: central; }
.lbl .c { fill: #10141a; font-size: 10px; text-anchor: middle; opacity: .8; }

/* Schlacht */
.cell { stroke: rgba(0,0,0,.25); stroke-width: 1; }
.cell.reach { cursor: pointer; }
.reachfx { fill: rgba(242,193,78,.38); pointer-events: none; }
.unit { cursor: pointer; }
.unit.done { opacity: .5; }
.unit .ring { fill: none; stroke-width: 3; }
.unit.selu .ring { stroke: var(--accent); }
.unit.tgt .ring { stroke: #fff; stroke-dasharray: 4 3; animation: dash 1s linear infinite; }
.unit text { pointer-events: none; }
.deco { pointer-events: none; font-size: 18px; opacity: .55; text-anchor: middle; dominant-baseline: central; }

#tip {
  position: fixed; pointer-events: none; background: #0d1014; border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; z-index: 5; max-width: 260px;
}
#toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); background: #0d1014;
  border: 1px solid var(--accent); border-radius: 10px; padding: 10px 16px; z-index: 10; max-width: 90vw;
}
.legend { font-size: 13px; color: var(--muted); }
.legend b { color: var(--text); }

@media (max-width: 860px) {
  #game { grid-template-columns: 1fr; height: auto; }
  #map, #battle { max-height: none; }
  #side { border-left: 0; border-top: 1px solid var(--line); }
}
