:root {
  --bg: #07090c;
  --panel: #0e1218;
  --panel2: #141a22;
  --line: #262e38;
  --text: #e8edf2;
  --dim: #8794a3;
  --accent: #ffe08a;
  --req: #ffe08a;
  --smp: #c79bff;
  --good: #7dff7a;
  --bad: #ff5544;
  --blue: #4cd3ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: "Pixelify Sans", monospace; font-size: 17px; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
kbd { background: #1d242d; border: 1px solid #3a4450; border-bottom-width: 3px; border-radius: 4px; padding: 1px 6px; font: inherit; font-size: 0.85em; }
.dim { color: var(--dim); font-weight: 400; }
.hidden { display: none !important; }

#game { position: fixed; inset: 0; display: block; }
body.in-mission #hub { display: none; }

/* ---------------- STATION PANELS (open over the walkable ship) ---------------- */
#hub { position: fixed; inset: 0; z-index: 5; background: rgba(3, 5, 8, 0.7); padding: 28px; display: flex; justify-content: center; align-items: flex-start; }
.hubwin {
  width: 100%; max-width: 1300px; max-height: calc(100vh - 56px); overflow-y: auto;
  background: rgba(10, 13, 18, 0.97); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 8px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.8); animation: winin .15s ease-out;
}
@keyframes winin { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.close { margin-left: 8px; background: none; border: 1px solid var(--line); color: var(--dim); padding: 6px 12px; border-radius: 4px; }
.close:hover { color: var(--text); border-color: var(--accent); }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .cols2 { grid-template-columns: 1fr; } }
.launch .brief ul { color: var(--dim); font-size: 14px; }
.launch .brief li.ex { color: var(--blue); }
.ccline { display: flex; align-items: center; gap: 10px; }
.topbar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 24px; padding: 14px 28px;
  background: rgba(7, 9, 12, 0.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); flex-wrap: wrap;
}
.logo { font-size: 28px; font-weight: 700; letter-spacing: 4px; }
.logo span { color: var(--accent); }
.logo small { display: block; font-size: 11px; letter-spacing: 1px; color: var(--dim); font-weight: 400; }
.tab { background: none; border: 1px solid transparent; padding: 8px 14px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; border-radius: 4px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-color: var(--accent); background: rgba(255, 224, 138, 0.06); }
.res { margin-left: auto; display: flex; gap: 18px; font-weight: 700; font-size: 18px; }
.res em { font-style: normal; font-size: 10px; color: var(--dim); letter-spacing: 1px; }
.req { color: var(--req); }
.smp { color: var(--smp); }

main { padding: 24px 28px 60px; max-width: 1400px; margin: 0 auto; }
h2 { font-size: 16px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); margin: 8px 0 14px; }
h3 { font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--dim); margin: 18px 0 10px; }

.tab-war { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 28px; }
@media (max-width: 900px) { .tab-war { grid-template-columns: 1fr; } }

