/* Игра: экраны и бой. Телефон боком; безопасные зоны — env(safe-area-inset-*) и полоса кнопок Telegram сверху. */
[hidden] { display: none !important; }
:root { --b: #2f86ff; --o: #ff8a1f; --y: #ffe14d; --bg: #0e141d; --panel: rgba(14, 20, 29, 0.82); --tgTop: 46px; }
html, body { background: var(--bg); overscroll-behavior: none; }
#app { position: fixed; inset: 0; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- вход ---------- */
.tm-menu { position: absolute; inset: 0; display: flex; gap: 2vw; padding: calc(var(--tgTop) + 6px) max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: radial-gradient(120% 120% at 20% 30%, #1c3150, #0b111a 70%); color: #fff; box-sizing: border-box; overflow: auto; }
.tm-left { flex: 1 1 42%; display: flex; flex-direction: column; min-width: 0; }
.tm-left .logo { font-weight: 900; font-size: clamp(28px, 6vh, 56px); letter-spacing: 1px; text-shadow: 0 4px 0 #0008; }
.tm-left .who { opacity: 0.7; margin-top: 4px; }
.tm-left .heroes { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 6vw; }
.tm-left .heroes i { width: 13vh; height: 30vh; border-radius: 40% 40% 20% 20%; background: linear-gradient(#3a3f48 30%, var(--b) 30% 62%, #262a31 62%); opacity: 0.8; }
.tm-left .heroes i.ho { background: linear-gradient(#3a3f48 30%, var(--o) 30% 62%, #262a31 62%); }
.tm-right { flex: 1 1 58%; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tm-right h4, .tm-room h4 { margin: 4px 0 0; font-size: 12px; letter-spacing: 1px; opacity: 0.75; text-transform: uppercase; }
.maps { display: flex; gap: 8px; }
.mapcard { flex: 1; background: #1b2533; border: 2px solid #ffffff30; border-radius: 12px; padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.mapcard.sel { border-color: var(--y); box-shadow: 0 0 0 2px #ffe14d55; }
.mapcard .thumb { width: 100%; height: auto; aspect-ratio: 64 / 40; border-radius: 6px; display: block; }
.mapcard .thumb.rnd { display: grid; place-items: center; background: #26334a; font-size: 6vh; font-weight: 900; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { flex: 1; min-height: 40px; border: 0; border-radius: 22px; background: #ffffff1c; font-weight: 700; padding: 6px 10px; }
.pill.sel { background: var(--y); color: #1d1a10; }
.pills.sm .pill { min-height: 34px; font-size: 13px; flex: 0 1 auto; }
.go-row { display: flex; gap: 10px; margin-top: auto; padding-top: 6px; }
.go { flex: 2; min-height: 54px; border: 0; border-radius: 16px; background: var(--o); font-size: 24px; font-weight: 900; letter-spacing: 1px; box-shadow: 0 4px 0 #a14f0a; }
.invite { flex: 1.2; min-height: 54px; border: 3px solid var(--b); border-radius: 16px; background: #2f86ff2e; font-weight: 800; }
.btn.danger { background: #b3362e; }

/* ---------- комната и итог ---------- */
.tm-room, .tm-result { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px; padding: calc(var(--tgTop) + 6px) max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: #101823; color: #fff; box-sizing: border-box; overflow: auto; }
.tm-room .head { display: flex; gap: 14px; align-items: baseline; font-size: 20px; }
.tm-room .code { font-family: monospace; color: var(--y); }
.tm-room .ctl { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.teams { display: flex; gap: 14px; }
.team { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.team.b h4 { color: var(--b); opacity: 1; }
.team.o h4 { color: var(--o); opacity: 1; }
.slot { display: flex; align-items: center; gap: 8px; background: #ffffff0f; border-radius: 8px; padding: 4px 8px; min-height: 28px; }
.slot i { width: 16px; height: 16px; border-radius: 50%; background: #5b6472; }
.team.b .slot:not(.free) i { background: var(--b); }
.team.o .slot:not(.free) i { background: var(--o); }
.slot.me { outline: 2px solid #ffffff55; }
.slot.free span, .slot.off span { opacity: 0.6; }
.slot em { font-size: 11px; opacity: 0.7; font-style: normal; }
.leave { align-self: center; }
.tm-result { align-items: center; }
.tm-result h2 { margin: 0; font-size: 30px; font-weight: 900; }
.tm-result h2.b { color: var(--b); }
.tm-result h2.o { color: var(--o); }
.tm-result .big { font-size: 28px; font-weight: 800; }
.tm-result .teams { width: min(760px, 100%); }
.tm-result .row { display: flex; justify-content: space-between; padding: 2px 6px; }
.tm-result .row.me { background: #ffffff18; border-radius: 6px; }
.tm-result h4 em { float: right; font-style: normal; font-weight: 400; opacity: 0.7; }
.tm-result .go-row { width: min(760px, 100%); }

/* ---------- бой ---------- */
.tb-host, .tb { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.tb-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud-top { position: absolute; top: 0; left: 0; right: 0; height: var(--tgTop); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.hud-gear { position: absolute; left: calc(max(12px, env(safe-area-inset-left)) + var(--tgLeft, 0px)); width: 38px; height: 38px; border-radius: 50%; background: #0008; border: 0; font-size: 20px; }
.score { display: flex; align-items: center; gap: 8px; background: #0009; border-radius: 14px; padding: 4px 12px; color: #fff; }
.score .sc { font-size: 22px; font-weight: 900; }
.score .sc.b { color: var(--b); }
.score .sc.o { color: var(--o); }
.score .timer { font-weight: 800; min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; }
.score .timer.late { color: #ff6a5a; }
.heads { display: flex; gap: 3px; }
.heads i { width: 11px; height: 11px; border-radius: 50%; background: var(--b); }
.heads.o i { background: var(--o); }
.heads i.dead { background: #555b66; opacity: 0.6; }
.hud-banner { position: absolute; top: 22%; left: 50%; transform: translateX(-50%); font-size: clamp(18px, 4.6vh, 34px); font-weight: 900; color: #fff; text-shadow: 0 3px 0 #000a, 0 0 18px #000a; white-space: nowrap; pointer-events: none; }
.hud-banner.b { color: var(--b); }
.hud-banner.o { color: var(--o); }
.hud-banner.go { color: var(--y); }
.hud-banner.ch { top: calc(var(--tgTop) + 10px); font-size: clamp(14px, 3.4vh, 22px); }
.hud-feed { position: absolute; top: calc(var(--tgTop) + 4px); right: calc(max(10px, env(safe-area-inset-right)) + 6px); display: flex; flex-direction: column; align-items: flex-end; gap: 2px; pointer-events: none; font-size: 12px; color: #fff; }
.hud-feed .fl { background: #0008; border-radius: 6px; padding: 2px 6px; }
.hud-feed b.b { color: #7fb4ff; }
.hud-feed b.o { color: #ffb36b; }
.hud-spect { position: absolute; bottom: 18%; left: 50%; transform: translateX(-50%); background: #000a; color: #fff; border-radius: 10px; padding: 6px 12px; font-weight: 700; pointer-events: none; white-space: nowrap; }
.hud-hp { position: absolute; bottom: max(10px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: min(220px, 30vw); height: 14px; background: #0009; border-radius: 8px; overflow: hidden; pointer-events: none; }
.hud-hp i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #4ad06a, #9be36a); }
.hud-hp span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 14px; font-weight: 800; color: #fff; }
.hud-conn { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); background: #000c; color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 700; pointer-events: none; }
.hud-hit { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.hud-hit.on { animation: hitflash 0.45s ease-out; }
.hud-hit.on.flat { background: radial-gradient(ellipse at center, transparent 55%, #ff20107a); }
.hud-hit.on.dir { background: conic-gradient(from calc(var(--a) + 90deg - 25deg), #ff2010aa 0 50deg, transparent 50deg); -webkit-mask: radial-gradient(ellipse at center, transparent 62%, #000 72%); mask: radial-gradient(ellipse at center, transparent 62%, #000 72%); }
@keyframes hitflash { from { opacity: 1; } to { opacity: 0; } }
.tb-note { position: absolute; left: 50%; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 20px); transform: translateX(-50%); font-size: 10px; color: #fff8; pointer-events: none; white-space: nowrap; }

/* стики и кнопки */
.tc-stick { position: absolute; border-radius: 50%; background: #ffffff1a; border: 3px solid #ffffff66; pointer-events: none; box-sizing: border-box; }
.tc-stick.idle { opacity: 0.45; }
.tc-aim { background: #ff463c22; border-color: #ff7a6e99; }
.tc-knob { position: absolute; left: 50%; top: 50%; width: 44%; height: 44%; margin: -22% 0 0 -22%; border-radius: 50%; background: #ffffff8c; }
.tc-aim .tc-knob { background: #ff8a7acc; }
.tc-btn { border: 0; background: #0009; color: #fff; }
.tb-reload { position: absolute; right: calc(max(12px, env(safe-area-inset-right)) + 2px); bottom: calc(max(10px, env(safe-area-inset-bottom)) + 18vh + 40px); width: 48px; height: 48px; border-radius: 50%; font-size: 24px; }
.tb-wpn { position: absolute; right: calc(max(12px, env(safe-area-inset-right)) + 58px); bottom: calc(max(10px, env(safe-area-inset-bottom)) + 18vh + 36px); min-width: 104px; padding: 4px 10px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; border: 2px solid #ffffff55; }
.tb-wpn b { font-size: 12px; }
.tb-wpn span { font-size: 17px; font-weight: 900; color: var(--y); font-variant-numeric: tabular-nums; }
.tb-pick { position: absolute; left: 50%; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 34px); transform: translateX(-50%); padding: 10px 18px; border-radius: 14px; background: #ffe14dde; color: #1d1a10; font-weight: 900; }
.tb-choose { position: absolute; left: 50%; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 36px); transform: translateX(-50%); display: flex; gap: 8px; }
.wcard { width: min(120px, 17vw); background: var(--panel); border: 2px solid #ffffff44; border-radius: 12px; padding: 6px 8px; display: flex; flex-direction: column; gap: 3px; text-align: left; }
.wcard.sel { border-color: var(--y); background: #3a3410e8; }
.wcard b { font-size: 13px; line-height: 1.1; min-height: 2.2em; }
.wcard .bar { display: flex; align-items: center; gap: 4px; font-size: 10px; opacity: 0.85; }
.wcard .bar span { width: 3.6em; }
.wcard .bar i { flex: 1; height: 5px; border-radius: 3px; background: linear-gradient(90deg, var(--y) var(--v), #ffffff22 var(--v)); }
.tc-panel { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #101823f2; border-radius: 16px; padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; min-width: 240px; color: #fff; z-index: 5; }
.tc-panel h3 { margin: 0 0 4px; }

/* низкий экран (телефон боком): плотнее */
@media (max-height: 460px) {
  .tm-menu, .tm-room, .tm-result { --tgTop: 40px; }
  .tm-right { gap: 3px; }
  .mapcard { padding: 4px; }
  .mapcard .thumb { height: 13vh; width: auto; max-width: 100%; aspect-ratio: auto; }
  .mapcard .thumb.rnd { width: 100%; font-size: 5vh; }
  .mapcard b { font-size: 13px; }
  .pill { min-height: 32px; padding: 4px 8px; }
  .go, .invite { min-height: 46px; }
  .go { font-size: 20px; }
}
.slot { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
@media (max-height: 460px) {
  .slot { min-height: 22px; padding: 1px 8px; font-size: 13px; }
  .tm-room { gap: 5px; }
  .tm-room .head { font-size: 17px; }
}
.tb-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* картинки пачки 2: логотип, фон меню, значки оружия */
.tm-menu { background: linear-gradient(90deg, #0b111a00 0%, #0b111a00 38%, #0b111ad9 56%, #0b111af2 100%), url(/img/menu-bg.webp) 8% 75% / cover no-repeat, #0b111a; }
.tm-left .logo-img { width: 100%; max-width: 230px; height: auto; filter: drop-shadow(0 4px 8px #000a); }
.tm-left .who { margin-top: auto; background: #0008; align-self: flex-start; padding: 2px 10px; border-radius: 10px; }
.wicon { display: block; height: 20px; width: auto; max-width: 100%; margin: 2px auto; opacity: 0.95; }
.wcard .wicon { height: 26px; margin: 4px 0; }
.tb-wpn .wicon { height: 16px; }

/* кнопки оружия и перезарядки — всегда над стиком огня (стик: радиус clamp(46px, 16vh, 80px), низ +24px) */
.tb-reload { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 2 * clamp(46px, 16vh, 80px) + 34px); right: calc(max(12px, env(safe-area-inset-right)) + 4px); }
.tb-wpn { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 2 * clamp(46px, 16vh, 80px) + 30px); right: calc(max(12px, env(safe-area-inset-right)) + 62px); }

/* настройка управления: прозрачность, размытие фона под кнопками, редактор */
.tc-stick.idle, .tb-reload, .tb-wpn, .tb-pick, .hud-gear { opacity: var(--ctlAlpha, 0.55); }
.tc-stick.on:not(.idle) { opacity: min(1, calc(var(--ctlAlpha, 0.55) + 0.35)); }
.hud-gear { z-index: 6; }
.ce-item.sel { border-color: #fff; border-style: solid; box-shadow: 0 0 0 3px #ffe14d88; }
.ce-who { flex: 1; font-size: 12px; font-weight: 800; color: #ffe14d; align-self: center; }
.ce-gear { border-radius: 50%; }
.tc-stick, .tc-btn { -webkit-backdrop-filter: blur(var(--ctlBlur, 0px)); backdrop-filter: blur(var(--ctlBlur, 0px)); }
.tb-reload, .tb-wpn, .tb-pick, .tb-fire { transform-origin: center; }
.tb-fire { position: absolute; width: 68px; height: 68px; border-radius: 50%; padding: 0; display: grid; place-items: center; background: #c8343acc; border: 2px solid #ffffff70; opacity: var(--ctlAlpha, 0.55); touch-action: none; }
.tb-fire.on { background: #ff5148; opacity: min(1, calc(var(--ctlAlpha, 0.55) + 0.35)); }
.ce-panel .pill.sel { background: #ffe14d; color: #1d1a10; }
/* лобби: места Игрок / Бот / Закрыто (набросок лобби-места-1) */
.tm-room.lobby { gap: 5px; }
.tm-room.lobby .ctl { align-items: center; gap: 4px 8px; }
.tm-room.lobby .ctl .lbl { font-size: 12px; font-weight: 800; opacity: 0.75; }
.tm-room.lobby .ctl .pills.sm .pill { min-height: 28px; padding: 2px 10px; font-size: 12px; }
.tm-room.lobby .teams { gap: 10px; min-height: 0; }
.tm-room.lobby .team { gap: 3px; min-width: 0; }
.seat { display: flex; align-items: center; gap: 6px; background: #ffffff0f; border-radius: 8px; padding: 2px 4px 2px 8px; min-height: 30px; }
.seat > i { flex: 0 0 auto; width: 14px; height: 14px; border-radius: 50%; background: #5b6472; }
.team.b .seat:not(.s-wait):not(.s-bot):not(.s-closed) > i { background: var(--b); }
.team.o .seat:not(.s-wait):not(.s-bot):not(.s-closed) > i { background: var(--o); }
.seat.s-wait > i { background: transparent; border: 2px dashed #ffffff88; }
.seat.s-closed { opacity: 0.45; }
.seat.me { outline: 2px solid #ffffff55; }
.seat.off .nm b { opacity: 0.6; }
.seat .nm { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.1; }
.seat .nm b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .nm small { font-size: 10px; opacity: 0.65; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .segs { display: flex; gap: 2px; flex: 0 0 auto; }
.seat .sk { border: 0; border-radius: 12px; padding: 3px 7px; font-size: 11px; font-weight: 800; background: #ffffff14; color: #ffffffb0; min-height: 24px; }
.seat .sk:disabled { cursor: default; }
.seat .sk.sel.k-open { background: var(--b); color: #fff; }
.team.o .seat .sk.sel.k-open { background: var(--o); }
.seat .sk.sel.k-bot { background: #6b7482; color: #fff; }
.seat .sk.sel.k-closed { background: #4a2a2a; color: #fff; }
.tm-room.lobby .go-row { align-items: center; }
.tm-room.lobby .go-row .leave { flex: 0 0 auto; }
.gear-ctl { margin-left: 8px; border: 0; border-radius: 10px; background: #ffffff26; padding: 2px 8px; font-size: 12px; }
.ce { position: absolute; inset: 0; z-index: 20; background: #0b111acc; touch-action: none; }
.ce-item { position: absolute; display: grid; place-items: center; border: 2px dashed #ffe14d; border-radius: 50%; background: #ffffff1f; opacity: var(--ctlAlpha, 0.55); backdrop-filter: blur(var(--ctlBlur, 0px)); color: #fff; font-weight: 800; font-size: 12px; cursor: grab; }
.ce-item.on { border-style: solid; opacity: 1; }
.ce-wpn, .ce-pick { border-radius: 12px; }
.ce-panel { position: absolute; left: 50%; top: calc(var(--tgTop) + 4px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 4px; background: #101823f2; border-radius: 14px; padding: 8px 14px; color: #fff; min-width: 300px; z-index: 21; }
.ce-panel small { opacity: 0.75; }
.ce-sl { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.ce-sl span { width: 9em; }
.ce-sl input { flex: 1; }
.ce-row { display: flex; gap: 8px; }
.ce-row .go { min-height: 36px; font-size: 16px; }

@media (max-height: 420px) {
  .tm-room.lobby { gap: 3px; }
  .tm-room.lobby .head { font-size: 15px; }
  .tm-room.lobby h4 { margin: 0; font-size: 11px; }
  .tm-room.lobby .ctl .pills.sm .pill { min-height: 24px; padding: 1px 8px; font-size: 11.5px; }
  .seat { min-height: 25px; padding: 1px 3px 1px 6px; }
  .seat .nm small { display: none; }
  .seat .sk { min-height: 21px; padding: 2px 6px; font-size: 10.5px; }
  .tm-room.lobby .go-row button { min-height: 36px; padding: 3px 10px; font-size: 15px; white-space: nowrap; }
}
