* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #10151b; color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; user-select: none; -webkit-user-select: none;
  touch-action: none; overscroll-behavior: none; }
#app, #app canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#touchLayer { position: fixed; inset: 0; z-index: 2; touch-action: none; }
#hud { position: fixed; inset: 0; z-index: 3; pointer-events: none; opacity: 0; transition: opacity .3s; }
body.playing #hud { opacity: 1; }
#hud .btn { pointer-events: auto; }
.shadowed { text-shadow: 0 1px 3px rgba(0,0,0,.8); }

#topbar { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: stretch; gap: 4px; }
#topbar .team { min-width: 50px; padding: 2px 10px; font: 800 22px/1.25 system-ui; text-align: center; border-radius: 6px; backdrop-filter: blur(4px); }
.team.blue { background: rgba(47,111,214,.75); } .team.red { background: rgba(214,69,47,.75); }
#center { background: rgba(10,14,20,.55); border-radius: 6px; padding: 2px 12px; text-align: center; min-width: 128px; backdrop-filter: blur(4px); }
#timer { font: 700 17px/1.2 system-ui; font-variant-numeric: tabular-nums; }
#zoneStatus { font-size: 11px; opacity: .9; letter-spacing: .3px; }
#zoneStatus.blue { color: #8fb8ff; } #zoneStatus.red { color: #ff9a85; } #zoneStatus.contested { color: #ffd040; }

#minimap { position: absolute; top: max(8px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right));
  width: 120px; height: 120px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.35), 0 2px 10px rgba(0,0,0,.5); }
#killfeed { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); font-size: 12px; }
#killfeed div { background: rgba(10,14,20,.5); padding: 2px 8px; border-radius: 4px; margin-bottom: 3px; }
#killfeed .blue { color: #8fb8ff; font-weight: 700; } #killfeed .red { color: #ff9a85; font-weight: 700; }

#crosshair { --gap: 6px; position: absolute; left: 50%; top: 50%; width: 0; height: 0; transition: opacity .12s; }
#crosshair.hide { opacity: 0; }
#crosshair i { position: absolute; background: rgba(255,255,255,.9); box-shadow: 0 0 2px rgba(0,0,0,.9); }
#crosshair i:nth-child(1) { width: 2px; height: 9px; left: -1px; bottom: var(--gap); }
#crosshair i:nth-child(2) { width: 2px; height: 9px; left: -1px; top: var(--gap); }
#crosshair i:nth-child(3) { width: 9px; height: 2px; top: -1px; right: var(--gap); }
#crosshair i:nth-child(4) { width: 9px; height: 2px; top: -1px; left: var(--gap); }
#crosshair::after { content: ''; position: absolute; width: 2px; height: 2px; left: -1px; top: -1px; background: #fff; }

#hitmarker { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px; opacity: 0; }
#hitmarker::before, #hitmarker::after { content: ''; position: absolute; left: 50%; top: 0; width: 2px; height: 100%; margin-left: -1px;
  background: linear-gradient(#fff 0 35%, transparent 35% 65%, #fff 65%); }
#hitmarker::before { transform: rotate(45deg); } #hitmarker::after { transform: rotate(-45deg); }
#hitmarker.show { opacity: 1; }
#hitmarker.head::before, #hitmarker.head::after { background: linear-gradient(#ffd040 0 35%, transparent 35% 65%, #ffd040 65%); }
#hitmarker.kill { width: 30px; height: 30px; margin: -15px; }
#hitmarker.kill::before, #hitmarker.kill::after { background: linear-gradient(#ff3b2f 0 38%, transparent 38% 62%, #ff3b2f 62%); }

#dmgDirs { position: absolute; left: 50%; top: 50%; }
.dmg { position: absolute; left: 0; top: 0; width: 0; height: 0; animation: fade 1.3s forwards; }
.dmg::before { content: ''; position: absolute; left: 110px; top: -40px; width: 14px; height: 80px; border-radius: 50%;
  border-right: 5px solid rgba(255,40,30,.85); filter: blur(.5px); }
@keyframes fade { 0% { opacity: 1 } 70% { opacity: .8 } 100% { opacity: 0 } }

#status { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); }
body.touch #status { left: 50%; transform: translateX(-50%); }
#hpBar { position: relative; width: 170px; height: 14px; background: rgba(10,14,20,.6); border-radius: 3px; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,.2); }
#hpFill { height: 100%; width: 100%; background: linear-gradient(90deg, #d8e8d8, #ffffff); transition: width .1s; }
#hpFill.low { background: linear-gradient(90deg, #ff6a5a, #c9342a); }
#hpText { position: absolute; inset: 0; text-align: center; font: 700 10px/14px system-ui; color: #111; mix-blend-mode: difference; filter: invert(1); }
#stance { font-size: 11px; opacity: .8; margin-top: 3px; text-align: center; text-shadow: 0 1px 2px #000; }
#ammoBox { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom));
  font: 800 30px/1 system-ui; text-shadow: 0 2px 6px rgba(0,0,0,.8); font-variant-numeric: tabular-nums; }
