/*
 * Beachball — единый стиль «солнечный пляжный аркейд» поверх анимированного
 * пляжа (#bg-canvas, beach.js: небо, море, волны, песок).
 * Светлые молочные карточки, сочные коралл-жёлтые CTA, мягкие тени.
 * Типографика: Fredoka (заголовки) + Nunito (текст), обе с кириллицей.
 */
:root {
  /* пляжная палитра */
  --sky: #36c5f0;
  --sea: #0fb6a6;
  --sand: #ffe2a8;
  --coral: #ff6b4a;
  --coral-2: #ff8a3d;
  --sun: #ffc02e;
  --gold: #f5a623;
  --gem: #19b6e6;

  /* CLAYMORPHISM-поверхности: тёплые, НИКОГДА чисто-белые */
  --card: #fffdf8;                 /* мягкий молочный */
  --card-soft: #fff4e2;            /* тёплый песочный (вложенные блоки) */
  --ink: #143a4a;                  /* основной тёмный текст */
  --ink-dim: #5d7c89;              /* вторичный текст */
  --line: rgba(20, 58, 74, 0.10);  /* тонкие границы */

  /* «пластилиновые» тени: мягкая внешняя + светлый внутренний хайлайт сверху
     + лёгкая внутренняя тень снизу = объём надутой глины */
  --clay:
    0 14px 30px rgba(17, 64, 83, 0.16),
    0 3px 8px rgba(17, 64, 83, 0.08),
    inset 0 2px 3px rgba(255, 255, 255, 0.95),
    inset 0 -6px 14px rgba(17, 64, 83, 0.055);
  --clay-sm:
    0 6px 16px rgba(17, 64, 83, 0.13),
    inset 0 1px 2px rgba(255, 255, 255, 0.9),
    inset 0 -4px 9px rgba(17, 64, 83, 0.05);
  --clay-pressed:
    inset 0 5px 12px rgba(17, 64, 83, 0.20),
    inset 0 -2px 4px rgba(255, 255, 255, 0.55);

  /* алиасы — старые правила автоматически получают clay-вид */
  --shadow: var(--clay);
  --shadow-sm: var(--clay-sm);
  --shadow-cta:
    0 12px 26px rgba(255, 107, 74, 0.42),
    inset 0 2px 3px rgba(255, 255, 255, 0.55),
    inset 0 -6px 13px rgba(190, 55, 15, 0.28);

  --radius: 30px;
  --radius-md: 22px;
  --radius-sm: 16px;
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font-head: 'Fredoka', 'Segoe UI', sans-serif;
  --font-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  /* статичный пляж-фолбэк до первого кадра #bg-canvas */
  background: linear-gradient(180deg, #5cc6f2 0%, #bdeeff 56%, #2fa3d9 62%, #7fd6ec 70%, #f6d999 72%, #e7c073 100%);
  overflow: hidden;
  touch-action: manipulation;
  /* iOS: долгое нажатие не вызывает лупу, выделение текста и callout-меню */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
input, textarea { -webkit-user-select: text; user-select: text; }

#bg-canvas { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

/* в игре отключаем все жесты браузера полностью */
#screen-game.active, #screen-game.active * { touch-action: none; }

/* #app — общий вертикальный скроллер: при прокрутке меню шапка уезжает вверх
   вместе с контентом, а не висит сверху и не перекрывает меню */
#app { height: 100%; display: flex; flex-direction: column; position: relative; z-index: 1; overflow-y: auto; }
.totem { display: none; }

/* ================= TOPBAR (тонкая минималистичная, всегда сверху) ================= */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  /* лёгкая фростед-полоса вместо тяжёлой плашки: контент читаем, не давит */
  background: rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
}
/* в игре полоса прозрачная — плавающая поверх поля */
#app:has(#screen-game.active) #topbar {
  background: none;
  border-bottom: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
/* в игре шапка минимальна (логотип + пинг + статус): онлайн-пилюли
   прячем — они не нужны в матче и налезали на HUD счёта */
#app:has(#screen-game.active) #online-count,
#app:has(#screen-game.active) #search-count { display: none; }
.logo {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.3px;
  color: var(--ink);
}
.logo span {
  color: transparent;
  background: linear-gradient(90deg, var(--sun), var(--coral));
  -webkit-background-clip: text;
  background-clip: text;
}
.logo small {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-left: 5px;
  color: var(--ink-dim);
}
.topbar-right { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

/* ===== валюты, магазин и выход (после входа): переехали из шапки
   в колонку «Скины» (валюты+магазин) и в герой-блок (выход) ===== */
.skins-wallet { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.skins-wallet.hidden { display: none; }
.hp-stat {
  font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-sm); color: var(--ink);
}
.hp-stat b { font-variant-numeric: tabular-nums; }
.hp-stat.coin b { color: var(--gold); }
.hp-stat.gem b { color: var(--gem); }
.hp-shop {
  border: none; cursor: pointer; font-family: var(--font-head); font-weight: 600; font-size: 12px;
  color: #fff; padding: 6px 13px; border-radius: 999px; white-space: nowrap;
  background: linear-gradient(135deg, var(--gem), var(--sky));
  box-shadow: var(--shadow-sm); transition: box-shadow 0.2s, filter 0.2s, transform 0.14s;
}
.hp-shop:hover { transform: translateY(-1px); filter: saturate(1.1); box-shadow: 0 6px 16px rgba(25, 182, 230, 0.4); }
.hp-logout {
  border: none; cursor: pointer; font-family: var(--font-head); font-weight: 600; font-size: 12px;
  color: var(--ink-dim); padding: 6px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  transition: color 0.2s, border-color 0.2s;
}
.hp-logout:hover { color: var(--coral); border-color: rgba(255, 107, 74, 0.5); }

/* на узких экранах шапка компактнее: прячем подпись и текст «Магазин» */
@media (max-width: 560px) {
  #topbar { padding: 6px 10px; gap: 6px; }
  .topbar-right { gap: 5px; }
  .logo { font-size: 19px; }
  .logo small { display: none; }
  .hp-shop-txt { display: none; }       /* остаётся только 💎 */
  .hp-shop { padding: 6px 10px; }
  .hp-stat { padding: 4px 8px; }
}

/* пилюли в топбаре — компактные белые капсулы */
.ping, .online-pill, .acc-info {
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
}
.ping { color: #119c79; }
.ping.hidden { display: none; }
.ping.warn { color: var(--gold); }
.ping.bad { color: #e0566f; }
.online-pill { color: #119c79; }
.online-pill.hidden { display: none; }
.search-pill { color: var(--coral); }
.acc-info { color: var(--ink); }
.acc-info.hidden, #btn-logout.hidden { display: none; }

/* ================= SCREENS ================= */
.screen {
  flex: 1;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 0;
  /* скроллит общий контейнер #app (вместе с шапкой), а не каждый экран отдельно */
  overflow-y: visible;
}
.screen.active { display: flex; }
/* меню — вертикальная лента: блок игры + лендинг-секции (SEO).
   justify-content:flex-start обязателен: при контенте выше экрана центрирование
   обрезало бы верх без возможности доскроллить */
#screen-menu.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  padding: 16px 16px 48px;
}

/* хедлайн-банд: приветствие + соцдоказательство над сеткой.
   Ограничиваем длину строки (≈читаемые 60–70 знаков) и центрируем — фокус сверху вниз. */
.menu-hero {
  width: min(720px, 94vw);
  text-align: center;
  margin-bottom: 4px;
}
.menu-hero .subtitle { margin-bottom: 12px; }

/* меню-сетка: мобайл — одна колонка; ПК — 3 колонки (скины | игра | лидеры) */
.menu-grid {
  width: min(560px, 94vw);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.menu-grid .panel { width: auto; margin: 0; }
.col-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 18px;
  color: var(--sea);
  margin-bottom: 12px;
}

/* большой живой превью выбранного скина */
.skin-preview-wrap, .hero-skin { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 18px; }
/* герой-блок: аватарка с ником снизу, справа — рейтинг/уровень/статистика */
.hero-skin { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 20px; }
.hero-id { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hero-stats { display: flex; flex-direction: column; gap: 3px; min-width: 215px; max-width: 270px; text-align: left; }
.hs-rating { font-family: var(--font-head); font-weight: 700; font-size: 21px; color: var(--ink); }
.hs-rating b { color: var(--gold); }
.hs-cap { margin-left: 7px; font-family: var(--font-body); font-size: 12px; font-weight: 700; color: var(--ink-dim); }
.hs-level-row { font-size: 14px; font-weight: 800; color: var(--ink); margin-top: 5px; }
.hs-divider { height: 1px; background: var(--line); margin: 9px 0 5px; }
.hs-line { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 700; color: var(--ink-dim); }
.hs-line b { color: var(--ink); font-variant-numeric: tabular-nums; }
.hs-mygames { margin-top: 9px; align-self: stretch; text-align: center; text-decoration: none; display: block; }
.hs-mygames.hidden { display: none; }
.hs-logout { margin-top: 7px; align-self: stretch; width: 100%; }
.hs-logout.hidden { display: none; }

/* единая иконка устройства рядом с ником (devicons.js) */
.dev-ico { width: 1em; height: 1em; margin-left: 6px; vertical-align: -0.12em; opacity: 0.8; flex: none; }
#skin-preview {
  width: 240px; height: 240px;
  border-radius: 22px;
  background-color: var(--card-soft);
  background-repeat: no-repeat;
  background-position: center 48%;
  background-size: 80% auto;            /* картинку выбранного персонажа ставит JS */
  border: 2px solid var(--line);
  box-shadow: var(--clay-pressed);      /* мягкий clay-колодец под скином */
}
.skin-preview-name { font-family: var(--font-head); font-weight: 600; font-size: 22px; color: var(--coral); }

/* большая главная кнопка — единственный «тёплый» полноширинный CTA (правило Фиттса) */
.btn.primary.big { font-size: 20px; padding: 19px 22px; margin-top: 4px; }

/* подчинённые режимы — компактный ряд равных кнопок-«пиров» под главной CTA.
   Визуально слабее главной (Гештальт: близость + равенство = второстепенные) */
.mode-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.mode-row .btn.secondary { margin-top: 0; }

/* подпись-приглашение в лобби с другом */
.friend-intro { margin-top: 0; margin-bottom: 14px; }

@media (min-width: 1180px) {
  .menu-grid {
    width: min(1480px, 96vw);
    display: grid;
    /* симметричные боковые колонки кадрируют доминирующий центр (центр-сцена):
       слева — кастомизация (скины), в центре — личность + ГЛАВНАЯ кнопка,
       справа — лидеры + справка. Центр заметно шире боковых = главный фокус. */
    grid-template-columns: minmax(300px, 1fr) minmax(460px, 1.5fr) minmax(300px, 1fr);
    align-items: start;
    gap: 22px;
  }
  /* DOM-порядок skins, main, side → закрепляем явно, центр между боковыми */
  .col-skins { order: 1; }
  .col-main  { order: 2; }
  .col-side  { order: 3; }

  /* центр приподнят над боковыми панелями — читается как главный (фигура/фон) */
  .col-main {
    box-shadow:
      0 22px 46px rgba(17, 64, 83, 0.20),
      0 6px 14px rgba(17, 64, 83, 0.10),
      inset 0 2px 3px rgba(255, 255, 255, 0.95),
      inset 0 -6px 14px rgba(17, 64, 83, 0.055);
  }

  /* крупное превью выбранного скина (фокус-якорь) + крупные миниатюры слева */
  #skin-preview { width: 270px; height: 270px; }
  .skin-preview-name { font-size: 26px; }
  .col-skins .thumb-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 12px; }
  .col-skins .thumb-grid.ball { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
}

/* ================= КАРТОЧКИ / ПАНЕЛИ ================= */
.panel {
  margin: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  width: min(560px, 94vw);
}
#screen-menu .panel { margin: 0; }
.panel.center { text-align: center; }

h1 {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0.2px;
  margin-bottom: 6px;
  color: var(--ink);
}
h2 { font-family: var(--font-head); font-weight: 600; font-size: 24px; margin: 14px 0 6px; color: var(--ink); }
.subtitle { color: var(--ink-dim); margin-bottom: 18px; font-weight: 600; }

.field { display: block; margin-bottom: 18px; }
.field span { display: block; font-weight: 800; font-size: 14px; margin-bottom: 6px; color: var(--ink-dim); }
.field input {
  width: 100%;
  padding: 14px 16px;
  background: var(--card-soft);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink);
  outline: none;
  /* слегка вдавленный clay-инпут */
  box-shadow: var(--clay-pressed);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input::placeholder { color: #9db4bd; font-weight: 600; }
.field input:focus { border-color: var(--sea); box-shadow: var(--clay-pressed), 0 0 0 4px rgba(15, 182, 166, 0.2); }

/* ================= КНОПКИ ================= */
.btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.3px;
  padding: 14px 22px;
  border-radius: var(--radius-md);
  color: #fff;
  transition: transform 0.18s var(--bounce), box-shadow 0.2s, filter 0.2s, background 0.2s;
}
.btn:hover { transform: translateY(-2px) scale(1.015); }
.btn:active { transform: scale(0.96); }              /* clay-squish */
.btn:focus-visible { outline: 3px solid var(--sea); outline-offset: 2px; }
.btn.primary {
  background: linear-gradient(135deg, var(--coral), var(--coral-2) 55%, var(--sun));
  width: 100%;
  box-shadow: var(--shadow-cta);
  text-shadow: 0 1px 2px rgba(120, 40, 10, 0.25);
}
.btn.primary:hover { box-shadow: 0 14px 30px rgba(255, 107, 74, 0.5); filter: saturate(1.08); }
.btn.secondary {
  background: var(--card);
  color: var(--sea);
  border: 2px solid rgba(15, 182, 166, 0.5);
  width: 100%;
  margin-top: 10px;
  box-shadow: var(--shadow-sm);
}
.btn.secondary:hover { background: rgba(15, 182, 166, 0.08); border-color: var(--sea); }
.btn.ghost {
  background: transparent;
  color: var(--ink-dim);
  border: 2px solid var(--line);
  margin-top: 16px;
}
.btn.ghost:hover { color: var(--ink); border-color: rgba(20, 58, 74, 0.3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; filter: saturate(0.6); }
.btn:disabled:active, .btn:disabled:hover { transform: none; }

/* ВХОД */
.auth-block { margin-bottom: 18px; }
.auth-block.hidden { display: none; }
.auth-block .auth-hint { margin-top: 8px; }
.btn.google { background: var(--card); color: #2b3a42; border: 2px solid var(--line); width: 100%; text-shadow: none; box-shadow: var(--shadow-sm); }
.btn.google:hover { background: #fff8ee; }
.btn.google.hidden, #btn-dev-login.hidden { display: none; }
#btn-dev-login { margin-top: 8px; }

/* Telegram Login Widget — кнопку рисует сам Telegram (iframe), центрируем её */
.tg-login { display: flex; justify-content: center; margin-top: 10px; }
.tg-login.hidden { display: none; }

/* ================= ПРОФИЛЬ ================= */
.profile {
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.profile.hidden { display: none; }
.prof-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-dim);
  margin-bottom: 8px;
}
.prof-row b { color: var(--gold); }
.xp-bar { height: 12px; border-radius: 999px; background: rgba(20, 58, 74, 0.1); overflow: hidden; }
#xp-fill {
  height: 100%; width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sea), var(--sun));
  transition: width 0.3s;
}
.prof-xp { font-size: 12px; color: var(--ink-dim); margin-top: 4px; font-weight: 700; }
.prof-ref {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap; margin-top: 10px;
  font-size: 13px; font-weight: 800; color: var(--ink-dim);
}
.prof-ref b { color: var(--ink); }

/* ================= ТАБЛИЦА ЛИДЕРОВ ================= */
/* ================= ТЕКУЩИЕ ИГРЫ (live-матчи) ================= */
.live-games h3 {
  font-family: var(--font-head); font-weight: 600; font-size: 16px;
  margin: 0 0 12px; color: var(--coral); letter-spacing: 0.2px;
  position: relative; display: inline-block;
}
.live-games h3::before {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 8px;
  border-radius: 50%; background: #ff5a3c; vertical-align: middle;
  box-shadow: 0 0 0 0 rgba(255, 90, 60, 0.55); animation: live-pulse 1.6s ease-out infinite;
}
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 90, 60, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(255, 90, 60, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 90, 60, 0); }
}
.live-rows { display: grid; gap: 6px; }
.live-row {
  display: grid; align-items: center; gap: 9px;
  grid-template-columns: 34px minmax(0, 1fr) auto minmax(0, 1fr) 34px;
  grid-template-areas: "la ln sc rn ra" "watch watch watch watch watch";
  padding: 8px 11px; border-radius: 15px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.34));
  border: 1px solid var(--line); box-shadow: var(--clay-sm);
}
.live-ava {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background-color: rgba(20, 58, 74, 0.06); background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  box-shadow: inset 0 0 0 1px rgba(20, 58, 74, 0.08);
}
.live-ava.bot { background-color: rgba(54, 197, 240, 0.12); }
.live-row > .live-ava:first-child { grid-area: la; }
.live-row > .live-ava:nth-of-type(2) { grid-area: ra; }
.live-name { min-width: 0; font-weight: 800; font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-name.left { grid-area: ln; }
.live-name.right { grid-area: rn; text-align: right; }
.live-score {
  grid-area: sc; flex: none; font-family: var(--font-head); font-weight: 700; font-size: 15px;
  color: var(--sea); font-variant-numeric: tabular-nums; padding: 2px 8px;
  border-radius: 999px; background: rgba(15, 182, 166, 0.12);
}
.live-watch {
  grid-area: watch; margin-top: 7px; text-align: center; text-decoration: none;
  font-family: var(--font-head); font-weight: 600; font-size: 13px; color: #fff;
  padding: 6px 12px; border-radius: 999px;
  background: linear-gradient(135deg, #ff8a5b, var(--coral));
  box-shadow: 0 4px 10px rgba(255, 107, 74, 0.32), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  transition: transform 0.16s var(--bounce), box-shadow 0.2s;
}
.live-watch:hover { transform: translateY(-2px); box-shadow: 0 7px 16px rgba(255, 107, 74, 0.4); }
.live-empty { font-size: 13px; color: var(--ink-dim); font-style: italic; padding: 8px 12px; }

.leaderboard { margin-top: 22px; border-top: 2px dashed var(--line); padding-top: 16px; }
.leaderboard h3, .controls-help h3 {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--sea);
}
/* радужный акцент под заголовком — задаёт тему «спектра уровней» */
.leaderboard h3 { position: relative; display: inline-block; margin-bottom: 16px; letter-spacing: 0.2px; }
.leaderboard h3::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg,
    hsl(0, 90%, 60%), hsl(45, 92%, 55%), hsl(120, 65%, 48%),
    hsl(190, 85%, 52%), hsl(265, 75%, 60%), hsl(300, 80%, 58%));
}

