* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0f14; font-family: system-ui, sans-serif; color: #fff; user-select: none; -webkit-user-select: none; touch-action: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#lookZone, #joyZone { display: none; position: fixed; }
#lookZone { inset: 0; z-index: 3; }
#joyZone { left: 0; bottom: 0; width: 45%; height: 65%; z-index: 4; }
body.touch #lookZone, body.touch #joyZone { display: block; }

#joyBase { position: fixed; display: none; width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(255,255,255,.45); background: rgba(255,255,255,.08); pointer-events: none; z-index: 5; }
#joyKnob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.5); }

#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; display: none; }
body.playing #hud { display: block; }
#stats { position: absolute; left: 10px; top: 8px; font-size: 12px; line-height: 1.5; opacity: .85; text-shadow: 0 0 3px #000; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
#crosshair::before, #crosshair::after { content: ""; position: absolute; background: #7CFF6B; box-shadow: 0 0 2px #000; }
#crosshair::before { left: -9px; top: -1px; width: 18px; height: 2px; }
#crosshair::after { left: -1px; top: -9px; width: 2px; height: 18px; }

#touchButtons { position: fixed; right: 18px; bottom: 22px; z-index: 6; display: none; flex-direction: column; gap: 14px; align-items: flex-end; }
body.touch.playing #touchButtons { display: flex; }
#touchButtons button { width: 84px; height: 84px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); background: rgba(255,255,255,.12); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 1px; }
#touchButtons button.on { background: rgba(0,229,255,.35); }

#menu { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; background: radial-gradient(ellipse at center, rgba(20,32,48,.82), rgba(5,8,12,.96)); }
#menu h1 { margin: 0; font-size: clamp(42px, 10vw, 84px); letter-spacing: 8px; }
#menu h1 span { color: #00e5ff; }
#menu .sub { opacity: .7; letter-spacing: 3px; font-size: 13px; }
#btnPlay { margin-top: 10px; padding: 16px 56px; font-size: 20px; font-weight: 800; letter-spacing: 4px; color: #001418; background: #00e5ff; border: 0; border-radius: 10px; }
#help { font-size: 13px; line-height: 1.7; opacity: .75; max-width: 440px; }

#errbox { position: fixed; left: 8px; right: 8px; top: 8px; z-index: 20; display: none; padding: 10px; background: #a40000; color: #fff; font-size: 13px; border-radius: 8px; user-select: text; -webkit-user-select: text; }

