:root {
  --bg: #07080f;
  --panel: #10121d;
  --panel2: #171a29;
  --line: #2a2f48;
  --text: #e4e6f0;
  --dim: #8d92ad;
  --gold: #ffd166;
  --red: #ff4d4d;
  --green: #7bd88f;
  --cyan: #3ad1ff;
  --purple: #c9a0ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: 'VT323', monospace; font-size: 20px; overflow: hidden; }
canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
.hidden { display: none !important; }
button, input, select { font-family: inherit; font-size: 20px; }
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
.screen { position: fixed; inset: 0; z-index: 1; }

/* ---------- przyciski / panele ---------- */
.btn { background: var(--panel2); color: var(--text); border: 2px solid var(--line); padding: 6px 14px; cursor: pointer; box-shadow: 0 3px 0 #000; transition: transform .05s, border-color .1s; }
.btn:hover { border-color: var(--cyan); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #000; }
.btn.big { width: 100%; padding: 10px; font-size: 24px; margin-top: 8px; }
.btn.gold { background: #3a2f10; border-color: var(--gold); color: var(--gold); }
.btn.gold:hover { background: #4a3c14; }
.btn.ghost { background: transparent; }
.btn.small { font-size: 18px; padding: 3px 10px; }
.btn.on { background: #143a22; border-color: var(--green); color: var(--green); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
input, select { background: #0b0d16; color: var(--text); border: 2px solid var(--line); padding: 6px 8px; outline: none; }
input:focus, select:focus { border-color: var(--cyan); }
.panel { background: rgba(16, 18, 29, .94); border: 2px solid var(--line); padding: 12px 14px; box-shadow: 0 6px 0 rgba(0, 0, 0, .5); }
h2, h3, h4 { font-family: 'Press Start 2P', monospace; font-weight: normal; margin: 4px 0 10px; }
h3 { font-size: 12px; color: var(--gold); letter-spacing: 1px; }
h4 { font-size: 10px; color: var(--cyan); margin-top: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.hint { color: var(--dim); font-size: 18px; margin-top: 8px; min-height: 22px; }
.small-label { color: var(--dim); font-size: 16px; }

/* ---------- menu ---------- */
.menu-wrap { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, 92vw); text-align: center; }
.logo { font-family: 'Press Start 2P', monospace; font-size: clamp(34px, 8vw, 62px); line-height: 1.15; color: var(--gold); text-shadow: 4px 4px 0 #6a3a10, 8px 8px 0 rgba(0, 0, 0, .6); display: flex; flex-direction: column; }
.logo .l2 { color: #fff; text-shadow: 4px 4px 0 #2a3a6a, 8px 8px 0 rgba(0, 0, 0, .6); }
.tag { color: var(--dim); margin: 14px 0 18px; }
.menu-panel { text-align: left; display: flex; flex-direction: column; gap: 6px; }
.menu-panel label { color: var(--dim); }
.menu-panel .row input { flex: 1; text-transform: uppercase; letter-spacing: 6px; text-align: center; }
.or { text-align: center; color: var(--dim); margin: 8px 0 2px; }
.career { margin-top: 14px; color: var(--dim); font-size: 18px; }
.career b { color: var(--gold); }
.foot { color: #555b78; font-size: 16px; margin-top: 10px; }

/* ---------- lobby ---------- */
.lobby-grid { position: absolute; inset: 16px; display: grid; grid-template-columns: 280px 1fr 340px; gap: 14px; overflow: auto; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.code-box { text-align: center; margin-bottom: 10px; }
.code-big { font-family: 'Press Start 2P', monospace; font-size: 32px; color: var(--gold); letter-spacing: 6px; margin: 6px 0; }
#crew .member { display: flex; align-items: center; gap: 10px; padding: 6px; border-bottom: 1px dashed var(--line); }
#crew .member canvas { width: 40px; height: 40px; background: #0b0d16; border: 1px solid var(--line); }
#crew .member .nm { flex: 1; }
#crew .member .st { font-size: 16px; }
.chat-panel { flex: 1; display: flex; flex-direction: column; min-height: 180px; }
#lobbyChat { flex: 1; overflow-y: auto; font-size: 18px; margin-bottom: 6px; max-height: 32vh; }
#lobbyChat .sys { color: var(--dim); }
#lobbyChat b { color: var(--cyan); }
#chars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ccard { background: var(--panel2); border: 2px solid var(--line); padding: 6px; text-align: center; cursor: pointer; position: relative; transition: transform .08s; }
.ccard:hover { transform: translateY(-2px); border-color: #4a5070; }
.ccard canvas { width: 72px; height: 72px; display: block; margin: 0 auto; }
.ccard .nm { font-family: 'Press Start 2P', monospace; font-size: 10px; margin-top: 4px; }
.ccard .rl { color: var(--dim); font-size: 16px; }
.ccard.mine { border-color: var(--gold); background: #2a2410; }
.ccard.taken { opacity: .45; cursor: not-allowed; }
.ccard .owner { position: absolute; top: 2px; right: 4px; font-size: 14px; color: var(--gold); }
#charInfo { margin-top: 12px; background: #0b0d16; border: 2px solid var(--line); padding: 10px 12px; min-height: 240px; }
#charInfo .top { display: flex; gap: 14px; align-items: center; }
#charInfo .top canvas { width: 96px; height: 96px; }
#charInfo .bio { color: var(--dim); }
.stats { display: grid; grid-template-columns: 110px 1fr; gap: 2px 10px; margin: 8px 0; font-size: 18px; }
.bar { height: 10px; background: #1a1d2c; margin-top: 5px; position: relative; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--cyan); }
.ab { margin: 6px 0; }
.ab .k { display: inline-block; min-width: 26px; text-align: center; background: #222638; border: 1px solid var(--line); margin-right: 6px; color: var(--gold); }
.ab .n { color: var(--gold); }
.ab .d { color: #c0c4d8; }
.ab .cd { color: var(--dim); font-size: 16px; }
.contract { background: var(--panel2); border: 2px solid var(--line); padding: 8px 10px; margin-bottom: 8px; cursor: pointer; }
.contract:hover { border-color: #4a5070; }
.contract.sel { border-color: var(--gold); background: #2a2410; }
.contract .t { display: flex; justify-content: space-between; align-items: baseline; }
.contract .nm { color: #fff; font-size: 21px; }
.contract .ty { color: var(--dim); font-size: 17px; }
.contract .stars { color: var(--gold); letter-spacing: 2px; }
.contract .pay { color: var(--green); }
.contract .mods { margin-top: 3px; }
.chip { display: inline-block; font-size: 15px; padding: 0 6px; margin: 2px 3px 0 0; border: 1px solid var(--line); color: #c0c4d8; }
#hostCtl { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
#hostCtl select { flex: 1; min-width: 0; }

/* ---------- gra ---------- */
#screen-game { background: #000; cursor: none; }
#game, #ui { position: absolute; inset: 0; width: 100%; height: 100%; }
#ui { pointer-events: none; image-rendering: auto; }
#vignette { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 160px rgba(0, 0, 0, .7); transition: box-shadow .2s; }
#vignette.hurt { box-shadow: inset 0 0 200px rgba(255, 30, 30, .7); }
#vignette.alarm { animation: alarmPulse 1.2s infinite; }
@keyframes alarmPulse { 0%, 100% { box-shadow: inset 0 0 160px rgba(0, 0, 0, .7); } 50% { box-shadow: inset 0 0 220px rgba(255, 30, 30, .45); } }
#hud { position: absolute; inset: 0; pointer-events: none; font-size: 19px; text-shadow: 2px 2px 0 #000; }
#hud .panel { padding: 8px 10px; }
#hTopLeft { position: absolute; left: 12px; top: 12px; max-width: 360px; }
#hMission { font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--gold); }
#hFloor { color: var(--cyan); margin-top: 4px; }
#hObj { margin-top: 6px; background: rgba(10, 11, 20, .75); border: 2px solid var(--line); padding: 6px 10px; }
#hObj .o { margin: 2px 0; }
#hObj .o.done { color: var(--green); }
#hObj .sub { color: var(--dim); font-size: 17px; }
#hAlarm { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); font-family: 'Press Start 2P', monospace; font-size: 12px; padding: 8px 14px; border: 2px solid; background: rgba(10, 11, 20, .8); white-space: nowrap; }
#hAlarm.calm { color: var(--green); border-color: #1f4a2a; }
#hAlarm.sus { color: var(--gold); border-color: #5a4a10; }
#hAlarm.alarm { color: #fff; border-color: var(--red); background: rgba(120, 10, 10, .85); animation: blink 1s infinite; }
@keyframes blink { 50% { background: rgba(60, 5, 5, .85); } }
#hTopRight { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#minimap { width: 200px; border: 2px solid var(--line); background: rgba(5, 6, 12, .85); }
#hTeam { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.tm { display: flex; align-items: center; gap: 6px; background: rgba(10, 11, 20, .78); border: 2px solid var(--line); padding: 2px 8px 2px 4px; min-width: 190px; }
.tm canvas { width: 28px; height: 28px; }
.tm .nm { flex: 1; }
.tm .hp { color: var(--red); letter-spacing: -2px; }
.tm .st { font-size: 15px; color: var(--dim); }
.tm.down { border-color: var(--red); }
.tm.out { opacity: .5; }
#hBottomLeft { position: absolute; left: 12px; bottom: 12px; }
#hInv { background: rgba(10, 11, 20, .78); border: 2px solid var(--line); padding: 6px 10px; min-width: 180px; }
#hInv .money { color: var(--green); font-size: 22px; }
#hInv .card { display: inline-block; width: 18px; height: 12px; margin-right: 4px; border: 1px solid #000; vertical-align: middle; }
#hInv .codes { color: var(--gold); font-size: 17px; }
#hBottom { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
#hPrompt { background: rgba(10, 11, 20, .85); border: 2px solid var(--line); padding: 4px 12px; font-size: 21px; min-height: 0; text-align: center; }
#hPrompt:empty { display: none; }
#hPrompt .key { color: #000; background: var(--gold); padding: 0 6px; margin-right: 6px; }
#hPrompt .why { color: var(--red); }
#hPrompt .hint { color: var(--dim); font-size: 17px; margin: 0; }
#hBag { color: var(--gold); background: rgba(10, 11, 20, .85); border: 2px solid #5a4a10; padding: 2px 10px; }
#hBag:empty { display: none; }
#hAbil { display: flex; gap: 10px; }
.abl { position: relative; width: 210px; background: rgba(10, 11, 20, .85); border: 2px solid var(--line); padding: 4px 8px 4px 40px; min-height: 48px; overflow: hidden; }
.abl .key { position: absolute; left: 6px; top: 8px; width: 26px; height: 26px; background: #222638; border: 1px solid var(--line); text-align: center; line-height: 24px; color: var(--gold); font-size: 22px; }
.abl .nm { font-size: 19px; }
.abl .ds { font-size: 15px; color: var(--dim); line-height: 1; }
.abl .cdv { position: absolute; inset: 0; background: rgba(0, 0, 0, .65); display: flex; align-items: center; justify-content: center; font-size: 24px; color: #fff; }
.abl.passive { border-style: dashed; }
.abl.ready { border-color: var(--green); }
#hFeed { position: absolute; right: 12px; bottom: 12px; width: 380px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
#hFeed div { background: rgba(10, 11, 20, .75); padding: 1px 8px; font-size: 18px; animation: fadeIn .2s; max-width: 100%; }
@keyframes fadeIn { from { opacity: 0; transform: translateX(10px); } }
#hSpect { position: absolute; left: 50%; top: 60px; transform: translateX(-50%); background: rgba(80, 10, 10, .85); border: 2px solid var(--red); padding: 6px 14px; }
#hKeys { position: absolute; left: 12px; bottom: 120px; color: #555b78; font-size: 16px; }
#chatIn { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); width: 420px; pointer-events: auto; }
#bigmap { position: absolute; inset: 40px; background: rgba(5, 6, 12, .94); border: 2px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 10px; z-index: 5; }
.bm-head { width: 100%; display: flex; justify-content: space-between; color: var(--gold); }
.bm-hint { color: var(--dim); }
#bigmapCv { flex: 1; max-width: 100%; max-height: calc(100% - 70px); margin: 8px 0; }
#bmLegend { color: var(--dim); font-size: 17px; }
#bmLegend i { display: inline-block; width: 10px; height: 10px; margin: 0 4px 0 12px; }

/* ---------- modale ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .7); z-index: 20; display: flex; align-items: center; justify-content: center; }
.help-panel { width: min(1100px, 94vw); max-height: 90vh; overflow: auto; }
.help-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.help-cols p { margin: 6px 0; color: #c8cbe0; }
.help-panel h2 { font-size: 16px; color: var(--gold); }
.result-panel { width: min(640px, 94vw); text-align: center; }
#resTitle { font-family: 'Press Start 2P', monospace; font-size: 26px; margin: 10px 0 14px; }
#resTitle.success { color: var(--gold); }
#resTitle.partial { color: var(--cyan); }
#resTitle.fail { color: var(--red); }
.res-pay { font-size: 40px; color: var(--green); margin: 6px 0; }
.res-grid { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; text-align: left; margin: 10px auto; max-width: 420px; }
.res-grid span:nth-child(even) { text-align: right; color: var(--gold); }
.res-pl { margin-top: 10px; text-align: left; }
.res-pl div { padding: 3px 0; border-bottom: 1px dashed var(--line); }
#toast { position: fixed; left: 50%; top: 20px; transform: translateX(-50%); background: #2a1010; border: 2px solid var(--red); padding: 6px 14px; z-index: 50; display: none; }

@media (max-width: 1100px) {
  .lobby-grid { grid-template-columns: 1fr; }
  #chars { grid-template-columns: repeat(4, 1fr); }
  .help-cols { grid-template-columns: 1fr; }
}