.lb-rows { display: grid; gap: 6px; }
.lb-row {
  --h: 0;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px 9px 9px; border-radius: 15px;
  font-size: 14px; font-weight: 700; color: var(--ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.34));
  border: 1px solid var(--line); box-shadow: var(--clay-sm);
  transition: transform 0.16s var(--bounce), box-shadow 0.2s;
}
.lb-row:hover { transform: translateY(-2px); box-shadow: var(--clay); }
.lb-row.me {
  background: linear-gradient(180deg, rgba(255, 107, 74, 0.16), rgba(255, 107, 74, 0.055));
  border-color: rgba(255, 107, 74, 0.55);
}

/* ранг-бейдж: топ-3 — металлик (золото/серебро/бронза), остальные — нейтральный чип */
.lb-place {
  flex: none; width: 28px; height: 28px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 700; font-size: 14px;
  color: var(--ink-dim); background: rgba(20, 58, 74, 0.06);
  font-variant-numeric: tabular-nums;
}
.lb-row.top .lb-place { color: #fff; text-shadow: 0 1px 2px rgba(60, 30, 0, 0.3); box-shadow: var(--clay-sm); }
.lb-row.top-1 .lb-place { background: linear-gradient(140deg, #ffe48a 0%, #f5b73a 55%, #e0922a 100%); }
.lb-row.top-2 .lb-place {
  background: linear-gradient(140deg, #f6f9fb 0%, #c6d2dd 55%, #a3b4c2 100%);
  color: #45596a; text-shadow: 0 1px 1px rgba(255, 255, 255, 0.55);
}
.lb-row.top-3 .lb-place { background: linear-gradient(140deg, #f6c08a 0%, #d98a45 55%, #b96a2c 100%); }

/* аватарка игрока — PNG-снимок персонажа (или 🏐, если снимок ещё не сохранён) */
.lb-ava {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  background-color: rgba(20, 58, 74, 0.06); background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  box-shadow: inset 0 0 0 1px rgba(20, 58, 74, 0.08);
}

.lb-name { flex: 1; min-width: 0; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* чип уровня — радужный градиент по --h (0°=красный … хвост до макс. уровня) */
.lb-level {
  flex: none; line-height: 1;
  font-family: var(--font-head); font-weight: 700; font-size: 12.5px;
  color: #fff; padding: 5px 11px; border-radius: 999px;
  background: linear-gradient(135deg, hsl(var(--h, 0), 92%, 60%), hsl(calc(var(--h, 0) + 22), 90%, 49%));
  box-shadow: 0 3px 8px hsla(var(--h, 0), 85%, 45%, 0.42), inset 0 1px 1px rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 1.5px rgba(40, 20, 0, 0.28);
}

/* рейтинг — тот же тон радуги, читаемая тёмная вариация */
.lb-rating {
  flex: none; min-width: 48px; text-align: right;
  font-family: var(--font-head); font-weight: 700; font-size: 16px;
  color: hsl(var(--h, 0), 62%, 42%); font-variant-numeric: tabular-nums;
}
.lb-empty { font-size: 13px; color: var(--ink-dim); font-style: italic; padding: 8px 12px; }

/* ================= УПРАВЛЕНИЕ (справка) ================= */
.controls-help { margin-top: 24px; border-top: 2px dashed var(--line); padding-top: 16px; }
.controls-help h3 { color: var(--ink-dim); }
.controls-help ul { list-style: none; display: grid; gap: 6px; }
.controls-help li { font-size: 14px; color: var(--ink-dim); font-weight: 600; }
.hint { margin-top: 12px; font-size: 13px; color: var(--ink-dim); font-weight: 600; }
kbd {
  background: var(--card); border: 1px solid var(--line); border-bottom-width: 3px;
  border-radius: 8px; padding: 2px 8px; font-family: inherit; font-size: 12px; font-weight: 800; color: var(--ink);
  box-shadow: var(--clay-sm);
}

/* ================= ВЫБОР СКИНОВ ================= */
.select-block { margin-bottom: 18px; }
.sel-label { display: block; font-weight: 800; font-size: 14px; margin: 10px 0 6px; color: var(--ink-dim); }
.sel-label b { color: var(--coral); }
/* аксессуары: компактные группы по слотам (очки/шапки/в зубы/за спиной) */
.sel-hint { font-weight: 400; font-size: 11px; color: var(--ink-dim); opacity: 0.8; }
.acc-groups { display: flex; flex-direction: column; gap: 10px; margin-top: 2px; }
.acc-cap { display: block; font-size: 12px; font-weight: 800; color: var(--sea); margin-bottom: 5px; }
.col-skins .thumb-grid.acc { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.thumb.acc-thumb { background-color: var(--card-soft); }
.thumb.acc-none {
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 900; color: #bca7a7; background-image: none;
}
.thumb.acc-none.on { color: var(--coral); background-color: #fff1ea; }
/* крупные тумбы: адаптивные ячейки ≥58px (раньше было 8 фиксированных мелких) */
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.thumb-grid.ball { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); max-width: none; }
.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  background: var(--card-soft) center/82% no-repeat;
  border: 2px solid var(--line);
  box-shadow: var(--clay-sm);
  cursor: pointer;
  transition: transform 0.18s var(--bounce), border-color 0.2s, box-shadow 0.2s;
}
.thumb:hover { transform: translateY(-3px) scale(1.04); border-color: var(--sea); box-shadow: var(--clay); }
.thumb:active { transform: scale(0.95); }
.thumb.on { border-color: var(--coral); box-shadow: 0 0 0 2.5px var(--coral) inset, var(--clay-sm); background-color: #fff1ea; }
.thumb.locked { cursor: not-allowed; filter: grayscale(1) opacity(0.5); }
.thumb.locked:hover { transform: none; border-color: var(--line); box-shadow: none; }
.thumb.locked .lock {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 16px; filter: none;
}
.thumb.buyable { cursor: pointer; filter: grayscale(0.5) opacity(0.82); }
.thumb.buyable:hover { transform: translateY(-2px); border-color: var(--gold); box-shadow: 0 6px 16px rgba(245, 166, 35, 0.4); filter: grayscale(0.1) opacity(1); }
.thumb.buyable .price {
  position: absolute; left: 0; right: 0; bottom: 0; text-align: center;
  font-size: 10px; font-weight: 900; color: #fff;
  background: linear-gradient(135deg, var(--gold), var(--coral-2));
  border-radius: 0 0 10px 10px; padding: 2px 0; filter: none;
}

/* бейджи (NEW / ХИТ / -% / лучшее) */
.badge {
  position: absolute; top: -7px; left: -6px; z-index: 2;
  font-family: var(--font-head); font-weight: 600;
  font-size: 9px; line-height: 1; letter-spacing: 0.3px;
  padding: 3px 6px; border-radius: 999px; color: #fff;
  box-shadow: var(--shadow-sm); pointer-events: none; white-space: nowrap;
}
.badge.new { background: linear-gradient(135deg, #17b6a6, #36c5f0); }
.badge.hot { background: linear-gradient(135deg, #ff5e62, #ff9966); }
.badge.sale { background: linear-gradient(135deg, #ff4d6d, #d6336c); }
.badge.best { background: linear-gradient(135deg, #8b5cf6, #36c5f0); }

/* ================= SPINNER ================= */
.spinner {
  width: 54px; height: 54px; margin: 0 auto 8px;
  border: 5px solid rgba(20, 58, 74, 0.12); border-top-color: var(--coral);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= ЛОББИ С ДРУГОМ ================= */
.lobby-block {
  margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--card-soft); padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.lobby-block.hidden { display: none; }
.lobby-block .lobby-hint { margin: 0 0 10px; }
.lobby-block .btn.ghost { margin-top: 10px; width: 100%; }
.lobby-status {
  margin: 12px 0 4px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--card-soft); box-shadow: var(--clay-pressed); padding: 6px 16px; text-align: left;
}
.lobby-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.lobby-row + .lobby-row { border-top: 1px dashed var(--line); }
.lobby-name { font-weight: 800; color: var(--ink); }
.lstate { font-weight: 800; font-size: 14px; color: var(--gold); }
.lstate.ready { color: #119c79; }
.lstate.wait { color: var(--ink-dim); font-style: italic; }
#btn-lobby-ready { margin-top: 12px; }

/* ================= ЛЕНДИНГ-СЕКЦИИ (SEO) ================= */
.landing { width: min(960px, 94vw); display: grid; gap: 18px; }
.land-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 28px;
}
.land-card h2 { margin-top: 0; }
.land-card p { color: var(--ink-dim); font-weight: 600; line-height: 1.5; }
.land-card p + p { margin-top: 10px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 6px; }
.feature { background: var(--card-soft); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px; box-shadow: var(--clay-sm); transition: transform 0.18s var(--bounce), box-shadow 0.2s; }
.feature:hover { transform: translateY(-3px); box-shadow: var(--clay); }
.feature .fi { font-size: 28px; }
.feature h3 { font-family: var(--font-head); font-weight: 600; font-size: 16px; margin: 6px 0 4px; color: var(--ink); }
.feature p { font-size: 13px; }
.faq-item { border-top: 1px dashed var(--line); padding: 12px 0; }
.faq-item:first-of-type { border-top: none; }
.faq-item h3 { font-family: var(--font-head); font-weight: 600; font-size: 16px; color: var(--ink); margin-bottom: 4px; }
.faq-item p { font-size: 14px; }
.site-footer { text-align: center; color: var(--ink-dim); font-size: 13px; font-weight: 600; padding: 6px 0 0; }
.site-footer a { color: var(--sea); text-decoration: none; }

/* социальное доказательство (живой онлайн) */
.social-proof {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: -4px 0 14px; font-size: 13px; font-weight: 800; color: #119c79;
}
.social-proof .live-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #19c37d;
  box-shadow: 0 0 0 0 rgba(25, 195, 125, 0.6); animation: livePulse 1.6s ease-out infinite;
}
@keyframes livePulse { 0% { box-shadow: 0 0 0 0 rgba(25,195,125,0.55); } 70% { box-shadow: 0 0 0 8px rgba(25,195,125,0); } 100% { box-shadow: 0 0 0 0 rgba(25,195,125,0); } }

/* ================= МАГАЗИН КРИСТАЛЛОВ ================= */
.shop-open-row { display: flex; gap: 10px; margin-top: 10px; }
.shop-open-row .btn { margin-top: 0; }
.shop-modal {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(17, 64, 83, 0.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  padding: 16px; overflow-y: auto;
}
.shop-modal.hidden { display: none; }
.shop-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; width: min(620px, 96vw);
  max-height: 92vh; overflow-y: auto; margin: auto; position: relative;
}
.shop-panel h2 { margin-top: 0; }
.shop-close {
  position: absolute; top: 14px; right: 16px; cursor: pointer; border: none; background: none;
  font-size: 26px; line-height: 1; color: var(--ink-dim); font-weight: 700;
}
.shop-sub { color: var(--ink-dim); font-weight: 700; margin-bottom: 14px; font-size: 14px; }

/* ---------- редактор посадки аксессуаров ---------- */
.acc-fit-btn { width: 100%; margin-top: 12px; }
.afit-slots { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.afit-slot {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 7px 12px; border-radius: 12px; font-weight: 700; font-size: 14px;
  background: var(--card-soft); border: 2px solid var(--line); color: var(--ink);
}
.afit-slot.on { border-color: var(--coral); background: rgba(255, 107, 74, 0.12); }
.afit-empty { color: var(--ink-dim); font-weight: 700; font-size: 14px; }
.afit-body { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.afit-canvas {
  width: 220px; height: 220px; flex: 0 0 auto; touch-action: none; cursor: grab;
  border-radius: 18px; background: var(--card-soft); border: 2px solid var(--line);
  box-shadow: var(--clay-pressed);
}
.afit-canvas:active { cursor: grabbing; }
.afit-controls { flex: 1 1 240px; display: flex; flex-direction: column; gap: 12px; }
.afit-row { display: grid; grid-template-columns: 72px 1fr 46px; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; color: var(--ink); }
.afit-row input[type="range"] { width: 100%; }
.afit-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 18px; }
.gem-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.gem-pack {
  position: relative; background: var(--card-soft); border: 2px solid var(--line);
  border-radius: var(--radius-md); padding: 16px 12px 14px; text-align: center;
  box-shadow: var(--clay-sm);
  cursor: pointer; transition: transform 0.18s var(--bounce), box-shadow 0.2s, border-color 0.2s;
}
.gem-pack:hover { transform: translateY(-4px) scale(1.03); box-shadow: var(--clay); border-color: var(--gem); }
.gem-pack:active { transform: scale(0.96); }
.gem-pack.popular { border-color: var(--coral); box-shadow: 0 0 0 2.5px rgba(255, 107, 74, 0.28), var(--clay); }
.gem-pack .gem-amount { font-family: var(--font-head); font-weight: 700; font-size: 26px; color: var(--ink); }
.gem-pack .gem-amount small { font-size: 15px; }
.gem-pack .gem-bonus { font-size: 12px; font-weight: 800; color: #119c79; min-height: 16px; }
.gem-pack .gem-buy {
  margin-top: 10px; display: inline-block; width: 100%;
  font-family: var(--font-head); font-weight: 600; font-size: 16px; color: #fff;
  background: linear-gradient(135deg, var(--coral), var(--sun)); border-radius: var(--radius-sm);
  padding: 9px 0; box-shadow: var(--shadow-cta);
}
.gem-pack .gem-old { font-size: 12px; color: var(--ink-dim); text-decoration: line-through; }
.shop-note { margin-top: 16px; font-size: 12px; color: var(--ink-dim); font-weight: 600; text-align: center; }

/* ================= ИГРА ================= */
#screen-game.active { position: fixed; inset: 0; z-index: 5; padding: 0; overflow: hidden; }
/* HUD: скошенные нейм-плейты по бокам (акцент-цвет стороны + индикатор подачи),
   крупный счёт — отдельной стеклянной плашкой сверху по центру */
#hud { position: absolute; top: 0; left: 0; right: 0; z-index: 6; pointer-events: none; }

/* центральное табло счёта */
.hud-score {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.18); border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 4px 22px; border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(17, 64, 83, 0.2);
  backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
}
.pscore {
  font-family: var(--font-head); font-weight: 700; font-size: 40px; line-height: 1;
  min-width: 38px; text-align: center; font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 6px rgba(255, 255, 255, 0.4);
}
.pscore.left { color: var(--coral); }
.pscore.right { color: var(--sea); }
.pscore.bump { animation: hudBump 0.36s var(--bounce); }
.hud-colon { font-family: var(--font-head); font-weight: 700; font-size: 26px; color: var(--ink-dim); transform: translateY(-3px); }

/* боковые скошенные нейм-плейты (стекло + клин внутреннего края) */
.hud-side {
  position: absolute; top: 54px; display: flex; align-items: center; gap: 9px;
  max-width: 252px; padding: 8px 16px;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 8px 22px rgba(17, 64, 83, 0.18);
  backdrop-filter: blur(13px) saturate(1.25); -webkit-backdrop-filter: blur(13px) saturate(1.25);
}
.hud-side::before { content: ''; position: absolute; top: 0; bottom: 0; width: 4px; }
.hud-side.left {
  left: 0; padding-left: 18px; padding-right: 26px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 18px) 100%, 0 100%);
}
.hud-side.left::before { left: 0; background: var(--coral); box-shadow: 0 0 12px 1px rgba(255, 107, 74, 0.85); }
.hud-side.right {
  right: 0; flex-direction: row-reverse; padding-right: 18px; padding-left: 26px;
  clip-path: polygon(18px 0, 100% 0, 100% 100%, 0 100%);
}
.hud-side.right::before { right: 0; background: var(--sea); box-shadow: 0 0 12px 1px rgba(15, 182, 166, 0.85); }

.hud-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hud-side.right .hud-info { align-items: flex-end; text-align: right; }
.hud-serve {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: rgba(20, 58, 74, 0.18); transition: background 0.25s, box-shadow 0.25s;
}
.hud-side.left.serving .hud-serve { background: var(--coral); box-shadow: 0 0 10px 2px rgba(255, 107, 74, 0.9); animation: servePulse 1.1s ease-in-out infinite; }
.hud-side.right.serving .hud-serve { background: var(--sea); box-shadow: 0 0 10px 2px rgba(15, 182, 166, 0.9); animation: servePulse 1.1s ease-in-out infinite; }

.pname {
  font-weight: 800; font-size: 15px; color: var(--ink);
  max-width: 178px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.55);
}
.prating { font-size: 12px; font-weight: 700; color: var(--ink-dim); white-space: nowrap; text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5); }
.prating:empty { display: none; }

@keyframes hudBump { 0% { transform: scale(1); } 38% { transform: scale(1.42); } 100% { transform: scale(1); } }
@keyframes servePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ПК (мышь): боковые нейм-плейты с никами крупнее ~в 1.5 раза */
@media (hover: hover) and (pointer: fine) {
  .hud-side { max-width: 372px; padding: 12px 24px; gap: 13px; }
  .hud-side::before { width: 6px; }
  .hud-side.left  { padding-left: 26px; padding-right: 38px; clip-path: polygon(0 0, 100% 0, calc(100% - 26px) 100%, 0 100%); }
  .hud-side.right { padding-right: 26px; padding-left: 38px; clip-path: polygon(26px 0, 100% 0, 100% 100%, 0 100%); }
  .hud-serve { width: 13px; height: 13px; }
  .pname { font-size: 22px; max-width: 264px; }
  .prating { font-size: 18px; }
}

/* на узких экранах нейм-плейты компактнее */
@media (max-width: 600px) {
  .hud-side { max-width: 150px; padding: 6px 12px; top: 48px; }
  .hud-side.left { padding-right: 20px; }
  .hud-side.right { padding-left: 20px; }
  .pname { font-size: 13px; max-width: 104px; }
  .prating { font-size: 11px; }
  .pscore { font-size: 31px; min-width: 27px; }
  .hud-colon { font-size: 22px; }
}

#canvas-wrap { position: relative; width: min(100vw, 177.71vh); aspect-ratio: 1706 / 960; overflow: hidden; }
#game-canvas { width: 100%; height: 100%; display: block; }

/* БАННЕР РАЗМИНКИ */
.search-banner {
  position: absolute; top: 84px; left: 50%; transform: translateX(-50%); z-index: 8;
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.2); border: 1px solid rgba(255, 255, 255, 0.45); color: var(--ink);
  padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 800;
  box-shadow: 0 6px 20px rgba(17, 64, 83, 0.14); white-space: nowrap;
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
}
.search-banner.hidden { display: none; }
.search-banner .sb-ai { display: flex; align-items: center; gap: 6px; }
.search-banner .sb-ai.hidden { display: none; }
.search-banner .sb-ai-label { font-size: 13px; color: var(--ink-dim); }
.search-banner .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--coral); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.btn-mini {
  border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--coral), var(--coral-2));
  color: #fff; font-family: var(--font-head); font-weight: 600; font-size: 12px;
  padding: 6px 13px; border-radius: 999px; box-shadow: var(--clay-sm);
  transition: box-shadow 0.2s, filter 0.2s, transform 0.18s var(--bounce);
}
.btn-mini:hover { box-shadow: var(--shadow-cta); filter: saturate(1.1); transform: translateY(-1px); }
.btn-mini:active { transform: scale(0.94); }

/* ================= СЕНСОРНОЕ УПРАВЛЕНИЕ ================= */
#touch-controls.hidden { display: none; }
.touch-btn {
  position: fixed; transform: translate(-50%, -50%); z-index: 7;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: rgba(255, 255, 255, 0.32); border: 3px solid rgba(255, 255, 255, 0.85);
  color: #fff; font-weight: 900; text-shadow: 0 1px 4px rgba(17, 64, 83, 0.5);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.touch-btn.pressed { background: rgba(255, 107, 74, 0.55); border-color: var(--coral); }
.touch-btn .tb-label { display: none; pointer-events: none; font-size: 12px; }
#touch-controls.editing .tb-label { display: block; }
#touch-controls.editing .touch-btn { border-style: dashed; border-color: var(--sun); background: rgba(255, 192, 46, 0.25); }
#touch-controls.editing .touch-btn.sel { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(255, 107, 74, 0.55); }

/* РЕЖИМ «ПАЛЕЦ»: невидимый слой во весь экран, ловит палец везде (и вне поля) */
#touch-follow { position: fixed; inset: 0; z-index: 7; touch-action: none; }
#touch-follow.hidden { display: none; }

/* РЕЖИМ «ДЖОЙСТИК»: слой во весь экран; база и стик рисуются под пальцем */
#touch-joystick { position: fixed; inset: 0; z-index: 7; touch-action: none; }
#touch-joystick.hidden { display: none; }
.joy-base, .joy-stick {
  position: fixed; border-radius: 50%; transform: translate(-50%, -50%);
  pointer-events: none; display: none;
}
#touch-joystick.active .joy-base, #touch-joystick.active .joy-stick { display: block; }
.joy-base {
  width: 116px; height: 116px;
  background: rgba(255, 255, 255, 0.14); border: 3px solid rgba(255, 255, 255, 0.5);
}
.joy-stick {
  width: 60px; height: 60px;
  background: rgba(255, 107, 74, 0.5); border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 14px rgba(17, 64, 83, 0.35);
}

/* ЗОНЫ ЭКРАНА */
#touch-zones.hidden { display: none; }
.tzone {
  position: fixed; z-index: 7; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; padding-bottom: 12vh; gap: 4px;
  border: 1px dashed rgba(255, 255, 255, 0.35);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.tzone[data-zone="left"]  { left: 0;   top: 0;   width: 25%; height: 100%; }
.tzone[data-zone="right"] { left: 25%; top: 0;   width: 25%; height: 100%; }
.tzone[data-zone="jump"]  { left: 50%; top: 0;   width: 50%; height: 55%; justify-content: center; padding-bottom: 0; }
.tzone[data-zone="down"]  { left: 50%; top: 55%; width: 50%; height: 45%; }
.tzone.pressed { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.6); }
.tzone .tz-main { font-size: 30px; color: #fff; opacity: 0.45; pointer-events: none; text-shadow: 0 1px 4px rgba(17,64,83,0.5); }
.tzone .tz-sub { font-size: 12px; font-weight: 800; color: #fff; opacity: 0.4; pointer-events: none; text-align: center; text-shadow: 0 1px 3px rgba(17,64,83,0.5); }

/* ================= ОВЕРЛЕИ В ИГРЕ ================= */
.overlay {
  position: absolute; inset: 0; z-index: 8;
  display: flex; align-items: center; justify-content: center;
  background: rgba(17, 64, 83, 0.45); color: var(--ink); text-align: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.overlay.hidden { display: none; }
#overlay-content {
  display: grid; gap: 16px; justify-items: center;
  background: rgba(255, 253, 248, 0.55); border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(17, 64, 83, 0.25);
  backdrop-filter: blur(20px) saturate(1.3); -webkit-backdrop-filter: blur(20px) saturate(1.3);
  padding: 28px 34px; min-width: min(360px, 86vw);
}
.big-count {
  font-family: var(--font-head); font-weight: 700; font-size: 96px; color: var(--coral);
  background: rgba(255, 255, 255, 0.22); border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%; width: 150px; height: 150px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 34px rgba(17, 64, 83, 0.22);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  text-shadow: 0 2px 6px rgba(255, 255, 255, 0.4);
}
.result-title { font-family: var(--font-head); font-weight: 700; font-size: 44px; color: var(--coral); }
.result-sub { font-size: 18px; font-weight: 700; color: var(--ink-dim); }
.result-progress { font-size: 16px; font-weight: 800; color: var(--sea); }
.result-progress:empty { display: none; }
.result-progress .lvl-up { color: var(--gold); font-size: 20px; }

/* ================= VS-ЗАСТАВКА (старт матча: соло-выход по очереди) ================= */
.vs-intro {
  position: absolute; inset: 0; z-index: 20; pointer-events: none; overflow: hidden;
  opacity: 1; transition: opacity 0.45s ease;
  /* диагональный раскол: коралл слева, бирюза справа, поверх размытого поля + виньетка */
  background:
    linear-gradient(112deg,
      rgba(255, 107, 74, 0.3) 0%, rgba(255, 138, 61, 0.12) 47%,
      rgba(15, 182, 166, 0.12) 53%, rgba(15, 182, 166, 0.3) 100%),
    radial-gradient(120% 120% at 50% 50%, transparent 48%, rgba(17, 64, 83, 0.55) 100%);
  backdrop-filter: blur(8px) brightness(0.9); -webkit-backdrop-filter: blur(8px) brightness(0.9);
}
.vs-intro.hidden { display: none; }
.vs-intro.vs-out { opacity: 0; }

/* боец абсолютный, центрирован; стартует за краем экрана и влетает в центр (соло),
   затем уезжает на свою сторону (side). Морфинг — через transition left/transform */
.vs-fighter {
  position: absolute; top: 50%; left: 50%; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  width: min(46vw, 380px);
  transform: translate(-50%, -50%) scale(0.8); opacity: 0;
  will-change: left, transform, opacity, filter;
  transition:
    left 0.55s cubic-bezier(0.2, 1.25, 0.3, 1),
    transform 0.55s cubic-bezier(0.2, 1.25, 0.3, 1),
    opacity 0.4s ease, filter 0.4s ease;
}
.vs-fighter.left  { left: -45%; }
.vs-fighter.right { left: 145%; }
.vs-fighter.solo  { left: 50%; opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
.vs-fighter.left.side  { left: 25%; opacity: 1; transform: translate(-50%, -50%) scale(0.88); filter: brightness(0.82) saturate(0.9); }
.vs-fighter.right.side { left: 75%; opacity: 1; transform: translate(-50%, -50%) scale(0.88); filter: brightness(0.82) saturate(0.9); }

.vs-portrait-wrap {
  width: min(38vh, 300px); height: min(38vh, 300px);
  display: flex; align-items: flex-end; justify-content: center;
}
.vs-fighter.left  .vs-portrait-wrap { filter: drop-shadow(0 14px 22px rgba(17, 64, 83, 0.5)) drop-shadow(0 0 30px rgba(255, 107, 74, 0.55)); }
.vs-fighter.right .vs-portrait-wrap { filter: drop-shadow(0 14px 22px rgba(17, 64, 83, 0.5)) drop-shadow(0 0 30px rgba(15, 182, 166, 0.55)); }
.vs-portrait {
  width: 100%; height: 100%;
  background-repeat: no-repeat; background-position: center bottom; background-size: contain;
}
.vs-fighter.right .vs-portrait { transform: scaleX(-1); } /* боец справа смотрит влево */

/* нейм-плейт со «штампом» (ник + рейтинг/уровень), акцент-цвет стороны */
.vs-card {
  text-align: center; max-width: min(60vw, 380px);
  background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.5);
  border-top-width: 3px; border-radius: var(--radius-md); padding: 8px 22px;
  box-shadow: 0 8px 24px rgba(17, 64, 83, 0.28);
  backdrop-filter: blur(12px) saturate(1.3); -webkit-backdrop-filter: blur(12px) saturate(1.3);
}
.vs-fighter.left  .vs-card { border-top-color: var(--coral); }
.vs-fighter.right .vs-card { border-top-color: var(--sea); }
.vs-card.stamp { animation: vsStamp 0.5s cubic-bezier(0.2, 1.5, 0.35, 1) both; }
.vs-name {
  font-family: var(--font-head); font-weight: 700; font-size: clamp(22px, 3.4vw, 36px);
  color: #fff; line-height: 1.1; max-width: min(54vw, 360px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-shadow: 0 2px 10px rgba(17, 64, 83, 0.7);
}
.vs-meta {
  font-weight: 800; font-size: clamp(13px, 1.7vw, 18px); color: #fffdf8; margin-top: 2px;
  text-shadow: 0 1px 6px rgba(17, 64, 83, 0.7);
}
.vs-meta:empty { display: none; }

/* лучи-спидлайны за VS (появляются на схлёсте) */
.vs-rays {
  position: absolute; left: 50%; top: 50%; width: 160vmax; height: 160vmax;
  margin: -80vmax 0 0 -80vmax; z-index: 1; opacity: 0; pointer-events: none;
  background: repeating-conic-gradient(from 0deg at 50% 50%,
    rgba(255, 255, 255, 0) 0deg, rgba(255, 255, 255, 0.1) 2deg,
    rgba(255, 255, 255, 0) 4deg, rgba(255, 255, 255, 0) 8deg);
  -webkit-mask: radial-gradient(circle at 50% 50%, #000 0, transparent 58%);
  mask: radial-gradient(circle at 50% 50%, #000 0, transparent 58%);
}
.vs-intro.clash .vs-rays { animation: vsRays 1.1s ease-out forwards; }

/* VS-бейдж */
.vs-badge {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(6); opacity: 0; z-index: 3;
  font-family: var(--font-head); font-weight: 700; font-size: clamp(80px, 15vw, 168px);
  line-height: 1; pointer-events: none;
}
.vs-badge span {
  display: block;
  background: linear-gradient(135deg, #fff 0%, var(--sand) 45%, var(--coral) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 rgba(17, 64, 83, 0.4)) drop-shadow(0 0 30px rgba(255, 107, 74, 0.7));
}
.vs-badge.in { animation: vsBadgePop 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) forwards; }

/* белая вспышка удара на схлёсте */
.vs-flash {
  position: absolute; inset: 0; z-index: 4; opacity: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, #fff 0%, rgba(255, 255, 255, 0.6) 35%, transparent 70%);
}
.vs-flash.on { animation: vsFlash 0.45s ease-out both; }

/* тряска контейнера на ударах */
.vs-intro.shake { animation: vsShake 0.3s ease; }
.vs-intro.shake-big { animation: vsShake 0.5s ease; }

@keyframes vsStamp {
  0%   { transform: scale(1.6) translateY(-14px); opacity: 0; filter: blur(4px); }
  60%  { transform: scale(0.94) translateY(0); opacity: 1; filter: blur(0); }
  80%  { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes vsBadgePop {
  0%   { transform: translate(-50%, -50%) scale(6); opacity: 0; filter: blur(10px); }
  55%  { transform: translate(-50%, -50%) scale(0.86); opacity: 1; filter: blur(0); }
  72%  { transform: translate(-50%, -50%) scale(1.18); }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@keyframes vsFlash {
  0% { opacity: 0; } 18% { opacity: 0.85; } 100% { opacity: 0; }
}
@keyframes vsRays {
  0%   { opacity: 0; transform: rotate(0deg) scale(0.6); }
  22%  { opacity: 0.7; }
  100% { opacity: 0; transform: rotate(26deg) scale(1); }
}
@keyframes vsShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-8px, 6px); }
  40% { transform: translate(9px, -7px); }
  60% { transform: translate(-7px, 8px); }
  80% { transform: translate(6px, -5px); }
}
@media (prefers-reduced-motion: reduce) {
  .vs-fighter { transition: opacity 0.3s ease; }
  .vs-fighter.left { left: 25%; opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  .vs-fighter.right { left: 75%; opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  .vs-fighter.solo, .vs-fighter.side { opacity: 1; }
  .vs-card.stamp { animation: none; }
  .vs-badge { transform: translate(-50%, -50%) scale(1); }
  .vs-badge.in { animation: none; opacity: 1; }
  .vs-intro.shake, .vs-intro.shake-big { animation: none; }
  .vs-intro.clash .vs-rays { animation: none; opacity: 0; }
  .vs-flash.on { animation: none; }
}
.overlay .btn.primary { width: auto; padding: 13px 30px; }

/* отсчёт без карточки-плашки */
#overlay-content:has(.big-count) { background: none; border: none; box-shadow: none; padding: 0; }

/* ================= ИНСТРУКЦИЯ ПО ЗОНАМ ================= */
.touch-gear {
  /* ниже карточки правого игрока (top 46-50 + ~46 высоты) */
  position: fixed; top: 104px; right: 12px; z-index: 8;
  width: 44px; height: 44px; border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 50%;
  cursor: pointer; color: var(--ink); font-size: 22px;
  background: rgba(255, 255, 255, 0.2); box-shadow: 0 6px 18px rgba(17, 64, 83, 0.16);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
}
.touch-gear.hidden { display: none; }
/* панель настройки тач-управления — компактная карточка вверху по центру */
.touch-edit-panel {
  position: fixed; top: 92px; left: 50%; transform: translateX(-50%); z-index: 9;
  display: flex; flex-direction: column; gap: 12px;
  width: min(330px, 94vw); color: var(--ink);
  background: rgba(255, 255, 255, 0.62); border: 1px solid rgba(255, 255, 255, 0.6);
  padding: 14px 16px 16px; border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(17, 64, 83, 0.26);
  backdrop-filter: blur(20px) saturate(1.3); -webkit-backdrop-filter: blur(20px) saturate(1.3);
}
.touch-edit-panel.hidden { display: none; }
.te-head { display: flex; align-items: center; justify-content: space-between; }
.te-title { font-family: var(--font-head); font-weight: 700; font-size: 17px; }
.te-x {
  border: none; cursor: pointer; width: 32px; height: 32px; border-radius: 50%;
  background: rgba(20, 58, 74, 0.08); color: var(--ink-dim); font-size: 21px; line-height: 1;
}
.te-x:active { background: rgba(20, 58, 74, 0.16); }
.te-section { display: flex; flex-direction: column; gap: 8px; }
.te-section.hidden { display: none; }
.te-cap { font-size: 11px; font-weight: 800; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.te-hint { font-size: 13px; font-weight: 700; color: var(--ink-dim); line-height: 1.35; }
/* сегмент-выбор способа управления */
.te-seg { display: flex; flex-wrap: wrap; gap: 5px; background: rgba(20, 58, 74, 0.07); padding: 4px; border-radius: 14px; }
.te-seg-btn {
  flex: 1 1 calc(50% - 3px); border: none; cursor: pointer; padding: 12px 4px; border-radius: 11px;
  background: transparent; color: var(--ink-dim);
  font-family: var(--font-head); font-weight: 600; font-size: 14px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.te-seg-btn.on { background: #fff; color: var(--coral); box-shadow: 0 3px 10px rgba(17, 64, 83, 0.16); }
/* размер выбранной кнопки */
.te-size { display: flex; align-items: center; gap: 10px; }
.te-size .te-cap { flex: 1; }
.te-round {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 26px; font-weight: 700; line-height: 1; cursor: pointer;
  box-shadow: var(--clay-sm); transition: transform 0.12s;
}
.te-round:active { transform: scale(0.9); }
.te-link {
  align-self: flex-start; border: none; background: none; cursor: pointer; padding: 0;
  color: var(--sea); font-weight: 800; font-size: 14px; text-decoration: underline;
}
.te-actions { display: flex; gap: 10px; }
.te-actions .btn { flex: 1; width: auto; margin: 0; padding: 13px; font-size: 15px; }
.btn-mini.on { box-shadow: 0 0 0 2px var(--sea); }
.btn-mini.warn { background: linear-gradient(135deg, #ff4d6d, #d6336c); }
.btn-mini.warn:hover { box-shadow: 0 6px 16px rgba(255, 77, 109, 0.5); }

.touch-help {
  position: fixed; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center;
  background: rgba(17, 64, 83, 0.5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); padding: 16px;
}
.touch-help.hidden { display: none; }
.touch-help-panel {
  background: rgba(255, 253, 248, 0.62); border: 1px solid rgba(255, 255, 255, 0.55); border-radius: var(--radius);
  box-shadow: 0 16px 44px rgba(17, 64, 83, 0.28); padding: 22px 24px; width: min(520px, 92vw); max-height: 86vh; overflow-y: auto; font-size: 14px;
  backdrop-filter: blur(22px) saturate(1.3); -webkit-backdrop-filter: blur(22px) saturate(1.3);
}
.touch-help-panel h3 { font-family: var(--font-head); font-weight: 600; font-size: 18px; margin-bottom: 10px; color: var(--sea); }
.touch-help-panel p { margin: 10px 0 4px; color: var(--ink-dim); font-weight: 700; }
.touch-help-panel ul { list-style: none; display: grid; gap: 5px; }
.touch-help-panel li { color: var(--ink); font-weight: 600; }
.touch-help-panel li b { color: var(--coral); }
.touch-help-panel .btn.primary { width: 100%; margin-top: 14px; }

/* ================= CLAY POP-IN МОДАЛОК ================= */
@keyframes clayPop {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.shop-panel, .touch-help-panel { animation: clayPop 0.26s var(--bounce) both; }
#overlay-content:not(:has(.big-count)) { animation: clayPop 0.26s var(--bounce) both; }

/* ================= ДОСТУПНОСТЬ ================= */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.6s; }
  .search-banner .dot, .social-proof .live-dot { animation: none; opacity: 1; }
  .btn, .btn-mini, .thumb, #xp-fill, .gem-pack { transition: none; }
  .btn:hover, .btn:active, .btn-mini:active, .thumb:hover, .thumb:active, .gem-pack:hover, .gem-pack:active { transform: none; }
  .shop-panel, .touch-help-panel, #overlay-content { animation: none; }
}
