:root { color-scheme: dark; --bg: #06121c; --card: #0c1c29; --card2: #12283a; --line: #1d3a50; --ink: #e8f4f8; --muted: #8fb0c0; --accent: #2dd4bf; --accent2: #22d3ee; --bad: #f87171; --warn: #fbbf24; --blue: #60a5fa; --amber: #fbbf24;
  --cw: #f87171; --cd: #4ade80; --cx: #facc15; --cr: #94a3b8; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; background: radial-gradient(1200px 520px at 50% -220px, #0b3a4a 0%, transparent 70%), linear-gradient(#06121c, #040b12); }
body.fl-hurt { animation: hurt .7s ease-out; }
body.fl-hit { animation: hitfx .7s ease-out; }
@keyframes hurt { 0% { box-shadow: inset 0 0 0 100vmax rgba(248,113,113,.35); } 100% { box-shadow: inset 0 0 0 100vmax rgba(248,113,113,0); } }
@keyframes hitfx { 0% { box-shadow: inset 0 0 0 100vmax rgba(45,212,191,.25); } 100% { box-shadow: inset 0 0 0 100vmax rgba(45,212,191,0); } }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); font-weight: 500; }
.sm { font-size: 13.5px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 6px; }
.back-link { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back-link:hover { color: var(--ink); }
.app { width: min(560px, 100%); margin: 0 auto; padding: 4px 14px calc(env(safe-area-inset-bottom, 0px) + 110px); }
.app.wide { width: min(1120px, 100%); }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
h3 { font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 4px; }
.btn { appearance: none; font: inherit; font-weight: 700; color: var(--ink); background: var(--card2); border: 1px solid var(--line); border-radius: 14px; min-height: 46px; padding: 0 16px; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.btn:hover:not(:disabled) { border-color: #2d5876; background: #173349; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 999px; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.pri { background: var(--accent); color: #032a26; border-color: var(--accent); }
.btn.pri:hover:not(:disabled) { background: #5eead4; }
.btn.big { min-height: 56px; font-size: 17px; width: 100%; border-radius: 16px; }
.btn.on { border-color: var(--accent); background: #0f3b3b; color: #ccfbf1; }
.btn.warnb { color: var(--warn); }
.link { background: none; border: 0; padding: 6px 0; font: inherit; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; }
.row { display: flex; gap: 10px; }
.row2 { display: flex; gap: 8px; flex-wrap: wrap; }
.row2 > .btn { flex: 1 1 auto; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: grid; gap: 10px; margin-bottom: 12px; }
.panel.center { text-align: center; justify-items: center; }
.fld { display: grid; gap: 6px; }
.fld span { font-size: 13px; color: var(--muted); font-weight: 600; }
input { font: inherit; font-size: 18px; color: var(--ink); background: #030a10; border: 1px solid var(--line); border-radius: 14px; min-height: 52px; padding: 0 14px; width: 100%; }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input.code { text-transform: uppercase; letter-spacing: .3em; font-weight: 800; text-align: center; flex: 1; min-width: 0; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.err { color: var(--bad); margin: 0; font-weight: 600; }
.warn { color: var(--warn); margin: 0; font-weight: 600; font-size: 14px; }
.foot { color: var(--muted); font-size: 13.5px; text-align: center; }
.hero { text-align: center; padding: 6px 0 14px; }
.hero h1 { font-size: 34px; margin-top: 2px; background: linear-gradient(90deg, #5eead4, #22d3ee); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .tag { color: var(--muted); margin: 8px auto 0; max-width: 440px; }
.logo svg { filter: drop-shadow(0 6px 18px rgba(45,212,191,.25)); animation: bob 4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(4px); } }
.solo { grid-template-columns: 1fr; }
.solo p { margin: 4px 0 0; }
.roombar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.roombar .rc { flex: 1; color: var(--muted); }
.roombar .rc b { color: var(--ink); letter-spacing: .12em; }
.roombar .off { color: var(--warn); font-size: 13px; }
.codebox { text-align: center; padding: 6px 0 12px; }
.codebox .lbl { margin: 0; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .1em; }
.bigcode { margin: 2px 0; font-size: 46px; font-weight: 900; letter-spacing: .18em; color: #ccfbf1; }
.codebox .hint { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .teams { gap: 8px; } .tcard { padding: 12px; } }
.tcard h3 .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tcard.blue { border-color: #1e4a7a; } .tcard.blue .dot { background: var(--blue); }
.tcard.amber { border-color: #6b4d12; } .tcard.amber .dot { background: var(--amber); }
.names { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.names li { display: grid; font-weight: 600; overflow-wrap: anywhere; }
.names li small { color: var(--muted); font-weight: 500; font-size: 12px; }
.names i { color: var(--muted); font-weight: 500; font-size: 13px; }
.names i.h { color: var(--accent); }
.seg { display: flex; gap: 6px; background: #030a10; border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.seg.wrap { flex-wrap: wrap; }
.segb { flex: 1 1 auto; appearance: none; font: inherit; font-weight: 700; font-size: 14px; color: var(--muted); background: transparent; border: 0; border-radius: 10px; min-height: 40px; padding: 0 10px; cursor: pointer; }
.segb[aria-pressed="true"] { background: var(--card2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); }
.segb:disabled { cursor: default; }
.wait { text-align: center; color: var(--muted); }
/* HUD */
.hud { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 8px 12px; margin-bottom: 6px; }
.hs { display: grid; gap: 3px; font-size: 12.5px; font-weight: 700; }
.hs.r { justify-items: end; text-align: right; }
.hs.blue .hn { color: var(--blue); } .hs.amber .hn { color: var(--amber); }
.hull { display: inline-flex; gap: 3px; }
.hull i { width: 16px; height: 9px; border-radius: 3px; background: #2a1414; border: 1px solid #5b2020; }
.hull i.on { background: var(--accent); border-color: var(--accent); }
.hmid { text-align: center; font-size: 14px; color: var(--muted); }
.hmid .you { color: var(--accent); font-size: 16px; }
.hmid .live { color: #4ade80; }
.mystation { margin: 2px 0 8px; font-size: 13px; color: var(--muted); text-align: center; }
.mystation.blue { color: #93c5fd; } .mystation.amber { color: #fcd34d; }
.feed { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.feed li { font-size: 14px; padding: 6px 10px; border-radius: 10px; background: #081622; border-left: 3px solid var(--line); }
.feed li.them { border-left-color: #f59e0b; }
.feed li.us { border-left-color: var(--accent); color: #b8d8e2; }
.feed li.k-torp, .feed li.k-det { background: #2a1010; }
.feed li:first-child { font-weight: 600; }
.radio .feed { max-height: 260px; overflow-y: auto; }
.note { margin: 0 0 10px; padding: 8px 12px; border-radius: 12px; background: #3a2a06; color: #fde68a; font-weight: 600; font-size: 14px; text-align: center; }
.note[hidden] { display: none; }
.cols { display: grid; gap: 0 14px; }
@media (min-width: 900px) { .cols { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; } }
/* Map */
.map { width: 100%; max-width: 520px; display: block; margin: 0 auto 10px; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.map.tap { cursor: crosshair; }
.map .sea { fill: #0a2a3d; stroke: #1d4a63; stroke-width: 1; }
.map .gl { stroke: #12405a; stroke-width: .5; }
.map .sl { stroke: #2b6a8a; stroke-width: 1.2; }
.map .secn { fill: #1b5674; font-size: 46px; font-weight: 900; text-anchor: middle; opacity: .45; pointer-events: none; }
.map .lab { fill: #6c93a8; font-size: 9px; font-weight: 700; text-anchor: middle; }
.map .lab.r { text-anchor: end; }
.map .isl { fill: #c8a96a; stroke: #8a6d33; stroke-width: 1; }
.map .hi { fill: rgba(45,212,191,.22); stroke: rgba(45,212,191,.7); stroke-width: 1; }
.map .hi.red { fill: rgba(248,113,113,.18); stroke: rgba(248,113,113,.6); }
.map .hisec { fill: rgba(251,191,36,.12); stroke: #fbbf24; stroke-width: 2; stroke-dasharray: 5 4; }
.map .wake { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; opacity: .7; }
.map .wake.blue, .map .wdot.blue { stroke: #60a5fa; fill: #60a5fa; }
.map .wake.amber, .map .wdot.amber { stroke: #fbbf24; fill: #fbbf24; }
.map .wake { fill: none !important; }
.map .mine { fill: #f472b6; stroke: #500724; stroke-width: 1; }
.map .subme ellipse, .map .subme rect { fill: #e8f4f8; }
.map .subme.blue ellipse, .map .subme.blue rect { fill: #93c5fd; }
.map .subme.amber ellipse, .map .subme.amber rect { fill: #fcd34d; }
.map .subme .halo { fill: none; stroke: #e8f4f8; stroke-width: 1.2; opacity: .8; animation: sonar 2.2s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes sonar { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(1.8); opacity: 0; } }
.map .trace { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 2 4; }
.map .trace.ok { stroke: #4ade80; } .map .trace.bad { stroke: #f87171; }
.map .tdot.ok { fill: #4ade80; } .map .tdot.bad { fill: #f87171; }
.map .tdot.end { fill-opacity: .35; stroke-width: 2; }
.map .tdot.end.ok { stroke: #4ade80; } .map .tdot.end.bad { stroke: #f87171; }
.map .tbad { stroke: #f87171; stroke-width: 2.5; }
.map .pmark { stroke: #fda4af; stroke-width: 2.4; stroke-linecap: round; opacity: .9; }
.map .selx circle { fill: none; stroke: #fff; stroke-width: 2; }
.map .selx path { stroke: #fff; stroke-width: 2; }
.map .boomring { fill: none; stroke: #fb923c; stroke-width: 2; opacity: 0; animation: boom 1.4s ease-out 2; transform-box: fill-box; transform-origin: center; }
.map .boomcore { fill: #fb923c; opacity: .5; }
@keyframes boom { 0% { transform: scale(.2); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
/* Helm */
.pad { display: grid; grid-template-columns: repeat(3, minmax(64px, 84px)); grid-template-rows: repeat(3, 60px); gap: 6px; justify-content: center; }
.pad .dir { display: grid; place-items: center; font-size: 20px; padding: 0; line-height: 1; border-radius: 16px; }
.pad .dir small { font-size: 11px; color: var(--muted); }
.pad .d0 { grid-column: 2; grid-row: 1; } .pad .d3 { grid-column: 1; grid-row: 2; } .pad .d1 { grid-column: 3; grid-row: 2; } .pad .d2 { grid-column: 2; grid-row: 3; }
.pad .padc { grid-column: 2; grid-row: 2; display: grid; place-items: center; font-size: 26px; border-radius: 50%; background: #030a10; border: 1px solid var(--line); }
.pad .dir:not(:disabled) { background: linear-gradient(#16405a, #0f2c40); border-color: #2b6a8a; }
.pad .dir.silm:not(:disabled) { background: linear-gradient(#3b3510, #2a250a); border-color: #a16207; }
.silrow { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; }
.silrow span { color: var(--muted); font-size: 14px; }
.silrow .btn { min-width: 46px; }
.waiting { margin: 0; text-align: center; color: var(--warn); font-size: 14px; font-weight: 600; }
.need { font-size: 12px; font-weight: 800; color: #032a26; background: var(--accent); border-radius: 999px; padding: 2px 8px; animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .55; } }
/* Systems */
.syslist { display: grid; gap: 6px; }
.sys { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.sysb { appearance: none; font: inherit; color: var(--ink); background: #081622; border: 1px solid var(--line); border-radius: 12px; min-height: 46px; padding: 6px 10px; display: grid; grid-template-columns: 26px 1fr auto auto; align-items: center; gap: 8px; text-align: left; cursor: pointer; }
.sysb:disabled { cursor: default; }
.sysb:not(:disabled) { border-color: var(--accent); background: #0b2a2e; }
.sys .si { font-size: 18px; }
.sys .sn { font-weight: 700; font-size: 14px; }
.sys .pips { display: inline-flex; gap: 3px; }
.sys .pips i { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid #3b5d70; }
.sys.c-w .pips i.on { background: var(--cw); border-color: var(--cw); }
.sys.c-d .pips i.on { background: var(--cd); border-color: var(--cd); }
.sys.c-x .pips i.on { background: var(--cx); border-color: var(--cx); }
.sys .plus { font-size: 12px; font-weight: 800; color: var(--accent); }
.sys.rdy .sysb { box-shadow: inset 3px 0 0 var(--accent); }
.sys.blk .sysb { box-shadow: inset 3px 0 0 var(--bad); opacity: .75; }
.sys .st { font-size: 12px; color: var(--muted); min-width: 64px; text-align: center; }
.sys .btn.sm { min-width: 76px; }
.hint2 { margin: 0; color: var(--muted); font-size: 14px; }
.secs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
/* Engineering */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ecol { display: grid; gap: 5px; padding: 6px; border-radius: 12px; border: 1px solid transparent; }
.ecol.need { border-color: var(--accent); background: #0b2a2e; }
.ecol .eh { text-align: center; font-weight: 800; color: var(--muted); }
.slot { position: relative; appearance: none; font: inherit; font-size: 17px; min-height: 40px; border-radius: 10px; border: 1.5px solid #27465a; background: #081622; color: var(--ink); cursor: pointer; padding: 0; }
.slot:disabled { cursor: default; }
.slot.c-w { color: var(--cw); } .slot.c-d { color: var(--cd); } .slot.c-x { color: var(--cx); } .slot.c-r { color: var(--cr); }
.slot.cir { border-style: solid; border-width: 2px; }
.slot.cir0 { border-color: #f97316; } .slot.cir1 { border-color: #38bdf8; } .slot.cir2 { border-color: #c084fc; }
.slot sub { position: absolute; right: 4px; bottom: 2px; font-size: 9px; color: var(--muted); }
.ecol.need .slot:not(:disabled) { background: #12384a; box-shadow: 0 0 0 1px rgba(45,212,191,.5); }
.slot.x { background: repeating-linear-gradient(45deg, #3a1515, #3a1515 4px, #2a0f0f 4px, #2a0f0f 8px); }
.slot.x::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: #fecaca; font-size: 20px; font-weight: 900; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; font-size: 12.5px; }
.legend .c-w { color: var(--cw); } .legend .c-d { color: var(--cd); } .legend .c-x { color: var(--cx); } .legend .c-r { color: var(--cr); }
/* Radio */
.dirs { margin: 0; font-family: ui-monospace, Menlo, monospace; font-weight: 800; letter-spacing: .12em; word-break: break-word; color: #fcd34d; }
.nudge .btn.sm { flex: 0 0 auto; min-width: 44px; }
.endrow { text-align: center; margin: 4px 0 0; }
/* Over */
.banner { text-align: center; padding: 18px; border-radius: 18px; margin-bottom: 12px; background: var(--card); border: 1px solid var(--line); }
.banner h2 { font-size: 28px; }
.banner p { margin: 4px 0 0; color: var(--muted); }
.banner.win { background: linear-gradient(135deg, #064e3b, #0c1c29); border-color: #10b981; }
.banner.lose { background: linear-gradient(135deg, #4c0519, #0c1c29); border-color: #e11d48; }
.over .tcard p { margin: 0; }
dialog { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 18px; padding: 18px 18px 16px; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); overflow-y: auto; }
dialog::backdrop { background: rgba(0,0,0,.65); }
dialog h2 { font-size: 20px; margin-bottom: 6px; }
dialog ol { padding-left: 20px; display: grid; gap: 8px; }
dialog ul { padding-left: 18px; margin: 6px 0; display: grid; gap: 4px; }
dialog .fine { color: var(--muted); font-size: 13px; }
dialog .btn { width: 100%; }
.btn.brk, .st.brk { color: var(--bad); border-color: #5b2020; opacity: .8; }
/* bug button: compact, in the header row (scrolls away with the page) so it never sits on top of game controls */
#req-fab.req-fab { position: absolute !important; width: 36px !important; height: 36px !important; border-width: 1px !important; top: calc(env(safe-area-inset-top, 0px) + 10px) !important; bottom: auto !important; right: calc(max(14px, env(safe-area-inset-right)) + 124px) !important; box-shadow: none !important; opacity: .7; }
#req-fab.req-fab .i { width: 16px !important; height: 16px !important; }
#req-fab.req-fab:hover, #req-fab.req-fab:focus-visible { opacity: 1; }
.dirs .nomono { font-family: inherit; font-weight: 500; letter-spacing: 0; font-size: 14px; }
.over .tcard p { margin: 0; }
