/* ============================================================
   RAGDOLL FURY — main.css
   Платформенные защиты по yandex.md + базовая визуальная система
   ============================================================ */

/* ---------- 0. Сброс и обязательные защиты (п.1.6.1.8/1.10) ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --app-height: 100%;

  /* Палитра арены */
  --c-bg-top:#0E1726; --c-bg-bot:#1B2940; --c-wall:#243450;
  --c-pillar:#2E4060; --c-banner:#C0492F; --c-floor:#2A3550; --c-floor-hi:#3C4E72;
  --c-vignette:#070B14;
  /* UI */
  --c-panel:#16213A; --c-panel-2:#1B2A47; --c-border:#33446B; --c-border-2:#243556;
  --c-text:#E9F0FF; --c-text-dim:#9FB4D6; --c-text-mut:#64789e;
  /* Акценты */
  --c-accent:#46E0FF; --c-accent-2:#1E9BE8; --c-accent-core:#EAFBFF;
  --c-gold:#FFC93C; --c-gold-2:#B8860B; --c-gem:#7AD0FF;
  --c-good:#54D98C; --c-bad:#E5564B; --c-warn:#FFB02E;
  /* Раритеты */
  --r-common:#8aa0c0; --r-rare:#4aa3ff; --r-epic:#b56bff; --r-legend:#ffb02e;

  --radius:16px; --radius-sm:10px;
  --safe-l: 0px; /* левый сайдбар платформы в ландшафте */
  --shadow-card: 0 8px 24px rgba(0,0,0,.45);
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: var(--app-height, 100%);
  overflow: hidden;
  background: #0a0f1a;
  color: var(--c-text);
  font-family: "Segoe UI", system-ui, -apple-system, "Roboto", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.3;
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#ui-root, .screen, #game-canvas {
  height: 100%;
  height: var(--app-height, 100%);
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  display: block;
  touch-action: none;
  z-index: 1;
}

#ui-root {
  position: fixed;
  inset: 0;
  width: 100%;
  z-index: 2;
  pointer-events: none; /* экраны включают сами */
}

/* интерактивные элементы — блок браузерных жестов (п.1.10.2) */
button, .btn, .btn-icon, .card, .tab, .slot, input[type="range"],
.toggle, .opt, .nav-item, .chip, .swatch {
  touch-action: none;
}

