:root {
  color-scheme: dark;
  --bg: #091012;
  --panel: #121e20;
  --panel-2: #18292b;
  --line: #345052;
  --text: #e7eee8;
  --muted: #9eb2ab;
  --acid: #c3f23b;
  --orange: #f29d38;
  --danger: #ef5b5b;
  --cell: 70px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 50% -30%, #284041, var(--bg) 45%); color: var(--text); }
button, select { font: inherit; }
button { cursor: pointer; border: 1px solid var(--line); border-radius: 8px; padding: .65rem .8rem; color: var(--text); background: #1b3032; transition: background .15s, transform .15s; }
button:hover:not(:disabled) { background: #28464a; transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .45; }
button.primary { background: #9ecb26; color: #102000; border-color: #c9f555; font-weight: 800; }
button.primary:hover:not(:disabled) { background: var(--acid); }
button.secondary { width: 100%; margin-top: .9rem; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem clamp(1rem, 3vw, 3rem); border-bottom: 1px solid var(--line); background: rgba(8, 16, 18, .85); }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.35rem, 3vw, 2rem); letter-spacing: .03em; }
h2 { margin-bottom: .75rem; font-size: 1rem; }
.eyebrow { color: var(--acid); text-transform: uppercase; letter-spacing: .16em; font-size: .67rem; margin-bottom: .15rem; }
.turn-status { color: var(--acid); font-weight: 700; text-align: right; }

.layout { display: grid; grid-template-columns: minmax(190px, 260px) minmax(0, 1fr) minmax(220px, 300px); gap: 1rem; padding: 1rem; max-width: 1800px; margin: 0 auto; }
.sidebar { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.panel { background: linear-gradient(145deg, rgba(25, 43, 45, .96), rgba(14, 26, 28, .96)); border: 1px solid var(--line); border-radius: 12px; padding: .95rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.setup-panel { display: grid; gap: .65rem; }
.setup-panel label, .hint { color: var(--muted); font-size: .82rem; }
.setup-panel select { border: 1px solid var(--line); border-radius: 8px; padding: .55rem; background: #0d191a; color: var(--text); }
.hint { line-height: 1.35; }

.board-area { min-width: 0; }
.board-toolbar { display: flex; align-items: stretch; gap: .65rem; margin-bottom: .8rem; }
.message { flex: 1; min-height: 2.5rem; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: .55rem .8rem; color: var(--muted); background: rgba(10, 23, 24, .7); }
.message.error { border-color: var(--danger); color: #ffc2c2; }
.zoom-controls { display: flex; gap: .35rem; }
.zoom-controls button { min-width: 2.5rem; padding-inline: .55rem; }
#zoom-reset { min-width: 4.4rem; font-size: .8rem; }
.board-viewport { --zoom: 1; min-height: 420px; max-height: calc(100vh - 185px); overflow: auto; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #071011; overscroll-behavior: contain; }
.board { display: grid; grid-template-columns: repeat(var(--columns, 8), calc(var(--cell) * var(--zoom))); gap: calc(4px * var(--zoom)); width: max-content; min-width: 100%; padding: calc(6px * var(--zoom)); }
.cell { position: relative; display: grid; place-items: center; width: calc(var(--cell) * var(--zoom)); height: calc(var(--cell) * var(--zoom)); min-width: 34px; min-height: 34px; overflow: hidden; border: 1px solid #274143; border-radius: 7px; background: linear-gradient(135deg, #274d42, #18352e); color: #dff0c5; font-size: .72rem; }
.cell--blocked { background: repeating-linear-gradient(135deg, #303738, #303738 6px, #202829 6px, #202829 12px); color: #728281; }
.cell--bunker { box-shadow: inset 0 0 0 2px var(--orange); }
.cell--reachable { cursor: pointer; border-color: var(--acid); box-shadow: inset 0 0 0 1px rgba(195, 242, 59, .6), 0 0 10px rgba(195, 242, 59, .15); }
.cell--reachable:hover { background: linear-gradient(135deg, #48764a, #264c36); transform: translateY(-1px); }
.cell__coord { position: absolute; top: 3px; left: 4px; font-size: .56rem; color: rgba(230, 255, 225, .65); }
.cell__tokens { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; padding: 10px 3px 3px; }
.token { display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid rgba(255,255,255,.55); border-radius: 50%; color: #0d1718; font-size: .67rem; font-weight: 900; }
.token--active { outline: 2px solid var(--acid); outline-offset: 2px; }
.token--capsule { border-radius: 4px; background: var(--orange); }

.move-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.move-controls button[data-direction="up"] { grid-column: 2; }
.move-controls button[data-direction="left"] { grid-column: 1; grid-row: 2; }
.move-controls button[data-direction="down"] { grid-column: 2; grid-row: 2; }
.move-controls button[data-direction="right"] { grid-column: 3; grid-row: 2; }

.player-card { border-top: 1px solid var(--line); padding: .65rem 0; }
.player-card:first-child { border-top: 0; padding-top: 0; }
.player-card--active .player-card__name { color: var(--acid); }
.player-card--dead { opacity: .55; }
.player-card__name { font-weight: 800; }
.player-card__stats, .player-card__meta { margin-top: .25rem; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.deck-row { display: flex; justify-content: space-between; gap: .7rem; padding: .34rem 0; border-top: 1px solid rgba(52,80,82,.65); color: var(--muted); font-size: .82rem; }
.deck-row:first-child { border-top: 0; }
.deck-row strong { color: var(--text); }
.log-panel { min-height: 260px; }
#log { display: grid; gap: .5rem; max-height: 50vh; overflow: auto; padding: 0; margin: 0; list-style: none; }
#log li { padding-left: .65rem; border-left: 2px solid var(--line); color: var(--muted); font-size: .76rem; line-height: 1.35; }

@media (max-width: 1000px) { .layout { grid-template-columns: minmax(180px, 240px) minmax(0, 1fr); } .right-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; } }
@media (max-width: 680px) { :root { --cell: 56px; } .topbar { align-items: flex-start; flex-direction: column; } .turn-status { text-align: left; } .layout { grid-template-columns: 1fr; } .left-panel, .right-panel { display: grid; grid-template-columns: 1fr; } .right-panel { grid-column: auto; } .board-toolbar { align-items: stretch; flex-direction: column; } .zoom-controls { justify-content: flex-end; } .board-viewport { min-height: 55vh; max-height: 65vh; } }