/* ---------- Этап 2: оружие ---------- */
#ammoBox { position: absolute; right: 16px; top: 10px; text-align: right; text-shadow: 0 0 4px #000; }
#weaponName { font-size: 12px; letter-spacing: 2px; opacity: .8; }
#ammoLine { font-size: 30px; font-weight: 800; line-height: 1.1; }
#ammoRes { font-size: 16px; opacity: .7; font-weight: 600; }
#ammoBox.low #ammoCur { color: #ff5a4d; }
#slots { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 8px; }
.slot { padding: 6px 12px; font-size: 11px; letter-spacing: 1px; border: 1px solid rgba(255,255,255,.25); border-radius: 6px; background: rgba(0,0,0,.35); opacity: .65; }
.slot b { color: #00e5ff; margin-right: 6px; }
.slot.on { opacity: 1; border-color: #00e5ff; background: rgba(0,229,255,.18); }
body.touch .slot b { display: none; }
#touchWeapon button { position: fixed; z-index: 6; display: none; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); background: rgba(255,255,255,.12); color: #fff; font-weight: 700; font-size: 10px; letter-spacing: 1px; }
body.touch.playing #touchWeapon button { display: block; }
#touchWeapon button.on { background: rgba(0,229,255,.35); }
#btnFire { width: 92px; height: 92px; right: 118px; bottom: 40px; background: rgba(255,70,70,.25); border-color: rgba(255,120,120,.8); font-size: 12px; }
#btnAim { width: 64px; height: 64px; right: 118px; bottom: 150px; }
#btnReload { width: 64px; height: 64px; right: 18px; bottom: 218px; }
#btnSwitch { width: 64px; height: 64px; right: 90px; bottom: 228px; }

/* ---------- Этап 3: боты ---------- */
#botStats { position: absolute; left: 10px; top: 52px; font-size: 12px; opacity: .85; text-shadow: 0 0 3px #000; }
#hitmarker { position: absolute; left: 50%; top: 50%; width: 0; height: 0; opacity: 0; }
#hitmarker.show { opacity: 1; }
#hitmarker::before, #hitmarker::after { content: ""; position: absolute; width: 16px; height: 2px; left: -8px; top: -1px; background: #fff; box-shadow: 0 0 2px #000; }
#hitmarker::before { transform: rotate(45deg); }
#hitmarker::after { transform: rotate(-45deg); }
#hitmarker.head::before, #hitmarker.head::after { background: #ffd23f; }
#hitmarker.kill::before, #hitmarker.kill::after { background: #ff3b3b; width: 22px; left: -11px; }
#killmsg { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-size: 18px; font-weight: 800; letter-spacing: 3px; color: #ff5a4d; text-shadow: 0 0 6px #000; opacity: 0; transition: opacity .35s; white-space: nowrap; }

/* ---------- Этап 4: интерфейс ---------- */
#crosshair::before, #crosshair::after { display: none !important; }
#crosshair .chp { position: absolute; pointer-events: none; }

#healthBox { position: absolute; left: 14px; bottom: 12px; width: 150px; text-shadow: 0 0 4px #000; }
#hpNum { font-size: 26px; font-weight: 800; line-height: 1; }
#hpBar { height: 6px; margin-top: 4px; background: rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.25); border-radius: 3px; overflow: hidden; }
#hpFill { width: 100%; height: 100%; background: #4cff6b; transition: width .15s, background .15s; }
#damageFlash { position: absolute; inset: 0; opacity: 0; transition: opacity .4s; background: radial-gradient(ellipse at center, rgba(255,0,0,0) 45%, rgba(255,0,0,.55) 100%); }
#damageFlash.on { opacity: 1; transition: none; }
#centerMsg { position: absolute; left: 50%; top: 35%; transform: translateX(-50%); font-size: 22px; font-weight: 800; letter-spacing: 4px; text-shadow: 0 0 8px #000; opacity: 0; transition: opacity .3s; white-space: nowrap; }
#scoreboard { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none; min-width: 280px; padding: 14px 18px; background: rgba(0,0,0,.7); border: 1px solid rgba(255,255,255,.25); border-radius: 12px; font-size: 14px; }
#scoreboard.on { display: block; }

#btnPause { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 6; display: none; width: 46px; height: 36px; border-radius: 8px; border: 1px solid rgba(255,255,255,.4); background: rgba(0,0,0,.35); color: #fff; font-weight: 800; letter-spacing: 2px; }
body.touch.playing #btnPause { display: block; }

#menu { justify-content: flex-start; overflow-y: auto; touch-action: pan-y; padding: 14px; }
#menu .screen { display: none; flex-direction: column; align-items: center; gap: 12px; width: 100%; margin: auto 0; }
#menu .screen.on { display: flex; }
#menu h2 { margin: 0; font-size: 22px; letter-spacing: 6px; }
#menu input[type=text] { user-select: text; -webkit-user-select: text; }
.help { font-size: 12px; line-height: 1.7; opacity: .7; max-width: 520px; }

#playerBar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; padding: 8px 14px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.15); border-radius: 10px; }
#playerBar div { display: flex; flex-direction: column; }
#playerBar .lbl { font-size: 9px; letter-spacing: 2px; opacity: .6; }
#playerBar b { font-size: 15px; }

.mbtn { padding: 14px 18px; font-size: 15px; font-weight: 800; letter-spacing: 2px; color: #e8f6ff; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.25); border-radius: 10px; }
.mbtn:active { background: rgba(0,229,255,.25); }
.mbtn.primary { color: #001418; background: #00e5ff; border-color: #00e5ff; }
.mbtn[disabled] { opacity: .4; }
.mbtn i { display: block; font-size: 10px; font-style: normal; letter-spacing: 1px; opacity: .8; margin-top: 2px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: min(92vw, 520px); }
.list { display: flex; flex-direction: column; gap: 10px; width: min(92vw, 520px); }
.row { display: flex; gap: 10px; width: min(92vw, 560px); }
.row .mbtn { flex: 1; }
.mode { text-align: left; }
.mode .t { font-size: 15px; font-weight: 800; letter-spacing: 2px; }
.mode .d { font-size: 12px; font-weight: 400; letter-spacing: 0; opacity: .75; margin-top: 3px; }

.panel { width: min(94vw, 560px); max-height: 60vh; overflow-y: auto; touch-action: pan-y; text-align: left; padding: 10px 14px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.15); border-radius: 12px; }
.sec { margin: 12px 0 6px; font-size: 11px; letter-spacing: 3px; color: #00e5ff; }
.srow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 13px; }
.rg { display: flex; align-items: center; gap: 8px; width: 55%; }
.rg input { flex: 1; min-width: 0; }
.rg output { min-width: 44px; text-align: right; font-size: 12px; opacity: .8; }
.srow select { color: #fff; background: #0e1620; border: 1px solid rgba(255,255,255,.3); border-radius: 6px; padding: 6px; font-size: 13px; }
.srow input[type=checkbox] { width: 22px; height: 22px; accent-color: #00e5ff; }
.sw { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sw b { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); }
.sw b.on { border-color: #fff; box-shadow: 0 0 0 2px #00e5ff; }
#chPreview { position: relative; height: 90px; margin: 6px 0; overflow: hidden; border-radius: 8px; background: linear-gradient(#5d7f99, #3b4c5a); }
#chPreview .c { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
#nickInput { width: 100%; padding: 10px; font-size: 16px; color: #fff; background: #0e1620; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; }
.rtitle { margin-bottom: 6px; font-size: 12px; letter-spacing: 2px; color: #00e5ff; }
.row2 { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
#pauseStats { max-width: 360px; }

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(4, 1fr); width: min(92vw, 780px); }
}
@media (max-height: 480px) {
  #menu h1 { font-size: 34px; letter-spacing: 6px; }
  #menu .screen { gap: 8px; }
  .mbtn { padding: 9px 12px; font-size: 13px; }
  .panel { max-height: 52vh; }
}

/* ---------- Этап 5: кнопки ---------- */
.mbtn.small { padding: 8px 12px; font-size: 12px; }
#layoutEditor { position: fixed; inset: 0; z-index: 15; display: none; background: rgba(0,0,0,.4); touch-action: none; user-select: none; -webkit-user-select: none; }
#layoutEditor .ghost { position: absolute; display: flex; align-items: center; justify-content: center; text-align: center; overflow: hidden; border-radius: 50%; border: 2px dashed rgba(255,255,255,.75); background: rgba(255,255,255,.16); color: #fff; font-weight: 700; letter-spacing: 1px; touch-action: none; transform: translate(-50%, -50%); }
#layoutEditor .ghost.rect { border-radius: 8px; }
#layoutEditor .ghost.sel { border-style: solid; border-color: #00e5ff; background: rgba(0,229,255,.3); }
#leBar { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 210px; padding: 12px; display: flex; flex-direction: column; gap: 8px; font-size: 12px; text-align: left; background: rgba(10,16,24,.92); border: 1px solid rgba(255,255,255,.25); border-radius: 12px; }
#leBar .row { width: 100%; }
#leBar .mbtn { padding: 10px 6px; font-size: 12px; }
#leBar .rg { width: 100%; }
#leName { font-size: 14px; font-weight: 800; }
#leHint { opacity: .7; line-height: 1.4; }

/* ---------- Этап 5: инвентарь ---------- */
.tabs { display: flex; gap: 8px; width: min(94vw, 560px); }
.tabs button { flex: 1; padding: 10px; font-size: 12px; font-weight: 800; letter-spacing: 2px; color: #e8f6ff; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.25); border-radius: 8px; }
.tabs button.on { color: #001418; background: #00e5ff; border-color: #00e5ff; }
.invpanel { max-height: 44vh; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.card { text-align: left; padding: 10px; color: #fff; background: rgba(255,255,255,.06); border: 2px solid #b0b8c4; border-radius: 10px; }
.card.on { background: rgba(0,229,255,.15); }
.cn { font-size: 13px; font-weight: 800; }
.cr { margin-top: 2px; font-size: 11px; letter-spacing: 1px; }
.ce { margin-top: 6px; font-size: 10px; font-weight: 800; letter-spacing: 2px; color: #00e5ff; }
.cs { display: flex; gap: 3px; margin-bottom: 6px; }
.cs i { flex: 1; height: 10px; border-radius: 3px; }
.gtitle { margin: 12px 0 6px; font-size: 11px; letter-spacing: 3px; color: #9fb0c0; }
#invRarities { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 12px; font-size: 11px; }
#invRarities span { display: flex; align-items: center; gap: 5px; }
#invRarities i { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- Этап 6: магазин и кейсы ---------- */
#shopBar, #caseBar { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 8px 14px; font-size: 13px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.15); border-radius: 10px; }
#shopBar b { font-size: 20px; color: #ffd23f; }
#caseBar b { color: #ffd23f; }
.price { margin-top: 6px; font-size: 12px; font-weight: 800; color: #ffd23f; }
.cdesc { margin-top: 4px; font-size: 11px; line-height: 1.4; opacity: .7; }
.orow { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 13px; border-bottom: 1px solid rgba(255,255,255,.08); }
#caseAnim { position: fixed; inset: 0; z-index: 12; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: rgba(3,6,10,.96); }
#caStage { position: relative; width: min(96vw, 720px); height: 150px; overflow: hidden; background: rgba(255,255,255,.04); border-top: 2px solid rgba(255,255,255,.2); border-bottom: 2px solid rgba(255,255,255,.2); }
#caStrip { position: absolute; left: 0; top: 0; height: 100%; display: flex; will-change: transform; }
#caMarker { position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; z-index: 2; background: #fff; transform: translateX(-50%); box-shadow: 0 0 12px #fff; }
.ci { flex: 0 0 110px; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 6px; text-align: center; font-size: 11px; font-weight: 700; background: rgba(255,255,255,.05); border-bottom: 4px solid #b0b8c4; }
.ci .cs { width: 70px; margin: 0; }
#caResult { min-height: 180px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
#caResult .big { padding: 16px 26px; background: rgba(255,255,255,.07); border: 3px solid; border-radius: 14px; }
#caResult .big .cn { font-size: 20px; }
#caResult .big .cr { font-size: 14px; }
#caResult .row { width: min(92vw, 420px); }

/* ---------- Этап 7: тренировки ---------- */
#trainHud { position: absolute; left: 50%; top: 52px; transform: translateX(-50%); display: none; text-align: center; text-shadow: 0 0 6px #000; }
body.trainer #trainHud { display: block; }
body.trainer #botStats { display: none; }
#thMode { font-size: 11px; letter-spacing: 3px; opacity: .8; }
#thMain { font-size: 24px; font-weight: 800; }

/* ---------- Этап 8: аккаунты ---------- */
#menu input[type=password] { user-select: text; -webkit-user-select: text; }
.authpanel { width: min(92vw, 380px); max-height: none; }
.alabel { display: block; margin: 8px 0 4px; font-size: 11px; letter-spacing: 2px; color: #00e5ff; }
#authName, #authPass, #authPass2 { width: 100%; padding: 10px; font-size: 16px; color: #fff; background: #0e1620; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; }
#authMsg { min-height: 18px; color: #ff8a80; }

/* ---------- Этап 9а: дуэли ---------- */
#duelHud { position: absolute; left: 50%; top: 52px; transform: translateX(-50%); display: none; text-align: center; text-shadow: 0 0 6px #000; white-space: nowrap; }
body.duel #duelHud { display: block; }
body.duel #botStats { display: none; }
#dhScore { font-size: 24px; font-weight: 800; }
#dhSub { font-size: 12px; opacity: .8; }

/* ---------- Этап 9б: лобби ---------- */
#lobbyCode { min-height: 48px; font-size: 40px; font-weight: 800; letter-spacing: 8px; color: #00e5ff; }
#roomCode { width: 100%; margin-bottom: 8px; padding: 10px; font-size: 22px; letter-spacing: 6px; text-align: center; text-transform: uppercase; color: #fff; background: #0e1620; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; }
#lobbyRoomBox .mbtn { width: 100%; margin-top: 6px; }

/* ---------- Этап 10: оптимизация ---------- */
:root { --ui: 1; }
html, body { overscroll-behavior: none; }
#stats, #botStats, #ammoBox, #healthBox { zoom: var(--ui); }
#stats { left: calc(10px + env(safe-area-inset-left, 0px)); top: calc(8px + env(safe-area-inset-top, 0px)); }
#botStats { left: calc(10px + env(safe-area-inset-left, 0px)); }
#ammoBox { right: calc(16px + env(safe-area-inset-right, 0px)); top: calc(10px + env(safe-area-inset-top, 0px)); }
#healthBox { left: calc(14px + env(safe-area-inset-left, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
#slots { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
#rotateHint { position: fixed; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; padding: 30px; text-align: center; font-size: 22px; font-weight: 800; letter-spacing: 3px; line-height: 1.7; background: rgba(3,6,10,.96); }
body.needLandscape #rotateHint { display: flex; }

/* ---------- Этап 10: подсказка (мягкая, ничего не блокирует) ---------- */
#rotateTip { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 8; padding: 8px 14px; font-size: 13px; background: rgba(0,0,0,.65); border-radius: 20px; pointer-events: none; }

/* ---------- Этап 11а: эффекты ---------- */
#dmgArrow { position: absolute; left: 50%; top: 50%; width: 0; height: 0; opacity: 0; }
#dmgArrow::before { content: ""; position: absolute; left: -16px; top: -150px; border-left: 16px solid transparent; border-right: 16px solid transparent; border-bottom: 30px solid rgba(255,60,60,.9); filter: drop-shadow(0 0 4px #000); }
#lowHp { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse at center, rgba(255,0,0,0) 50%, rgba(255,0,0,.5) 100%); }
body.lowhp #lowHp { animation: lowpulse 1s ease-in-out infinite; }
@keyframes lowpulse { 0%, 100% { opacity: .25; } 50% { opacity: .9; } }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#menu .screen.on { animation: screenIn .18s ease-out; }
@media (prefers-reduced-motion: reduce) { #menu .screen.on { animation: none; } }

/* ---------- Этап 11б: прицел снайперки ---------- */
#scope { position: absolute; inset: 0; display: none; background: radial-gradient(circle at center, transparent 0, transparent 34vmin, #000 34.4vmin); }
#scope::before, #scope::after { content: ""; position: absolute; background: rgba(0,0,0,.85); }
#scope::before { left: 50%; top: calc(50% - 34vmin); width: 2px; height: 68vmin; transform: translateX(-1px); }
#scope::after { top: 50%; left: calc(50% - 34vmin); height: 2px; width: 68vmin; transform: translateY(-1px); }
