* {
  box-sizing: border-box;
  -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
  /* Standard user-select alone doesn't stop iOS Safari's long-press
     "Copy/Look Up" callout bubble on touch controls - this is the
     separate, Safari-specific property that does. Also had no
     user-select rule at all before this. */
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  /* #canvas-container and the individual touch buttons/move-pad already
     had their own touch-action:none, but that left gaps (any HUD
     element sitting above the canvas without its own rule) where
     repeated/rapid taps could still be read as a double-tap-zoom
     gesture - reported as "zooms in so far you can't keep playing".
     The viewport meta's maximum-scale/user-scalable is already set
     here too, but that alone isn't reliable either (iOS Safari has
     ignored it for accessibility since ~iOS 10). Blanket
     touch-action:none is the actual fix; the two scrollable menu
     surfaces (.screen-layer, .scoreboard-card) get an explicit pan-y
     exception below so they keep working.
  */
  touch-action: none;
}
:root {
  color-scheme: dark;
  --cyan: #65f5e5;
  --red: #ff536a;
  --gold: #ffc56f;
  --panel: rgba(7, 12, 19, .88);
  --line: rgba(149, 186, 204, .2);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
html, body, #game-root { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #080c12; }
body { color: #edf4fa; }
button, select { font: inherit; }
button { color: inherit; }
#game-root { position: relative; isolation: isolate; }
#canvas-container { position: absolute; inset: 0; touch-action: none; }
#canvas-container canvas { display: block; width: 100%; height: 100%; outline: none; }
.hidden { display: none !important; }

.screen-layer {
  position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  overflow: auto; padding: 22px;
  background: linear-gradient(110deg, rgba(5, 9, 15, .91) 0%, rgba(7, 13, 21, .76) 55%, rgba(5, 9, 15, .5) 100%);
  backdrop-filter: blur(5px);
  /* Needs to keep scrolling on mobile (arena-select/pause/results can
     be taller than the viewport) despite the blanket touch-action:none
     on * above - pan-y keeps that scroll while still blocking zoom. */
  touch-action: pan-y;
}
.menu-panel, .modal-panel {
  width: min(980px, 100%); border: 1px solid rgba(101, 245, 229, .28);
  background: linear-gradient(145deg, rgba(13, 21, 31, .97), rgba(7, 12, 19, .97));
  box-shadow: 0 30px 100px rgba(0, 0, 0, .58), inset 0 1px rgba(255,255,255,.04);
  padding: clamp(22px, 4vw, 42px); position: relative;
}
.menu-panel::before, .modal-panel::before {
  content: ""; position: absolute; top: -1px; left: 34px; width: 112px; height: 2px;
  background: var(--cyan); box-shadow: 0 0 15px var(--cyan);
}
.eyebrow, .section-label, .controls-row, .menu-footnote, .arena-copy small, .hud-top small, .health-panel small,
.weapon-panel small, .scoreboard-heading, .ammo-count, .reload-message {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .12em;
}
.eyebrow { color: var(--cyan); font-size: 10px; font-weight: 800; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin: 0 9px 1px 0; border-radius: 50%; background: var(--red); box-shadow: 0 0 12px var(--red); }
h1 { margin: 9px 0 7px; font-size: clamp(42px, 8vw, 76px); line-height: .9; letter-spacing: -.065em; font-weight: 900; }
h1 span { color: var(--cyan); }
.menu-lede { max-width: 650px; margin: 12px 0 24px; color: #aebbc9; font-size: 14px; line-height: 1.6; }
.section-label { display: block; color: #778a9c; font-size: 9px; font-weight: 800; margin-bottom: 9px; }
.arena-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.arena-card {
  display: grid; grid-template-columns: 76px 1fr auto; align-items: center; gap: 12px;
  min-width: 0; text-align: left; border: 1px solid #26323f; padding: 8px 10px;
  background: rgba(255,255,255,.025); cursor: pointer; transition: .18s ease;
}
.arena-card:hover { border-color: rgba(101,245,229,.65); transform: translateY(-2px); }
.arena-card.selected { border-color: var(--cyan); background: rgba(101,245,229,.08); box-shadow: 0 0 18px rgba(101,245,229,.08); }
.arena-art { display: block; position: relative; height: 50px; overflow: hidden; background: #111a24 center/cover no-repeat; }
.arena-art::before { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,.05)); }
.arena-art i { position: absolute; bottom: 0; width: 12px; background: rgba(255,255,255,.12); border-top: 1px solid currentColor; }
.arena-art i:nth-child(1) { left: 11px; height: 60%; }
.arena-art i:nth-child(2) { left: 32px; height: 90%; }
.arena-art i:nth-child(3) { right: 10px; height: 48%; }
.art-forge { color: #ff7f49; background-image: linear-gradient(135deg, rgba(57,33,22,.3), rgba(21,24,32,.68)), url("assets/gns-deathmatch/core-forge-arena.jpg"); }
.art-forge i { color: #ff7f49; }
.art-void { color: #6f8dff; background-image: linear-gradient(135deg, rgba(26,34,80,.3), rgba(17,24,32,.68)), url("assets/gns-deathmatch/void-bridge-arena.jpg"); }
.art-void i { color: #6f8dff; }
.art-cathedral { color: #69ecc7; background-image: linear-gradient(135deg, rgba(18,55,47,.3), rgba(16,24,32,.68)), url("assets/gns-deathmatch/ion-cathedral-arena.jpg"); }
.art-cathedral i { color: #69ecc7; }
.arena-copy { min-width: 0; }
.arena-copy b { display: block; font-size: 11px; letter-spacing: .06em; }
.arena-copy small { display: block; margin-top: 5px; color: #718193; font-size: 8px; letter-spacing: .08em; }
.arena-check { color: #51606e; font: 800 9px ui-monospace, monospace; }
.arena-card.selected .arena-check { color: var(--cyan); }
.loadout-row { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-top: 21px; }
.weapon-preview-row { display: flex; align-items: center; gap: 3px; height: 42px; }
.weapon-preview-row img { width: 35px; height: 38px; object-fit: contain; opacity: .85; filter: drop-shadow(0 3px 5px rgba(0,0,0,.7)); }
.weapon-swatch { display: block; width: 42px; height: 7px; margin: 0 3px; border-radius: 4px; background: var(--weapon-color); box-shadow: 0 0 12px var(--weapon-color); transform: skewX(-24deg); }
.match-length { flex: 0 0 210px; }
.match-length select {
  width: 100%; padding: 10px; border: 1px solid #344453; border-radius: 2px;
  background: #111a24; color: #e7f2fa; font: 700 10px ui-monospace, monospace; letter-spacing: .04em;
}
.controls-row { display: flex; flex-wrap: wrap; gap: 7px 15px; border-top: 1px solid var(--line); margin-top: 16px; padding-top: 13px; color: #708092; font-size: 8px; }
.controls-row b { color: #d5e2eb; }
.primary-button {
  border: 1px solid var(--cyan); background: var(--cyan); color: #061013;
  min-height: 46px; padding: 0 24px; font-size: 12px; font-weight: 900; letter-spacing: .13em;
  cursor: pointer; box-shadow: 0 0 24px rgba(101,245,229,.16); transition: .18s ease;
}
.primary-button:hover { background: #c2fff4; transform: translateY(-1px); box-shadow: 0 0 30px rgba(101,245,229,.34); }
.primary-button:disabled { cursor: wait; opacity: .55; transform: none; box-shadow: none; }
.primary-button span { padding-left: 16px; font-size: 17px; }
#start-match { display: block; width: 100%; margin-top: 17px; }
.menu-footnote { margin: 11px 0 0; text-align: center; color: #536170; font-size: 8px; letter-spacing: .06em; }

.hud-top { position: absolute; z-index: 6; inset: 0 0 auto; min-height: 70px; display: grid; grid-template-columns: 1fr minmax(280px, 1.4fr) 1fr; align-items: center; padding: 10px 22px; background: linear-gradient(rgba(5,9,14,.82), transparent); }
.hud-brand { display: flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--cyan); color: var(--cyan); font: 900 20px/1 ui-monospace, monospace; }
.hud-brand small { display: block; color: #8192a3; margin-top: 4px; font-size: 8px; font-weight: 600; }
.live-leaderboard { display: flex; min-width: 0; max-width: 100%; justify-content: flex-start; align-items: center; gap: 5px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
.live-leaderboard::-webkit-scrollbar { display: none; }
.live-score-chip { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; min-width: 58px; padding: 6px 7px; border: 1px solid rgba(194,211,225,.13); background: rgba(4,8,13,.56); }
.live-score-chip.me { border-color: rgba(101,245,229,.55); }
.live-score-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #94a5b4; font: 700 8px ui-monospace, monospace; }
.live-score-chip b { margin-left: auto; color: #f5f8fa; font: 900 12px ui-monospace, monospace; }
.hud-clock { justify-self: end; text-align: right; }
.hud-clock small { display: block; color: #7890a2; font-size: 8px; }
.hud-clock b { display: block; margin-top: 2px; color: #fff; font: 900 28px/1 ui-monospace, monospace; letter-spacing: .04em; }
.hud-clock.low b { color: var(--red); animation: timerPulse .6s ease-in-out infinite alternate; }
@keyframes timerPulse { to { opacity: .5; } }
.crosshair { position: absolute; z-index: 4; left: 50%; top: 50%; width: 20px; height: 20px; transform: translate(-50%,-50%); }
.crosshair i { position: absolute; background: rgba(235,250,255,.92); box-shadow: 0 0 5px #54f7e4; }
.crosshair i:nth-child(1) { width: 5px; height: 1px; left: 0; top: 9px; }
.crosshair i:nth-child(2) { width: 5px; height: 1px; right: 0; top: 9px; }
.crosshair i:nth-child(3) { width: 1px; height: 5px; top: 0; left: 9px; }
.crosshair i:nth-child(4) { width: 1px; height: 5px; bottom: 0; left: 9px; }
.crosshair b { position: absolute; width: 2px; height: 2px; left: 9px; top: 9px; background: var(--cyan); border-radius: 50%; }
#hitmarker { position: absolute; left: 50%; top: 50%; z-index: 5; transform: translate(-50%,-50%) scale(.5); opacity: 0; color: #fff; font: 900 28px/1 Arial,sans-serif; text-shadow: 0 0 10px var(--red); pointer-events: none; }
#hitmarker.active { animation: hitFlash .18s ease-out; }
@keyframes hitFlash { 0% { opacity: 1; transform: translate(-50%,-50%) scale(1.25); } 100% { opacity: 0; transform: translate(-50%,-50%) scale(.75); } }
.hud-bottom { position: absolute; z-index: 5; left: 22px; right: 22px; bottom: 84px; display: flex; justify-content: space-between; align-items: end; pointer-events: none; }
.health-panel, .weapon-panel { min-width: 198px; padding: 10px 12px; border: 1px solid rgba(156,185,204,.21); background: rgba(5,10,16,.72); backdrop-filter: blur(5px); }
.health-panel small, .weapon-panel small { color: #8194a5; font-size: 8px; }
.health-line { display: flex; align-items: baseline; gap: 2px; margin-top: 5px; }
.health-line>b { color: var(--cyan); font: 900 26px/1 ui-monospace, monospace; }
.health-line>span { color: #7891a0; font: 700 10px ui-monospace, monospace; }
.health-track { flex: 1; height: 4px; margin-left: 12px; background: #26323c; }
.health-track i { display: block; height: 100%; width: 100%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); transition: width .18s ease; }
.weapon-panel { display: flex; align-items: center; gap: 22px; min-width: 260px; }
.weapon-panel>div:first-child { min-width: 0; }
.weapon-panel small { display: block; }
.weapon-panel b { display: block; margin-top: 4px; color: #f7fbff; font-size: 11px; letter-spacing: .06em; }
.ammo-count { display: flex; align-items: baseline; gap: 5px; margin-left: auto; }
.ammo-count>b { color: var(--gold); font-size: 24px; }
.ammo-count>span, .ammo-count>small { color: #8291a0; font-size: 11px; }
.weapon-keybar { position: absolute; z-index: 5; left: 50%; bottom: 16px; display: flex; gap: 4px; transform: translateX(-50%); }
.weapon-key-slot { appearance: none; display: flex; align-items: center; gap: 6px; min-width: 50px; padding: 5px 7px; border: 1px solid rgba(145,168,184,.15); background: rgba(5,9,14,.68); color: inherit; font: inherit; cursor: pointer; opacity: .7; }
.weapon-key-slot.active { border-color: var(--cyan); opacity: 1; box-shadow: 0 0 12px rgba(101,245,229,.15); }
.weapon-key-slot kbd { color: var(--cyan); font: 800 9px ui-monospace, monospace; }
.weapon-key-slot span { overflow: hidden; color: #9baab8; font: 700 7px ui-monospace, monospace; text-overflow: ellipsis; }
#weapon-view { position: absolute; z-index: 3; left: 50%; bottom: -11vh; width: min(54vh, 50vw); height: min(64vh, 62vw); object-fit: contain; object-position: center bottom; transform: translateX(-50%); pointer-events: none; filter: drop-shadow(0 12px 24px rgba(0,0,0,.6)); }
#weapon-view.fire { animation: weaponFire .12s ease-out; }
@keyframes weaponFire { 0% { transform: translate(-50%, 1.8vh) scale(.97); } 52% { transform: translate(-50%, -.6vh) scale(1.01); } 100% { transform: translate(-50%,0) scale(1); } }
#laser-flare { position: absolute; z-index: 4; left: 50%; top: 53%; width: 70px; height: 90px; opacity: 0; transform: translate(-50%,-50%) scale(.4); pointer-events: none; background: radial-gradient(ellipse, rgba(255,255,255,.95) 0, var(--flare-color, rgba(255,70,85,.8)) 16%, transparent 70%); mix-blend-mode: screen; }
#laser-flare.active { animation: laserFlare .14s ease-out; }
@keyframes laserFlare { 0% { opacity: 1; transform: translate(-50%,-50%) scale(1.35); } 100% { opacity: 0; transform: translate(-50%,-50%) scale(.35); } }
.reload-message { position: absolute; z-index: 6; left: 50%; top: 58%; transform: translate(-50%,-50%); color: var(--gold); font-size: 11px; text-shadow: 0 0 10px #000; }
.kill-feed { position: absolute; z-index: 5; top: 86px; right: 22px; width: min(310px, 34vw); display: flex; flex-direction: column; gap: 5px; align-items: end; }
.kill-feed-item { padding: 6px 9px; color: #d7e0e8; background: rgba(5,9,14,.74); font: 700 9px ui-monospace, monospace; border-right: 2px solid var(--red); animation: feedIn .2s ease-out; }
.kill-feed-item .killer { color: var(--cyan); }
.kill-feed-item .victim { color: #ff7985; }
@keyframes feedIn { from { opacity: 0; transform: translateX(12px); } }
.radar-canvas { position: absolute; z-index: 4; top: 82px; right: 22px; width: 118px; height: 118px; border: 1px solid rgba(151,183,203,.28); background: rgba(5,10,16,.62); }
.scoreboard-overlay { position: absolute; z-index: 9; inset: 0; display: grid; place-items: center; padding: 12px; background: rgba(3,7,12,.4); }
.scoreboard-card { width: min(580px, calc(100% - 8px)); max-height: min(88vh, 780px); overflow-y: auto; touch-action: pan-y; padding: 20px; border: 1px solid rgba(101,245,229,.4); background: rgba(7,12,19,.94); box-shadow: 0 20px 70px rgba(0,0,0,.45); }
.scoreboard-heading { display: flex; justify-content: space-between; padding-bottom: 11px; margin-bottom: 8px; border-bottom: 1px solid var(--line); color: var(--cyan); font-size: 10px; font-weight: 900; }
.scoreboard-heading small { color: #68798a; font-size: 8px; }
.score-row { display: grid; grid-template-columns: 30px 1fr 70px 70px; align-items: center; gap: 8px; padding: 9px 6px; color: #c1ccd5; border-bottom: 1px solid rgba(255,255,255,.05); font: 700 11px ui-monospace, monospace; }
.score-row.me { color: var(--cyan); background: rgba(101,245,229,.06); }
.score-row .rank { color: #718293; }
.score-row .frags { color: var(--gold); text-align: right; }
.score-row .deaths { color: #8293a2; text-align: right; }
.scoreboard-head { color: #7e8e9e; font: 700 8px ui-monospace, monospace; }
.damage-hit { animation: damageFlash .24s ease-out; }
@keyframes damageFlash { 0% { background: rgba(255,32,62,.42); } 100% { background: rgba(255,32,62,0); } }

.modal-panel { width: min(680px, 100%); }
.compact-panel { width: min(430px,100%); text-align: center; }
.modal-panel h2 { margin: 10px 0; font-size: clamp(28px,6vw,46px); letter-spacing: -.04em; }
.winner-subtitle { color: #9daebe; margin: 0 0 18px; }
.final-scoreboard { margin: 16px 0 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.final-scoreboard .score-row { grid-template-columns: 30px 1fr 70px 70px; }
.result-actions { display: flex; gap: 12px; align-items: center; }
.result-actions .primary-button { flex: 1; }
.text-button { border: 0; background: transparent; color: #9bacbb; font-size: 10px; font-weight: 800; letter-spacing: .1em; cursor: pointer; padding: 14px; }
.text-button:hover { color: var(--cyan); }
.renderer-error { position: absolute; z-index: 30; inset: 0; display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; text-align: center; background: #080c12; color: #dce6ef; padding: 24px; }
.renderer-error b { color: var(--red); font-size: 19px; }
.renderer-error span { max-width: 440px; color: #91a0af; line-height: 1.55; font-size: 13px; }
.touch-controls { display: block; position: absolute; z-index: 7; inset: auto 0 64px; pointer-events: none; }
.fallback-badge { position: absolute; z-index: 12; top: 72px; left: 50%; transform: translateX(-50%); padding: 6px 10px; border: 1px solid rgba(255,197,111,.55); color: #ffd28c; background: rgba(10,13,18,.82); font: 800 8px ui-monospace, monospace; letter-spacing: .12em; white-space: nowrap; }
.fallback-mode #weapon-view { width: min(25vh, 28vw); height: min(30vh, 32vw); bottom: -3vh; opacity: .78; }
.fallback-mode .crosshair { display: none; }

@media (max-width: 900px) {
  .screen-layer { align-items: start; padding: 14px; }
  .menu-panel { margin: auto 0; padding: 21px 18px; }
  .arena-picker { grid-template-columns: 1fr; }
  .arena-card { grid-template-columns: 64px 1fr auto; }
  .arena-art { height: 42px; }
  .loadout-row { align-items: start; flex-direction: column; gap: 14px; margin-top: 16px; }
  .weapon-preview-row { height: 30px; }
  .weapon-swatch { width: 33px; }
  .weapon-preview-row img { width: 27px; height: 29px; }
  .match-length { flex-basis: auto; width: 100%; }
  .controls-row { gap: 7px 11px; font-size: 7px; }
  .menu-footnote { font-size: 7px; line-height: 1.5; }
  .hud-top { grid-template-columns: 1fr auto; min-height: 57px; padding: 8px 10px; }
  .live-leaderboard { position: absolute; left: 10px; right: 10px; top: 62px; justify-content: center; }
  .live-score-chip { min-width: 52px; gap: 4px; padding: 5px 6px; }
  .live-score-chip span { max-width: 35px; font-size: 7px; }
  .live-score-chip b { font-size: 10px; }
  .hud-clock b { font-size: 24px; }
  .hud-bottom { left: 10px; right: 10px; bottom: 75px; align-items: end; }
  .health-panel, .weapon-panel { min-width: 0; padding: 7px 8px; }
  .health-panel { width: 34%; }
  .weapon-panel { width: 62%; gap: 8px; }
  .weapon-panel b { max-width: 38vw; font-size: 9px; }
  .radar-canvas { top: 106px; right: 10px; width: 84px; height: 84px; opacity: .82; }
  .ammo-count>b { font-size: 20px; }
  .weapon-keybar { left: 8px; right: 8px; bottom: 7px; justify-content: center; gap: 2px; transform: none; }
  .weapon-key-slot { min-width: 0; flex: 1; justify-content: center; padding: 5px 2px; }
  .weapon-key-slot span { display: none; }
  #weapon-view { width: min(52vh, 78vw); height: min(58vh, 82vw); bottom: -9vh; }
  .kill-feed { top: 104px; right: 10px; width: 48vw; }
  .fallback-badge { top: 86px; font-size: 7px; }
  .fallback-mode #weapon-view { width: 29vw; height: 32vw; bottom: -3vw; }
  .move-pad { position: absolute; left: 17px; bottom: 0; width: 118px; height: 118px; border-radius: 50%; border: 1px solid rgba(205,225,238,.35); background: rgba(9,16,24,.32); pointer-events: auto; touch-action: none; }
  .move-pad::before { content: ""; position: absolute; inset: 27px; border: 1px solid rgba(205,225,238,.15); border-radius: 50%; }
  .move-pad i { position: absolute; left: 50%; top: 50%; width: 39px; height: 39px; margin: -19px 0 0 -19px; border: 1px solid var(--cyan); border-radius: 50%; background: rgba(101,245,229,.22); }
  .move-pad small { position: absolute; inset: auto 0 10px; text-align: center; color: rgba(225,240,248,.7); font: 700 7px ui-monospace, monospace; letter-spacing: .1em; }
  .touch-controls button { position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.48); background: rgba(12,20,29,.55); color: #fff; font: 900 9px ui-monospace, monospace; pointer-events: auto; touch-action: none; }
  #touch-fire { right: 20px; bottom: 5px; width: 76px; height: 76px; border-color: var(--red); color: #ff9ca9; background: rgba(100,10,27,.5); }
  #touch-jump { right: 105px; bottom: 12px; width: 50px; height: 50px; }
  #touch-reload { right: 119px; bottom: 70px; width: 39px; height: 39px; }
}
@media (max-height: 650px) and (min-width: 901px) {
  .menu-panel { padding: 20px 28px; }
  h1 { font-size: 52px; }
  .menu-lede { margin: 7px 0 14px; }
  .arena-art { height: 38px; }
  .loadout-row { margin-top: 12px; }
  #start-match { margin-top: 11px; min-height: 38px; }
}