:root {
  --white: #eef0f2;
  --dim: #9aa1a9;
  --gold: #d8ab4c;
  --gold2: #f1cf7a;
  --red: #ff3b30;
  --cyan: #6fd3ff;
  --green: #4cd964;
  --panel: rgba(8, 10, 14, 0.55);
  --line: rgba(255, 255, 255, 0.14);
  --mono: 'Share Tech Mono', ui-monospace, Menlo, monospace;
  --sans: 'Rajdhani', 'Arial Narrow', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--white); font-family: var(--sans); user-select: none; -webkit-user-select: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
canvas#hudcanvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.hidden { display: none !important; }
button { font-family: var(--sans); font-weight: 600; letter-spacing: 0.12em; font-size: 15px; color: var(--white); background: rgba(255,255,255,0.06); border: 1px solid var(--line); padding: 11px 18px; border-radius: 3px; cursor: pointer; transition: background .15s, border-color .15s, transform .1s; }
button:hover { background: rgba(255,255,255,0.13); border-color: rgba(255,255,255,0.35); }
button:active { transform: translateY(1px); }
button.primary { background: var(--white); color: #0b0c0f; border-color: var(--white); }
button.primary:hover { background: #fff; }
button.ghost { padding: 8px 12px; letter-spacing: 0; }
input, select { font-family: var(--sans); font-size: 16px; font-weight: 500; color: var(--white); background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-radius: 3px; padding: 9px 11px; width: 100%; outline: none; }
input:focus, select:focus { border-color: var(--gold); }
select option { background: #15171c; }
label { display: block; font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--dim); margin: 12px 0 6px; }
kbd { font-family: var(--mono); font-size: 12px; background: rgba(255,255,255,0.1); border: 1px solid var(--line); border-bottom-width: 2px; padding: 1px 6px; border-radius: 3px; margin-right: 3px; }
.dim { color: var(--dim); }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; z-index: 20; }
#loading { background: radial-gradient(ellipse at center, #15171c 0%, #050608 70%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
#loading .bar { width: 320px; height: 2px; background: rgba(255,255,255,0.12); overflow: hidden; }
#loading #loadbar { width: 0; height: 100%; background: var(--gold); transition: width .2s; }
#loadtext { font-family: var(--mono); font-size: 13px; color: var(--dim); letter-spacing: 0.1em; }
.logo { font-weight: 300; font-size: 34px; letter-spacing: 0.42em; color: var(--white); white-space: nowrap; }
.logo span { color: var(--gold); font-weight: 600; }
.logo.big { font-size: 38px; letter-spacing: 0.24em; }

#menu { background: linear-gradient(90deg, rgba(4,5,8,0.92) 0%, rgba(4,5,8,0.75) 34%, rgba(4,5,8,0) 62%); display: flex; }
.menu-left { width: min(520px, 100%); padding: 48px 40px 70px; overflow-y: auto; max-height: 100vh; }
.tagline { font-size: 16px; color: var(--dim); margin: 6px 0 22px; letter-spacing: 0.06em; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 6px 16px 16px; margin-bottom: 14px; backdrop-filter: blur(6px); }
.row { display: flex; gap: 8px; align-items: center; }
.row3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.hint { font-size: 12px; color: var(--dim); margin-top: 8px; }
#swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.15); cursor: pointer; position: relative; transition: transform .12s; }
.swatch:hover { transform: scale(1.08); }
.swatch.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(216,171,76,0.35); }
.swatch::after { content: attr(data-name); position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--dim); white-space: nowrap; opacity: 0; transition: opacity .12s; pointer-events: none; }
.swatch:hover::after { opacity: 1; }
#roomlist { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; max-height: 120px; overflow-y: auto; }
.roomitem { display: flex; justify-content: space-between; padding: 6px 10px; border: 1px solid var(--line); border-radius: 3px; cursor: pointer; font-size: 14px; }
.roomitem:hover { border-color: var(--gold); }
.roomitem span { color: var(--dim); font-family: var(--mono); font-size: 12px; }
.buttons { display: flex; gap: 10px; margin-top: 6px; }
.buttons button { flex: 1; padding: 14px; font-size: 16px; }
.links { margin-top: 14px; font-size: 14px; color: var(--dim); }
.links a { color: var(--white); text-decoration: none; border-bottom: 1px solid var(--line); }
.links a:hover { border-color: var(--gold); }
.menu-right { flex: 1; display: flex; align-items: flex-end; justify-content: flex-end; padding: 40px; pointer-events: none; }
.spec { background: var(--panel); border: 1px solid var(--line); padding: 14px 18px; border-radius: 4px; backdrop-filter: blur(6px); }
.spec-title { font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em; color: var(--gold); margin-bottom: 10px; }
.spec-grid { display: grid; grid-template-columns: repeat(3, auto); gap: 10px 26px; }
.spec-grid b { display: block; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); font-weight: 500; }
.spec-grid span { font-size: 20px; font-weight: 600; }
.disclaimer { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 40px; font-size: 12px; color: rgba(255,255,255,0.45); background: linear-gradient(0deg, rgba(0,0,0,0.6), transparent); pointer-events: none; }

