:root {
  --bg: #0b0d12; --panel: #13161d; --panel2: #1a1e27; --line: #272c37; --text: #e6e8ec;
  --muted: #8a909c; --accent: #f59e0b; --go: #22c55e; --bad: #ef4444; --warn: #eab308;
  --radius: 12px; --nav: 64px; --top: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

.btn { white-space: nowrap; border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 9px 14px; }
.btn:hover { border-color: #3a404d; }
.btn.primary { background: var(--go); border-color: var(--go); color: #06210f; font-weight: 600; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #241500; font-weight: 600; }
.btn.danger { border-color: #5b2323; color: #fca5a5; }
.btn.good { border-color: #1f5132; color: #86efac; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 40px; height: 40px; padding: 0; display: inline-grid; place-items: center; }
.btn:disabled { opacity: .45; cursor: default; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
input[type=color] { padding: 2px; height: 40px; width: 56px; }
input[type=checkbox] { width: auto; }
textarea { min-height: 80px; resize: vertical; }
label.f { display: block; }
label.f > span { display: block; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.badge.open { color: var(--accent); border-color: #5a3b06; }
.badge.success, .badge.running { color: #86efac; border-color: #1f5132; }
.badge.failed, .badge.paused { color: #fca5a5; border-color: #5b2323; }
.badge.reported_success, .badge.reported_failed, .badge.countdown { color: #fde68a; border-color: #5a4a06; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; }
.err { color: #fca5a5; font-size: 13.5px; min-height: 18px; }

/* --- splash screens (language, login) --- */
.splash { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.splash .box { width: 100%; max-width: 420px; text-align: center; }
.logo { width: 84px; height: 84px; border-radius: 22px; background: var(--panel2); border: 1px solid var(--line);
  display: inline-grid; place-items: center; margin-bottom: 18px; }
.logo svg { width: 52px; height: 52px; }
.splash h1 { font-size: 22px; margin: 0 0 4px; }
.splash .sub { color: var(--muted); margin: 0 0 22px; }
.choice { display: block; width: 100%; padding: 16px; margin-bottom: 12px; font-size: 18px; font-weight: 600;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.splash form { text-align: left; }
.langrow { display: flex; gap: 8px; justify-content: center; margin-bottom: 18px; }
.langrow .btn.on { border-color: var(--accent); color: var(--accent); }

/* --- player app shell --- */
.app { position: fixed; inset: 0; }
.topbar { position: absolute; top: 0; left: 0; right: 0; height: calc(var(--top) + var(--safe-t)); padding: var(--safe-t) 12px 0;
  display: flex; align-items: center; gap: 8px; background: rgba(11,13,18,.92); border-bottom: 1px solid var(--line); z-index: 1000; }
.topbar .who { flex: 1; min-width: 0; line-height: 1.15; }
.topbar .logo svg { width: 24px; height: 24px; }
.topbar .who small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who small { color: var(--muted); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); display: inline-block; }
.dot.on { background: var(--go); }
#map { position: absolute; z-index: 0; top: calc(var(--top) + var(--safe-t)); bottom: calc(var(--nav) + var(--safe-b)); left: 0; right: 0; background: #0f1218; }
.panel { position: absolute; top: calc(var(--top) + var(--safe-t)); bottom: calc(var(--nav) + var(--safe-b)); left: 0; right: 0;
  background: var(--bg); overflow-y: auto; padding: 14px 16px 24px; z-index: 900; }
.panel h2 { font-size: 18px; margin: 4px 0 14px; }
.nav { position: absolute; bottom: 0; left: 0; right: 0; height: calc(var(--nav) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(6, 1fr); background: var(--panel); border-top: 1px solid var(--line); z-index: 1000; }
.nav button { background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; font-size: 11px; position: relative; padding: 0; }
.nav button svg { width: 22px; height: 22px; }
.nav button.on { color: var(--accent); }
.nav .count { position: absolute; top: 6px; left: calc(50% + 6px); background: var(--bad); color: #fff; font-size: 10.5px;
  border-radius: 99px; min-width: 17px; height: 17px; padding: 0 4px; display: grid; place-items: center; font-weight: 700; }
.mapctl { position: absolute; right: 12px; z-index: 950; display: flex; flex-direction: column; gap: 8px;
  top: calc(var(--top) + var(--safe-t) + 12px); }
.mapctl .btn { background: rgba(19,22,29,.92); }
.banner { position: absolute; left: 12px; right: 64px; top: calc(var(--top) + var(--safe-t) + 12px); z-index: 950;
  padding: 10px 14px; border-radius: 12px; font-weight: 700; text-align: center; letter-spacing: .04em; }
.banner.paused { background: #7f1d1d; color: #fff; }
.banner.ended, .banner.lobby { background: var(--panel2); border: 1px solid var(--line); }
.overlay { position: fixed; inset: 0; background: rgba(5,6,9,.94); z-index: 3000; display: grid; place-items: center; text-align: center; padding: 24px; }
.overlay .big { font-size: 84px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent); }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; max-width: 360px; width: 100%; }
.modal img { width: 100%; background: #fff; border-radius: 10px; }
.toast:nth-last-child(n+3) { display: none; }
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav) + var(--safe-b) + 8px); z-index: 4000; display: grid; gap: 8px; pointer-events: none; }
.toast { background: var(--panel2); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  pointer-events: auto; animation: drop .2s ease-out; }
.toast b { color: var(--accent); display: block; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
@keyframes drop { from { transform: translateY(-8px); opacity: 0; } }

/* lists */
.item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.item .head { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.item h3 { margin: 0; font-size: 16px; }
.item p { margin: 8px 0 0; white-space: pre-wrap; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.scoreline { display: flex; align-items: center; gap: 12px; padding: 14px; }
.scoreline .pts { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.scoreline.mine { border-color: var(--accent); }

/* chat */
.chlist .ch { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.ch .unread { margin-left: auto; background: var(--accent); color: #241500; border-radius: 99px; font-size: 12px; font-weight: 700; padding: 1px 8px; }
.chatview { display: flex; flex-direction: column; height: 100%; }
.chatview .msgs { flex: 1; overflow-y: auto; padding: 4px 0 8px; }
.msg { margin: 6px 0; max-width: 85%; }
.msg .bub { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px 12px 12px 4px; padding: 7px 11px; display: inline-block; white-space: pre-wrap; word-break: break-word; }
.msg.mine { margin-left: auto; text-align: right; }
.msg.mine .bub { background: #3a2a07; border-color: #5a3b06; border-radius: 12px 12px 4px 12px; text-align: left; }
.msg.hq .bub { border-color: var(--accent); }
.msg .meta { font-size: 11.5px; color: var(--muted); margin: 0 4px 2px; }
.quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; }
.quick .btn { white-space: nowrap; }
.chatpanel { display: flex; flex-direction: column; padding-bottom: 10px; }

/* leaflet markers */
.pmark { background: none; border: 0; }
.pdot { position: absolute; left: 0; top: 0; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.4); }
.pdot.me { width: 18px; height: 18px; left: -2px; top: -2px; box-shadow: 0 0 0 6px rgba(245,158,11,.35); }
.ppin { position: absolute; left: 0; top: 0; width: 18px; height: 18px; transform: rotate(45deg); border: 3px solid; background: rgba(0,0,0,.55); border-radius: 3px; }
.plabel { position: absolute; left: 20px; top: -3px; white-space: nowrap; font-size: 12px; font-weight: 700; color: #fff;
  text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 3px #000; }
.stale .pdot { opacity: .45; }
.leaflet-container { background: #0f1218; font: inherit; }

/* --- HQ --- */
.hq { display: grid; grid-template-columns: 540px 1fr; height: 100vh; }
.hq aside { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.hq aside header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.hq .tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.hq .tabs button { background: none; border: 1px solid transparent; border-radius: 8px; padding: 6px 9px; color: var(--muted); font-size: 13.5px; }
.hq .tabs button.on { border-color: var(--line); background: var(--panel2); color: var(--text); }
.hq .body { overflow-y: auto; padding: 14px; flex: 1; }
.hq .body h3 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.hq .body h3:first-child { margin-top: 0; }
.hq #hqmap { height: 100vh; position: relative; }
.tree .fac { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; background: var(--bg); }
.tree .pl { margin: 8px 0 0 14px; }
.tree .tm { margin: 6px 0 0 14px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.grid th { color: var(--muted); font-weight: 600; font-size: 12px; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; }
.hqchat .msgs { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; background: var(--bg); }
.checks { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg); }
.checks label { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
.maphint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 900; background: var(--accent); color: #241500;
  font-weight: 700; padding: 8px 14px; border-radius: 10px; }

/* print cards */
.cards { display: none; }
@media print {
  body > *:not(.cards) { display: none !important; }
  .cards { display: grid !important; grid-template-columns: repeat(3, 1fr); gap: 6mm; background: #fff; color: #000; }
  .pcard { border: 1px dashed #999; border-radius: 4mm; padding: 4mm; text-align: center; break-inside: avoid; }
  .pcard img { width: 48mm; height: 48mm; }
  .pcard .fac { font-weight: 800; font-size: 14pt; padding: 2mm; border-radius: 2mm; color: #fff; }
  /* player ID cards: 54 x 85.6 mm, 3 x 3 per A4 page, dashed lines to cut along */
  @page { size: A4 portrait; margin: 10mm; }
  html, body { background: #fff !important; }
  .cards.idcards { display: block !important; }
  .idpage { display: grid; grid-template-columns: repeat(3, 54mm); grid-auto-rows: 85.6mm; justify-content: center;
    break-after: page; page-break-after: always; }
  .idpage:last-child { break-after: auto; page-break-after: auto; }
  .idcard { box-sizing: border-box; width: 54mm; height: 85.6mm; border: 0.2mm dashed #888; padding: 3mm 3mm 2mm;
    display: flex; flex-direction: column; align-items: center; text-align: center; overflow: hidden; break-inside: avoid;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .idcard img { width: 44mm; height: 44mm; display: block; }
  .idcard .cs { font-size: 15pt; font-weight: 900; margin-top: 1.5mm; line-height: 1.1; min-height: 7mm; max-width: 48mm;
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .idcard .cs.blank { border-bottom: 0.3mm solid #000; width: 40mm; }
  .idcard .unit { font-size: 7.5pt; color: #333; margin-top: 1mm; min-height: 3.5mm; }
  .idcard .fac { margin-top: auto; width: 100%; box-sizing: border-box; font-weight: 900; font-size: 13pt; color: #fff;
    padding: 1.5mm; border-radius: 1.5mm; }
  .idcard .code { font-family: ui-monospace, monospace; font-size: 7pt; color: #555; margin-top: 1mm; letter-spacing: .1em; }
}
@media (max-width: 900px) { .hq { grid-template-columns: 1fr; } .hq #hqmap { height: 60vh; } }

/* artillery */
.arty { position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; border: 3px solid #ef4444;
  background: radial-gradient(circle, #ef4444 0 3px, transparent 4px), rgba(239,68,68,.15); animation: pulse 1.4s infinite; }
.arty + .plabel { left: 32px; top: 4px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(239,68,68,.15); } }
.hit { background: rgba(127,29,29,.97); }
.hit h1 { font-size: 30px; line-height: 1.15; margin: 0 0 14px; color: #fff; letter-spacing: .03em; }
.hit p { font-size: 18px; color: #fecaca; margin: 0 0 28px; }
.hit .btn { background: #fff; color: #7f1d1d; border-color: #fff; font-weight: 700; padding: 14px 28px; font-size: 17px; }
.btn.arty-on { background: #7f1d1d; border-color: #ef4444; color: #fff; }
.placing-hint { position: absolute; left: 12px; right: 64px; top: calc(var(--top) + var(--safe-t) + 12px); z-index: 960;
  background: #7f1d1d; color: #fff; padding: 10px 14px; border-radius: 12px; font-weight: 700; text-align: center; }
.badge.pending { color: #fca5a5; border-color: #5b2323; }
.badge.executed { color: #86efac; border-color: #1f5132; }
.nearlist label { display: flex; gap: 10px; align-items: center; padding: 6px 2px; border-bottom: 1px solid var(--line); }

/* scanner */
.scanbox { position: relative; width: 100%; aspect-ratio: 1; max-height: 52vh; background: #000; border-radius: 14px; overflow: hidden; }
.scanvideo { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanframe { position: absolute; inset: 18%; border: 3px solid rgba(245,158,11,.9); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); }
.bigcount { font-size: 96px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; color: var(--accent); line-height: 1; }
.result { border-radius: 16px; padding: 22px 16px; text-align: center; font-weight: 800; font-size: 22px; }
.result.good { background: #14532d; color: #dcfce7; }
.result.bad { background: #7f1d1d; color: #fee2e2; }
.result.warn { background: #713f12; color: #fef3c7; }
.result small { display: block; font-weight: 500; font-size: 15px; margin-top: 8px; opacity: .9; }

/* top bar chips */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 9px; border-radius: 99px; background: var(--panel2);
  border: 1px solid var(--line); font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; }
.chip.lives { color: #fca5a5; }
.chip.lives.zero { background: #7f1d1d; color: #fff; border-color: #ef4444; }
.chip.stock { color: #86efac; }
.btn.sos { background: #b91c1c; border-color: #ef4444; color: #fff; font-weight: 800; padding: 0 10px; height: 40px; }
.outbar { position: absolute; left: 0; right: 0; top: calc(var(--top) + var(--safe-t)); z-index: 960; background: #7f1d1d; color: #fff;
  text-align: center; font-weight: 800; padding: 8px; letter-spacing: .02em; }
.ceasefire { background: rgba(127,29,29,.97); z-index: 3500; }
.ceasefire h1 { font-size: 40px; margin: 0; color: #fff; letter-spacing: .05em; }
.ceasefire p { color: #fecaca; font-size: 18px; }
.jam { position: absolute; top: calc(var(--top) + var(--safe-t)); bottom: calc(var(--nav) + var(--safe-b)); left: 0; right: 0; z-index: 940;
  display: grid; place-items: center; text-align: center; color: #fde68a; font-weight: 800; font-size: 22px;
  background: repeating-linear-gradient(0deg, rgba(20,20,20,.97) 0 2px, rgba(40,40,40,.97) 2px 4px); }
.nav { grid-template-columns: repeat(var(--tabs, 6), 1fr); }
.nav button { font-size: 10.5px; }

/* sites on the map */
.sicon { position: absolute; left: 0; top: 0; width: 26px; height: 26px; display: grid; place-items: center; }
.sicon.victory { border-radius: 4px; transform: rotate(45deg); border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.5); }
.sicon.respawn { border-radius: 50%; border: 3px solid; background: rgba(0,0,0,.6); color: #fff; font-weight: 900; font-size: 20px; line-height: 1; }
.slabel { left: 30px; top: 4px; }
.capturing .sicon.victory { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.leaflet-popup-content { font: 14px/1.4 system-ui, sans-serif; }
.leaflet-popup-content .btn { color: #e6e8ec; }
.menu .btn { width: 100%; justify-content: flex-start; text-align: left; margin-bottom: 8px; }
.kindrow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.kindrow button { padding: 8px 4px; border-radius: 10px; border: 2px solid transparent; background: var(--panel2); font-size: 12px; color: var(--text); }
.kindrow button.on { border-color: var(--accent); }
.kindrow i { display: block; width: 16px; height: 16px; border-radius: 4px; margin: 0 auto 4px; }
.pts-big { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cat { display: flex; align-items: center; gap: 10px; }
.cat .cost { font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.badge.scheduled, .badge.approved { color: #fde68a; border-color: #5a4a06; }
.badge.done { color: #86efac; border-color: #1f5132; }
.badge.rejected, .badge.cancelled { color: #fca5a5; border-color: #5b2323; }

/* push-notification hint bar */
.pushbar { position: fixed; left: 8px; right: 8px; top: calc(env(safe-area-inset-top) + 58px); z-index: 900;
  display: flex; gap: 8px; align-items: center; background: #1e293b; border: 1px solid #f59e0b; color: #fde68a;
  border-radius: 10px; padding: 10px 12px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }

/* bomb sites, players who left the game, readiness */
.sicon.bomb { border-radius: 50%; border: 3px solid; background: rgba(0,0,0,.75); font-size: 14px; line-height: 1; }
.sicon.bomb.armed { background: #b91c1c; animation: blink .6s infinite; }
.sicon.bomb.exploded { background: #111; opacity: .6; }
.out .pdot { background: #9ca3af !important; opacity: .6; }
.out .plabel { opacity: .6; text-decoration: line-through; }
.chip.out { background: #374151; color: #e5e7eb; }
.ready-list { display: grid; gap: 8px; }
.ready-list .r { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 4px 10px; padding: 10px 12px;
  border-radius: 10px; background: var(--panel2); min-width: 0; }
.ready-list .r > .small { grid-column: 2 / -1; grid-row: 2; overflow-wrap: anywhere; }
.ready-list .r > button { grid-column: 3; grid-row: 1; }
.ready-list .ok { color: #86efac; } .ready-list .bad { color: #fca5a5; } .ready-list .warn { color: #fde68a; }
.progress { height: 10px; border-radius: 99px; background: var(--panel2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.cfack { margin-top: 14px; }
.replaybar { position: absolute; left: 12px; right: 12px; bottom: 26px; z-index: 900; background: rgba(11,13,18,.92);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; }
.replaybar input[type=range] { flex: 1; }
.alarmline { color: #fca5a5; font-weight: 700; }
