:root {
  --bg: #14171b;
  --card: rgba(22, 25, 30, 0.94);
  --line: #2c3139;
  --text: #e6e8eb;
  --dim: #8c939c;
  --red: #e5484d;
  --acc: #ff7a1a;
  --r: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: #8fbfff; }
#map { position: absolute; inset: 0; }
#wind, #fx { position: absolute; inset: 0; pointer-events: none; width: 100%; height: 100%; }
.maplibregl-ctrl-attrib { background: rgba(20, 23, 27, 0.7) !important; color: var(--dim); }
.maplibregl-ctrl-attrib a { color: var(--dim); }

.clock, .tally, .layers, .legend, .panel { position: absolute; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(6px); }
.clock { top: 12px; left: 12px; padding: 8px 10px; z-index: 3; }
.clock .time { font: 600 22px/1.1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.5px; }
.speeds { display: flex; gap: 4px; margin-top: 6px; }
.speeds button { background: #22262d; border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; font-size: 12px; min-width: 30px; }
.speeds button.on { background: var(--acc); border-color: var(--acc); color: #111; font-weight: 600; }

.tally { top: 12px; left: calc((100% - 384px) / 2); transform: translateX(-50%); max-width: calc(100% - 384px - 24px); padding: 8px 14px; z-index: 3; text-align: center; font-size: 13px; display: none; }
@media (min-width: 761px) and (max-width: 1100px) { .tally { top: 96px; left: 12px; transform: none; text-align: left; } }
.tally.show { display: block; }
.tally b { font-size: 18px; color: var(--red); }
.tally .next { font: 600 20px/1.2 ui-monospace, Menlo, monospace; color: #ffb38a; }
.tally .next small { font: 13px -apple-system, sans-serif; color: var(--text); }
.tally .sub { color: var(--dim); }

.layers { left: 12px; bottom: 28px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; z-index: 3; }
.layers label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.layers button { background: none; border: 0; padding: 2px 0 0; text-align: left; color: #8fbfff; font-size: 13px; }
.legend { left: 12px; bottom: 150px; padding: 10px 12px; width: 300px; font-size: 12.5px; z-index: 4; max-height: 60vh; overflow: auto; }
.legend div { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; }
.legend i { flex: 0 0 14px; height: 14px; border-radius: 3px; margin-top: 1px; }

.panel { top: 12px; right: 12px; bottom: 12px; width: 360px; display: flex; flex-direction: column; z-index: 5; }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.tabs button { flex: 1; background: none; border: 0; padding: 11px 6px; color: var(--dim); font-weight: 600; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--acc); }
.tabs .fold { flex: 0 0 40px; display: none; }
.tab { overflow: auto; padding: 4px 14px 16px; flex: 1; }
.tab h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--dim); margin: 14px 0 6px; }
.hint { color: var(--dim); margin: 4px 0; }
.note { color: var(--dim); font-size: 12.5px; margin: 4px 0 0; min-height: 1em; }

.powers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.powers button { background: #20242a; border: 1px solid var(--line); border-radius: 8px; padding: 6px 4px; text-align: center; font-size: 13px; line-height: 1.2; }
.powers button small { display: block; color: var(--dim); font-size: 11px; }
.powers button.on { border-color: var(--pc); box-shadow: inset 0 0 0 1px var(--pc); background: color-mix(in srgb, var(--pc) 18%, #20242a); }
.carriers { display: flex; flex-direction: column; gap: 4px; }
.carriers button { display: flex; justify-content: space-between; gap: 8px; background: #20242a; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; text-align: left; }
.carriers button span { display: block; }
.carriers button small { display: block; color: var(--dim); font-size: 11.5px; margin-top: 2px; }
.carriers button .n { color: var(--dim); font-size: 12px; white-space: nowrap; }
.carriers button.on { border-color: var(--acc); background: #2a2520; }
.carriers button:disabled { opacity: 0.4; cursor: default; }
.row { margin-top: 10px; }
.row label { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--dim); }
.row select { flex: 1; max-width: 230px; background: #20242a; border: 1px solid var(--line); border-radius: 7px; padding: 6px; color: var(--text); }
.stepper { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.stepper button { width: 28px; height: 28px; background: #20242a; border: 1px solid var(--line); border-radius: 7px; }
.stepper b { min-width: 22px; text-align: center; }
.seg { display: flex; background: #20242a; border: 1px solid var(--line); border-radius: 8px; padding: 2px; margin-top: 6px; }
.seg button { flex: 1; background: none; border: 0; border-radius: 6px; padding: 6px 4px; color: var(--dim); font-size: 13px; }
.seg button.on { background: #343a43; color: var(--text); }
.targets { display: flex; flex-direction: column; gap: 4px; }
.targets .t { display: flex; align-items: center; gap: 8px; background: #20242a; border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.targets .t span { flex: 1; }
.targets .t small { color: var(--dim); }
.targets .rad { color: var(--dim); font-size: 12px; margin: 2px 0 4px; }
.targets .rad i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 3px 0 6px; vertical-align: -1px; }
.targets .t.bad { color: var(--dim); text-decoration: line-through; }
.targets .t button { background: none; border: 0; color: var(--dim); font-size: 16px; padding: 0 2px; }
.gobar { position: sticky; bottom: -16px; margin: 12px -14px 0; padding: 10px 14px 12px; background: #16191e; border-top: 1px solid var(--line); z-index: 2; }
.go { width: 100%; background: var(--red); border: 0; border-radius: 9px; padding: 12px; font-weight: 700; font-size: 16px; color: #fff; }
.go:disabled { background: #3a2426; color: #8c7f80; cursor: default; }
.all { width: 100%; margin-top: 8px; background: none; border: 1px solid #5a2a2c; color: #ff9a9d; border-radius: 9px; padding: 9px; font-weight: 600; }
.chk { display: flex; gap: 8px; align-items: center; margin-top: 12px; color: var(--dim); font-size: 13px; }
.reset { margin-top: 12px; background: none; border: 0; color: var(--dim); text-decoration: underline; padding: 0; }

.me button { width: 100%; margin-top: 10px; background: #20242a; border: 1px solid var(--line); border-radius: 9px; padding: 10px; font-weight: 600; }
#meCard { margin-top: 8px; }
.fate { background: #1c1f24; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font-size: 13px; }
.fate .big { font: 600 20px/1.2 ui-monospace, Menlo, monospace; }
.fate .sv { font-size: 18px; font-weight: 700; }
.fate p { margin: 4px 0; }
.incoming .i, .log .l { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px solid #22262c; font-size: 13px; cursor: pointer; }
.incoming .i b { font-family: ui-monospace, Menlo, monospace; min-width: 58px; color: var(--red); }
.incoming .i span { flex: 1; }
.incoming .i small, .log .l small { color: var(--dim); }
.log .l time { font-family: ui-monospace, Menlo, monospace; color: var(--dim); min-width: 58px; font-size: 12px; }
.log .l.burst span { color: #ffb38a; }
.log .l.decide span { color: #ff8b8e; font-weight: 600; }
.log .l.down span { color: #8fd0ff; }
.log .l.order span { color: var(--dim); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.stats div { background: #1c1f24; border-radius: 9px; padding: 8px 10px; }
.stats b { display: block; font-size: 19px; }
.stats small { color: var(--dim); font-size: 12px; }
.stats .wide { grid-column: span 2; }
.doom { margin-top: 10px; background: #2a1517; border: 1px solid #5a2a2c; border-radius: 9px; padding: 10px 12px; }
.doom b { font-size: 22px; color: #ff8b8e; }
table.cc { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
table.cc td { padding: 4px 2px; border-bottom: 1px solid #22262c; }
table.cc td:nth-child(n+2) { text-align: right; white-space: nowrap; }
table.cc td small { color: var(--dim); }
.src { padding-left: 18px; font-size: 12.5px; color: var(--dim); }
.src li { margin: 4px 0; }

.maplibregl-popup-content { background: #1c1f24; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; max-width: 290px; }
.maplibregl-popup-tip { border-top-color: #1c1f24 !important; border-bottom-color: #1c1f24 !important; }
.maplibregl-popup-close-button { color: var(--dim); font-size: 18px; }
.pop h4 { margin: 0 18px 4px 0; font-size: 15px; }
.pop p { margin: 4px 0; }
.pop .z { display: flex; gap: 6px; margin: 3px 0; }
.pop .z i { flex: 0 0 10px; height: 10px; border-radius: 2px; margin-top: 4px; }
.pop .acts { display: flex; gap: 6px; margin-top: 8px; }
.pop .acts button { flex: 1; white-space: nowrap; background: #2a2f37; border: 1px solid var(--line); border-radius: 7px; padding: 6px; font-size: 12.5px; }
.pop .acts button.red { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }

@media (max-width: 760px) {
  .clock { top: 8px; left: 8px; padding: 6px 8px; }
  .clock .time { font-size: 17px; }
  .speeds button { padding: 3px 5px; min-width: 0; font-size: 11px; }
  .tally { top: 84px; left: 8px; transform: none; padding: 5px 9px; font-size: 12px; }
  .tally b { font-size: 15px; }
  .layers { top: auto; right: 8px; left: auto; bottom: calc(46vh + 8px); padding: 5px 8px; font-size: 12px; gap: 2px; }
  .layers button { font-size: 12px; }
  body.folded .layers { bottom: 56px; }
  .legend { left: 8px; right: 8px; width: auto; top: 90px; bottom: auto; }
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 46vh; border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .panel.folded { height: auto; }
  .panel.folded .tab { display: none; }
  .tabs .fold { display: block; }
  .maplibregl-ctrl-bottom-right { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
