* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --blood: #d01026; --blood-d: #6e0712; --ink: #0a0410; --acid: #ffe066; --neon: #ff2d6f; --violet: #b23cff;
  --mono: "Rubik Mono One", "Arial Black", sans-serif;
}
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--ink); color: #fff;
  font-family: var(--mono);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none; touch-action: none;
}
#game { position: fixed; inset: 0; overflow: hidden; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; left: 0; right: 0; top: 0;
  padding: calc(env(safe-area-inset-top, 0px) + var(--tg-safe-area-inset-top, 0px) + 10px) 12px 0;
  display: flex; gap: 10px; align-items: flex-start; pointer-events: none;
}
#hud .side { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
#hud .side.right { align-items: flex-end; }
#hud .name { font-size: 11px; letter-spacing: 1px; text-shadow: 0 2px 0 #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bar { position: relative; width: 100%; height: 14px; border-radius: 7px; background: #2b1630; border: 2px solid #120812; overflow: hidden; }
.bar i { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transform-origin: left center; border-radius: 5px; }
.side.right .bar i { left: auto; right: 0; transform-origin: right center; }
.bar.hp .fill { background: linear-gradient(#ffd23f, #ff8a1f); transition: transform .12s ease-out; }
.bar.hp .lag { background: #fff; transition: transform .6s ease-in .25s; }
.side.right .bar.hp .fill { background: linear-gradient(#ff6b6b, #d9263b); }
.bar.st { height: 8px; width: 80%; }
.bar.st .fill { background: linear-gradient(#7af0ff, #2fa8ff); transition: transform .1s linear; }
.bar.st.tired .fill { background: linear-gradient(#ff9ab0, #ff4d79); }
.bar.sp, .bar.esp { height: 7px; width: 70%; }
.bar.sp .fill { background: linear-gradient(90deg, #ffe066, #fff6b0); transition: transform .2s ease-out; }
.bar.esp .fill { background: linear-gradient(90deg, #ff2d6f, #ff9ab0); transition: transform .2s ease-out; }
.bar.sp.full { box-shadow: 0 0 10px #ffe066; animation: pulse .5s infinite alternate; }
.splabel { font-size: 8px; letter-spacing: .5px; color: var(--acid); text-shadow: 0 1px 0 #000; white-space: nowrap; }
@keyframes pulse { to { box-shadow: 0 0 18px #fff6b0; } }
#pauseBtn {
  pointer-events: auto; width: 34px; height: 34px; border-radius: 50%; flex: none;
  border: 2px solid #120812; background: #3a1f45; color: #fff; font: inherit; font-size: 11px;
}
#hud .mid { flex: none; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.ping { font-size: 8px; letter-spacing: .5px; color: #7dff7a; text-shadow: 0 1px 0 #000; white-space: nowrap; }
.ping.warn { color: #ffd23f; }
.ping.bad { color: #ff4d79; }

#spBtn {
  pointer-events: auto; position: absolute; left: 50%; top: calc(env(safe-area-inset-top, 0px) + var(--tg-safe-area-inset-top, 0px) + 82px);
  transform: translateX(-50%); padding: 10px 26px; border-radius: 16px;
  font: inherit; font-size: 18px; color: #1a0a12; background: linear-gradient(#fff6b0, #ffd23f);
  border: 3px solid #120812; box-shadow: 0 5px 0 #120812, 0 0 22px #ffe066;
  animation: spPulse .45s ease-in-out infinite alternate;
}
#spBtn:active { transform: translateX(-50%) translateY(3px); box-shadow: 0 2px 0 #120812; }
@keyframes spPulse { to { box-shadow: 0 5px 0 #120812, 0 0 36px #fff6b0; transform: translateX(-50%) scale(1.06); } }

/* ---------- Экраны ---------- */
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px 16px; background: rgba(10, 4, 16, .82); backdrop-filter: blur(3px);
  text-align: center; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain;
}
.screen.menu {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(208,16,38,.45), transparent 60%),
    radial-gradient(ellipse at 50% 110%, rgba(178,60,255,.3), transparent 60%),
    repeating-linear-gradient(115deg, rgba(255,255,255,.025) 0 2px, transparent 2px 7px),
    #0a0410;
}
.badge18 {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 14px); right: 14px;
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--blood); border: 3px solid #fff; font-size: 16px; transform: rotate(12deg);
  box-shadow: 0 0 0 3px var(--blood), 0 6px 20px rgba(208,16,38,.6);
}
.logo { display: flex; flex-direction: column; align-items: center; line-height: .9; margin-top: 10px; }
.logo .l1 { font-size: clamp(44px, 16vw, 76px); color: #fff; text-shadow: 0 5px 0 #000, 0 0 22px rgba(255,45,111,.55); letter-spacing: 4px; transform: rotate(-4deg); margin-bottom: -6px; }
.logo .l2 {
  font-family: "Rubik Wet Paint", var(--mono); font-size: clamp(72px, 27vw, 130px); color: var(--blood);
  text-shadow: 0 6px 0 var(--blood-d), 0 12px 24px rgba(208,16,38,.5);
  animation: throb 1.6s ease-in-out infinite;
}
@keyframes throb { 50% { transform: scale(1.04) rotate(-1deg); } }
.tag { font-size: 12px; color: var(--acid); letter-spacing: .5px; max-width: 340px; }
.profile { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px; max-width: 320px; }
.profile .pnick { font-family: system-ui, sans-serif; font-size: 16px; font-weight: 800; color: #fff; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile .plvl { font-size: 13px; padding: 3px 9px; border-radius: 9px; background: linear-gradient(#ffd23f, #c98a00); color: #2a1400; border: 2px solid #120812; box-shadow: 0 3px 0 #120812; }
.pxp { position: relative; width: 100%; height: 14px; border-radius: 7px; background: #241430; border: 2px solid #120812; overflow: hidden; }
.pxp i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #8a3cff, #ff3fa4); transition: width .6s ease; }
.pxp span { position: relative; display: block; font-family: system-ui, sans-serif; font-size: 10px; font-weight: 700; line-height: 10px; color: #fff; }
.endxp { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; max-width: 280px; font-size: 16px; color: var(--acid); }
.endxp .up { color: #ffd23f; font-size: 20px; text-shadow: 0 3px 0 #000; animation: throb .8s ease-in-out infinite; }
.warn { font-family: system-ui, sans-serif; font-size: 12px; opacity: .55; max-width: 300px; }
.btns { display: flex; flex-direction: column; gap: 12px; align-items: center; width: 100%; max-width: 320px; margin: 10px 0; }
.btns .big { width: 100%; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.stitle { font-size: 24px; text-shadow: 0 4px 0 #000; color: #fff; }
.stitle.big { font-family: "Rubik Wet Paint", var(--mono); font-size: 54px; color: var(--blood); text-shadow: 0 5px 0 var(--blood-d); }
.help { list-style: none; font-family: system-ui, sans-serif; font-size: 15px; display: flex; flex-direction: column; gap: 6px; max-width: 380px; width: 100%; }
.help li { display: flex; gap: 10px; text-align: left; background: rgba(255,255,255,.06); border-radius: 10px; padding: 7px 10px; }
.help span { flex: 0 0 140px; color: var(--acid); font-weight: 800; }
.keys { font-family: system-ui, sans-serif; font-size: 12px; opacity: .6; max-width: 360px; }
.stats { font-family: system-ui, sans-serif; font-size: 16px; line-height: 1.6; }
/* итоги боя: бойцы и ники игроков под ними */
.vs { display: flex; align-items: center; justify-content: center; gap: 10px; max-width: 100%; }
.vs .who { display: flex; flex-direction: column; align-items: center; gap: 4px; width: min(38vw, 150px); min-width: 0; }
.vs canvas { width: min(30vw, 110px); height: min(30vw, 110px); border-radius: 18px; background: radial-gradient(circle at 50% 40%, #3a1838, #14060f); border: 3px solid #120812; }
.vs .win canvas { border-color: #ffd23f; box-shadow: 0 0 18px rgba(255,210,63,.55); }
.vs .lose canvas { filter: grayscale(.7) brightness(.75); }
.vs .ch { font-size: 13px; letter-spacing: 1px; }
.vs .nick { font-family: system-ui, sans-serif; font-size: 14px; font-weight: 700; color: var(--acid); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs .mark { font-size: 11px; letter-spacing: 1px; color: #ffd23f; min-height: 14px; }
.vs .vsl { font-size: 22px; color: #ff3a52; text-shadow: 0 2px 0 #120812; }
button { touch-action: manipulation; cursor: pointer; }
button.big {
  font: inherit; font-size: 22px; padding: 14px 32px; border-radius: 16px; color: #fff;
  background: linear-gradient(#ff3a52, #b30d22); border: 3px solid #120812; box-shadow: 0 6px 0 #120812, 0 0 24px rgba(208,16,38,.45);
  text-shadow: 0 2px 0 #4a0510;
}
button.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #120812; }
button.big.ghost { background: #241430; color: #8a7a96; box-shadow: 0 6px 0 #120812; text-shadow: none; }
button.big.alt { background: linear-gradient(#8a3cff, #4b1596); box-shadow: 0 6px 0 #120812, 0 0 24px rgba(178,60,255,.4); text-shadow: 0 2px 0 #24064a; }

/* ---------- Сложность ---------- */
.diff { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; width: 100%; }
.diff button {
  font: inherit; color: #c9b8d6; background: #241430; border: 2px solid #120812; border-radius: 12px;
  padding: 8px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 62px; box-shadow: 0 4px 0 #120812;
}
.diff b { font-weight: normal; font-size: 10px; line-height: 1.15; letter-spacing: .3px; }
.diff small { font-family: system-ui, sans-serif; font-size: 10px; opacity: .65; }
.diff button.on { color: #fff; background: linear-gradient(#ff3a52, #8a0a1b); box-shadow: 0 4px 0 #120812, 0 0 14px rgba(208,16,38,.55); }
.diff button[data-diff="hard"].on { background: linear-gradient(#1a0a12, #000); border-color: var(--blood); color: var(--blood); text-shadow: 0 0 8px rgba(208,16,38,.8); }

/* ---------- Лобби ---------- */
.lobby-status { font-family: system-ui, sans-serif; font-size: 16px; max-width: 320px; }
.lobby-code { font-size: 14px; color: #c9b8d6; }
.lobby-code b { font-weight: normal; color: var(--acid); font-size: 22px; letter-spacing: 3px; }
/* разминка: экран лобби прозрачный, сверху арена с манекеном, внизу код и кнопки */
#lobbyScreen.warm { background: none; backdrop-filter: none; justify-content: flex-end; gap: 10px; pointer-events: none;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); }
#lobbyScreen.warm > * { pointer-events: auto; }
#lobbyScreen.warm .stitle, #lobbyScreen.warm .lobby-status { display: none; }
#lobbyScreen.warm .lobby-code { background: rgba(10,4,16,.7); padding: 4px 12px; border-radius: 10px; }

/* вызов кента: самая заметная кнопка лобби */
button.big.call { font-size: 17px; padding: 14px 18px; background: linear-gradient(#ffe066, #ff7a1a); color: #1a0a12; text-shadow: none;
  box-shadow: 0 6px 0 #120812, 0 0 26px rgba(255,160,40,.6); animation: callPulse .8s ease-in-out infinite alternate; }
@keyframes callPulse { to { box-shadow: 0 6px 0 #120812, 0 0 40px rgba(255,210,63,.85); transform: scale(1.03); } }

/* «СЛУЧАЙНЫЙ ЧЕПУХ»: кнопка в меню, в лобби нет кода и вызовов, окно «живых нет» */
button.big.quick { background: linear-gradient(#c8ff5a, #3fae1a); color: #10200a; text-shadow: none; box-shadow: 0 6px 0 #120812, 0 0 24px rgba(160,255,90,.45); }
#lobbyScreen.quick .lobby-code, #lobbyScreen.quick #btnCall, #lobbyScreen.quick #btnInvite { display: none; }
.nobody { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px 16px;
  background: rgba(10,4,16,.86); z-index: 5; }
.nobody-text { font-size: 18px; line-height: 1.35; max-width: 320px; color: #fff; text-shadow: 0 3px 0 #000; }

/* онлайн в меню */
.online { font-family: system-ui, sans-serif; font-size: 13px; font-weight: 700; color: #c9b8d6; padding: 5px 12px; border-radius: 12px; background: rgba(255,255,255,.06); }
.online b { color: #7dff7a; }
.online i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #7dff7a; box-shadow: 0 0 8px #7dff7a; animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* карточка нокаута и кнопка «в чат» */
.kocard { width: min(52vw, 210px); border-radius: 14px; border: 3px solid #ffd23f; box-shadow: 0 0 24px rgba(255,210,63,.45); transform: rotate(-2deg); }
button.big.brag { font-size: 16px; padding: 14px 18px; background: linear-gradient(#ffe066, #ff7a1a); color: #1a0a12; text-shadow: none;
  box-shadow: 0 6px 0 #120812, 0 0 26px rgba(255,160,40,.6); animation: callPulse .8s ease-in-out infinite alternate; }
.vs .nick.copy { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }

/* ШМОТЛЯНДИЯ */
button.big.shop { background: linear-gradient(#b06cff, #6a2bc4); }
button.big.shop.locked { background: #4a4450; color: #9a93a3; box-shadow: 0 6px 0 #120812; text-shadow: none; }
#shopScreen { justify-content: flex-start; }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; width: 100%; max-width: 520px; }
.shop .card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px; border-radius: 14px; text-align: center;
  background: rgba(255,255,255,.06); border: 2px solid transparent; cursor: pointer; }
.shop .card.on { border-color: var(--acid); background: rgba(200,255,90,.1); }
.shop .card canvas { width: 96px; height: 96px; }
.shop .gn { font-size: 11px; letter-spacing: .5px; line-height: 1.25; }
.shop .gd { font-family: system-ui, sans-serif; font-size: 11px; opacity: .7; line-height: 1.3; }
.shop .gp { font-size: 13px; color: #ffd23f; }
.shop .gs { font-size: 10px; color: var(--acid); min-height: 12px; }
.shop .gw { font-size: 9px; letter-spacing: 1px; color: #ff9bd0; }
#shopScreen .tabs { display: flex; gap: 8px; width: 100%; max-width: 520px; margin: 4px 0 10px; }
#shopScreen .tab { flex: 1; padding: 10px 6px; border-radius: 12px; border: 2px solid rgba(255,255,255,.15); background: rgba(255,255,255,.06);
  color: #cfc6d8; font: inherit; font-size: 13px; letter-spacing: .5px; cursor: pointer; }
#shopScreen .tab.on { border-color: var(--acid); background: rgba(200,255,90,.12); color: #fff; }

/* ТОП РАЙОНА */
button.big.top { background: linear-gradient(#ffe066, #ff9f1c); color: #1a0a12; text-shadow: none; }
.top-sub { font-family: system-ui, sans-serif; font-size: 13px; opacity: .7; }
.toplist { list-style: none; margin: 0; padding: 0; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 6px; }
.toplist li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 12px; background: rgba(255,255,255,.06); text-align: left; }
.toplist li:nth-child(1) { background: rgba(255,210,63,.18); }
.toplist li:nth-child(2) { background: rgba(220,220,235,.12); }
.toplist li:nth-child(3) { background: rgba(205,127,50,.16); }
.toplist .pl { flex: 0 0 26px; font-size: 16px; color: var(--acid); text-align: center; }
.toplist .av { flex: none; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid #120812; background: #3a1f45;
  display: flex; align-items: center; justify-content: center; font-size: 15px; overflow: hidden; }
.toplist .nm { flex: 1; min-width: 0; font-family: system-ui, sans-serif; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toplist .wn { flex: none; font-size: 14px; color: #ffd23f; }
.toplist li.tap { cursor: pointer; }
.toplist li.tap:active { transform: scale(.97); background: rgba(208,16,38,.3); }
.toplist .empty { justify-content: center; font-family: system-ui, sans-serif; opacity: .7; }
button.big small { font-size: 11px; vertical-align: middle; opacity: .8; }
button.small { font: inherit; font-size: 12px; padding: 9px 16px; border-radius: 12px; color: #fff; background: #3a1f45; border: 2px solid #120812; }

/* ---------- Выбор бойца ---------- */
.carousel { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; max-width: 420px; }
#preview { width: min(68vw, 300px); height: min(68vw, 300px); border-radius: 22px; background: radial-gradient(circle at 50% 40%, #3a1838, #14060f); border: 3px solid #120812; box-shadow: 0 0 30px rgba(208,16,38,.35); touch-action: none; }
.arrow { font: inherit; font-size: 34px; width: 46px; height: 64px; border-radius: 14px; color: #fff; background: #3a1f45; border: 2px solid #120812; }
.chname { font-size: 26px; color: var(--acid); text-shadow: 0 3px 0 #000; }
.chtitle { font-family: system-ui, sans-serif; font-size: 14px; opacity: .8; margin-top: -8px; }
.spbox { display: flex; flex-direction: column; gap: 4px; max-width: 340px; padding: 10px 14px; border-radius: 14px; background: rgba(208,16,38,.15); border: 1px solid rgba(208,16,38,.5); }
.spbox b { font-size: 14px; color: var(--neon); font-weight: normal; }
.spbox span { font-family: system-ui, sans-serif; font-size: 13px; opacity: .9; }
.dots { display: flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: #3a1f45; }
.dots i.on { background: var(--blood); }

#toast {
  position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); padding: 10px 18px; border-radius: 12px;
  background: #241430; border: 2px solid var(--blood); font-size: 12px; z-index: 10;
}

/* ---------- ЧЕТЫРЕ ЧЕПУХА ---------- */
button.big.cup { background: linear-gradient(#ff5a8a, #b0123c); box-shadow: 0 6px 0 #120812, 0 0 24px rgba(255,60,120,.45); }
#lobbyScreen.cup .lobby-code { display: none; }
#lobbyScreen.cup #btnCall { display: none; }
.cupbox { width: 100%; max-width: 360px; padding: 10px 12px; border-radius: 14px; background: rgba(10,4,16,.82); border: 2px solid rgba(255,60,120,.6); }
.cup-title { font-size: 16px; color: var(--acid); text-shadow: 0 2px 0 #000; line-height: 1.25; }
.cup-text { font-family: system-ui, sans-serif; font-size: 13px; line-height: 1.35; margin-top: 4px; opacity: .9; }
.cup-list { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.cup-list li { font-family: system-ui, sans-serif; font-weight: 700; font-size: 13px; padding: 6px 8px; border-radius: 10px; background: rgba(255,255,255,.07);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cup-list li.me { background: rgba(200,255,90,.16); }
.cup-list li.empty { opacity: .45; font-weight: 400; }
.cup-list li.gone { text-decoration: line-through; opacity: .5; }
.cup-list li.vs { grid-column: 1 / -1; text-align: center; background: none; padding: 0; font-size: 11px; opacity: .6; }
.watchbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 14px); width: min(92vw, 380px);
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 14px; background: rgba(10,4,16,.75); pointer-events: none; text-align: center; }
.watchbar .wl { font-size: 11px; color: var(--acid); line-height: 1.3; }
.watchbar .wh { font-family: system-ui, sans-serif; font-size: 12px; }
.watchbar b { letter-spacing: 2px; }
#watchSwap { pointer-events: auto; font: inherit; font-size: 11px; padding: 7px 12px; border-radius: 10px; color: #fff; background: #3a1f45; border: 2px solid #120812; }
.cup-places { list-style: none; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 6px; }
.cup-places li { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,.06); text-align: left; }
.cup-places li:nth-child(1) { background: rgba(255,210,63,.2); }
.cup-places li.me { outline: 2px solid var(--acid); }
.cup-places .t { font-size: 12px; color: var(--acid); line-height: 1.3; }
.cup-places .n { font-family: system-ui, sans-serif; font-weight: 700; font-size: 14px; }

/* ---------- рейтинг и лиги ---------- */
.leagues { font-size: 11px; color: #c9b8d6; letter-spacing: .5px; }
.leagues small { font-size: 9px; opacity: .7; }
.plvl.league { color: #7af0ff; }
.toplist .rt { flex: none; font-size: 14px; color: #ffd23f; text-align: right; line-height: 1.1; }
.toplist .rt small { display: block; font-family: system-ui, sans-serif; font-size: 10px; color: #c9b8d6; }
.endxp .rate { color: #7af0ff; }
.endxp .rate.minus { color: #ff8aa8; }