.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
.modal-body { width: min(720px, calc(100% - 32px)); max-height: calc(100vh - 60px); overflow-y: auto; background: rgba(12,14,18,0.96); border: 1px solid var(--line); border-radius: 6px; padding: 26px 30px; font-size: 16px; line-height: 1.5; }
.modal-body h2 { margin: 0 0 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.modal-body h3 { margin: 18px 0 4px; color: var(--gold); font-weight: 600; letter-spacing: 0.06em; }
.modal-body p { margin: 6px 0; color: #c9ced4; }
.modal-body .close { margin-top: 18px; }
.ctrl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 22px; font-size: 15px; }
.set-row { display: grid; grid-template-columns: 1fr 1.4fr; align-items: center; gap: 10px; margin: 8px 0; }
.set-row label { margin: 0; }
.set-row input[type=checkbox] { width: 20px; height: 20px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; font-family: var(--mono); text-shadow: 0 1px 2px rgba(0,0,0,0.7); }
#killfeed { position: absolute; top: 16px; left: 16px; display: flex; flex-direction: column; gap: 4px; font-family: var(--sans); font-size: 16px; font-weight: 600; }
.kf { background: rgba(0,0,0,0.42); padding: 3px 10px; border-left: 2px solid var(--gold); animation: kfin .25s ease-out; }
.kf .w { color: var(--dim); font-weight: 500; margin: 0 6px; font-size: 13px; }
.kf.me { border-left-color: var(--white); background: rgba(255,255,255,0.12); }
@keyframes kfin { from { transform: translateX(-20px); opacity: 0; } to { transform: none; opacity: 1; } }
#topcenter { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); text-align: center; }
#timer { font-size: 24px; letter-spacing: 0.12em; }
#leader { font-family: var(--sans); font-size: 14px; color: var(--dim); letter-spacing: 0.08em; }
#warn { position: absolute; top: 22%; left: 50%; transform: translateX(-50%); white-space: nowrap; font-family: var(--sans); font-weight: 700; font-size: 24px; letter-spacing: 0.22em; color: var(--red); padding: 4px 18px; border: 1px solid var(--red); background: rgba(80,0,0,0.25); animation: blink .5s steps(2) infinite; }
#warn.lock { color: var(--gold2); border-color: var(--gold2); background: rgba(80,60,0,0.2); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
#popups { position: absolute; top: 34%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; font-family: var(--sans); }
.pop { font-size: 26px; font-weight: 700; letter-spacing: 0.18em; color: var(--white); animation: popin 1.8s ease-out forwards; white-space: nowrap; }
.pop small { display: block; text-align: center; font-size: 15px; color: var(--gold2); letter-spacing: 0.12em; }
.pop.kill { color: var(--gold2); font-size: 30px; }
.pop.trick { color: var(--cyan); }
@keyframes popin { 0% { transform: scale(1.4); opacity: 0; } 12% { transform: scale(1); opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
#minimapwrap { position: absolute; top: 14px; right: 14px; }
#minimap { border-radius: 50%; border: 1px solid var(--line); background: rgba(0,0,0,0.35); display: block; }
#netinfo { text-align: right; font-size: 11px; color: var(--dim); margin-top: 4px; }

#flightpanel { position: absolute; left: 18px; bottom: 18px; min-width: 230px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
#flightpanel .big { font-size: 46px; line-height: 1; font-family: var(--sans); font-weight: 600; }
#flightpanel .big small { font-size: 14px; margin-left: 6px; color: var(--dim); letter-spacing: 0.15em; }
#flightpanel .row { justify-content: space-between; font-size: 13px; margin-top: 4px; color: #d6dade; gap: 14px; }
#flightpanel .tags span { font-size: 10px; letter-spacing: 0.08em; padding: 1px 5px; border: 1px solid var(--line); border-radius: 2px; color: var(--dim); }
#flightpanel .tags span.on { color: var(--gold2); border-color: rgba(216,171,76,0.6); }
#mode { color: var(--gold2); }

#vitals { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); width: 420px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
.vrow { display: grid; grid-template-columns: 54px 1fr 74px; align-items: center; gap: 10px; margin: 3px 0; font-size: 12px; }
.vrow label { margin: 0; font-size: 11px; letter-spacing: 0.15em; color: var(--dim); }
.vrow > span { text-align: right; }
.vrow.sub { grid-template-columns: 1fr auto; font-size: 11px; color: var(--dim); margin: -1px 0 4px 64px; }
#airwarn { color: var(--red); }
.bar { height: 7px; background: rgba(255,255,255,0.1); position: relative; overflow: hidden; border-radius: 1px; }
.bar > div { position: absolute; inset: 0; width: 100%; transform-origin: left; transition: background .2s; }
.bar.hp > div { background: linear-gradient(90deg, #eef0f2, #ffffff); }
.bar.hp > div.low { background: var(--red); }
.bar.air > div { background: linear-gradient(90deg, #6fd3ff, #bfefff); }
.bar.air > div.low { background: #ff9f0a; }
.bar.heat > div { background: linear-gradient(90deg, #d8ab4c, #ff6b2c); }
.bar.heat > div.over { background: var(--red); }
.copvs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.vrow.weapons { grid-template-columns: 1fr 1fr 1fr; margin-top: 6px; }
.vrow.weapons > div { display: flex; align-items: center; gap: 6px; }
.pip { display: inline-block; width: 7px; height: 12px; margin-right: 2px; background: rgba(255,255,255,0.15); }
.pip.on { background: var(--gold2); }
#blastst.ready { color: var(--cyan); }

#thrusterpanel { position: absolute; right: 18px; bottom: 18px; padding: 8px 10px 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; text-align: center; }
#thrusterpanel .cap { font-size: 10px; letter-spacing: 0.14em; color: var(--dim); }

#chat { position: absolute; left: 18px; bottom: 170px; width: 380px; font-family: var(--sans); font-size: 15px; pointer-events: none; }
#chatlog > div { background: rgba(0,0,0,0.35); padding: 2px 8px; margin-top: 2px; animation: kfin .2s; }
#chatlog > div b { color: var(--gold2); font-weight: 600; }
#chatlog > div.sys { color: var(--dim); font-style: italic; }
#chatin { pointer-events: auto; margin-top: 6px; }

#scoreboard { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(8,10,14,0.88); border: 1px solid var(--line); border-radius: 6px; padding: 14px 20px; min-width: 520px; }
#scoreboard table, #matchend table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 17px; }
#scoreboard th { font-size: 11px; letter-spacing: 0.15em; color: var(--dim); text-align: left; padding: 4px 10px; font-weight: 500; }
#scoreboard td, #matchend td { padding: 5px 10px; border-top: 1px solid rgba(255,255,255,0.06); }
#scoreboard tr.me td, #matchend tr.me td { background: rgba(255,255,255,0.08); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.bot { font-size: 11px; color: var(--dim); margin-left: 6px; letter-spacing: 0.1em; }

#death, #matchend { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); text-align: center; font-family: var(--sans); }
#death .t1, #matchend .t1 { font-size: 44px; font-weight: 300; letter-spacing: 0.5em; }
#deathby { font-size: 20px; color: var(--gold2); margin-top: 6px; letter-spacing: 0.08em; }
#respawn { font-family: var(--mono); color: var(--dim); margin-top: 10px; }
#matchend { background: rgba(8,10,14,0.88); border: 1px solid var(--line); padding: 20px 28px; border-radius: 6px; min-width: 460px; top: 46%; }
#winner { color: var(--gold2); font-size: 22px; margin: 6px 0 12px; }
#nextmatch { font-family: var(--mono); color: var(--dim); margin-top: 10px; }
#clickto { position: absolute; top: 58%; left: 50%; transform: translateX(-50%); font-family: var(--sans); font-size: 18px; letter-spacing: 0.25em; background: rgba(0,0,0,0.5); padding: 8px 18px; border: 1px solid var(--line); }
#damageflash { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(255,30,20,0.55) 100%); opacity: 0; transition: opacity .25s; }

#pause { background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); z-index: 30; }
.pause-box { display: flex; flex-direction: column; gap: 10px; width: 320px; text-align: center; }
.pause-box .logo { font-size: 22px; margin-bottom: 14px; }
#roominfo { font-family: var(--mono); font-size: 12px; margin-top: 10px; }

@media (max-width: 900px) {
  .menu-right { display: none; }
  .logo.big { font-size: 30px; }
  #vitals { width: 320px; }
  #thrusterpanel, #chat { display: none; }
  .ctrl-grid { grid-template-columns: 1fr; }
}