#ammoBox small { font-size: 14px; opacity: .7; margin-left: 3px; }
#ammo.low { color: #ff7a5a; }
body.touch #ammoBox { right: auto; left: 50%; transform: translateX(110px); bottom: max(8px, env(safe-area-inset-bottom)); font-size: 22px; }

#elevation { position: absolute; left: 50%; top: 62%; transform: translateX(-50%); color: #ffe08a; font: 700 12px system-ui;
  text-shadow: 0 1px 3px #000; opacity: 0; transition: opacity .2s; }
#elevation.show { opacity: 1; }
#respawn { position: absolute; top: 30%; width: 100%; text-align: center; font: 700 22px system-ui; text-shadow: 0 2px 6px #000; display: none; padding: 0 20px; }
#respawn.show { display: block; }
#vignette { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse at center, transparent 50%, rgba(150,0,0,.8)); }
#lockHint { position: absolute; top: 60%; width: 100%; text-align: center; font: 700 16px system-ui; text-shadow: 0 1px 4px #000; display: none; }
#lockHint.show { display: block; }

.stick { position: absolute; width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35);
  background: radial-gradient(circle, rgba(255,255,255,.04), rgba(255,255,255,.12)); display: none; }
.stick.on { display: block; }
.stick .knob { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px; border-radius: 50%;
  background: rgba(255,255,255,.5); box-shadow: 0 2px 8px rgba(0,0,0,.4); }

.btn { position: absolute; display: none; width: 58px; height: 58px; border-radius: 50%; overflow: hidden;
  background: rgba(10,14,20,.38); border: 2px solid rgba(255,255,255,.45); font: 700 10px/54px system-ui; text-align: center;
  touch-action: none; backdrop-filter: blur(3px); letter-spacing: .3px; }
