:root {
  --hud-font: 'Bahnschrift', 'DIN Alternate', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --big-font: 'Impact', 'Haettenschweiler', 'Arial Black', sans-serif;
  --gold: #e8c547;
  --green: #5fbf5f;
  --money: #7dc27d;
  --blue: #5aa2e0;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: #fff; font-family: var(--hud-font); user-select: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#topright { position: absolute; top: 18px; right: 26px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
#clock { font: 700 34px var(--hud-font); letter-spacing: 1px; text-shadow: 0 0 3px #000, 2px 2px 0 #000; }
#weaponbox { display: flex; align-items: center; gap: 8px; }
#weaponicon { width: 74px; height: 74px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #3a3a3a, #111 70%); border: 3px solid #000; display: grid; place-items: center; font-size: 36px; box-shadow: 0 2px 6px #0008; }
#ammo { font: 700 22px var(--hud-font); text-shadow: 2px 2px 0 #000; }
#bars { display: none; }
#money { font: 700 36px var(--hud-font); color: var(--money); letter-spacing: 2px; -webkit-text-stroke: 1.5px #0a2a0a; text-shadow: 2px 2px 0 #000; }
#stars { display: flex; gap: 2px; font-size: 30px; height: 34px; }
#stars span { color: #fff; opacity: .18; text-shadow: 0 0 2px #000, 2px 2px 0 #000; }
#stars span.on { opacity: 1; color: #f2f2f2; }
#stars.flash span.on { animation: starflash .5s steps(2) infinite; }
@keyframes starflash { 50% { color: #5aa2e0; } }

#minimapwrap { position: absolute; left: 28px; bottom: 26px; width: 300px; height: 212px; }
#minimap { width: 300px; height: 190px; border: 3px solid #000; border-radius: 4px; background: #0d1a26; box-shadow: 0 4px 14px #0009; }
#minimapbars { display: flex; gap: 3px; height: 12px; margin-top: 4px; }
#mmhealth, #mmarmor { height: 100%; border: 2px solid #000; background: #1a3a1a; position: relative; overflow: hidden; }
#mmhealth { flex: 2; } #mmarmor { flex: 1; background: #16304a; }
#mmhealth::after, #mmarmor::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: var(--v, 100%); }
#mmhealth::after { background: var(--green); } #mmarmor::after { background: var(--blue); }
#mmhealth.low::after { background: #d23b3b; animation: lowhp 1s infinite; }
@keyframes lowhp { 50% { opacity: .4; } }

#zonename, #vehname { position: absolute; right: 34px; font: italic 700 38px var(--big-font); letter-spacing: 1px; color: #e8e8e8; text-shadow: 3px 3px 0 #000, 0 0 6px #000; opacity: 0; transition: opacity .6s; text-align: right; }
#zonename { bottom: 38px; }
#zonename small { display: block; font: 700 20px var(--hud-font); font-style: normal; color: #d8d8d8; letter-spacing: 2px; text-transform: uppercase; }
#vehname { bottom: 110px; color: #9fd1ff; font-size: 34px; }
#zonename.show, #vehname.show { opacity: 1; }
#speedo { position: absolute; right: 34px; bottom: 168px; font: 700 40px var(--hud-font); text-shadow: 2px 2px 0 #000; }
#speedo small { font-size: 16px; margin-left: 4px; opacity: .8; }

#help { position: absolute; left: 26px; top: 22px; max-width: 420px; background: rgba(0,0,0,.78); padding: 14px 18px; font: 500 18px/1.35 var(--hud-font); border-radius: 3px; box-shadow: 0 3px 10px #0008; }
#help kbd { display: inline-block; background: #eee; color: #111; border-radius: 3px; padding: 0 6px; font: 700 15px var(--hud-font); margin: 0 2px; }
#subtitle { position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%); width: min(900px, 80vw); text-align: center; font: 600 24px/1.3 var(--hud-font); text-shadow: 2px 2px 0 #000, 0 0 5px #000; }
#subtitle b { color: var(--gold); }
#subtitle .blue { color: #7cc0ff; }
#missiontimer { position: absolute; right: 34px; top: 230px; font: 700 30px var(--hud-font); text-shadow: 2px 2px 0 #000; }
#bigmsg { position: absolute; left: 0; right: 0; top: 36%; text-align: center; font: 72px var(--big-font); letter-spacing: 3px; opacity: 0; transition: opacity .8s; -webkit-text-stroke: 2px #000; text-shadow: 4px 4px 0 #000; }
#bigmsg.show { opacity: 1; }
#bigmsg.wasted { color: #b3181b; font-size: 110px; }
#bigmsg.busted { color: #3c79c8; font-size: 110px; }
#bigmsg.passed { color: var(--gold); }
#bigmsg small { display: block; font: 700 30px var(--hud-font); color: #fff; letter-spacing: 1px; -webkit-text-stroke: 0; margin-top: 8px; }
#crosshair { position: absolute; left: 50%; top: 45%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 2px #000; }
#crosshair::after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; background: #fff; border-radius: 50%; }
#crosshair.hit { border-color: #ff4040; }
#crosshair.hit::after { background: #ff4040; }
#notify { position: absolute; left: 50%; top: 16%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; }
#notify div { background: rgba(0,0,0,.72); padding: 8px 18px; font: 600 20px var(--hud-font); border-left: 4px solid var(--gold); animation: nfade 3.2s forwards; }
@keyframes nfade { 0% { opacity: 0; transform: translateY(-8px); } 8%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#damageflash { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55)); opacity: 0; transition: opacity .25s; }

/* ---------- Map ---------- */
#mapscreen { position: fixed; inset: 0; background: #0b1520; cursor: grab; }
#mapscreen:active { cursor: grabbing; }
#bigmap { width: 100%; height: 100%; display: block; }
#maplegend { position: absolute; right: 24px; top: 24px; background: rgba(0,0,0,.72); padding: 12px 16px; font: 500 16px/1.6 var(--hud-font); border-radius: 4px; pointer-events: none; }
#maplegend .li { display: flex; gap: 10px; align-items: center; }
#maplegend i { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-style: normal; font-size: 13px; font-weight: 700; border: 2px solid #000; }
#maphint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: rgba(0,0,0,.7); padding: 8px 16px; font: 500 16px var(--hud-font); border-radius: 4px; pointer-events: none; }

/* ---------- Pause ---------- */
#pause { position: fixed; inset: 0; background: rgba(5,10,16,.72); backdrop-filter: blur(4px); display: flex; gap: 40px; padding: 8vh 7vw; }
#pause .menu { display: flex; flex-direction: column; gap: 8px; min-width: 280px; }
#pause h1 { font: 64px var(--big-font); margin: 0 0 20px; letter-spacing: 3px; -webkit-text-stroke: 1.5px #000; }
#pause button, #playbtn { background: rgba(0,0,0,.55); color: #fff; border: 0; border-left: 4px solid transparent; font: 600 24px var(--hud-font); text-align: left; padding: 10px 18px; cursor: pointer; }
#pause button:hover, #pause button.sel { background: rgba(255,255,255,.12); border-left-color: var(--gold); }
#pausepanel { flex: 1; max-width: 760px; background: rgba(0,0,0,.5); padding: 24px 30px; overflow: auto; font: 500 18px/1.55 var(--hud-font); border-radius: 4px; }
#pausepanel:empty { display: none; }
#pausepanel h2 { font: 700 28px var(--hud-font); margin: 0 0 12px; color: var(--gold); }
#pausepanel table { border-collapse: collapse; width: 100%; }
#pausepanel td { padding: 4px 8px; border-bottom: 1px solid #ffffff18; }
#pausepanel td:first-child { color: var(--gold); white-space: nowrap; width: 40%; }
#pausepanel .opt { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #ffffff18; }
#pausepanel select, #pausepanel input[type=range] { font: 500 17px var(--hud-font); background: #111; color: #fff; border: 1px solid #555; padding: 4px 8px; }

/* ---------- Title ---------- */
#title { position: fixed; inset: 0; display: grid; place-items: center; background: #000; z-index: 10; transition: opacity 1s; }
#titlebg { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 60%, #3d2a14 0%, #120c06 60%, #000 100%); background-size: cover; background-position: center; filter: saturate(1.1); }
#titlebg.img { background-image: linear-gradient(180deg, #0008, #000c 85%), url(../assets/title.jpg); }
#titleinner { position: relative; text-align: center; }
.logo { font: min(150px, 14vw)/0.9 var(--big-font); letter-spacing: -4px; -webkit-text-stroke: 5px #000; text-shadow: 8px 8px 0 #000; }
.logo .g { color: #f4f4f4; } .logo .t { color: #e8c547; } .logo .a { color: #f4f4f4; }
.logosub { font: 84px/1 var(--big-font); letter-spacing: 10px; color: #fff; -webkit-text-stroke: 3px #000; text-shadow: 5px 5px 0 #7a1414; margin-top: -6px; }
.tag { font: 600 22px var(--hud-font); letter-spacing: 6px; text-transform: uppercase; color: #e8c547; margin: 10px 0 34px; text-shadow: 2px 2px 0 #000; }
#loadbar { width: 420px; height: 8px; background: #ffffff22; margin: 0 auto; border-radius: 4px; overflow: hidden; }
#loadfill { width: 0%; height: 100%; background: #e8c547; transition: width .2s; }
#loadtext { margin-top: 10px; font: 500 17px var(--hud-font); color: #ccc; min-height: 24px; }
#playbtn { margin: 14px auto 0; display: block; text-align: center; font: 44px var(--big-font); letter-spacing: 4px; padding: 10px 60px; border: 3px solid #e8c547; background: #000a; color: #e8c547; }
#playbtn:hover { background: #e8c547; color: #000; }
#titlecontrols { margin-top: 30px; font: 500 15px/1.8 var(--hud-font); color: #bbb; max-width: 900px; }
#titlecontrols b { color: #e8c547; margin-right: 6px; }

#money .eur { font-family: Arial, sans-serif; font-weight: 700; margin-right: 2px; }
#eventinfo { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); background: rgba(0,0,0,.72); padding: 6px 16px; font: 700 20px var(--hud-font); border-bottom: 3px solid var(--gold); display: none; }

/* ---------- Touch (phones/tablets): body.touch is set in src/device.js ---------- */
#titletouch, #mapbtns, #rotate { display: none; }
body.touch { --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px); touch-action: none; overscroll-behavior: none; -webkit-touch-callout: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
body.touch #titlecontrols { display: none; }
body.touch #titletouch { display: block; margin-top: 18px; font: 500 14px/1.5 var(--hud-font); color: #bbb; max-width: 80vw; }

#touch { position: fixed; inset: 0; touch-action: none; }
#tzlook { position: absolute; inset: 0; }
#tzstick { position: absolute; left: 0; bottom: 0; width: 42%; height: 62%; }
#tstick { position: fixed; left: calc(var(--sl) + 100px); top: calc(100% - 100px); width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); background: rgba(0,0,0,.25); opacity: .4; pointer-events: none; transition: opacity .15s; }
#tstick.on { opacity: 1; }
#tknob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px; border-radius: 50%; background: rgba(255,255,255,.8); box-shadow: 0 2px 8px #0008; }
.tb { position: absolute; width: 64px; height: 64px; padding: 0; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,.42); border: 2px solid rgba(255,255,255,.55); color: #fff; font: 700 13px var(--hud-font); letter-spacing: .5px; text-shadow: 0 1px 2px #000; touch-action: none; user-select: none; -webkit-user-select: none; }
.tb.on { background: rgba(232,197,71,.55); border-color: var(--gold); }
#touch[data-mode=foot] .tb[data-mode=car], #touch[data-mode=car] .tb[data-mode=foot], #touch:not(.armed) .tb-aim, #touch:not(.police) .tb-siren { display: none; }
/* on foot */
.tb-attack { right: calc(var(--sr) + 22px); bottom: 24px; width: 92px; height: 92px; font-size: 38px; }
.tb-jump { right: calc(var(--sr) + 128px); bottom: 14px; }
.tb-enter { right: calc(var(--sr) + 210px); bottom: 14px; font-size: 26px; }
.tb-sprint { right: calc(var(--sr) + 24px); bottom: 134px; }
.tb-aim { right: calc(var(--sr) + 110px); bottom: 104px; width: 58px; height: 58px; font-size: 26px; }
/* driving */
.tb-gas { right: calc(var(--sr) + 22px); bottom: 24px; width: 92px; height: 92px; font-size: 36px; }
.tb-brake { right: calc(var(--sr) + 128px); bottom: 14px; width: 74px; height: 74px; font-size: 30px; }
.tb-hand { right: calc(var(--sr) + 30px); bottom: 134px; }
.tb-exit { right: calc(var(--sr) + 116px); bottom: 110px; width: 58px; height: 58px; }
.tb-horn, .tb-cam, .tb-radio, .tb-lights, .tb-siren { width: 46px; height: 46px; font-size: 20px; bottom: 16px; }
.tb-horn { right: calc(var(--sr) + 216px); }
.tb-cam { right: calc(var(--sr) + 268px); }
.tb-radio { right: calc(var(--sr) + 320px); }
.tb-lights { right: calc(var(--sr) + 372px); }
.tb-siren { right: calc(var(--sr) + 216px); bottom: 70px; }
.tb-pause, .tb-full { left: calc(var(--sl) + 156px); top: 10px; width: 44px; height: 44px; font-size: 18px; }
.tb-full { left: calc(var(--sl) + 206px); font-size: 20px; }

/* HUD rearranged around the thumbs */
body.touch #minimapwrap { left: calc(var(--sl) + 10px); top: 10px; bottom: auto; width: 136px; height: 98px; pointer-events: auto; }
body.touch #minimap { width: 136px; height: 86px; border-width: 2px; }
body.touch #minimapbars { height: 6px; margin-top: 3px; }
body.touch #topright { top: 6px; right: calc(var(--sr) + 12px); transform: scale(.55); transform-origin: top right; }
body.touch #weaponicon { pointer-events: auto; }
body.touch #help { left: calc(var(--sl) + 10px); top: 114px; max-width: 290px; padding: 8px 12px; font-size: 14px; }
body.touch #help kbd { font-size: 13px; }
body.touch #zonename, body.touch #vehname { right: auto; left: 50%; transform: translateX(-50%); bottom: auto; text-align: center; white-space: nowrap; }
body.touch #zonename { top: 8px; font-size: 22px; }
body.touch #zonename small { font-size: 13px; }
body.touch #vehname { top: 50px; font-size: 20px; }
body.touch #speedo { right: calc(var(--sr) + 18px); bottom: 210px; font-size: 26px; }
body.touch #subtitle { bottom: 104px; width: min(46vw, 520px); font-size: 15px; }
body.touch #missiontimer { top: 112px; right: calc(var(--sr) + 16px); font-size: 20px; }
body.touch #eventinfo { display: none !important; } /* the match/party banner covers too much of a phone screen */
body.touch #notify { top: 30%; }
body.touch #notify div { font-size: 15px; padding: 6px 12px; }
body.touch #bigmsg { font-size: 42px; }
body.touch #bigmsg.wasted, body.touch #bigmsg.busted { font-size: 64px; }
body.touch #bigmsg small { font-size: 18px; }

/* map, pause and title on small screens */
body.touch #mapbtns { display: flex; position: absolute; left: calc(var(--sl) + 12px); top: 12px; gap: 8px; }
body.touch #mapbtns button { background: rgba(0,0,0,.75); color: #fff; border: 2px solid #fff6; border-radius: 6px; font: 600 15px var(--hud-font); padding: 8px 12px; }
body.touch #maplegend { transform: scale(.7); transform-origin: top right; right: calc(var(--sr) + 10px); top: 10px; }
body.touch #maphint { font-size: 13px; bottom: 10px; white-space: nowrap; }
body.touch #pause { padding: 12px calc(var(--sr) + 16px) 12px calc(var(--sl) + 16px); gap: 16px; }
body.touch #pause .menu { min-width: 170px; gap: 4px; }
body.touch #pause h1 { font-size: 34px; margin: 0 0 6px; }
body.touch #pause button { font-size: 18px; padding: 8px 12px; }
body.touch #pausepanel { padding: 12px 16px; font-size: 14px; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
body.touch #pausepanel h2 { font-size: 20px; }
body.touch #pausepanel select { font-size: 14px; max-width: 48vw; }
@media (max-height: 520px) {
  .logo { font-size: min(110px, 11vw); }
  .logosub { font-size: 46px; letter-spacing: 6px; }
  .tag { font-size: 14px; margin: 6px 0 16px; }
  #loadbar { width: min(420px, 70vw); }
  #playbtn { font-size: 32px; padding: 6px 44px; }
}
@media (orientation: portrait) {
  body.touch #rotate { display: grid; place-content: center; text-align: center; gap: 12px; position: fixed; inset: 0; z-index: 50; background: #000; color: #e8c547; font: 700 20px var(--hud-font); }
  body.touch #rotate div { font-size: 54px; }
}

/* ---------- Online (rooms) ---------- */
#onlinebtn { display: block; margin: 10px auto 0; font: 26px var(--big-font); letter-spacing: 3px; padding: 6px 30px; border: 2px solid #9fd1ff; background: #000a; color: #9fd1ff; cursor: pointer; }
#onlinebtn:hover { background: #9fd1ff; color: #000; }
#fsbtn { display: block; margin: 10px auto 0; background: none; border: 0; color: #ccc; font: 600 15px var(--hud-font); cursor: pointer; }
#title.onl .logosub, #title.onl .tag, #title.onl #titlecontrols, #title.onl #titletouch, #title.onl #loadtext { display: none; }
#title.onl .logo { font-size: min(70px, 9vw); }
#onlinebox { width: min(460px, 92vw); margin: 12px auto 0; text-align: left; background: rgba(0,0,0,.72); padding: 14px 18px; border-radius: 4px; }
#onlineback { margin-top: 8px; background: none; border: 0; color: #bbb; font: 600 16px var(--hud-font); cursor: pointer; }
#onlinepanel h2, #pausepanel h2 { margin-top: 0; }
#onlinepanel h2 { font: 700 22px var(--hud-font); color: var(--gold); margin: 0 0 8px; }
.onlrow { display: flex; gap: 8px; margin: 8px 0; }
.onlrow input { flex: 1; min-width: 0; font: 600 16px var(--hud-font); padding: 8px 10px; background: #111; color: #fff; border: 1px solid #666; border-radius: 3px; -webkit-user-select: text; user-select: text; touch-action: manipulation; }
.onlrow input[data-o=code] { text-transform: uppercase; letter-spacing: 3px; }
.onlrow button { font: 700 16px var(--hud-font); padding: 8px 14px; background: #e8c547; color: #000; border: 0; border-radius: 3px; cursor: pointer; touch-action: manipulation; }
.onlrow button:disabled { opacity: .5; }
.onlrow button[data-o=leave] { background: #7a1414; color: #fff; }
.onlstatus { font: 500 14px/1.4 var(--hud-font); color: #bbb; min-height: 20px; word-break: break-all; }
.onlstatus.err { color: #ff7a6a; }
.onlcode { font: 600 18px var(--hud-font); } .onlcode b { color: var(--gold); letter-spacing: 3px; font-size: 24px; }
.onlnames { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.onlnames span { background: #ffffff1a; padding: 3px 8px; border-radius: 3px; font: 500 14px var(--hud-font); }
#netinfo { position: absolute; left: 50%; top: 56px; transform: translateX(-50%); background: rgba(0,0,0,.6); padding: 4px 12px; font: 600 15px var(--hud-font); border-radius: 3px; color: #9fd1ff; }
body.touch #netinfo { left: calc(var(--sl) + 260px); top: 20px; transform: none; font-size: 12px; padding: 3px 8px; }
body.touch #onlinebtn { font-size: 22px; padding: 4px 24px; }
