:root {
  --bg: #0d1117; --panel: rgba(14, 18, 26, 0.93); --line: #2a3342; --text: #eef2f6; --muted: #9aa6b5;
  --accent: #f5b62a; --green: #5cd06a; --red: #ff4a4a; --blue: #6ab8ff; --hudc: #b8ffb0;
  --hud: 'Arial Black', 'Segoe UI Black', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-user-select: none; user-select: none; touch-action: none; }
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
canvas#ov { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 1; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
kbd { background: #f2f2f2; color: #111; border-radius: 4px; padding: 0 6px; font: 700 12px system-ui; box-shadow: 0 2px 0 #888; }

/* ------------------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
#hud button { pointer-events: auto; }
#feed { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 16px; display: flex; flex-direction: column; gap: 4px; max-width: 42vw; }
.feeditem { background: rgba(0,0,0,.45); padding: 4px 10px; border-radius: 6px; font-size: 13px; transition: opacity .6s; }
.feeditem.kill { border-left: 3px solid var(--red); } .feeditem.big { background: rgba(245,182,42,.85); color: #1b1300; font-weight: 700; } .feeditem.record { background: rgba(92,208,106,.85); color: #062b0d; font-weight: 700; }
.feeditem.out { opacity: 0; }
#notes { position: absolute; top: 20%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.note { background: rgba(10,14,20,.82); border: 1px solid var(--line); padding: 8px 16px; border-radius: 8px; font-weight: 600; transition: opacity .5s; text-align: center; max-width: 80vw; }
.note.error { border-color: #a33; color: #ffb3b3; } .note.warn { border-color: var(--accent); color: #ffe2a3; } .note.good { border-color: #3a7; color: #b8f5c8; }
.note.out { opacity: 0; }
#warn { position: absolute; top: 30%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: var(--hud); font-size: 20px; letter-spacing: 1px; text-shadow: 0 2px 0 #000, 0 0 8px rgba(0,0,0,.7); }
#warn .red { color: #ff3a3a; } #warn .amber { color: #ffc23a; }
#warn .blink { animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25 } }
#timer { position: absolute; top: max(62px, calc(env(safe-area-inset-top) + 50px)); left: 50%; transform: translateX(-50%); font-family: var(--hud); font-size: 26px; text-shadow: 0 3px 0 #000; white-space: nowrap; }
#timer b { font-family: system-ui; font-size: 14px; color: var(--accent); margin-right: 8px; vertical-align: 4px; } #timer small { font-size: 15px; color: var(--muted); margin-left: 6px; }
#help { position: absolute; bottom: max(150px, calc(env(safe-area-inset-bottom) + 130px)); left: 50%; transform: translateX(-50%); background: rgba(8,10,14,.75); border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; font-weight: 600; white-space: nowrap; }
#gauges { position: absolute; right: 22px; bottom: max(24px, env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 14px; font-family: var(--hud); color: var(--hudc); text-shadow: 0 2px 0 #000, 0 0 6px rgba(0,0,0,.6); }
.gauge { text-align: right; font-size: 34px; line-height: 1; min-width: 92px; }
.gauge small { font-size: 13px; margin-left: 3px; }
.gauge .sub { font: 600 11px system-ui; color: #ffd27a; margin-top: 3px; min-height: 13px; }
.thr { position: relative; width: 12px; height: 64px; border: 1px solid rgba(184,255,176,.6); border-radius: 3px; background: rgba(0,0,0,.4); }
.thr i { position: absolute; left: 1px; right: 1px; bottom: 1px; background: var(--hudc); border-radius: 2px; }
.thr::after { content: attr(data-v); position: absolute; top: -17px; right: -4px; font: 700 10px system-ui; }
#status { position: absolute; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(340px, 50vw); display: flex; flex-direction: column; gap: 5px; align-items: center; }
.bar { width: 100%; height: 8px; background: rgba(0,0,0,.55); border-radius: 4px; overflow: hidden; border: 1px solid rgba(0,0,0,.6); }
.bar i { display: block; height: 100%; width: 100%; transition: width .2s; }
.bar.hp i { background: linear-gradient(#69d16a, #3e9a46); } .bar.hp i.low { background: linear-gradient(#ff6a5a, #c0392b); }
.bar.heat { height: 4px; } .bar.heat i { background: #ffd27a; transition: none; } .bar.heat i.hot { background: #ff5a3a; }
#g-ammo { display: flex; gap: 16px; font-weight: 700; text-shadow: 0 1px 3px #000; }
#g-ammo .regen { font-size: 11px; color: var(--muted); font-weight: 600; }
#g-score { font-size: 12px; color: var(--muted); text-shadow: 0 1px 2px #000; }
#radarwrap { position: absolute; left: 18px; bottom: max(18px, env(safe-area-inset-bottom)); }
#radar { width: 190px; height: 190px; border-radius: 50%; border: 3px solid rgba(0,0,0,.75); box-shadow: 0 4px 18px rgba(0,0,0,.5); display: block; }
#chat { position: absolute; left: 226px; bottom: max(24px, env(safe-area-inset-bottom)); width: min(400px, 30vw); }
#chatlog { display: flex; flex-direction: column; gap: 2px; max-height: 170px; overflow: hidden; justify-content: flex-end; }
.chatline { font-size: 13px; text-shadow: 0 1px 2px #000; background: rgba(0,0,0,.3); padding: 2px 8px; border-radius: 4px; transition: opacity 1s; }
.chatline.old { opacity: 0; } #chatlog.open .chatline.old { opacity: .85; }
.chatline b { color: var(--accent); } .chatline.mine b { color: #9be7ff; }
#chatin { pointer-events: auto; width: 100%; margin-top: 4px; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--line); background: rgba(5,8,12,.85); color: var(--text); font: inherit; }
#hitmarker { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; opacity: 0; background: linear-gradient(45deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%), linear-gradient(-45deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%); }
#hitmarker.show { animation: hm .25s ease-out; }
#hitmarker.kill { background: linear-gradient(45deg, transparent 42%, #ff4040 42%, #ff4040 58%, transparent 58%), linear-gradient(-45deg, transparent 42%, #ff4040 42%, #ff4040 58%, transparent 58%); }
@keyframes hm { 0% { opacity: 1; transform: scale(1.3) } 100% { opacity: 0; transform: scale(1) } }
#dmgflash { position: absolute; inset: 0; box-shadow: inset 0 0 120px rgba(255,0,0,.75); opacity: 0; }
#dmgflash.show { animation: dmg .5s ease-out; }
@keyframes dmg { 0% { opacity: 1 } 100% { opacity: 0 } }
#bigtext { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
#bigtext .t { font-family: var(--hud); font-size: clamp(40px, 8vw, 100px); letter-spacing: 3px; text-shadow: 0 5px 0 #000, 0 0 30px rgba(0,0,0,.8); animation: bigin .5s ease-out; }
#bigtext .s { font-size: 19px; font-weight: 700; text-shadow: 0 2px 4px #000; margin-top: 4px; }
#bigtext.down .t { color: #e0202a; } #bigtext.pass .t { color: var(--accent); } #bigtext.record .t { color: var(--green); } #bigtext.fail .t { color: #ff5a4a; font-size: clamp(30px, 5vw, 60px); }
@keyframes bigin { 0% { transform: scale(1.6); opacity: 0 } 100% { transform: scale(1); opacity: 1 } }
body.dead canvas#view { filter: saturate(.4) brightness(.8); transition: filter 1.5s; }
#playerlist { position: absolute; top: 16%; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 18px; min-width: 380px; }
#playerlist table { border-collapse: collapse; width: 100%; } #playerlist td { padding: 3px 8px; } #playerlist td:nth-child(n+3) { text-align: right; }
#playerlist .plh td { font-weight: 700; color: var(--accent); border-bottom: 1px solid var(--line); } #playerlist .me { color: #9be7ff; }
.tick { color: var(--green); } .ai { font-size: 10px; color: #ff9a3a; border: 1px solid #ff9a3a; border-radius: 4px; padding: 0 4px; }
#fpsbox { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); font: 12px monospace; background: rgba(0,0,0,.5); padding: 2px 8px; border-radius: 4px; }
#topbtns { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 14px; display: flex; gap: 6px; align-items: center; }
.iconbtn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: rgba(10,14,20,.6); font-size: 17px; display: grid; place-items: center; }
.pill { height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line); background: rgba(10,14,20,.6); font-weight: 700; font-size: 13px; }
.pill.on { border-color: var(--blue); color: var(--blue); }

/* ------------------------------------------------------------ panels */
.panel { position: fixed; z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.6); left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); display: flex; flex-direction: column; }
.phead { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.phead span:first-child { flex: 1; }
.x { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); padding: 0 4px; }
.pbody { padding: 12px 14px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.course { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: rgba(255,255,255,.02); }
.course.current { border-color: var(--accent); }
.ct { font-weight: 700; } .lvl { font-size: 11px; color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 0 5px; margin-left: 6px; vertical-align: 1px; }
.cd { color: var(--muted); font-size: 13px; margin: 3px 0 4px; } .cs { font-size: 12px; color: var(--muted); margin-bottom: 8px; } .cs b { color: var(--green); }
.course button { padding: 7px 12px; border-radius: 8px; border: 0; background: var(--accent); color: #1b1300; font-weight: 700; }
.course button.ghost { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.course button.danger { background: #c0392b; color: #fff; }
.course .cs:last-child { margin-bottom: 0; }
#respawn { width: min(720px, calc(100vw - 32px)); }
.rsgo { display: flex; gap: 10px; } .rsgo .go { flex: 1; }
#mapwrap { position: fixed; inset: 0; z-index: 15; background: #10283a; }
#bigmap { width: 100%; height: 100%; display: block; }
.maptools { position: absolute; top: 14px; right: 14px; display: flex; gap: 6px; }
.maptools button { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font-weight: 700; }
.maplegend { position: absolute; left: 14px; bottom: 14px; display: flex; flex-wrap: wrap; gap: 12px; background: var(--panel); padding: 8px 12px; border-radius: 10px; font-size: 12px; }
.maplegend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }

/* ------------------------------------------------------------ hangar */
.pcards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pcard { text-align: left; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: rgba(255,255,255,.02); display: flex; flex-direction: column; gap: 3px; }
.pcard.on { border-color: var(--accent); background: rgba(245,182,42,.07); }
.pcard small { color: var(--accent); font-size: 11px; } .pdesc { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); width: 100%; }
.stat i { font-style: normal; width: 66px; white-space: nowrap; } .stat .trk { flex: 1; height: 5px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; } .stat em { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.pinfo { font-size: 11px; color: var(--muted); margin-top: 3px; }
.swrow { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.sw { display: flex; flex-wrap: wrap; gap: 6px; }
.sw button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.sw button.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.sw.text button { width: auto; height: auto; border-radius: 8px; padding: 5px 10px; border: 1px solid var(--line); background: transparent; color: var(--text); font-size: 12px; }
.sw.text button.on { border-color: var(--accent); color: var(--accent); box-shadow: none; }

/* ------------------------------------------------------------ menu */
.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; }
#menu { background: linear-gradient(90deg, rgba(8,10,16,.85) 0%, rgba(8,10,16,.5) 45%, rgba(8,10,16,0) 75%); place-items: center start; padding: 24px; overflow: auto; }
.menu-panel { width: min(520px, 100%); background: rgba(12,16,24,.84); border: 1px solid var(--line); border-radius: 18px; padding: 22px 24px; box-shadow: 0 24px 80px rgba(0,0,0,.5); backdrop-filter: blur(6px); margin-left: clamp(0px, 4vw, 60px); max-height: calc(100vh - 48px); overflow: auto; }
.menu-panel h1 { margin: 0; font-family: var(--hud); font-size: 54px; letter-spacing: 2px; line-height: 1; font-style: italic; text-shadow: 0 4px 0 #000; }
.menu-panel h1 span { color: var(--accent); margin-left: 10px; }
.lead { color: var(--muted); margin: 8px 0 6px; }
.online { font-size: 13px; color: var(--green); min-height: 1.4em; }
.mtabs { display: flex; gap: 4px; margin: 12px 0 14px; flex-wrap: wrap; }
.mtabs button { flex: 1; padding: 8px 6px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 600; }
.mtabs button.on { border-color: var(--accent); color: var(--accent); }
.menu-panel section { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field input:not([type=range]), .field select { padding: 10px 12px; border-radius: 8px; border: 1px solid #334; background: #0a0d12; color: var(--text); font: inherit; }
.field input[type=range] { accent-color: var(--accent); }
.seg { display: flex; gap: 6px; } .seg button { flex: 1; padding: 9px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 600; }
.seg button.on { border-color: var(--accent); color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.go { padding: 14px; border-radius: 10px; border: 0; background: var(--accent); color: #1b1300; font-weight: 800; font-size: 17px; letter-spacing: .5px; }
.go.alt { background: #3a7bd5; color: #fff; }
.go:disabled { opacity: .5; cursor: default; }
.msg { min-height: 1.3em; margin: 0; color: #ffb3b3; font-size: 13px; }
.account { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.account button { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--accent); background: transparent; color: var(--accent); font-weight: 700; }
.account .acctbtns { display: flex; gap: 8px; flex: none; }
.account a.acctlink { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); color: inherit; font-weight: 700; text-decoration: none; }
.account a.acctlink:hover { border-color: var(--accent); color: var(--accent); }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; font-size: 13px; }
footer { margin-top: 16px; font-size: 12px; color: var(--muted); } footer a { color: var(--muted); }
#board table { width: 100%; border-collapse: collapse; font-size: 13px; } #board td { padding: 4px 6px; border-bottom: 1px solid rgba(255,255,255,.05); } #board td:last-child { text-align: right; color: var(--green); } #board h3 { margin: 10px 0 4px; font-size: 14px; color: var(--accent); }
#loading { background: var(--bg); z-index: 40; flex-direction: column; }
#loading p { color: var(--muted); }
.spin { width: 42px; height: 42px; border-radius: 50%; border: 4px solid #223; border-top-color: var(--accent); animation: spin 1s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg) } }

/* ------------------------------------------------------------ touch */
#touch { position: fixed; inset: 0; z-index: 5; touch-action: none; }
#joy { position: absolute; width: 140px; height: 140px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); left: 40px; bottom: 120px; opacity: .5; pointer-events: none; }
#joy.on { opacity: 1; }
#joyknob { position: absolute; left: 45px; top: 45px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.35); }
.tbtns { position: absolute; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 58px); gap: 10px; direction: rtl; }
.tb { width: 58px; height: 58px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); background: rgba(10,14,20,.45); font-size: 20px; font-weight: 800; direction: ltr; }
.tb.big { width: 74px; height: 74px; font-size: 30px; color: #ff9a6a; }
.tb.on { background: rgba(245,182,42,.55); }
#touch.nomissile .msl { visibility: hidden; }
body.touch #gauges { bottom: auto; top: 60px; right: 14px; }
body.touch #radarwrap { left: 10px; top: 60px; bottom: auto; } body.touch #radar { width: 120px; height: 120px; }
body.touch #chat { display: none; } body.touch #status { bottom: 8px; width: 40vw; }
@media (max-width: 760px) {
  .menu-panel { margin-left: 0; padding: 18px; } .menu-panel h1 { font-size: 42px; }
  #menu { place-items: start center; background: rgba(8,10,16,.75); }
  .keys, .pcards { grid-template-columns: 1fr; }
  .gauge { font-size: 26px; min-width: 70px; }
}
.pcards.compact { grid-template-columns: repeat(4, 1fr); } .pcards.compact .pcard { padding: 8px 10px; }
@media (max-width: 760px) { .pcards.compact { grid-template-columns: repeat(2, 1fr); } }

/* ------------------------------------------------------------ v2: handling + options */
:root { --hs: 1; }
#gauges { transform: scale(var(--hs)); transform-origin: right bottom; }
#status { transform: translateX(-50%) scale(var(--hs)); transform-origin: center bottom; }
#radarwrap { transform: scale(var(--hs)); transform-origin: left bottom; }
#g-sys { display: flex; gap: 8px; min-height: 0; font: 800 12px var(--hud); letter-spacing: 1px; }
#g-sys span { padding: 1px 8px; border-radius: 6px; background: rgba(0,0,0,.45); }
#g-sys .flaps { color: #9be7ff; } #g-sys .boost { color: #ffb347; } #g-sys .hot { color: #ff6a5a; }
.bar.eng { height: 4px; } .bar.eng i { background: #ffb347; transition: none; } .bar.eng i.hot { background: #ff5a3a; }
#landing { position: absolute; bottom: max(196px, calc(env(safe-area-inset-bottom) + 176px)); left: 50%; transform: translateX(-50%); background: rgba(8,10,14,.78); border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px; font-weight: 600; font-size: 13px; white-space: nowrap; }
#landing .ok { color: var(--green); } #landing .bad { color: #ff7a6a; }
.stabs { display: flex; gap: 4px; flex-wrap: wrap; }
.stabs button { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.stabs button.on { border-color: var(--accent); color: var(--accent); }
#settingsbody { display: flex; flex-direction: column; gap: 12px; }
.field .val { float: right; color: var(--text); font-weight: 600; }
.field .hint, .check + .hint { font-size: 11.5px; color: var(--muted); margin-top: -2px; }
.check-wrap { display: flex; flex-direction: column; gap: 2px; }
.srow-end { display: flex; justify-content: flex-end; }
.ghostbtn { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.ghostbtn:hover { color: var(--text); border-color: var(--muted); }
.keybind { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; font-size: 13px; }
.keybind button { min-width: 70px; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--line); background: #0a0d12; color: var(--text); font: 700 12px system-ui; }
.keybind button.wait { border-color: var(--accent); color: var(--accent); }
.keybind button.dup { border-color: #a33; }
