:root {
  --bg: #0d1117; --panel: rgba(14, 18, 26, 0.92); --line: #2a3342; --text: #eef2f6; --muted: #9aa6b5;
  --accent: #f5b62a; --green: #5cd06a; --red: #ff4a4a; --blue: #4aa3ff;
  --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; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud .iconbtn { pointer-events: auto; }
.txt { text-shadow: 0 2px 0 #000, 0 0 6px rgba(0, 0, 0, .6); }
#topright { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 18px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
#weapon { font-family: var(--hud); font-size: 15px; display: flex; gap: 10px; align-items: baseline; text-shadow: 0 2px 0 #000; letter-spacing: .5px; }
#weapon #wammo { font-size: 18px; }
#weapon #wammo.low { color: var(--red); }
#weapon.reloading #wammo::after { content: ' ⟳'; color: var(--accent); }
#weapon.nodrive { opacity: .45; }
#money { font-family: var(--hud); font-size: 30px; color: #7ee07a; text-shadow: 0 3px 0 #0b2e0b, 0 0 8px rgba(0,0,0,.7); letter-spacing: 1px; }
#moneypops { position: relative; height: 0; }
.moneypop { position: absolute; right: 0; top: 0; white-space: nowrap; font-family: var(--hud); font-size: 16px; text-shadow: 0 2px 0 #000; animation: pop 2.6s ease-out forwards; }
.moneypop.up { color: #9cf59a; } .moneypop.down { color: #ff8a8a; }
@keyframes pop { 0% { transform: translateY(0); opacity: 0 } 10% { opacity: 1 } 100% { transform: translateY(34px); opacity: 0 } }
#stars { display: flex; gap: 2px; font-size: 26px; line-height: 1; opacity: .25; }
#stars.active { opacity: 1; }
#stars i { font-style: normal; color: rgba(255,255,255,.25); text-shadow: 0 2px 0 #000; }
#stars i.on { color: #fff; }
#stars i.on.blink { color: rgba(255,255,255,.35); }
#timer { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); font-family: var(--hud); font-size: 28px; text-shadow: 0 3px 0 #000; }
#timer.low { color: var(--red); }
#feed { position: absolute; top: 14px; left: 16px; display: flex; flex-direction: column; gap: 4px; max-width: 46vw; }
.feeditem { background: rgba(0,0,0,.45); padding: 4px 10px; border-radius: 6px; font-size: 13px; transition: opacity .6s; }
.feeditem.big { background: rgba(245,182,42,.85); color: #1b1300; font-weight: 700; }
.feeditem.out { opacity: 0; }
#notes { position: absolute; top: 22%; 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.pickup { border-color: #3a7; color: #b8f5c8; }
.note.out { opacity: 0; }
#radarwrap { position: absolute; left: 18px; bottom: max(18px, env(safe-area-inset-bottom)); width: 200px; }
#radar { width: 200px; height: 200px; border-radius: 50%; border: 3px solid rgba(0,0,0,.75); box-shadow: 0 4px 18px rgba(0,0,0,.5); display: block; }
#bars { display: flex; gap: 4px; margin-top: 6px; }
.bar { flex: 1; 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%; transition: width .25s; }
.bar.hp i { background: linear-gradient(#69d16a, #3e9a46); } .bar.hp i.low { background: linear-gradient(#ff6a5a, #c0392b); }
.bar.ar i { background: linear-gradient(#6ab8ff, #2f74c6); }
#chat { position: absolute; left: 230px; bottom: max(24px, env(safe-area-inset-bottom)); width: min(420px, 42vw); }
#chatlog { display: flex; flex-direction: column; gap: 2px; max-height: 180px; 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; }
#mission { position: absolute; bottom: max(70px, calc(env(safe-area-inset-bottom) + 56px)); left: 50%; transform: translateX(-50%); max-width: min(640px, 70vw); text-align: center; font-size: 17px; font-weight: 600; text-shadow: 0 2px 2px #000, 0 0 8px #000; }
#mission b { color: var(--accent); }
#prompt { position: absolute; bottom: max(118px, calc(env(safe-area-inset-bottom) + 104px)); left: 50%; transform: translateX(-50%); background: rgba(8,10,14,.78); border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; font-weight: 600; white-space: nowrap; }
#prompt kbd, .keys kbd { background: #f2f2f2; color: #111; border-radius: 4px; padding: 0 6px; font: 700 12px system-ui; box-shadow: 0 2px 0 #888; }
#district, #vehname { position: absolute; right: 22px; bottom: max(26px, env(safe-area-inset-bottom)); font-family: var(--hud); font-size: 24px; font-style: italic; text-shadow: 0 3px 0 #000; opacity: 0; }
#vehname { bottom: max(62px, calc(env(safe-area-inset-bottom) + 40px)); color: #ffd780; font-size: 20px; }
#district.show, #vehname.show { animation: fadeshow 3.2s ease forwards; }
@keyframes fadeshow { 0% { opacity: 0; transform: translateX(20px) } 10% { opacity: 1; transform: none } 80% { opacity: 1 } 100% { opacity: 0 } }
#speedo { position: absolute; right: 22px; bottom: max(100px, calc(env(safe-area-inset-bottom) + 80px)); font-family: var(--hud); font-size: 34px; text-shadow: 0 3px 0 #000; text-align: right; }
#speedo small { font-size: 14px; margin-left: 4px; }
.carhp { width: 110px; height: 6px; background: rgba(0,0,0,.5); border-radius: 3px; margin-left: auto; overflow: hidden; }
.carhp i { display: block; height: 100%; background: linear-gradient(90deg, #ff6a3a, #ffd23a); }
#crosshair { position: absolute; left: 50%; top: 50%; width: 0; height: 0; opacity: .55; --gap: 8px; }
#crosshair.on { opacity: 1; }
#crosshair i { position: absolute; background: #fff; box-shadow: 0 0 2px #000; }
#crosshair i:nth-child(1) { width: 2px; height: 7px; left: -1px; top: calc(-1 * var(--gap) - 7px); }
#crosshair i:nth-child(2) { width: 2px; height: 7px; left: -1px; top: var(--gap); }
#crosshair i:nth-child(3) { height: 2px; width: 7px; top: -1px; left: calc(-1 * var(--gap) - 7px); }
#crosshair i:nth-child(4) { height: 2px; width: 7px; top: -1px; left: var(--gap); }
#crosshair b { position: absolute; width: 3px; height: 3px; left: -1.5px; top: -1.5px; background: #fff; border-radius: 50%; box-shadow: 0 0 2px #000; }
#crosshair:not(.on) i { display: none; }
#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 { filter: drop-shadow(0 0 2px red) hue-rotate(0deg); 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 .6s ease-out; }
@keyframes dmg { 0% { opacity: 1 } 100% { opacity: 0 } }
#dmgdir { position: absolute; left: 50%; top: 50%; width: 260px; height: 260px; opacity: 0; border-radius: 50%; background: radial-gradient(circle at 50% 2%, rgba(255,40,40,.9) 0 10px, transparent 26px); }
#dmgdir.show { animation: dmg 1.2s ease-out; }
#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(44px, 9vw, 110px); 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: 20px; font-weight: 700; text-shadow: 0 2px 4px #000; margin-top: 4px; }
#bigtext.wasted .t { color: #d8141e; } #bigtext.busted .t { color: #4a7dff; } #bigtext.pass .t { color: var(--accent); } #bigtext.fail .t { color: #ff5a4a; } #bigtext.lost .t { color: #fff; font-size: clamp(28px, 5vw, 54px); }
@keyframes bigin { 0% { transform: scale(1.6); opacity: 0 } 100% { transform: scale(1); opacity: 1 } }
body.wasted canvas#view { filter: grayscale(1) brightness(.75) contrast(1.15); transition: filter 1.2s; }
#playerlist { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 18px; min-width: 260px; display: flex; flex-direction: column; gap: 4px; }
#playerlist .plh { font-weight: 700; color: var(--accent); margin-bottom: 4px; } #playerlist .me { color: #9be7ff; } .st { color: #ff9a8a; }
#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; }
.iconbtn { position: absolute; width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: rgba(10,14,20,.6); font-size: 18px; display: grid; place-items: center; }
#menubtn { top: max(10px, env(safe-area-inset-top)); left: 50%; margin-left: -120px; display: none; }
#phonebtn { top: max(10px, env(safe-area-inset-top)); left: 50%; margin-left: 70px; display: none; }
#mapbtn { top: max(10px, env(safe-area-inset-top)); left: 50%; margin-left: 120px; display: none; }
body.touch #menubtn, body.touch #phonebtn, body.touch #mapbtn { display: grid; }

/* ------------------------------------------------------------ panels: phone, shop, map */
.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); }
#phone { right: 24px; bottom: 24px; width: min(380px, calc(100vw - 32px)); max-height: min(620px, calc(100vh - 48px)); display: flex; flex-direction: column; }
#shop { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); display: flex; flex-direction: column; }
.phonehead { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.phonehead span:first-child { flex: 1; }
#shopmoney { color: #7ee07a; font-family: var(--hud); }
.x { background: none; border: 0; font-size: 24px; line-height: 1; color: var(--muted); padding: 0 4px; }
.tabs { display: flex; gap: 4px; padding: 8px 12px 0; }
.tabs button, .mtabs button { flex: 1; padding: 8px 6px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 600; }
.tabs button.on, .mtabs button.on { border-color: var(--accent); color: var(--accent); }
#phonebody, #shopbody { padding: 12px 14px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.job { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: rgba(255,255,255,.02); }
.job.current { border-color: var(--accent); }
.jt { font-weight: 700; } .jt .pay { color: #7ee07a; float: right; } .jd { color: var(--muted); font-size: 13px; margin: 4px 0 8px; }
.job button, .shoprow button { padding: 7px 12px; border-radius: 8px; border: 0; background: var(--accent); color: #1b1300; font-weight: 700; }
.job button.danger { background: #c0392b; color: #fff; }
button:disabled { opacity: .45; cursor: default; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; } .plist .me { color: #9be7ff; } .tick { color: var(--green); } .adm { font-size: 11px; color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 0 4px; }
.srow { display: flex; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,.05); padding: 4px 0; }
.shoprow { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.06); padding: 8px 0; }
.sn { font-weight: 700; } .ss { color: var(--muted); font-size: 12px; } .own { color: var(--green); font-size: 12px; font-weight: 600; }
#mapwrap { position: fixed; inset: 0; z-index: 15; background: #1d3445; }
#bigmap { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.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: 10px; background: var(--panel); padding: 8px 12px; border-radius: 10px; font-size: 12px; max-width: calc(100vw - 28px); }
.maplegend i { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; font: 700 10px system-ui; font-style: normal; margin-right: 4px; vertical-align: -3px; }

/* ------------------------------------------------------------ menu */
.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; }
#menu { background: linear-gradient(90deg, rgba(8,10,16,.88) 0%, rgba(8,10,16,.55) 45%, rgba(8,10,16,0) 75%); place-items: center start; padding: 24px; overflow: auto; }
.menu-panel { width: min(470px, 100%); background: rgba(12,16,24,.82); 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); }
.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; }
.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); }
.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: 18px; letter-spacing: .5px; }
.go:disabled { opacity: .6; }
.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: 6px 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: #7ee07a; } #board h3 { margin: 6px 0; font-size: 14px; color: var(--accent); }
#charedit { display: flex; flex-direction: column; gap: 10px; }
.swrow { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.sw { display: flex; flex-wrap: wrap; gap: 6px; }
.sw button { width: 28px; height: 28px; 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; }
#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 controls */
#touch { position: fixed; inset: 0; z-index: 5; touch-action: none; }
#joy { position: absolute; width: 130px; height: 130px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); left: 40px; bottom: 150px; opacity: .5; pointer-events: none; }
#joy.on { opacity: 1; }
#joyknob { position: absolute; left: 40px; top: 40px; 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; grid-row: span 1; font-size: 26px; }
.tb.on { background: rgba(245,182,42,.55); }
#touch .car { display: none; }
#touch.incar .car { display: grid; } #touch.incar .foot { display: none; }
body.touch #radarwrap { width: 140px; left: 10px; top: 60px; bottom: auto; }
body.touch #radar { width: 140px; height: 140px; }
body.touch #chat { left: 10px; bottom: auto; top: 230px; width: 40vw; }
body.touch #mission { bottom: 12px; font-size: 14px; max-width: 50vw; }
body.touch #prompt { bottom: 70px; }
@media (max-width: 700px) {
  #money { font-size: 24px; } #stars { font-size: 20px; }
  .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 { grid-template-columns: 1fr; }
}