.planet {
  display: flex; gap: 16px; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line);
  border-left: 4px solid var(--accent); padding: 16px; margin-bottom: 12px; border-radius: 6px; transition: transform .1s, border-color .1s;
}
.planet:hover { transform: translateX(3px); }
.planet.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 24px -8px var(--accent); }
.planet.locked { filter: grayscale(0.8); opacity: 0.55; }
.orb { width: 64px; height: 64px; border-radius: 50%; flex: none; box-shadow: inset -8px -8px 16px rgba(0,0,0,0.6), 0 0 20px -6px var(--accent); }
.pinfo h3 { margin: 0; color: var(--text); font-size: 18px; letter-spacing: 1px; text-transform: none; }
.faction { color: var(--accent); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.pinfo p { margin: 6px 0 10px; color: var(--dim); font-size: 13px; }
.libbar { height: 8px; background: #1a2028; border-radius: 4px; overflow: hidden; }
.libbar div { height: 100%; background: var(--accent); }
.libtxt { font-size: 12px; margin-top: 4px; color: var(--dim); }
.lockmsg { font-size: 12px; margin-top: 6px; color: var(--bad); }
.stats { color: var(--dim); font-size: 12px; margin-top: 8px; }

.ops-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.missions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 700px) { .missions { grid-template-columns: 1fr; } }
.mission { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px; }
.mission:hover { border-color: #3d4856; }
.mission.sel { border-color: var(--accent); background: rgba(255, 224, 138, 0.05); }
.mission h4 { margin: 0 0 8px; font-size: 15px; }
.mission ul { margin: 0; padding-left: 18px; color: var(--dim); font-size: 13px; }
.mission li.ex { color: var(--blue); }
.brief { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 16px 10px; margin-top: 14px; }
.brief p { font-size: 13px; color: var(--dim); margin: 8px 0; }
.brief b { color: var(--text); }
.diffs { display: flex; gap: 8px; flex-wrap: wrap; }
.dbtn { background: var(--panel); border: 1px solid var(--line); padding: 10px 14px; border-radius: 6px; display: flex; gap: 8px; align-items: center; }
.dbtn b { color: var(--accent); }
.dbtn.sel { border-color: var(--accent); background: rgba(255, 224, 138, 0.08); }
.diffnote { font-size: 12px; color: var(--dim); margin-top: 8px; }
.deploy-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; flex-wrap: wrap; }
.reward { color: var(--dim); font-size: 13px; }
.deploy {
  background: var(--accent); color: #1a1505; border: none; font-weight: 700; font-size: 20px; letter-spacing: 3px;
  padding: 14px 40px; border-radius: 4px; clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
}
.deploy:hover { filter: brightness(1.1); }
.ghost { background: none; border: 1px solid var(--line); color: var(--dim); padding: 6px 12px; border-radius: 4px; font-size: 12px; }
.ghost:hover { color: var(--text); border-color: #3d4856; }
.ghost.red { color: var(--bad); border-color: rgba(255, 85, 68, 0.4); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card {
  --c: var(--accent);
  text-align: left; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--c);
  border-radius: 6px; padding: 14px; display: flex; flex-direction: column; gap: 6px;
}
button.card:hover { border-color: #3d4856; border-top-color: var(--c); }
.card.on { box-shadow: 0 0 0 1px var(--c), 0 0 20px -8px var(--c); }
.card h4 { margin: 0; font-size: 15px; }
.card p { margin: 0; font-size: 13px; color: var(--dim); flex: 1; }
.card .meta { font-size: 12px; color: var(--dim); display: flex; justify-content: space-between; align-items: center; }
.card .icon { font-size: 26px; color: var(--c); }
.code { display: flex; gap: 4px; }
.ar { color: var(--c); background: #1a2028; border-radius: 3px; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.tag { font-size: 11px; color: var(--good); letter-spacing: 1px; font-weight: 700; }
.buy { background: #1d242d; border: 1px solid #3a4450; padding: 8px; border-radius: 4px; font-weight: 600; margin-top: 4px; }
.buy:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.pips { display: flex; gap: 4px; }
.pips i { width: 18px; height: 6px; background: #1d242d; border-radius: 2px; }
.pips i.f { background: var(--accent); }

.help .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 900px) { .help .cols { grid-template-columns: 1fr; } }
.help table { border-collapse: collapse; width: 100%; }
.help td { padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
.help td:first-child { white-space: nowrap; color: var(--accent); }
.help ol, .help p { color: var(--dim); font-size: 14px; line-height: 1.6; }
.danger { margin-top: 30px; display: flex; gap: 10px; }

/* ---------------- OVERLAYS ---------------- */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(3, 5, 8, 0.72); z-index: 10; padding: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 8px; padding: 26px 32px; min-width: 340px; max-width: 520px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.panel h2 { font-size: 26px; margin: 0; }
.big { background: var(--accent); color: #1a1505; border: none; font-weight: 700; font-size: 18px; letter-spacing: 2px; padding: 12px; border-radius: 4px; }
.results.win { border-top-color: var(--good); }
.results.win h2 { color: var(--good); }
.results.lose { border-top-color: var(--bad); }
.results.lose h2 { color: var(--bad); }
.results table { width: 100%; border-collapse: collapse; text-align: left; }
.results td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.results td:last-child { text-align: right; font-weight: 700; }
.banner { background: rgba(255, 224, 138, 0.1); border: 1px solid var(--accent); color: var(--accent); padding: 8px; border-radius: 4px; font-weight: 700; }

.lu { text-align: center; }
.lu h2 { font-size: 22px; margin-bottom: 20px; }
.cards { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.lcard {
  --c: var(--accent);
  width: 230px; min-height: 260px; background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--c);
  border-radius: 8px; padding: 18px 16px; position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: transform .1s, box-shadow .1s; animation: pop .25s ease-out both;
}
.lcard:nth-child(2) { animation-delay: .05s; }
.lcard:nth-child(3) { animation-delay: .1s; }
@keyframes pop { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.lcard:hover { transform: translateY(-4px); box-shadow: 0 0 0 1px var(--c), 0 10px 30px -10px var(--c); }
.lcard .key { position: absolute; top: 8px; left: 10px; color: var(--dim); font-size: 12px; border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; }
.lcard .kind { font-size: 11px; letter-spacing: 1.5px; color: var(--c); font-weight: 700; }
.lcard .licon { font-size: 40px; color: var(--c); line-height: 1.2; margin: 6px 0; }
.lcard h3 { margin: 0; color: var(--text); font-size: 17px; text-transform: none; letter-spacing: 0.5px; }
.lcard p { color: var(--dim); font-size: 14px; margin: 6px 0 0; }
.lcard .lvl { display: flex; gap: 3px; }
.lcard .lvl i { width: 14px; height: 5px; background: #1d242d; border-radius: 2px; }
.lcard .lvl i.f { background: var(--c); }
.reroll { margin-top: 20px; background: none; border: 1px solid var(--line); color: var(--dim); padding: 8px 20px; border-radius: 4px; }
.reroll:hover { color: var(--text); border-color: var(--accent); }
.brief p.tip { color: var(--blue); }
.brief p.tip b { color: var(--blue); }

/* ---------------- PIXEL UI OVERRIDES ---------------- */
* { border-radius: 0 !important; }
#game { image-rendering: pixelated; }
.hubwin { border: 3px solid #000; outline: 2px solid var(--line); border-top: 4px solid var(--accent); box-shadow: 8px 8px 0 rgba(0,0,0,0.6); animation: none; background: #0b0e13; }
.topbar { backdrop-filter: none; background: #0b0e13; border-bottom: 3px solid #000; }
.planet, .mission, .card, .brief, .dbtn, .lcard, .panel { border-width: 2px; box-shadow: 4px 4px 0 #000; }
.planet:hover, .lcard:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 #000; }
.deploy, .big { clip-path: none; box-shadow: 4px 4px 0 #000; border: 2px solid #000; }
.deploy:active, .big:active, .buy:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #000; }
.buy, .ghost, .close, .reroll, .tab { box-shadow: 3px 3px 0 #000; border-width: 2px; }
.orb { image-rendering: pixelated; box-shadow: 0 0 0 3px #000; }
.libbar { height: 10px; border: 2px solid #000; }
.lcard { animation: none; }
.logo { letter-spacing: 2px; }
h2 { letter-spacing: 1px; }
kbd { border-width: 2px; border-bottom-width: 4px; }

/* ---------------- CO-OP ---------------- */
#toasts { position: fixed; top: 16px; right: 16px; z-index: 30; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; background: #0b0e13; border: 2px solid #000; outline: 2px solid var(--line); border-left: 6px solid var(--accent); padding: 10px 14px; box-shadow: 4px 4px 0 #000; max-width: 340px; font-size: 15px; }
.toast.invite { border-left-color: var(--blue); }
.toast .row { display: flex; gap: 8px; margin-top: 8px; }
.toast button { background: var(--accent); color: #1a1505; border: 2px solid #000; padding: 4px 12px; font-weight: 700; box-shadow: 2px 2px 0 #000; }
.toast button.ghost { background: none; color: var(--dim); }
.squad input { flex: 1; min-width: 0; background: #06080b; border: 2px solid var(--line); color: var(--text); padding: 8px 10px; font: inherit; }
.squad input:focus { outline: 2px solid var(--accent); }
.netrow { display: flex; gap: 8px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.member { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.member i { width: 10px; height: 16px; display: inline-block; }
.member button { margin-left: auto; }
.err { color: var(--bad); }

/* online level-up: non-blocking bar at the bottom, the fight stays visible */
#levelup.live { background: none; align-items: flex-end; padding-bottom: 96px; pointer-events: none; }
#levelup.live .lu { pointer-events: auto; background: rgba(8,11,16,0.92); border: 2px solid #000; outline: 2px solid var(--line); padding: 10px 14px; box-shadow: 4px 4px 0 #000; }
#levelup.live h2 { font-size: 16px; margin: 0 0 8px; }
#levelup.live .cards { gap: 10px; flex-wrap: nowrap; }
#levelup.live .lcard { width: 190px; min-height: 0; padding: 10px; gap: 2px; }
#levelup.live .lcard .licon { font-size: 22px; margin: 0; }
#levelup.live .lcard h3 { font-size: 14px; }
#levelup.live .lcard p { font-size: 13px; margin: 2px 0 0; }
#levelup.live .reroll { margin-top: 8px; padding: 4px 12px; }
