:root {
  --bg: #0b0b14; --panel: #151526; --panel2: #1d1d33; --line: #2e2e4e; --text: #e8e6f0; --muted: #8a88a8;
  --gold: #ffd23a; --green: #3aff8a; --red: #ff3a4a; --blue: #4ab0ff; --purple: #c05aff;
}
* { 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; }
body { user-select: none; }
.hidden { display: none !important; }
canvas { image-rendering: pixelated; }
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
.screen { position: fixed; inset: 0; z-index: 2; overflow-y: auto; }
h2 { font-family: 'Pixelify Sans', sans-serif; font-size: 22px; margin: 14px 0 8px; color: var(--gold); letter-spacing: 1px; display: flex; gap: 10px; align-items: center; }
h3 { font-family: 'Pixelify Sans', sans-serif; color: var(--gold); margin: 10px 0 4px; }
.muted { color: var(--muted); }
.money { color: var(--green); }
.panel { background: rgba(21, 21, 38, 0.92); border: 2px solid var(--line); box-shadow: 0 0 0 2px #05050a, 6px 6px 0 rgba(0,0,0,.4); padding: 14px; }
button {
  font-family: 'Pixelify Sans', sans-serif; font-size: 18px; color: #111; background: var(--gold); border: none; padding: 9px 16px; cursor: pointer;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,.25), inset 3px 3px 0 rgba(255,255,255,.35), 0 0 0 2px #05050a; transition: transform .05s;
}
button:hover { filter: brightness(1.1); }
button:active { transform: translateY(2px); }
button.ghost { background: var(--panel2); color: var(--text); }
button.small { font-size: 14px; padding: 5px 10px; }
button.big { font-size: 22px; padding: 12px 22px; }
button:disabled { opacity: .45; cursor: default; }
input, select {
  font-family: 'VT323', monospace; font-size: 22px; background: #0b0b16; color: var(--text); border: 2px solid var(--line); padding: 6px 10px; outline: none;
}
input:focus, select:focus { border-color: var(--gold); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

/* MENU */
#menu { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.logo { font-family: 'Pixelify Sans', sans-serif; font-weight: 700; text-align: center; line-height: .9; text-shadow: 6px 6px 0 #000; }
.logo .l1 { display: block; font-size: clamp(54px, 11vw, 120px); color: var(--text); letter-spacing: 8px; }
.logo .l2 { display: block; font-size: clamp(54px, 11vw, 120px); color: var(--gold); letter-spacing: 8px; }
.tag { color: var(--muted); font-size: 22px; letter-spacing: 2px; }
.menuPanel { display: flex; flex-direction: column; gap: 10px; width: min(380px, 92vw); }
.menuPanel label { color: var(--muted); }
#code { text-transform: uppercase; letter-spacing: 6px; text-align: center; }
.conn { color: var(--muted); font-size: 18px; }
.conn.ok { color: var(--green); }

/* LOBBY */
#lobby { padding: 16px; background: rgba(8, 8, 14, .55); }
.lobbyHead { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 14px; background: rgba(21,21,38,.95); border: 2px solid var(--line); }
#roomCode { font-family: 'Pixelify Sans'; font-size: 30px; color: var(--gold); letter-spacing: 6px; margin: 0 10px; }
.cols { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; max-width: 1400px; margin: 0 auto; }
@media (max-width: 1000px) { .cols { grid-template-columns: 1fr; } }
#crew { display: flex; gap: 10px; flex-wrap: wrap; }
.crewCard { display: flex; gap: 8px; align-items: center; background: var(--panel); border: 2px solid var(--line); padding: 6px 10px 6px 6px; min-width: 180px; }
.crewCard canvas { width: 48px; height: 48px; background: #0b0b16; }
.crewCard .nm { font-size: 22px; }
.crewCard .rl { color: var(--muted); font-size: 16px; }
.crewCard.me { border-color: var(--gold); }
.badge { font-size: 14px; padding: 1px 6px; background: var(--panel2); color: var(--muted); margin-left: 4px; }
.badge.ok { background: #1a4a2a; color: var(--green); }
.badge.host { background: #4a3a10; color: var(--gold); }
.charGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 600px) { .charGrid { grid-template-columns: repeat(2, 1fr); } }
.charCard { background: var(--panel); border: 2px solid var(--line); padding: 8px; cursor: pointer; text-align: center; position: relative; }
.charCard:hover { border-color: #5a5a8a; }
.charCard.sel { border-color: var(--gold); background: #24243c; }
.charCard.taken { opacity: .4; cursor: not-allowed; }
.charCard canvas { width: 64px; height: 64px; display: block; margin: 0 auto 4px; }
.charCard .nm { font-family: 'Pixelify Sans'; font-size: 18px; }
.charCard .rl { color: var(--muted); font-size: 16px; }
.charCard .who { position: absolute; top: 4px; right: 4px; font-size: 13px; background: var(--gold); color: #111; padding: 0 4px; }
#charInfo { margin-top: 10px; display: grid; grid-template-columns: 96px 1fr; gap: 14px; }
#charInfo canvas { width: 96px; height: 96px; background: #0b0b16; border: 2px solid var(--line); }
.stat { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 6px; font-size: 17px; }
.stat .bar { display: flex; gap: 2px; }
.stat .bar i { width: 18px; height: 9px; background: #2a2a44; }
.stat .bar i.on { background: var(--gold); }
.abil { margin-top: 6px; font-size: 18px; line-height: 1.1; }
.abil b { color: var(--gold); font-family: 'Pixelify Sans'; font-weight: 600; font-size: 16px; }
.abil kbd, kbd { display: inline-block; background: #2a2a44; color: var(--text); padding: 0 6px; border-bottom: 2px solid #111; font-family: 'Pixelify Sans'; font-size: 14px; }
#contracts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.contract { background: var(--panel); border: 2px solid var(--line); padding: 10px; cursor: pointer; position: relative; }
.contract:hover { border-color: #5a5a8a; }
.contract.sel { border-color: var(--gold); background: #24243c; }
.contract .ct { font-family: 'Pixelify Sans'; font-size: 19px; color: var(--text); }
.contract .cd { color: var(--muted); font-size: 17px; line-height: 1; margin: 4px 0; }
.contract .meta { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 15px; padding: 0 6px; background: #2a2a44; }
.chip.d-latwy { background: #1a4a2a; color: var(--green); }
.chip.d-normalny { background: #4a3a10; color: var(--gold); }
.chip.d-trudny { background: #4a1418; color: #ff8a8a; }
.chip.mod { background: #2a1a44; color: #d0a0ff; }
.stars { color: var(--gold); letter-spacing: 1px; }
.custom { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.custom.sel { border-color: var(--gold); }
.ctitle { font-family: 'Pixelify Sans'; color: var(--gold); }
.mods { display: flex; flex-wrap: wrap; gap: 6px; font-size: 17px; }
.mods label { display: flex; align-items: center; gap: 4px; background: #1a1a2e; padding: 2px 6px; cursor: pointer; }
.hist { margin: 10px 0; font-size: 17px; color: var(--muted); }
.chat { margin-top: 10px; padding: 8px; }
#chatLog { height: 110px; overflow-y: auto; font-size: 18px; margin-bottom: 6px; }
#chatLog .from { color: var(--gold); }
#chatIn { width: 100%; font-size: 18px; }
.startRow { display: flex; gap: 10px; margin-top: 12px; justify-content: flex-end; }

/* GRA */
#game { position: fixed; inset: 0; z-index: 3; background: #000; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
#hud { position: absolute; inset: 0; pointer-events: none; }
.hpanel { background: rgba(10, 10, 20, .8); border: 2px solid #26264a; padding: 8px 10px; }
#hObj { position: absolute; left: 12px; top: 12px; max-width: 360px; font-size: 19px; line-height: 1.05; }
#hObj .ot { font-family: 'Pixelify Sans'; color: var(--gold); font-size: 15px; letter-spacing: 1px; }
#hObj .on { font-size: 21px; }
#hObj .done { color: var(--green); }
#hObj .sub { color: var(--muted); font-size: 17px; margin-top: 4px; }
#hObj .icons { display: flex; gap: 6px; margin-top: 4px; align-items: center; }
#hObj .card { width: 22px; height: 14px; display: inline-block; border: 1px solid #000; }
#hAlarm { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); font-family: 'Pixelify Sans'; font-size: 22px; padding: 6px 18px; border: 2px solid; letter-spacing: 2px; text-align: center; min-width: 220px; }
#hAlarm.a0 { color: var(--green); border-color: #1a5a3a; background: rgba(10,30,20,.8); }
#hAlarm.a1 { color: var(--gold); border-color: #6a5a1a; background: rgba(40,30,5,.85); }
#hAlarm.a2 { color: #fff; border-color: #ff3a4a; background: rgba(120,10,20,.88); animation: blink 0.8s infinite; }
@keyframes blink { 50% { background: rgba(60,5,10,.88); } }
#hAlarm small { display: block; font-family: 'VT323'; font-size: 18px; letter-spacing: 0; }
#hMapWrap { position: absolute; right: 12px; top: 12px; padding: 6px; }
#hFloor { font-family: 'Pixelify Sans'; color: var(--gold); font-size: 15px; margin-bottom: 4px; display: flex; justify-content: space-between; }
#mini { display: block; width: 200px; height: 150px; background: #05050a; }
#hTeam { position: absolute; left: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.tm { display: flex; gap: 6px; align-items: center; background: rgba(10,10,20,.8); border: 2px solid #26264a; padding: 4px 8px 4px 4px; min-width: 210px; }
.tm canvas { width: 32px; height: 32px; }
.tm .nm { font-size: 18px; line-height: 1; }
.tm .hp { width: 140px; height: 7px; background: #3a1a1a; margin-top: 3px; }
.tm .hp i { display: block; height: 100%; background: var(--green); }
.tm .st { font-size: 15px; color: var(--muted); }
.tm.down { border-color: var(--red); }
#hBar { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 8px; align-items: flex-end; }
.ab { width: 74px; height: 74px; background: rgba(10,10,20,.85); border: 2px solid #3a3a6a; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 3px; }
.ab .k { position: absolute; left: 3px; top: 1px; font-family: 'Pixelify Sans'; font-size: 13px; color: var(--gold); }
.ab .n { font-size: 15px; line-height: .9; }
.ab .cd { position: absolute; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; font-family: 'Pixelify Sans'; font-size: 22px; color: #fff; }
.ab.ready { border-color: var(--gold); }
.bag { min-width: 190px; max-width: 280px; font-size: 16px; line-height: 1; background: rgba(10,10,20,.85); border: 2px solid #3a3a6a; padding: 5px 7px; }
.bag .bt { font-family: 'Pixelify Sans'; color: var(--gold); font-size: 13px; display: flex; justify-content: space-between; }
.bag .w { height: 5px; background: #2a2a44; margin: 3px 0; }
.bag .w i { display: block; height: 100%; background: var(--gold); }
.bag .it { color: #cfcfe8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bag .it.tg { color: #ff8aff; }
#hPrompt { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); font-size: 22px; background: rgba(10,10,20,.85); border: 2px solid var(--gold); padding: 4px 12px; white-space: nowrap; display: none; }
#hPrompt.hint { border-color: #6a6a8a; color: var(--muted); }
#hPrompt kbd { margin-right: 6px; background: var(--gold); color: #111; }
#hProg { position: absolute; left: 50%; bottom: 190px; transform: translateX(-50%); width: 260px; height: 18px; background: rgba(0,0,0,.8); border: 2px solid var(--gold); display: none; }
#hProgIn { height: 100%; width: 0; background: var(--gold); }
#hProgL { position: absolute; inset: 0; text-align: center; font-size: 16px; line-height: 14px; color: #fff; text-shadow: 1px 1px 0 #000; }
#hLog { position: absolute; right: 12px; top: 200px; width: 360px; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.lg { background: rgba(10,10,20,.82); padding: 2px 8px; font-size: 18px; border-left: 3px solid #4a4a7a; transition: opacity .5s; }
.lg.good { border-color: var(--green); }
.lg.warn { border-color: var(--gold); color: #ffe9a0; }
.lg.alarm { border-color: var(--red); color: #ffb0b0; }
.lg.chat { border-color: var(--blue); }
#hCenter { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); text-align: center; font-family: 'Pixelify Sans'; font-size: 30px; text-shadow: 3px 3px 0 #000; }
#hCenter small { display: block; font-family: 'VT323'; font-size: 22px; color: #ddd; }
#gChat { position: absolute; left: 50%; bottom: 110px; transform: translateX(-50%); width: 420px; pointer-events: auto; }
#hKeys { position: absolute; right: 12px; bottom: 8px; color: #6a6a8a; font-size: 16px; }

/* OVERLAY */
.overlay { position: fixed; inset: 0; z-index: 10; background: rgba(4,4,10,.86); display: flex; align-items: center; justify-content: center; overflow-y: auto; padding: 20px; }
.helpPanel { max-width: 860px; font-size: 19px; line-height: 1.15; }
.helpPanel .keys { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; margin: 10px 0; }
.helpPanel ul { padding-left: 20px; margin: 4px 0 14px; }
#bigmap { flex-direction: column; gap: 8px; }
.bmHead { font-family: 'Pixelify Sans'; color: var(--gold); display: flex; gap: 10px; align-items: center; font-size: 20px; }
#bmc { max-width: 95vw; max-height: 82vh; background: #05050a; border: 2px solid var(--line); }
.resPanel { max-width: 760px; width: 100%; text-align: center; }
.rank { font-family: 'Pixelify Sans'; font-size: 120px; line-height: 1; text-shadow: 6px 6px 0 #000; }
.rank.r-S, .rank.r-Splus { color: var(--gold); }
.rank.r-A { color: var(--green); }
.rank.r-B { color: var(--blue); }
.rank.r-C { color: #c8a0ff; }
.rank.r-D { color: var(--red); }
.resT { font-family: 'Pixelify Sans'; font-size: 30px; margin: 6px 0 12px; }
.resGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; margin: 12px 0; }
.resGrid .panel { padding: 10px; }
.resLine { display: flex; justify-content: space-between; font-size: 20px; }
.resLine b { color: var(--green); }
.payout { font-family: 'Pixelify Sans'; font-size: 40px; color: var(--green); margin: 10px 0; }
#toast { position: fixed; left: 50%; top: 20px; transform: translateX(-50%); z-index: 20; background: #4a1418; border: 2px solid var(--red); padding: 8px 16px; font-size: 20px; display: none; }
