:root {
  --bg: #05080d;
  --panel: rgba(10, 18, 28, 0.82);
  --panel-solid: #0b141f;
  --line: rgba(120, 180, 220, 0.18);
  --line-strong: rgba(120, 190, 230, 0.4);
  --text: #cfe3f1;
  --muted: #6f8798;
  --accent: #4fc3f7;
  --accent-2: #ffb74d;
  --good: #7ed69a;
  --warn: #ff8a65;
  --bad: #ef5350;
  --shield: #64b5f6;
  --armor: #ffcc80;
  --hull: #e0e0e0;
  --cap: #ffe082;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: 'Exo 2', system-ui, sans-serif; overflow: hidden; }
#game { position: fixed; inset: 0; }
#game canvas { display: block; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--line-strong); border-radius: 3px; background: rgba(255,255,255,0.04); }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1em; }

/* ---------- LOBBY ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 50;
  background: radial-gradient(ellipse at 30% 20%, rgba(40,90,140,0.25), transparent 60%), radial-gradient(ellipse at 80% 80%, rgba(140,60,40,0.18), transparent 55%), rgba(3,6,10,0.75); padding: 16px; }
.lobby-card { width: min(560px, 100%); max-height: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px; padding: 28px 30px; backdrop-filter: blur(6px); }
.lobby-card h1 { margin: 0; font-weight: 800; letter-spacing: 0.12em; font-size: 34px; }
.lobby-card h1 span { color: var(--accent); }
.tag { color: var(--muted); margin: 6px 0 22px; }
#join-form, #lb-host { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
input, select { background: #08111b; color: var(--text); border: 1px solid var(--line-strong); padding: 9px 10px; border-radius: 4px; font-size: 15px; text-transform: none; letter-spacing: 0; }
input:focus, select:focus { outline: 1px solid var(--accent); }
button.primary { background: linear-gradient(180deg, #2f8fc0, #1d6690); border: 1px solid #5fc4f5; color: white; padding: 10px 16px; font-weight: 600; letter-spacing: 0.08em; border-radius: 4px; font-size: 15px; }
button.primary:hover { filter: brightness(1.15); }
button.ghost { background: transparent; border: 1px solid var(--line-strong); color: var(--text); border-radius: 4px; padding: 6px 10px; }
button.small { font-size: 12px; padding: 4px 8px; }
.room-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#lb-players { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 4px; }
#lb-players li { padding: 7px 10px; background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: 3px; display: flex; justify-content: space-between; }
#lb-players li .host { color: var(--accent-2); font-size: 12px; }
.help { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 12px; }
.help summary { cursor: pointer; color: var(--accent); }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 13px; margin: 12px 0; }
.rules { font-size: 13px; color: var(--text); padding-left: 18px; line-height: 1.5; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; font-size: 13px; }
#hud .panel, #hud button, #hud input, #hud select, #locks, #rack, #players-panel, #minimap { pointer-events: auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
.panel-title { padding: 6px 10px; border-bottom: 1px solid var(--line); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; font-size: 12px; color: var(--accent); display: flex; justify-content: space-between; align-items: center; gap: 8px; }

#topbar { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
#topbar > div { padding: 6px 12px; white-space: nowrap; }
.tb-phase { background: rgba(79,195,247,0.12); display: flex; gap: 10px; font-weight: 600; letter-spacing: 0.06em; }
.tb-phase.p1 { background: rgba(255,183,77,0.15); }
.tb-phase.p2 { background: rgba(239,83,80,0.2); }
#hud-time { font-family: var(--mono); }
.tb-item { color: var(--muted); }
.tb-item b { color: var(--text); font-family: var(--mono); font-weight: 600; }
#flags { position: absolute; top: 46px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.flag { padding: 3px 10px; border-radius: 3px; font-weight: 700; font-size: 12px; letter-spacing: 0.08em; }
.flag.web { background: rgba(156, 39, 176, 0.5); }
.flag.scr { background: rgba(239, 83, 80, 0.55); }
.flag.warp { background: rgba(79, 195, 247, 0.4); }
.flag.crim { background: rgba(255, 60, 60, 0.75); animation: blink 0.8s infinite; }
.flag.wt { background: rgba(255, 152, 0, 0.45); }
.flag.ap { background: rgba(255,255,255,0.12); }
@keyframes blink { 50% { opacity: 0.4; } }

#players-panel { position: absolute; top: 8px; left: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; min-width: 190px; }
.pl-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 6px; align-items: center; padding: 2px 0; font-size: 12px; }
.pl-row .dot { width: 8px; height: 8px; border-radius: 50%; }
.pl-row.elim { opacity: 0.4; text-decoration: line-through; }
.pl-row .an { font-family: var(--mono); color: var(--muted); }
.pl-anom { height: 3px; background: rgba(255,255,255,0.08); grid-column: 2 / 4; }
.pl-anom div { height: 100%; }

#locks { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; margin-top: 18px; }
.lock { width: 128px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; cursor: pointer; position: relative; }
.lock.active { border-color: var(--bad); box-shadow: 0 0 10px rgba(239,83,80,0.4); }
.lock .ln { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 12px; }
.lock .ld { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.lock .x { position: absolute; top: 2px; right: 5px; color: var(--muted); font-size: 12px; }
.bars { display: grid; gap: 2px; margin-top: 4px; }
.bar { height: 4px; background: rgba(255,255,255,0.07); }
.bar div { height: 100%; }
.bar.s div { background: var(--shield); } .bar.a div { background: var(--armor); } .bar.h div { background: var(--hull); }
.lock .prog { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--accent); }

#overview { position: absolute; top: 8px; right: 8px; width: 330px; max-height: 44vh; display: flex; flex-direction: column; }
.ov-tabs { display: flex; gap: 2px; }
.ov-tabs button { background: transparent; border: 1px solid transparent; color: var(--muted); font-size: 11px; padding: 2px 6px; border-radius: 3px; }
.ov-tabs button.on { border-color: var(--line-strong); color: var(--text); }
.ov-head, .ov-row { display: grid; grid-template-columns: 16px 1fr 92px 64px; gap: 6px; padding: 3px 10px; align-items: center; }
.ov-head { color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--line); }
#ov-list { overflow-y: auto; flex: 1; }
.ov-row { cursor: pointer; font-size: 12px; border-bottom: 1px solid rgba(255,255,255,0.025); }
.ov-row:hover { background: rgba(79,195,247,0.08); }
.ov-row.sel { background: rgba(79,195,247,0.18); }
.ov-row .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-row .ty { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.ov-row .di { font-family: var(--mono); text-align: right; }
.ov-row .ic { width: 10px; height: 10px; }
.ov-row.hostile .nm { color: #ff8a80; }
.ov-row.locked .nm::after { content: ' ◎'; color: var(--bad); }

#selected { position: absolute; top: calc(44vh + 16px); right: 8px; width: 330px; }
.sel-info { padding: 6px 10px; font-family: var(--mono); font-size: 12px; color: var(--muted); display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.sel-info b { color: var(--text); font-weight: 400; }
.sel-actions { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 10px 10px; }
.sel-actions button, .sel-actions select { background: rgba(255,255,255,0.04); border: 1px solid var(--line-strong); color: var(--text); padding: 4px 8px; font-size: 12px; border-radius: 3px; }
.sel-actions button:hover { background: rgba(79,195,247,0.15); }
.sel-actions button.dis { opacity: 0.35; }

#shipui { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); display: flex; align-items: flex-end; gap: 12px; }
#gauges { position: relative; width: 220px; height: 166px; background: var(--panel); border: 1px solid var(--line); border-radius: 110px 110px 6px 6px; padding: 8px 10px 0; }
#gauge-svg { width: 200px; height: 120px; }
#gauge-svg path { fill: none; stroke-width: 10; stroke-linecap: butt; }
.g-bg { stroke: rgba(255,255,255,0.07); }
.g-bg.cap { stroke-width: 14 !important; }
.g-shield { stroke: var(--shield); } .g-armor { stroke: var(--armor); } .g-hull { stroke: var(--hull); }
.g-cap { stroke: var(--cap); stroke-width: 14 !important; }
#g-text { position: absolute; left: 0; right: 0; top: 122px; text-align: center; font-family: var(--mono); font-size: 10px; color: var(--muted); }
#g-speed { position: absolute; left: 10px; right: 10px; bottom: 5px; height: 14px; background: rgba(255,255,255,0.05); border-radius: 2px; overflow: hidden; }
#g-speed-bar { height: 100%; background: linear-gradient(90deg, #2a6d8f, #4fc3f7); width: 0; }
#g-speed-txt { position: absolute; inset: 0; text-align: center; font-family: var(--mono); font-size: 10px; line-height: 14px; }
#rack { display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 6px; }
.rrow { display: flex; gap: 4px; min-height: 44px; }
.mod { width: 44px; height: 44px; border: 1px solid var(--line-strong); border-radius: 50%; position: relative; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; text-align: center; line-height: 1.05; cursor: pointer; background: rgba(255,255,255,0.03); color: var(--text); user-select: none; overflow: hidden; }
.mod.empty { border-style: dashed; opacity: 0.25; cursor: default; }
.mod.passive { cursor: default; opacity: 0.6; border-radius: 6px; }
.mod.on { border-color: #8be28b; box-shadow: 0 0 10px rgba(139,226,139,0.5) inset, 0 0 8px rgba(139,226,139,0.4); }
.mod.off { border-color: var(--accent-2); }
.mod .cyc { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.mod .key { position: absolute; bottom: 1px; left: 0; right: 0; font-size: 9px; color: var(--muted); font-family: var(--mono); }
.mod .lbl { position: relative; z-index: 1; padding-bottom: 6px; }
.mod.t-turret, .mod.t-missile { color: #ffab91; }
.mod.t-mining { color: #a5d6a7; }
.mod.t-prop { color: #81d4fa; }
.mod.t-web, .mod.t-scram { color: #ce93d8; }
.mod.t-shieldrep { color: var(--shield); }
.mod.t-armorrep { color: var(--armor); }
#ship-meta { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; font-family: var(--mono); font-size: 11px; color: var(--muted); min-width: 170px; line-height: 1.6; }
#ship-meta b { color: var(--text); font-weight: 400; }
#ship-meta .cargo-list { max-height: 90px; overflow: auto; }
#ship-meta .cargo-list div { display: flex; justify-content: space-between; gap: 6px; }

#log { position: absolute; left: 8px; bottom: 8px; width: 380px; height: 190px; display: flex; flex-direction: column; }
#log-lines { flex: 1; overflow-y: auto; padding: 6px 8px; font-size: 12px; line-height: 1.4; }
#log-lines .l { margin-bottom: 1px; }
#log-lines .warn { color: var(--warn); }
#log-lines .good { color: var(--good); }
#log-lines .crime { color: #ff5252; font-weight: 600; }
#log-lines .kill { color: #ffab91; }
#log-lines .phase { color: var(--accent-2); font-weight: 600; }
#log-lines .chat b { font-weight: 600; }
#log-lines .tm { color: var(--muted); font-family: var(--mono); font-size: 10px; margin-right: 4px; }
#chat-in { border: none; border-top: 1px solid var(--line); background: rgba(0,0,0,0.3); font-size: 12px; padding: 6px 8px; border-radius: 0; }
#minimap { position: absolute; right: 8px; bottom: 8px; width: 200px; height: 200px; background: rgba(5,10,16,0.85); border: 1px solid var(--line); border-radius: 50%; }

#toast { position: fixed; top: 96px; left: 50%; transform: translateX(-50%); z-index: 60; pointer-events: none; text-align: center; }
#toast .t { background: rgba(10,18,28,0.92); border: 1px solid var(--line-strong); padding: 8px 16px; border-radius: 4px; margin-bottom: 6px; font-weight: 600; animation: fadein 0.2s; }
#toast .t.warn { border-color: var(--warn); color: var(--warn); }
#toast .t.big { font-size: 20px; letter-spacing: 0.08em; padding: 12px 24px; border-color: var(--accent-2); color: var(--accent-2); }
@keyframes fadein { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- STANICE ---------- */
#station { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(2,5,9,0.55); padding: 60px 16px 16px; }
.st-card { width: min(1100px, 100%); height: min(760px, 100%); background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 6px; display: flex; flex-direction: column; }
.st-card header { display: flex; align-items: center; gap: 20px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.st-card header h2 { margin: 0; font-weight: 800; letter-spacing: 0.06em; }
.st-card header > div:first-child { flex: 1; }
.st-isk { font-size: 16px; color: var(--muted); }
.st-isk b { color: var(--accent-2); font-family: var(--mono); }
#btn-undock { font-size: 18px; padding: 10px 28px; }
.st-tabs { display: flex; gap: 2px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.st-tabs button { background: transparent; border: none; color: var(--muted); padding: 10px 16px; font-size: 14px; border-bottom: 2px solid transparent; }
.st-tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
#st-body { flex: 1; overflow-y: auto; padding: 14px 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-content: start; }
#st-body h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
#st-body .full { grid-column: 1 / -1; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 400; color: var(--muted); font-size: 11px; text-transform: uppercase; padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.t td { padding: 5px 6px; border-bottom: 1px solid rgba(255,255,255,0.04); }
table.t td.n { font-family: var(--mono); text-align: right; white-space: nowrap; }
table.t td .sub { color: var(--muted); font-size: 11px; }
table.t button, .fit-slot button { background: rgba(255,255,255,0.05); border: 1px solid var(--line-strong); color: var(--text); padding: 3px 8px; font-size: 12px; border-radius: 3px; white-space: nowrap; }
table.t button:hover { background: rgba(79,195,247,0.2); }
table.t button:disabled { opacity: 0.3; cursor: default; }
.price-down { color: var(--bad); } .price-up { color: var(--good); }
.fit-group { margin-bottom: 14px; }
.fit-slot { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 3px; margin-bottom: 4px; font-size: 13px; }
.fit-slot.empty { border-style: dashed; color: var(--muted); }
.res-bar { height: 8px; background: rgba(255,255,255,0.07); border-radius: 2px; margin: 4px 0 10px; overflow: hidden; }
.res-bar div { height: 100%; background: var(--accent); }
.res-bar.over div { background: var(--bad); }
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 14px; font-size: 12px; font-family: var(--mono); color: var(--muted); }
.statgrid b { color: var(--text); font-weight: 400; }
.need-ok { color: var(--good); } .need-no { color: var(--bad); }
.note { color: var(--muted); font-size: 12px; line-height: 1.5; }

#end-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
#end-table th { text-align: left; color: var(--muted); font-weight: 400; font-size: 11px; padding: 4px; border-bottom: 1px solid var(--line); }
#end-table td { padding: 5px 4px; border-bottom: 1px solid rgba(255,255,255,0.05); font-family: var(--mono); }
#end-table td:first-child { font-family: inherit; }

@media (max-width: 1100px) {
  #overview, #selected { width: 260px; }
  #log { width: 280px; height: 150px; }
  #minimap { width: 140px; height: 140px; }
  #st-body { grid-template-columns: 1fr; }
}