/* ---------- 1. Boot splash ---------- */
.boot-splash {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px;
  background: radial-gradient(120% 90% at 50% 35%, #1B2940 0%, #0E1726 60%, #070B14 100%);
  transition: opacity .45s ease, visibility .45s;
}
.boot-splash.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-logo {
  font-weight: 900; font-size: clamp(34px, 9vw, 72px); letter-spacing: 2px;
  color: var(--c-text); text-shadow: 0 0 22px rgba(70,224,255,.35);
  display: flex; gap: .35em;
}
.boot-logo span { color: var(--c-accent); text-shadow: 0 0 26px rgba(70,224,255,.7); }
.boot-spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid rgba(70,224,255,.18);
  border-top-color: var(--c-accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 1b. Шторка ожидания рекламы (п.4.4) ----------
   Поднимается синхронно в обработчике клика — в том же кадре, что и действие игрока. Без transition:
   любое затухание = видимый зазор, в котором игрок успевает увидеть геймплей, а реклама выглядит
   «прилетевшей с задержкой». z-index выше всех экранов и сплэша. */
.ad-veil {
  position: fixed; inset: 0; z-index: 60;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  background: radial-gradient(120% 90% at 50% 35%, #1B2940 0%, #0E1726 60%, #070B14 100%);
}
.ad-veil.on { display: flex; }
.ad-veil-cap {
  color: var(--c-text-mut); font-size: 12px; font-weight: 700;
  letter-spacing: 3px; text-transform: uppercase;
}

/* ---------- 2. Система экранов (классы, НЕ id — п.15.1/15.2) ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .28s ease, visibility .28s;
  z-index: 3;
}
.screen.active { opacity: 1; visibility: visible; pointer-events: auto; }
.screen.behind { z-index: 2; }

/* Геймплейный оверлей: сам прозрачен для кликов. Интерактивны ТОЛЬКО реальные контролы (кнопки),
   а НЕ полноширинные полосы hud-top/hud-bottom и пустой спейсер — иначе они перехватывают тач над
   ареной и создают мёртвые зоны ввода (замах ближним по врагу у пола не доходит до canvas). (п.15.3) */
.screen.gameplay { pointer-events: none !important; background: transparent; }
.screen.gameplay .btn-icon,
.screen.gameplay .action-btn { pointer-events: auto; }

/* фон-панель экранов меню */
.screen.panelled {
  background:
    radial-gradient(130% 100% at 50% 0%, rgba(46,64,96,.55) 0%, rgba(14,23,38,.92) 55%, rgba(7,11,20,.97) 100%);
  backdrop-filter: blur(2px);
}

/* ---------- 3. Контейнеры/скролл ---------- */
.scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.scroll::-webkit-scrollbar { display: none; }

.col { display: flex; flex-direction: column; }
.row { display: flex; flex-direction: row; align-items: center; }
.center { align-items: center; justify-content: center; }
.gap-s { gap: 8px; } .gap-m { gap: 14px; } .gap-l { gap: 22px; }
.grow { flex: 1 1 auto; }
.hidden { display: none !important; }

/* ---------- 4. Типографика ---------- */
.h-logo {
  font-weight: 900; letter-spacing: 1.5px; line-height: 1;
  font-size: clamp(30px, 8vw, 64px);
  display: flex; gap: .3em; justify-content: center;
}
.h-logo span { color: var(--c-accent); text-shadow: 0 0 24px rgba(70,224,255,.6); }
.menu-weapon { width: 240px; max-width: 100%; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.menu-weapon canvas { height: 120px; }
.menu-weapon-eyebrow {
  margin-top: 4px; font-size: 11px; font-weight: 800; letter-spacing: 2.5px;
  text-transform: uppercase; color: var(--c-text-mut);
}
.menu-weapon-name {
  font-weight: 800; font-size: 22px; letter-spacing: .4px; line-height: 1.1; text-align: center;
  color: var(--c-text); text-shadow: 0 0 18px rgba(70,224,255,.5);
}
.h-title { font-weight: 800; font-size: clamp(20px, 5vw, 30px); letter-spacing: .5px; }
.h-sub { font-weight: 600; font-size: 15px; color: var(--c-text-dim); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- 5. Кнопки (мин 48px, п.1.8) ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 24px; border: none; border-radius: var(--radius-sm);
  font: inherit; font-weight: 800; font-size: 17px; letter-spacing: .3px;
  color: #06121c; cursor: pointer; white-space: nowrap;
  background: linear-gradient(180deg, #6EEBFF 0%, var(--c-accent) 55%, var(--c-accent-2) 100%);
  box-shadow: 0 6px 0 #0d5e86, 0 10px 22px rgba(70,224,255,.30);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #0d5e86, 0 6px 14px rgba(70,224,255,.25); }
.btn.secondary {
  color: var(--c-text);
  background: linear-gradient(180deg, var(--c-panel-2) 0%, var(--c-panel) 100%);
  box-shadow: 0 6px 0 #0c1426, 0 8px 18px rgba(0,0,0,.4);
  border: 1px solid var(--c-border);
}
.btn.secondary:active { transform: translateY(4px); box-shadow: 0 2px 0 #0c1426; }
.btn.gold {
  color: #2a1a00;
  background: linear-gradient(180deg, #FFE08A 0%, var(--c-gold) 55%, var(--c-gold-2) 100%);
  box-shadow: 0 6px 0 #7a5c0a, 0 10px 22px rgba(255,201,60,.3);
}
.btn.gold:active { transform: translateY(4px); box-shadow: 0 2px 0 #7a5c0a; }
.btn.ad {
  color: var(--c-text);
  background: linear-gradient(180deg, #3a2c6b 0%, #2a2050 100%);
  box-shadow: 0 6px 0 #170f33, 0 8px 18px rgba(120,80,255,.25);
  border: 1px solid #5b46a8;
}
.btn.ad:active { transform: translateY(4px); box-shadow: 0 2px 0 #170f33; }
/* опасное действие (сброс прогресса) визуально отделено от безопасного «Нет» */
.btn.danger {
  color: #fff;
  background: linear-gradient(180deg, #f0776c 0%, #d34133 55%, #a82a1e 100%);
  box-shadow: 0 6px 0 #6d1d16, 0 10px 22px rgba(229,86,75,.28);
}
.btn.danger:active { transform: translateY(4px); box-shadow: 0 2px 0 #6d1d16; }
.btn:disabled { filter: grayscale(.6) brightness(.7); pointer-events: none; }
.btn.block { width: 100%; }
.btn.lg { min-height: 62px; font-size: 20px; }
.btn .sub { font-size: 12px; font-weight: 700; opacity: .85; }
.btn .col { align-items: center; gap: 1px; }
/* ряды кнопок в меню переносятся, если длинные подписи (RU/EN) не влезают в ширину на узких телефонах —
   кнопка уходит на новую строку вместо обрезки текста по краю экрана */
.menu-mid .row { flex-wrap: wrap; justify-content: center; }

/* иконка-кнопка (HUD/настройки) */
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--c-border); cursor: pointer;
  background: rgba(22,33,58,.78); color: var(--c-text);
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  transition: transform .08s ease, background .15s ease;
}
.btn-icon:active { transform: scale(.92); }
.btn-icon svg { width: 24px; height: 24px; display: block; }

/* ---------- 6. Панели / карточки ---------- */
.panel {
  background: rgba(22,33,58,.92);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255,255,255,.05);
}
.panel.glass { background: rgba(22,33,58,.78); backdrop-filter: blur(8px); }

.card {
  position: relative;
  display: flex; flex-direction: column;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  background: linear-gradient(180deg, rgba(27,42,71,.95) 0%, rgba(18,28,48,.95) 100%);
  box-shadow: var(--shadow-card);
  overflow: hidden; cursor: pointer;
  transition: transform .1s ease, border-color .15s ease, box-shadow .15s ease;
}
.card:active { transform: scale(.97); }
.card.locked { filter: saturate(.5) brightness(.8); }
.card.selected { border-color: var(--c-accent); box-shadow: 0 0 0 2px var(--c-accent), var(--shadow-card); }
.card .rarity-bar { height: 4px; width: 100%; }
.card .thumb { width: 100%; aspect-ratio: 1.5 / 1; display: block; }
.card .label { padding: 6px 8px; font-weight: 700; font-size: 13px; text-align: center;
  line-height: 1.2; min-height: 2.4em; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.card .price { padding: 0 8px 8px; display: flex; align-items: center; justify-content: center; gap: 5px;
  font-weight: 800; font-size: 14px; }
.card .lock-ic { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(8,12,22,.35); }

/* чип валюты */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 12px 0 8px; border-radius: 20px;
  background: rgba(12,18,32,.7); border: 1px solid var(--c-border);
  font-weight: 800; font-size: 16px;
}
.chip svg { width: 22px; height: 22px; }

/* ---------- 7. HUD (геймплей) ---------- */
.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 12px; gap: 10px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-left: max(12px, var(--safe-l), env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
}
.hud-left, .hud-right { display: flex; gap: 8px; align-items: center; }
.hud-stat { display: flex; flex-direction: column; gap: 2px; }
.hud-wave { font-weight: 900; font-size: 18px; letter-spacing: .5px; }
.hud-score { font-weight: 800; font-size: 26px; line-height: 1; text-shadow: 0 0 14px rgba(70,224,255,.4); }
.hud-combo { font-weight: 900; font-size: 16px; color: var(--c-warn); transform-origin: left center; }

.hp-bar { width: 160px; max-width: 38vw; height: 12px; border-radius: 8px;
  background: rgba(8,12,22,.7); border: 1px solid var(--c-border); overflow: hidden; }
.hp-fill { height: 100%; width: 100%; border-radius: 8px;
  background: var(--c-good);
  transition: width .2s ease, background .2s ease; }

/* комбо-метр: полоса затухания серии + тир-цвета + «поп» числа */
.hud-combo-bar { width: 96px; max-width: 32vw; height: 5px; margin-top: 4px;
  border-radius: 4px; background: rgba(8,12,22,.6); overflow: hidden;
  opacity: 0; transition: opacity .15s ease; }
.hud-combo-bar.on { opacity: 1; }
.hud-combo-fill { height: 100%; width: 100%; border-radius: 4px; background: var(--c-warn);
  transition: width .09s linear; }
.hud-combo.t1, .hud-combo-fill.t1 { }
.hud-combo.t1 { color: #cfe0ff; }   .hud-combo-fill.t1 { background: #7aa0ff; }
.hud-combo.t2 { color: var(--c-warn); } .hud-combo-fill.t2 { background: var(--c-warn); }
.hud-combo.t3 { color: #ffd24a; text-shadow: 0 0 12px rgba(255,210,74,.6); } .hud-combo-fill.t3 { background: #ffd24a; }
.hud-combo.pop { animation: combo-pop .22s ease; }
@keyframes combo-pop { 0% { transform: scale(1.55); } 100% { transform: scale(1); } }

/* нижняя панель геймплея (спец-кнопка / огонь) */
.hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 16px; gap: 12px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  padding-left: max(16px, var(--safe-l), env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  pointer-events: none;
}
.action-btn {
  width: 84px; height: 84px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 14px; color: #06121c;
  background: radial-gradient(circle at 38% 32%, #7af0ff, var(--c-accent) 60%, var(--c-accent-2));
  box-shadow: 0 6px 18px rgba(70,224,255,.4), inset 0 2px 6px rgba(255,255,255,.5);
  border: none; cursor: pointer; user-select: none;
  transition: transform .07s ease, filter .1s;
}
.action-btn:active { transform: scale(.9); filter: brightness(1.15); }
.action-btn.cooldown { filter: grayscale(.7) brightness(.6); }
.action-btn svg { width: 38px; height: 38px; }

/* floating toast */
#toast-layer {
  position: fixed; left: 50%; bottom: 22%; transform: translateX(-50%);
  z-index: 30; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 90vw;
}
.toast {
  padding: 10px 18px; border-radius: 24px; font-weight: 800; font-size: 15px;
  background: rgba(12,18,32,.92); border: 1px solid var(--c-border); color: var(--c-text);
  box-shadow: 0 8px 22px rgba(0,0,0,.5);
  animation: toast-in .3s ease, toast-out .3s ease 1.7s forwards;
}
@keyframes toast-in { from { opacity:0; transform: translateY(14px) scale(.9);} to {opacity:1;transform:none;} }
@keyframes toast-out { to { opacity:0; transform: translateY(-10px) scale(.96);} }

/* ---------- 8. Сетки магазина ---------- */
.shop-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px; padding: 12px;
}
/* сумма кристаллов под названием пачки + иконка портальной валюты из SDK */
.shop-gem-amt { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 2px 4px; color: var(--c-gem); font-weight: 800; }
.shop-gem-amt svg { width: 16px; height: 16px; }
.cur-ic { width: 18px; height: 18px; vertical-align: -3px; margin-right: 5px; }

.tabs { display: flex; gap: 8px; padding: 10px 12px; overflow-x: auto; }
.tab {
  flex: 0 0 auto; padding: 10px 16px; border-radius: 22px; font-weight: 800; font-size: 14px;
  border: 1px solid var(--c-border); background: rgba(18,28,48,.8); color: var(--c-text-dim);
  cursor: pointer;
}
.tab.active { color: #06121c; background: var(--c-accent); border-color: var(--c-accent); }

/* топ-бар экранов меню */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px; gap: 10px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-left: max(12px, var(--safe-l), env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
}
/* заголовок занимает свободную ширину слева; многоточие — лишь страховка, если валюта рядом */
.topbar .title { font-weight: 800; font-size: 20px; flex: 1 1 auto; min-width: 0; text-align: left;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .row.gap-s { flex: 0 0 auto; }

/* ---------- 9. Модалки ---------- */
.modal-back {
  position: absolute; inset: 0; z-index: 10;
  display: flex; padding: 20px;
  overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain;
  scrollbar-width: none; -ms-overflow-style: none;
  background: rgba(5,8,16,.66); backdrop-filter: blur(3px);
  opacity: 0; visibility: hidden; transition: opacity .22s, visibility .22s;
}
.modal-back::-webkit-scrollbar { display: none; }
.modal-back.active { opacity: 1; visibility: visible; }
/* margin:auto центрирует, когда помещается, и НЕ обрезает при прокрутке (короткий ландшафт) */
.modal {
  width: min(440px, 92vw); margin: auto; display: flex; flex-direction: column;
  transform: scale(.92); transition: transform .22s ease;
}
.modal-back.active .modal { transform: scale(1); }
.modal-head { padding: 16px 18px 6px; display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 8px 18px 18px; }

/* статы оружия */
.statline { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.statline .lbl { width: 96px; font-size: 13px; color: var(--c-text-dim); }
.statline .track { flex: 1; height: 8px; border-radius: 6px; background: rgba(8,12,22,.7); overflow: hidden; }
.statline .fill { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg,var(--c-accent-2),var(--c-accent)); }

/* настройки */
.set-row { display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px 12px;
  padding: 14px 4px; border-bottom: 1px solid rgba(51,68,107,.4); }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 160px; height: 6px;
  border-radius: 4px; background: var(--c-border); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px;
  border-radius: 50%; background: var(--c-accent); box-shadow: 0 0 10px rgba(70,224,255,.6); cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border: none;
  border-radius: 50%; background: var(--c-accent); cursor: pointer; }
.toggle { width: 56px; height: 30px; border-radius: 16px; background: var(--c-border);
  position: relative; cursor: pointer; transition: background .18s; flex: 0 0 auto; }
.toggle.on { background: var(--c-accent); }
.toggle::after { content:""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; transition: transform .18s; }
.toggle.on::after { transform: translateX(26px); }
.seg { display: flex; border: 1px solid var(--c-border); border-radius: 10px; overflow: hidden; max-width: 100%; }
.seg .opt { padding: 8px 11px; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--c-text-dim); white-space: nowrap; }
.seg .opt.active { background: var(--c-accent); color: #06121c; }

/* ---------- 10. Game over / результат ---------- */
.result-stat { display: flex; align-items: baseline; justify-content: center; gap: 10px; }
.result-big { font-weight: 900; font-size: 56px; line-height: 1; text-shadow: 0 0 22px rgba(70,224,255,.5); }
.coins-earned { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 22px; color: var(--c-gold); }

/* лидерборд */
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; }
.lb-row.me { background: rgba(70,224,255,.12); border: 1px solid var(--c-accent); }
.lb-rank { width: 34px; text-align: center; font-weight: 900; font-size: 18px; }
.lb-name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; }
.lb-av { width: 36px; height: 36px; border-radius: 50%; background: var(--c-panel-2);
  display: flex; align-items: center; justify-content: center; font-weight: 900; }

/* ---------- 11. Адаптив ---------- */
.wrap { width: min(720px, 100%); margin: 0 auto; }
.pad { padding: 16px; }

/* Перекрытие сайдбаром платформы в ландшафте (п.1.10.3) */
@media (orientation: landscape) and (max-height: 540px) {
  :root { --safe-l: 70px; }
  .h-logo { font-size: clamp(26px, 6vh, 46px); }
  .action-btn { width: 72px; height: 72px; }
  /* компактное меню в коротком ландшафте — чтобы «Играть» был виден без прокрутки */
  .menu-weapon { display: none; }
  .menu-mid .gap-l { gap: 10px; }
  .menu-mid .btn.lg { min-height: 50px; font-size: 18px; }
}

/* низкие экраны: сжимаем вертикальный ритм модалок, чтобы стопка кнопок
   (в т.ч. «Нет/Да» в подтверждении сброса) гарантированно помещалась без прокрутки */
@media (max-height: 700px) {
  .modal.gap-m, .modal .gap-m { gap: 8px; }
  .modal .btn { min-height: 46px; }
  .modal .btn.lg { min-height: 54px; }
}
/* короткий ландшафт: окно шире и ниже — иначе нижняя кнопка уходит за экран, а скроллбары скрыты */
@media (orientation: landscape) and (max-height: 560px) {
  .modal { width: min(640px, 94vw); }
  .modal.pad, .modal .pad { padding: 10px 14px; }
  .modal.gap-m, .modal .gap-m { gap: 5px; }
  .modal .h-title { font-size: 20px; }
  .modal .h-sub { font-size: 13px; }
  .modal .btn { min-height: 40px; font-size: 15px; }
  .modal .btn.lg { min-height: 44px; font-size: 16px; }
  .modal .btn .sub { font-size: 10px; }
}

/* узкие телефоны: компактные чипы валюты, чтобы длинный заголовок + 5-значные суммы
   помещались в топбар без обрезки (заголовок-многоточие выше — лишь страховка на крайний случай) */
@media (max-width: 430px) {
  .chip { height: 34px; padding: 0 10px 0 7px; font-size: 14px; gap: 5px; }
  .chip svg { width: 18px; height: 18px; }
}

@media (max-width: 380px) {
  .shop-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 9px; }
  .btn { font-size: 16px; min-height: 50px; }
  .chip { font-size: 13px; padding: 0 8px 0 6px; }
}

/* ---------- 12. Экран выбора улучшения ---------- */
.up-modal { width: min(700px, 96vw); }
.up-cards { display: flex; gap: 12px; width: 100%; margin: 6px 0; }
.up-card {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 0 6px; min-height: 168px;
  border: 2px solid var(--r-common); border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(30,46,78,.96) 0%, rgba(17,26,46,.97) 100%);
  color: var(--c-text); font: inherit; text-align: center; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  box-shadow: 0 8px 22px rgba(0,0,0,.45);
  transition: transform .1s ease, box-shadow .15s ease, filter .15s ease;
}
.up-card:active { transform: scale(.97); }
.up-card .rarity-bar { height: 5px; width: 100%; border-radius: 4px 4px 0 0; }
.up-card.up-rare   { border-color: var(--r-rare);   box-shadow: 0 0 0 1px var(--r-rare),   0 8px 22px rgba(0,0,0,.45); }
.up-card.up-epic   { border-color: var(--r-epic);   box-shadow: 0 0 0 1px var(--r-epic),   0 0 16px rgba(181,107,255,.30), 0 8px 22px rgba(0,0,0,.45); }
.up-card.up-legend { border-color: var(--r-legend); box-shadow: 0 0 0 1px var(--r-legend), 0 0 18px rgba(255,176,46,.40),  0 8px 22px rgba(0,0,0,.45); }
.up-ic { width: 46px; height: 46px; margin: 12px 0 2px; color: var(--c-accent); display: flex; align-items: center; justify-content: center; }
.up-ic svg { width: 42px; height: 42px; }
.up-name { font-weight: 800; font-size: 16px; padding: 2px 8px; }
.up-desc { font-size: 13px; line-height: 1.35; color: var(--c-text-dim); padding: 4px 10px 6px; flex: 1; }
.up-meta { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 2px 0 6px; flex-wrap: wrap; }
.up-tier { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 9px; background: rgba(255,255,255,.06); letter-spacing: .3px; }
.up-tier-common { color: var(--r-common); }
.up-tier-rare   { color: var(--r-rare); }
.up-tier-epic   { color: var(--r-epic); }
.up-tier-legend { color: var(--r-legend); }
.up-stack { font-size: 12px; font-weight: 900; color: var(--c-accent); }
.up-footer { width: 100%; margin-top: 6px; }
.up-reroll, .up-skip { flex: 1; min-height: 52px; }
.up-card.disabled, .up-reroll.disabled, .up-skip.disabled, .up-shop.disabled { filter: grayscale(.65) brightness(.6); pointer-events: none; }
.up-card.declined { opacity: .45; }

/* магазин между волнами: монеты забега (валюта) + кнопки лечения/реролла + баниш карты */
.up-card { position: relative; }
.up-coins { display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 900; margin: -2px 0 2px; }
.up-coins svg { width: 20px; height: 20px; }
.up-footer.wrap { flex-wrap: wrap; }
.up-shop { flex: 1; min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 7px; }
.up-cost { display: inline-flex; align-items: center; gap: 3px; font-weight: 900; color: var(--c-accent); }
.up-cost svg { width: 16px; height: 16px; }
.up-shop.poor .up-cost, .up-banish.poor .up-cost { color: #e5564b; }
.up-banish {
  position: absolute; top: 5px; left: 5px; z-index: 2;
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 5px; border-radius: 9px;
  background: rgba(0,0,0,.42); color: var(--c-text-dim);
  font-size: 10px; font-weight: 800; cursor: pointer;
  transition: background .12s ease, color .12s ease, transform .1s ease;
}
.up-banish svg { width: 13px; height: 13px; }
.up-banish .up-cost svg { width: 12px; height: 12px; }
.up-banish:hover { background: rgba(229,86,75,.85); color: #fff; }
.up-banish:active { transform: scale(.9); }

/* косметика: превью трейла (облика) на карточке */
.trail-prev { height: 28px; width: 84%; margin: 26px auto 8px; border-radius: 20px; box-shadow: 0 0 12px rgba(255,255,255,.18), inset 0 0 6px rgba(255,255,255,.25); }

/* челлендж дня: рекорд дня — две строки (label + число), адаптивный размер числа (влезает при любом счёте) */
.dc-best-line { display: flex; align-items: baseline; justify-content: center; gap: 10px; }
.dc-best-num { font-weight: 900; font-size: clamp(22px, 7vw, 34px); line-height: 1.1; text-shadow: 0 0 16px rgba(70,224,255,.45); }

/* AD-карта — безошибочно особенная: фиолетово-золотое пульсирующее свечение */
.up-card.ad { border-color: #8a6bff; background: linear-gradient(180deg, rgba(48,34,86,.97) 0%, rgba(26,18,48,.98) 100%);
  animation: up-pulse 1.5s ease-in-out infinite; }
/* отклонённая/заблокированная ad-карта НЕ должна звать кликом — гасим пульс */
.up-card.ad.disabled, .up-card.ad.declined { animation: none; }
.up-card.ad .up-ic { color: #c9b6ff; }
.up-card.ad .up-name { color: #f1ebff; }
@keyframes up-pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(138,107,255,.45), 0 0 0 1px #8a6bff, 0 8px 22px rgba(0,0,0,.45); }
  50%      { box-shadow: 0 0 28px rgba(255,201,60,.55), 0 0 0 2px #b48bff, 0 8px 22px rgba(0,0,0,.45); }
}
.up-adbadge { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 900; letter-spacing: .5px;
  color: #16102e; background: linear-gradient(90deg, #ffd24a, #b48bff); padding: 3px 9px; border-radius: 9px; }
.up-adbadge svg { width: 14px; height: 14px; }
.up-adsub { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; color: #c9b6ff; padding: 2px 0 6px; }
.up-adsub svg { width: 16px; height: 16px; }
.up-risk { font-size: 11px; font-weight: 800; color: var(--c-bad); padding: 0 0 6px; }

/* мобильные: стек компактных карт во всю ширину (тап-таргет велик) */
@media (max-width: 560px) {
  .up-cards { flex-direction: column; gap: 9px; }
  /* вертикальный стек: карта по высоте контента (flex:1 1 0 в колонке + overflow:hidden схлопывал её в пустую полоску) */
  .up-card { min-height: 0; padding-bottom: 8px; flex: 0 0 auto; }
  .up-ic { width: 36px; height: 36px; margin: 8px 0 0; }
  .up-ic svg { width: 34px; height: 34px; }
  .up-name { font-size: 15px; }
  .up-desc { padding: 2px 12px 4px; }
}
/* короткий ландшафт: держим 3 карты в ряд + футер без прокрутки */
@media (orientation: landscape) and (max-height: 480px) {
  .up-cards { flex-direction: row; gap: 8px; }
  .up-card { min-height: 0; padding-bottom: 4px; flex: 1 1 0; }   /* ряд: 3 карты делят ширину */
  .up-ic { width: 30px; height: 30px; margin: 6px 0 0; }
  .up-ic svg { width: 28px; height: 28px; }
  .up-name { font-size: 14px; }
  .up-desc { font-size: 11px; padding: 2px 8px 3px; }
  .up-reroll, .up-skip { min-height: 48px; }
}

/* бейдж «МАКС» на капнутой карте улучшения */
.up-card.maxed { opacity: .62; }
.up-max { position: absolute; top: 6px; right: 6px; font-size: 10px; font-weight: 900; letter-spacing: .5px;
  color: #0b1320; background: var(--c-warn); padding: 2px 6px; border-radius: 6px; }

/* «морковка» на экране смерти: следующее оружие + прогресс по монетам */
.next-weapon { width: 100%; margin: 4px 0 2px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.05); border: 1px solid var(--c-border); text-align: center; }
.nw-label { font-size: 14px; color: var(--c-text-dim); margin-bottom: 6px; }
.nw-label b { color: var(--c-text); }
.nw-bar { height: 8px; border-radius: 5px; background: rgba(8,12,22,.7); overflow: hidden; }
.nw-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--c-accent), var(--c-accent-2)); transition: width .3s ease; }
.nw-sub { font-size: 12px; color: var(--c-warn); font-weight: 800; margin-top: 5px; }
.record-bonus { font-size: 14px; color: var(--c-warn); font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 4px; }
.record-bonus svg { width: 16px; height: 16px; vertical-align: middle; }

/* near-miss «так близко» + цель-эволюция на экране смерти (конверсия в «ещё разок») */
.near-miss { color: var(--c-warn); font-weight: 800; font-size: 15px; text-align: center; }
.evolve-goal { width: 100%; text-align: center; font-size: 13px; font-weight: 800; color: var(--c-accent);
  padding: 8px 12px; border-radius: var(--radius-sm); border: 1px dashed rgba(70,224,255,.5); background: rgba(70,224,255,.06); }
@keyframes nmpulse { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.btn.pulse { animation: nmpulse 1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .btn.pulse { animation: none; } }

/* подсказки-онбординг поверх боя (instant-play): плашка по центру-верху, не блокирует ввод,
   плавно появляется/гаснет; z-index выше HUD (3), ниже модалок (10) */
.coach-hint {
  position: absolute; left: 50%; top: 15%; transform: translate(-50%, -8px);
  z-index: 7; pointer-events: none; max-width: 92vw;
  padding: 11px 20px; border-radius: 999px; text-align: center;
  background: rgba(14,23,38,.94); border: 1px solid var(--c-accent);
  box-shadow: 0 8px 24px rgba(0,0,0,.5), 0 0 20px rgba(70,224,255,.28);
  color: var(--c-text); font-weight: 800; font-size: clamp(14px, 2.6vw, 19px); letter-spacing: .2px;
  opacity: 0; transition: opacity .5s ease, transform .5s ease;
}
.coach-hint.show { opacity: 1; transform: translate(-50%, 0); }

/* индикатор «есть что забрать» (ачивки/награды/задания) */
.claim-dot { display: none; position: absolute; top: -3px; right: -3px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--c-bad); border: 2px solid #0E1726; box-shadow: 0 0 6px rgba(229,86,75,.7); }
.btn.has-claim { position: relative; overflow: visible; }
.btn.has-claim > .claim-dot { display: block; }
.tab { position: relative; }
.tab > .claim-dot { display: block; top: 2px; right: 4px; }

/* уважение к prefers-reduced-motion (вспышки/анимации) */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .08s !important; }
}
