@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=Material+Symbols+Outlined');

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #000;
  font-family: 'Rajdhani', sans-serif;
  color: #eafff5;
  touch-action: none;
  overscroll-behavior: none;
}

#game-canvas { position: fixed; inset: 0; display: block; outline: none; }

.msi { font-family: 'Material Symbols Outlined'; font-weight: normal; font-style: normal; line-height: 1; vertical-align: middle; }

/* ---------- Loading ---------- */
#loading-screen {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(circle at 50% 40%, #0f2a24 0%, #030907 70%, #000 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
#loading-screen h1 { font-size: 2.6rem; letter-spacing: 6px; color: #4bffb0; text-shadow: 0 0 20px rgba(75,255,176,.6); }
.loader-bar-wrap { width: 60vw; max-width: 420px; height: 10px; background: rgba(255,255,255,.08); border: 1px solid rgba(75,255,176,.35); border-radius: 6px; overflow: hidden; }
#loader-bar { height: 100%; width: 0%; background: linear-gradient(90deg,#1fae7a,#4bffb0); transition: width .15s ease; }
#loading-status { font-size: .95rem; letter-spacing: 2px; color: #9fd; opacity: .8; }

/* ---------- Menu ---------- */
#menu-screen {
  position: fixed; inset: 0; z-index: 90;
  background: radial-gradient(circle at 50% 30%, #123128 0%, #05100c 65%, #000 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px;
  text-align: center; padding: 20px;
}
#menu-screen.hidden { display: none; }
.title-block h1 { font-size: 3.2rem; letter-spacing: 10px; color: #4bffb0; text-shadow: 0 0 25px rgba(75,255,176,.55); }
.title-block p { letter-spacing: 3px; opacity: .65; margin-top: 6px; font-size: .85rem; }
.menu-btn {
  pointer-events: auto; cursor: pointer;
  background: linear-gradient(180deg, rgba(75,255,176,.16), rgba(75,255,176,.04));
  border: 1px solid rgba(75,255,176,.55); color: #d9fff0;
  padding: 14px 46px; font-size: 1.2rem; letter-spacing: 4px; border-radius: 4px;
  font-family: inherit; font-weight: 600; transition: all .15s ease;
}
.menu-btn:hover, .menu-btn:active { background: rgba(75,255,176,.28); box-shadow: 0 0 22px rgba(75,255,176,.4); }
.menu-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.menu-hint { font-size: .8rem; opacity: .55; letter-spacing: 1px; max-width: 460px; }

/* ---------- Online flow screens (connect / name / lobby / match-over) ---------- */
#browser-screen, #name-screen, #lobby-screen, #matchover-screen {
  position: fixed; inset: 0; z-index: 91;
  background: radial-gradient(circle at 50% 30%, #123128 0%, #05100c 65%, #000 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  text-align: center; padding: 20px;
}
#browser-screen.hidden, #name-screen.hidden, #lobby-screen.hidden, #matchover-screen.hidden { display: none; }

.form-box { width: min(92vw, 420px); display: flex; flex-direction: column; gap: 14px; pointer-events: auto; }
.form-box label { font-size: .8rem; letter-spacing: 2px; opacity: .75; text-align: left; }
.form-box input[type=text] {
  width: 100%; padding: 12px 14px; font-size: 1.05rem; font-family: inherit;
  background: rgba(255,255,255,.05); border: 1px solid rgba(75,255,176,.4); border-radius: 4px;
  color: #eafff5; letter-spacing: 1px;
}
.form-box input[type=text]:focus { outline: none; border-color: #4bffb0; box-shadow: 0 0 10px rgba(75,255,176,.35); }
.form-status { font-size: .85rem; letter-spacing: 1px; min-height: 1.2em; opacity: .85; }
.form-status.error { color: #ff6b6b; }
.form-status.ok { color: #4bffb0; }
.menu-btn.ghost { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.25); }
.menu-btn.disabled { opacity: .35; pointer-events: none; }

#lobby-list { display: flex; flex-direction: column; gap: 8px; max-height: 38vh; overflow-y: auto; }
.lobby-entry { display: flex; align-items: center; gap: 10px; background: rgba(75,255,176,.07); border: 1px solid rgba(75,255,176,.25); padding: 10px 14px; border-radius: 4px; font-size: 1rem; letter-spacing: 1px; text-align: left; }
.lobby-entry .msi { color: #4bffb0; font-size: 1.1rem; }
.lobby-entry.me { border-color: #4bffb0; background: rgba(75,255,176,.14); }

#room-list { display: flex; flex-direction: column; gap: 8px; max-height: 34vh; overflow-y: auto; }
.room-entry { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.18); padding: 10px 12px; border-radius: 4px; text-align: left; }
.room-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
.room-info .msi { color: #4bffb0; font-size: 1.1rem; flex-shrink: 0; }
.room-name { font-size: .95rem; letter-spacing: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }
.room-meta { font-size: .75rem; letter-spacing: 1px; opacity: .6; flex-shrink: 0; }
.menu-btn.small { padding: 8px 14px; font-size: .85rem; flex-shrink: 0; }
.room-list-empty-hint { font-size: .85rem; opacity: .55; letter-spacing: 1px; padding: 8px 0; text-align: left; }
.lobby-empty-hint { font-size: .85rem; opacity: .55; letter-spacing: 1px; padding: 8px 0; }

#matchover-scores { display: flex; flex-direction: column; gap: 8px; max-height: 44vh; overflow-y: auto; }
.score-entry { display: flex; justify-content: space-between; gap: 10px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.15); padding: 10px 16px; border-radius: 4px; font-size: 1rem; letter-spacing: 1px; }
.score-entry.winner { border-color: #ffcf3a; background: rgba(255,207,58,.12); color: #ffcf3a; }

#match-timer {
  position: absolute; top: 68px; left: 50%; transform: translateX(-50%);
  font-size: 1.1rem; letter-spacing: 3px; font-weight: 700;
  background: rgba(5,15,12,.55); border: 1px solid rgba(75,255,176,.3);
  padding: 6px 16px; border-radius: 8px;
}
#match-timer.low-time { color: #ff6b6b; border-color: rgba(255,107,107,.5); }

/* ---------- Settings panel ---------- */
#settings-panel {
  position: fixed; inset: 0; z-index: 95; display: none;
  background: rgba(2,8,6,.85); backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
}
#settings-panel.open { display: flex; }
.settings-box {
  pointer-events: auto;
  width: min(92vw, 420px); background: #0a1712; border: 1px solid rgba(75,255,176,.4);
  border-radius: 10px; padding: 22px 24px; display: flex; flex-direction: column; gap: 16px;
}
.settings-box h2 { letter-spacing: 3px; color: #4bffb0; font-size: 1.3rem; display:flex; align-items:center; gap:8px;}
.setting-row { display: flex; flex-direction: column; gap: 8px; }
.setting-row label { font-size: .85rem; letter-spacing: 2px; opacity: .8; display:flex; justify-content:space-between; }
.seg-control { display: flex; gap: 6px; }
.seg-btn {
  flex: 1; padding: 9px 0; text-align: center; border: 1px solid rgba(255,255,255,.15);
  border-radius: 4px; cursor: pointer; font-size: .85rem; letter-spacing: 1px; background: rgba(255,255,255,.03);
}
.seg-btn.active { background: rgba(75,255,176,.25); border-color: #4bffb0; color: #fff; }
input[type=range] { -webkit-appearance: none; width: 100%; height: 4px; background: rgba(255,255,255,.15); border-radius: 3px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #4bffb0; cursor: pointer; }
.close-settings { margin-top: 6px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; display: none; }
#hud.active { display: block; }

#crosshair {
  position: absolute; top: 50%; left: 50%; width: 22px; height: 22px; transform: translate(-50%,-50%);
  transition: transform .06s ease; --bloom: 0px;
}
#crosshair div { position: absolute; background: rgba(230,255,245,.85); box-shadow: 0 0 3px rgba(0,0,0,.6); }
#crosshair .h { width: 8px; height: 2px; top: 10px; }
#crosshair .h.l { left: calc(0px - var(--bloom)); } #crosshair .h.r { right: calc(0px - var(--bloom)); }
#crosshair .v { height: 8px; width: 2px; left: 10px; }
#crosshair .v.t { top: calc(0px - var(--bloom)); } #crosshair .v.b { bottom: calc(0px - var(--bloom)); }
#crosshair.firing { transform: translate(-50%,-50%) scale(1.35); }

#hitmarker {
  position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; transform: translate(-50%,-50%);
  opacity: 0; pointer-events: none;
}
#hitmarker svg { width: 100%; height: 100%; }
#hitmarker.show { animation: hitflash .22s ease-out; }
#hitmarker.headshot svg line { stroke: #ffcf3a !important; }
@keyframes hitflash { 0% { opacity: 1; transform: translate(-50%,-50%) scale(1.2);} 100% { opacity: 0; transform: translate(-50%,-50%) scale(.85);} }

#hit-flash { position: absolute; inset: 0; background: radial-gradient(circle, rgba(255,30,30,0) 40%, rgba(255,20,20,.45) 100%); opacity: 0; }
#hit-flash.show { animation: dmgflash .4s ease-out; }
@keyframes dmgflash { 0% { opacity: 1; } 100% { opacity: 0; } }

.hud-bl { position: absolute; left: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; }
.hud-br { position: absolute; right: 22px; bottom: 22px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.stat-pill { display: flex; align-items: center; gap: 8px; background: rgba(5,15,12,.55); border: 1px solid rgba(75,255,176,.3); padding: 8px 14px; border-radius: 8px; font-size: 1.15rem; letter-spacing: 1px; }
.stat-pill .msi { color: #4bffb0; font-size: 1.4rem; }
#health-bar-wrap { width: 190px; height: 12px; background: rgba(0,0,0,.4); border: 1px solid rgba(255,90,90,.4); border-radius: 6px; overflow: hidden; }
#health-bar { height: 100%; width: 100%; background: linear-gradient(90deg,#ff3b3b,#ff8a3b); transition: width .15s ease; }
#ammo-text { font-size: 1.6rem; font-weight: 700; }
#ammo-text .reserve { font-size: 1rem; opacity: .55; }
#weapon-name { font-size: .85rem; letter-spacing: 3px; opacity: .7; text-transform: uppercase; }

#reload-indicator { position: absolute; bottom: 90px; right: 26px; font-size: .95rem; letter-spacing: 3px; color: #ffcf3a; opacity: 0; text-shadow: 0 0 8px rgba(0,0,0,.8); }
#reload-indicator.show { opacity: 1; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: .5; } 50% { opacity: 1; } }

#scope-overlay {
  position: absolute; inset: 0; display: none; pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%, transparent 21%, #000 21.6%);
}
#scope-overlay.show { display: block; }
#scope-overlay svg { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 44vh; height: 44vh; opacity: .9;}

#killfeed { position: absolute; top: 20px; right: 22px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.kill-entry { background: rgba(5,15,12,.6); border-left: 3px solid #4bffb0; padding: 5px 10px; font-size: .85rem; letter-spacing: 1px; border-radius: 3px; animation: fadein .2s ease; }
.kill-entry.headshot { border-left-color: #ffcf3a; }
@keyframes fadein { from { opacity: 0; transform: translateX(10px);} to { opacity: 1; transform: translateX(0);} }

#score-panel { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); display:flex; gap:18px; background: rgba(5,15,12,.55); border: 1px solid rgba(75,255,176,.3); padding: 8px 20px; border-radius: 8px; font-size: 1.05rem; letter-spacing: 2px; }

#fps-counter { position: absolute; top: 20px; left: 20px; font-size: .8rem; letter-spacing: 1px; opacity: .55; }

#pause-btn, #settings-open-ingame { position: absolute; top: 18px; pointer-events: auto; cursor: pointer; width: 42px; height: 42px; border-radius: 50%; background: rgba(5,15,12,.55); border: 1px solid rgba(75,255,176,.35); display:flex; align-items:center; justify-content:center; }
#pause-btn { right: 20px; }

#center-msg { position: absolute; top: 40%; left: 50%; transform: translate(-50%,-50%); text-align: center; font-size: 2.2rem; letter-spacing: 6px; color: #ff5a5a; text-shadow: 0 0 18px rgba(255,60,60,.6); display: none; }
#center-msg.show { display: block; }
#center-msg .sub { font-size: 1rem; letter-spacing: 3px; color: #cceee0; margin-top: 10px; opacity: .8; }

/* ---------- Pause overlay ---------- */
#pause-overlay { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; background: rgba(2,8,6,.75); backdrop-filter: blur(4px); }
#pause-overlay.open { display: flex; }
.pause-box { pointer-events: auto; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.pause-box h2 { letter-spacing: 6px; color: #4bffb0; margin-bottom: 6px; }

/* ---------- Mobile controls ---------- */
#mobile-controls { position: fixed; inset: 0; z-index: 30; display: none; pointer-events: none; }
#mobile-controls.active { display: block; }

#joy-zone { position: absolute; left: 0; bottom: 0; width: 46vw; height: 55vh; pointer-events: auto; touch-action: none; }
#joy-base {
  position: absolute; left: 34px; bottom: calc(34px + env(safe-area-inset-bottom, 0px));
  width: 124px; height: 124px; border-radius: 50%;
  background: rgba(75,255,176,.09); border: 2px solid rgba(75,255,176,.4);
  opacity: .6; transition: opacity .15s ease, background .15s ease, border-color .15s ease;
  touch-action: none;
}
#joy-base.active { opacity: 1; background: rgba(75,255,176,.15); border-color: rgba(75,255,176,.75); }
#joy-stick {
  position: absolute; left: 70px; bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(75,255,176,.55); border: 1px solid #cfffe9;
  touch-action: none; will-change: transform;
}

#look-zone { position: absolute; right: 0; top: 0; width: 54vw; height: 100vh; pointer-events: auto; touch-action: none; }

.mbtn { position: absolute; pointer-events: auto; touch-action: none; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(5,15,12,.55); border: 1.5px solid rgba(75,255,176,.5); color: #eafff5; font-size: 1.6rem; transition: background .12s ease, box-shadow .12s ease, border-color .12s ease; }
.mbtn:active { background: rgba(75,255,176,.35); }
/* Toggle buttons (run/scope): stays lit while engaged, independent of finger contact */
.mbtn.mbtn-on { background: rgba(75,255,176,.55); border-color: #cfffe9; box-shadow: 0 0 14px rgba(75,255,176,.75), inset 0 0 8px rgba(255,255,255,.25); color: #05130d; }
/* Right side (primary combat actions): fire -> jump -> reload, stacked bottom to top */
#btn-fire   { width: 90px; height: 90px; right: 22px; bottom: 86px;  background: rgba(255,60,60,.18); border-color: rgba(255,110,110,.6); }
#btn-jump   { width: 64px; height: 64px; right: 35px; bottom: 196px; }
#btn-reload { width: 56px; height: 56px; right: 39px; bottom: 278px; }
/* Right side, inner column: scope */
#btn-scope  { width: 64px; height: 64px; right: 140px; bottom: 100px; }
/* Left side, near the joystick: run/sprint toggle */
#btn-run    { width: 60px; height: 60px; left: 64px; bottom: calc(198px + env(safe-area-inset-bottom, 0px)); }
.mbtn .msi { font-size: 1.8rem; }
.mbtn-label { font-size: .55rem; letter-spacing: 1px; position: absolute; bottom: 6px; opacity:.8; }

/* ---------- Fullscreen prompt (mobile) ---------- */
#fs-prompt { position: fixed; inset: 0; z-index: 99; background: #04100b; display:none; align-items:center; justify-content:center; flex-direction:column; gap:16px; text-align:center; padding:30px;}
#fs-prompt.show { display:flex; }
#fs-prompt .msi { font-size: 3rem; color:#4bffb0; }

.hidden { display: none !important; }