.btn span { position: relative; }
.btn.pressed { background: rgba(255,255,255,.3); }
.btn.active { border-color: #ffd27a; color: #ffd27a; }
.btn.big { width: 86px; height: 86px; line-height: 82px; font-size: 13px; border-color: rgba(255,120,90,.8); background: rgba(120,30,20,.35); }
.btn.small { width: 48px; height: 48px; line-height: 44px; }
body.touch .btn { display: block; }
/* right-hand cluster around the fire button */
#btnFire { right: calc(max(18px, env(safe-area-inset-right)) + 40px); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 40px); }
#btnAds { right: calc(max(18px, env(safe-area-inset-right)) + 140px); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 30px); }
#btnJump { right: max(18px, env(safe-area-inset-right)); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 140px); }
#btnCrouch { right: calc(max(18px, env(safe-area-inset-right)) + 82px); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 150px); }
#btnGrenade { right: calc(max(18px, env(safe-area-inset-right)) + 150px); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 110px); border-color: rgba(255,170,50,.8); }
#btnReload { right: calc(max(18px, env(safe-area-inset-right)) + 172px); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 182px); }
/* second trigger on the left, above the move area */
#btnFire2 { left: max(22px, env(safe-area-inset-left)); top: 42%; border-color: rgba(255,120,90,.8); background: rgba(120,30,20,.3); }
#grenadeCd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(255,255,255,.25); }
#btnReload.busy { opacity: .45; }
#desktopHelp { position: absolute; bottom: 40px; width: 100%; text-align: center; font-size: 11px; opacity: .55; text-shadow: 0 1px 2px #000; }
body.touch #desktopHelp { display: none; }
body.locked #desktopHelp { opacity: 0; transition: opacity 4s 3s; }

.screen { position: fixed; inset: 0; z-index: 10; display: none; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px; background: linear-gradient(180deg, rgba(10,14,22,.35), rgba(6,9,14,.88) 60%); text-align: center; overflow-y: auto; }
.screen.show { display: flex; }
.screen h1 { margin: 0 0 4px; font: 900 clamp(38px, 9vw, 72px)/1 system-ui; letter-spacing: 6px; text-shadow: 0 4px 20px rgba(0,0,0,.6); }
.screen h1 span { color: #ffb23f; }
.screen .tag { margin: 0 0 14px; opacity: .85; letter-spacing: 1px; }
.screen ul { text-align: left; max-width: 600px; font-size: 14px; line-height: 1.45; opacity: .92; padding-left: 20px; margin: 0 0 12px;
  background: rgba(0,0,0,.25); border-radius: 10px; padding: 10px 14px 10px 30px; }
.screen button { pointer-events: auto; font: 800 20px system-ui; padding: 14px 40px; border: 0; border-radius: 10px; color: #1b2430;
  background: linear-gradient(#ffd27a, #ff9f2f); box-shadow: 0 4px 0 #b86a10, 0 8px 24px rgba(255,160,40,.3); letter-spacing: 1px; }
.screen button:active { transform: translateY(3px); box-shadow: 0 1px 0 #b86a10; }
.screen .hint { opacity: .6; font-size: 12px; }
.screen .big { font: 800 44px system-ui; margin: 8px 0; }
.sens { display: flex; gap: 10px; align-items: center; font-size: 13px; opacity: .85; margin-bottom: 14px; pointer-events: auto; }
.sens input { width: 160px; }

#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  body.playing #rotate { display: block; position: fixed; z-index: 4; top: 64px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,.6); padding: 6px 12px; border-radius: 8px; font-size: 13px; pointer-events: none; }
  #minimap { width: 90px; height: 90px; top: 64px; }
}
@media (max-height: 430px) {
  .screen ul { font-size: 12px; line-height: 1.3; margin-bottom: 8px; }
  .screen h1 { font-size: 36px; }
  .screen .tag { margin-bottom: 8px; }
  .screen button { padding: 10px 30px; }
  #minimap { width: 96px; height: 96px; }
}

#btnStart { opacity: .5; pointer-events: none; }
body.ready #btnStart { opacity: 1; pointer-events: auto; }
#fps { position: fixed; z-index: 20; left: 8px; bottom: 60px; font: 12px monospace; background: rgba(0,0,0,.6); padding: 2px 6px; border-radius: 4px; pointer-events: none; }

/* ---- menus, shop, lobby ---- */
.screen h2 { margin: 0 0 12px; font: 800 30px system-ui; letter-spacing: 2px; display: flex; gap: 14px; align-items: center; justify-content: center; }
.screen .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.screen button.secondary { font-size: 15px; padding: 10px 20px; color: #fff; background: rgba(255,255,255,.12); box-shadow: inset 0 0 0 1px rgba(255,255,255,.3); }
.screen button:disabled { opacity: .45; }
.tokens-bar { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; margin: 0 0 12px; background: rgba(0,0,0,.35); padding: 4px 12px; border-radius: 20px; }
.tokens-bar.small { font-size: 14px; margin: 0; }
.coin { display: inline-block; width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff3b0, #e5a823 55%, #a8700c); box-shadow: 0 0 0 1px #7a5208; }
.seg { display: flex; gap: 4px; align-items: center; margin: 12px 0 4px; font-size: 13px; }
.seg span { opacity: .8; margin-right: 6px; }
.seg button { font: 600 13px system-ui; padding: 6px 12px; border-radius: 6px; background: rgba(255,255,255,.1); color: #fff; box-shadow: none; }
.seg button.on { background: #ffb23f; color: #1b2430; }
#shopList { width: min(900px, 100%); text-align: left; }
#shopList h3 { margin: 12px 0 6px; font-size: 15px; letter-spacing: 1px; opacity: .85; text-transform: uppercase; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.card { background: rgba(255,255,255,.07); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 4px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.card.equipped { box-shadow: inset 0 0 0 2px #ffb23f; }
.card p { margin: 0; font-size: 12px; opacity: .8; flex: 1; }
.card .stats { font-size: 11px; opacity: .65; }
.card button { font: 700 13px system-ui; padding: 7px 10px; border-radius: 7px; margin-top: 4px; box-shadow: none; }
.card button.on { background: #3fae5f; color: #fff; }
.swatch { display: flex; gap: 3px; } .swatch i { width: 22px; height: 12px; border-radius: 3px; }
#mp label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; margin: 6px auto; width: 240px; text-align: left; }
#mp input { font: 600 18px system-ui; padding: 8px 10px; border-radius: 8px; border: 0; background: rgba(255,255,255,.9); color: #111; user-select: text; -webkit-user-select: text; }
#mp .code { font-size: 26px; letter-spacing: 4px; color: #ffb23f; }
#lobbyTeams { display: flex; gap: 14px; justify-content: center; }
.tm { min-width: 160px; background: rgba(0,0,0,.3); border-radius: 10px; padding: 8px 14px; text-align: left; }
.tm h4 { margin: 0 0 6px; } .tm.blue h4 { color: #8fb8ff; } .tm.red h4 { color: #ff9a85; }
.tm ul { list-style: none; padding: 0; margin: 0; font-size: 14px; line-height: 1.6; background: none; }
.tm li.bot { opacity: .6; } .tm li.me { font-weight: 800; }
.error { color: #ff8a7a; min-height: 1em; }
.screen { justify-content: safe center; touch-action: pan-y; }
.card button:disabled { background: rgba(255,255,255,.15); color: rgba(255,255,255,.7); }
.card button.on:disabled { background: #3fae5f; color: #fff; opacity: .8; }
.seg.worldSel { margin-top: 6px; }
.seg.worldSel.locked button { pointer-events: none; opacity: .55; }
.seg.worldSel.locked button.on { opacity: 1; }
.sliders { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.sliders .sens input { width: 130px; }
#toast { position: fixed; left: 50%; top: 22%; transform: translate(-50%, -6px); background: rgba(40,70,40,.85); color: #eaffe6; font: 700 15px system-ui;
  padding: 8px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 30; text-shadow: 0 1px 2px #000; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
