:root {
  --bg: rgba(8, 14, 28, 0.86);
  --line: #24406a;
  --acc: #4cff9a;
  --txt: #cfe3ff;
  --dim: #7890b0;
  --warn: #ffb347;
  --bad: #ff5a5a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #02030a; color: var(--txt); font: 14px/1.35 "Segoe UI", system-ui, sans-serif; }
button, input, select { font: inherit; color: var(--txt); background: #0f1d36; border: 1px solid var(--line); border-radius: 4px; padding: 5px 10px; }
button { cursor: pointer; }
button:hover:not(:disabled) { background: #183056; border-color: #3a6aa8; }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: #0f4a2e; border-color: #2fae6a; }
button.primary:hover { background: #166a42; }
#game { position: fixed; inset: 0; }
#game canvas { display: block; }
.labels { position: absolute; inset: 0; pointer-events: none; }
.lbl { font-size: 11px; white-space: nowrap; text-shadow: 0 0 3px #000, 0 0 3px #000; pointer-events: none; }
.lbl.planet { color: #9fb8d8; font-size: 12px; }
.lbl.ship { text-align: center; }
.lbl.ship.me .n { font-weight: bold; text-decoration: underline; }
.lbl.ship.sel .n { background: rgba(255,255,255,0.12); padding: 0 3px; border-radius: 3px; }
.lbl .hp { width: 40px; height: 3px; background: #300; margin: 1px auto 0; }
.lbl .hp i { display: block; height: 100%; background: currentColor; }
.lbl .sh { width: 40px; height: 2px; background: #0a2030; margin: 1px auto 0; }
.lbl .sh i { display: block; height: 100%; background: #66ccff; }
.lbl .sh[hidden] { display: none !important; }
.lbl.ship.boss .n { font-size: 14px; font-weight: 700; letter-spacing: 0.5px; }
.lbl.ship.boss .hp, .lbl.ship.boss .sh { width: 110px; height: 5px; }
.lbl.ship.elite .n { font-weight: 700; }
.lbl.ship.elite .n::before { content: '♛ '; }
.lbl.planet.station { font-size: 11px; font-weight: 600; opacity: 0.9; }

#lobby { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 30% 20%, #16244a 0%, #02030a 70%); z-index: 20; padding: 16px; overflow: auto; }
.lobby-box { width: 480px; max-width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.lobby-box h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: 1px; }
.lobby-box h1 span { color: var(--acc); }
.lobby-box .sub { color: var(--dim); margin: 0 0 16px; }
.lobby-box label { display: flex; justify-content: space-between; align-items: center; margin: 8px 0; gap: 12px; }
.lobby-box label input { flex: 1; max-width: 240px; }
.lobby-box input[type=color] { padding: 0; height: 32px; }
.row { display: flex; gap: 8px; margin: 12px 0; }
.row > * { flex: 1; }
#l-code { text-transform: uppercase; letter-spacing: 3px; text-align: center; }
#l-status { min-height: 20px; color: var(--warn); }
details { margin-top: 10px; color: var(--dim); }
details li { margin: 4px 0; }
summary { cursor: pointer; color: var(--txt); }

.panel { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
#hud { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); display: flex; gap: 16px; align-items: center; padding: 6px 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; white-space: nowrap; z-index: 5; }
#hud b { color: #fff; }
#hud .bar { display: inline-block; width: 70px; height: 7px; background: #301018; vertical-align: middle; border-radius: 2px; overflow: hidden; }
#hud .bar i { display: block; height: 100%; background: var(--acc); }
#hud .wanted { color: var(--bad); font-weight: bold; }
#side { position: fixed; top: 8px; right: 8px; width: 230px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; z-index: 5; }
#room { font-size: 12px; color: var(--dim); margin-bottom: 8px; }
#room b { color: var(--acc); font-size: 16px; letter-spacing: 2px; }
#room button { padding: 1px 6px; font-size: 11px; }
#players .p { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 13px; }
#players .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
#players .st { margin-left: auto; font-size: 11px; color: var(--dim); }
#players .st.ok { color: var(--acc); }
#players .st.warn { color: var(--warn); }
#players .off { opacity: 0.4; }
#turnbox { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
#endturn { font-size: 16px; padding: 10px; background: #0f4a2e; border-color: #2fae6a; }
#endturn.ready { background: #4a3a0f; border-color: #ae8a2f; }
#turninfo { font-size: 12px; color: var(--dim); text-align: center; min-height: 16px; }
.chk { font-size: 12px; display: flex; align-items: center; gap: 6px; color: var(--dim); }
.chk select { padding: 1px 4px; margin-left: auto; }

#planet { position: fixed; top: 56px; left: 8px; width: 460px; max-height: calc(100vh - 280px); overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; z-index: 5; }
#planet h2 { margin: 0; font-size: 18px; padding-right: 36px; }
#planet .close { position: absolute; top: 8px; right: 8px; padding: 1px 8px; }
#planet .meta { color: var(--dim); font-size: 12px; margin-bottom: 8px; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button { flex: 1; }
.tabs button.on { background: #1e3c6c; border-color: #4a7ac0; }
.tabs button.hot { color: #ffd66b; border-color: #a08030; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { padding: 3px 4px; text-align: left; }
th { color: var(--dim); font-weight: normal; font-size: 11px; }
tr:nth-child(even) td { background: rgba(255,255,255,0.03); }
td button { padding: 1px 5px; font-size: 11px; }
.good { color: var(--acc); }
.badp { color: var(--bad); }
.warnp { color: var(--warn); }
.fxd { color: #ff9ae8; font-style: italic; }
.eq { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; margin: 6px 0; }
.eq h4 { margin: 0 0 4px; font-size: 12px; color: var(--dim); font-weight: normal; }
.eq .opt { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 0; }
.eq .opt span { flex: 1; }
.eq .cur { color: var(--acc); }

#selinfo { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; z-index: 5; min-width: 280px; max-width: 460px; }
#selinfo .t { font-weight: bold; }
#selinfo .d { font-size: 12px; color: var(--dim); margin: 3px 0 6px; }
#selinfo .btns { display: flex; gap: 6px; flex-wrap: wrap; }

#logbox { position: fixed; left: 8px; bottom: 8px; width: 420px; z-index: 5; }
#log { max-height: 180px; overflow-y: auto; font-size: 12px; background: rgba(4,8,18,0.7); border: 1px solid var(--line); border-radius: 8px 8px 0 0; padding: 6px 8px; }
#log div { margin: 1px 0; }
#log .day { color: #506a90; }
#log .me { color: #b8ffd6; }
#log .chat { color: #ffe08a; }
#chat { width: 100%; border-radius: 0 0 8px 8px; font-size: 12px; }

#hyper { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; font-size: 22px; text-shadow: 0 0 10px #48f; background: radial-gradient(ellipse at center, rgba(40,60,160,0.15), rgba(0,0,30,0.65)); z-index: 3; text-align: center; }
#map { position: fixed; inset: 40px 250px 40px 40px; background: rgba(4,8,18,0.96); border: 1px solid var(--line); border-radius: 10px; z-index: 10; }
#mapc { width: 100%; height: 100%; display: block; border-radius: 10px; }
#mapinfo { position: absolute; left: 12px; bottom: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 240px; }
#mapinfo:empty { display: none; }
#mapclose { position: absolute; top: 8px; right: 8px; }
#toast { position: fixed; top: 150px; left: 50%; transform: translateX(-50%); background: #3a2008; border: 1px solid var(--warn); border-radius: 6px; padding: 6px 14px; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 15; }
#toast.on { opacity: 1; }
.host-only { display: none; }
body:not(.debug) .debug-only { display: none !important; }
body.is-host .host-only { display: flex; }

@media (max-width: 800px) {
  #side { width: 170px; font-size: 12px; }
  #planet { width: calc(100vw - 196px); }
  #logbox { width: calc(100vw - 196px); }
  #hud { font-size: 11px; gap: 8px; left: 8px; transform: none; right: 186px; overflow-x: auto; }
  #map { inset: 8px; }
}
@media (max-width: 1150px) {
  #selinfo { bottom: auto; top: 56px; left: auto; right: 250px; transform: none; }
}

#bigtimer { position: fixed; top: 52px; left: 50%; transform: translateX(-50%); z-index: 4; pointer-events: none; text-align: center; min-width: 220px; padding: 6px 18px 8px; background: rgba(4,8,18,0.55); border: 1px solid var(--line); border-radius: 12px; }
#bigtimer .bar { height: 6px; background: #13233d; border-radius: 3px; overflow: hidden; margin: 6px 0 3px; }
#bigtimer .bar i { display: block; height: 100%; background: #7d8898; }
#bigtimer .cap { font-size: 12px; color: var(--dim); }

#ship { position: fixed; top: 150px; right: 250px; width: 480px; max-height: calc(100vh - 170px); overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; z-index: 6; }
#ship .close { position: absolute; top: 8px; right: 8px; padding: 1px 8px; }
#ship h2 { margin: 0; font-size: 18px; }
#ship h3 { margin: 12px 0 5px; font-size: 13px; color: var(--dim); font-weight: normal; text-transform: uppercase; letter-spacing: 1px; }
#ship h3 small { text-transform: none; letter-spacing: 0; }
#ship .stats { display: grid; grid-template-columns: 70px 1fr 110px; gap: 3px 8px; align-items: center; font-size: 13px; margin-top: 8px; }
#ship .stats > div:nth-child(3n) { text-align: right; color: #fff; }
#ship .meta { color: var(--dim); font-size: 12px; }
.sbar { display: block; height: 8px; background: #13233d; border-radius: 3px; overflow: hidden; }
.sbar i { display: block; height: 100%; }
/* inventory tiles */
.inv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.inv.hold { min-height: 62px; padding: 5px; border: 1px solid var(--line); border-radius: 6px; background: rgba(0,0,0,0.2); align-content: start; }
.it { position: relative; min-width: 0; min-height: 56px; padding: 4px 6px 5px; border: 1px solid #1e3558; border-left: 3px solid var(--tc); border-radius: 5px; background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01)); cursor: pointer; user-select: none; }
.it:hover { background: rgba(120,170,255,0.1); }
.it.sel { border-color: #6aa0ff; box-shadow: 0 0 0 1px #6aa0ff inset; }
.it[draggable="true"] { cursor: grab; }
.it.empty { border-style: dashed; border-left-style: dashed; opacity: 0.55; cursor: default; }
.it .sn { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.5px; }
.it .nm { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #fff; line-height: 1.2; }
.it .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.it .sub { font-size: 10px; color: var(--dim); line-height: 1.3; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.it .sub .tier { margin-left: 0; }
.it .sz { color: #5fe0d0; }
.it .q { position: absolute; right: 6px; bottom: 4px; font-size: 14px; color: #fff; }
.ic { width: 14px; height: 14px; flex: none; fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; vertical-align: -2px; }
.holdempty { grid-column: 1 / -1; color: var(--dim); font-size: 12px; text-align: center; padding: 16px 0; }
.capbar { display: flex; height: 6px; margin-bottom: 5px; background: #13233d; border-radius: 3px; overflow: hidden; }
.capbar i { display: block; height: 100%; }
.outzone { margin-top: 5px; padding: 7px; border: 1px dashed var(--line); border-radius: 6px; text-align: center; color: var(--dim); font-size: 12px; }
#ship.dragging [data-zone].ok { border-color: var(--acc); box-shadow: 0 0 0 1px rgba(76,255,154,0.5) inset; }
#ship.dragging [data-zone].ok.empty { opacity: 1; }
#ship [data-zone].over { background: rgba(76,255,154,0.16) !important; }
#ship .detail { margin-top: 8px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255,255,255,0.03); font-size: 12px; min-height: 40px; }
#ship .detail .t { font-weight: bold; font-size: 13px; display: flex; align-items: center; gap: 5px; }
#ship .detail .d { color: #a9bedc; margin-top: 3px; line-height: 1.45; }
#ship .detail .btns { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; align-items: center; }
#ship .detail .btns button { padding: 3px 9px; font-size: 12px; }
.tier { color: #ffc857; font-size: 10px; letter-spacing: -1px; margin-left: 3px; }
.tier s { color: #33415a; text-decoration: none; }
@media (max-width: 800px) { #ship { right: 8px; left: 8px; width: auto; } #bigtimer { top: 90px; } .inv { grid-template-columns: repeat(3, 1fr); } }

#tip { position: fixed; z-index: 12; pointer-events: none; max-width: 360px; background: rgba(6,12,26,0.94); border: 1px solid #3a6aa8; border-radius: 8px; padding: 7px 10px; font-size: 12px; box-shadow: 0 4px 18px rgba(0,0,0,0.5); }
#tip .t, #selinfo .t { font-weight: bold; font-size: 13px; }
#tip .d, #selinfo .d { color: #a9bedc; margin-top: 3px; line-height: 1.45; }
.hpline { display: flex; align-items: center; gap: 8px; margin: 2px 0 3px; }
.hpline .sbar { flex: 1; }
.hpline span:last-child { color: #fff; font-size: 11px; white-space: nowrap; }
#bigtimer .date { font-size: 13px; color: #cfe3ff; letter-spacing: 0.5px; margin-bottom: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#bigtimer.paused .date, #bigtimer.paused .cap { color: var(--warn); }
.vol { display: flex; gap: 8px; font-size: 13px; }
.vol label { flex: 1; display: flex; align-items: center; gap: 4px; }
.vol input { width: 100%; min-width: 0; padding: 0; accent-color: var(--acc); }
#playerbtn { padding: 1px 6px; font-size: 13px; flex: none; }
#player { position: fixed; top: 330px; right: 8px; width: 260px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; z-index: 6; }
#player .ph { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
#player .ph button { padding: 1px 8px; }
#player .pnow { font-size: 12px; color: var(--dim); margin-bottom: 6px; }
#player .pnow b { color: var(--acc); }
#plist { display: flex; flex-direction: column; gap: 4px; }
.ptrack { display: flex; gap: 8px; align-items: center; text-align: left; padding: 5px 8px; }
.ptrack .pi { width: 12px; color: var(--acc); flex: none; }
.ptrack b { display: block; font-size: 13px; }
.ptrack small { display: block; font-size: 11px; color: var(--dim); }
.ptrack.on { background: #1e3c6c; border-color: #4a7ac0; }
#player .pbtns { display: flex; gap: 6px; margin-top: 8px; }
#player .pbtns button { flex: 1; font-size: 16px; }
.lbl.float { font-weight: 700; font-size: 13px; pointer-events: none; }
.lbl.float span { display: inline-block; text-shadow: 0 0 4px #000, 0 0 2px #000; }
.lbl.float.big { font-size: 14px; }

/* rarity & exotics */
.tier.exo { color: #ff4fd8; letter-spacing: 0.5px; font-size: 9px; font-weight: 700; }
@keyframes exoglow { 0% { border-left-color: #ff4fd8; box-shadow: 0 0 6px rgba(255,79,216,0.45); } 33% { border-left-color: #6af0ff; box-shadow: 0 0 6px rgba(106,240,255,0.45); } 66% { border-left-color: #ffe066; box-shadow: 0 0 6px rgba(255,224,102,0.45); } 100% { border-left-color: #ff4fd8; box-shadow: 0 0 6px rgba(255,79,216,0.45); } }
.it.exo { animation: exoglow 3s linear infinite; background: linear-gradient(135deg, rgba(255,79,216,0.12), rgba(106,240,255,0.08)); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; font-size: 11px; }
.chips span { background: rgba(255,255,255,0.05); border: 1px solid var(--line); border-radius: 10px; padding: 1px 7px; color: #cfe3ff; white-space: nowrap; }
#ship .meta button { padding: 0 5px; font-size: 11px; }
#planet .tabs + .tabs button { font-size: 12px; padding: 3px 4px; }
#planet .opt span small { white-space: normal; }

/* text quests */
#quest { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 60px); display: flex; flex-direction: column; background: rgba(8, 14, 28, 0.97); border: 1px solid #3a6aa8; border-radius: 10px; padding: 14px 16px; z-index: 11; box-shadow: 0 10px 40px rgba(0,0,0,0.6); }
#quest[hidden] { display: none !important; }
#quest .qhead { display: flex; justify-content: space-between; align-items: center; font-size: 17px; color: #ffd66b; margin-bottom: 8px; }
#quest .qhead .close { padding: 1px 8px; }
#quest .qparams { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; font-size: 12px; }
#quest .qparams span { background: rgba(255,255,255,0.05); border: 1px solid var(--line); border-radius: 10px; padding: 2px 9px; color: var(--dim); }
#quest .qparams span b { color: #fff; }
#quest .qparams span.danger b { color: var(--warn); }
#quest .qtext { white-space: pre-line; line-height: 1.55; font-size: 14.5px; color: #dde9fa; overflow: auto; flex: 1; min-height: 60px; padding-right: 4px; }
#quest .qresult { margin-top: 10px; font-weight: 700; font-size: 15px; }
#quest .qchoices { display: flex; flex-direction: column; gap: 5px; margin-top: 12px; }
#quest .qchoices button { text-align: left; padding: 7px 10px; display: flex; gap: 8px; align-items: baseline; }
#quest .qchoices .qn { color: #ffd66b; font-weight: 700; min-width: 12px; }
.qoffer { font-size: 13px; line-height: 1.45; margin-bottom: 6px; }
