* { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }
html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  background: #0a0612;
  font-family: "Patrick Hand", "Pangolin", "Comic Sans MS", sans-serif;
  color: #e8d4ff;
}
#wrap {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#hud {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  z-index: 2;
  text-shadow: 2px 2px 0 #1a0a2e, -1px -1px 0 #000;
  padding: 0 8px;
}
#hud .time {
  font-family: "Caveat", "Pangolin", sans-serif;
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.05em;
}
#hud .hint {
  font-size: 0.95rem;
  opacity: 0.75;
  margin-top: 4px;
}
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 4, 18, 0.72);
  z-index: 80;
  padding: 24px max(24px, env(safe-area-inset-right)) 24px max(24px, env(safe-area-inset-left));
  pointer-events: auto;
}
#overlay.hidden { display: none; }
.panel {
  max-width: 420px;
  max-height: min(92vh, 720px);
  overflow-y: auto;
  border: 3px solid #c9a0ff;
  border-radius: 8px;
  padding: 28px 24px;
  background: #120a1e;
  box-shadow: 6px 6px 0 #4a2a6a, inset 0 0 40px rgba(80, 40, 120, 0.15);
  text-align: center;
}
.panel-view:not(.panel-hidden) {
  animation: panel-pop 0.18s ease-out;
}
@keyframes panel-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.panel h1 {
  font-family: "Caveat", "Pangolin", sans-serif;
  font-size: 2.2rem;
  margin-bottom: 12px;
  color: #ff9ecd;
  line-height: 1.1;
}
.panel p {
  font-size: 1.1rem;
  line-height: 1.45;
  margin-bottom: 10px;
  color: #dcc8f0;
}
.panel .btn {
  margin-top: 18px;
  font-family: inherit;
  font-size: 1.35rem;
  padding: 12px 28px;
  border: 3px solid #7cf5c6;
  background: #1e3d32;
  color: #b8ffe8;
  cursor: pointer;
  border-radius: 6px;
  box-shadow: 4px 4px 0 #2a6a55;
  min-height: 48px;
}
.panel .btn:hover {
  background: #2a5244;
}
.panel .btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #2a6a55;
}
.record { color: #ffd080; font-size: 1rem; margin-top: 8px; }
.mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 14px 0 4px;
}
.mode-switch .mode-chip {
  margin-top: 0;
  padding: 8px 14px;
  font-size: 1.05rem;
  min-height: 42px;
  box-shadow: 3px 3px 0 #2a4a5a;
}
.mode-switch .mode-chip.mode-chip--active {
  border-color: #ffe8a0 !important;
  color: #fff8d0 !important;
  background: #2a4860 !important;
  box-shadow: 2px 2px 0 #1a3050 !important;
}
body.mountain-active #multiplayerOpenBtn,
body.mountain-active #rewardAdBtn,
body.defense-active #multiplayerOpenBtn,
body.defense-active #rewardAdBtn {
  display: none !important;
}
body.mountain-active #bulletDensityRow,
body.defense-active #bulletDensityRow {
  display: none !important;
}
body.defense-active #mobileJoystick {
  display: none !important;
}
/**
 * Клики должны попадать в #overlay и модалки, а не в канвас «под ними» (wrap часто fullscreen).
 * Для canvas это нужно задать отдельно: дети могут оставаться target при pointer-events:none у родителя.
 */
body:not(.game-playing) #wrap,
body:not(.game-playing) #wrap canvas {
  pointer-events: none !important;
}
body.game-playing #wrap,
body.game-playing #wrap canvas {
  pointer-events: auto;
}
.yandex-profile {
  color: #9cf8d4;
  font-size: 0.98rem;
  margin: 8px 0 0;
}
.settings-title {
  font-family: "Caveat", "Pangolin", sans-serif;
  font-size: 1.35rem;
  color: #c9a0ff;
  margin-bottom: 10px;
  text-align: center;
}
.overlay-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(960px, 100%);
}

.overlay-wallet-line {
  font-size: 1.05rem;
  color: #ffd080;
  text-shadow: 2px 2px 0 #1a0a2e, -1px -1px 0 #000;
  margin: 0;
  text-align: center;
}

.panel-view.panel-hidden {
  display: none !important;
}

.panel.menu-panel-wide {
  max-width: 420px;
  width: 100%;
  position: relative;
}

.panel.shop-panel-full {
  max-width: min(940px, 96vw);
  width: 100%;
  overscroll-behavior-y: contain;
}

.shop-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.shop-back-btn {
  margin-top: 0 !important;
  padding: 8px 16px;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.shop-panel-heading {
  font-family: "Caveat", "Pangolin", sans-serif;
  font-size: 1.5rem;
  color: #c9a0ff;
  margin: 0;
  flex: 1;
  text-align: center;
  min-width: 140px;
  font-weight: 700;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  align-items: stretch;
}

.menu-actions .btn {
  margin-top: 0;
}
.menu-start-btn {
  width: 100%;
  min-height: 52px !important;
  font-size: 1.42rem !important;
  border-color: #7cf5c6 !important;
  background: linear-gradient(180deg, #265a48, #1b3f34) !important;
  box-shadow: 4px 4px 0 #2a6a55 !important;
}
.menu-section {
  border: 2px solid rgba(201, 160, 255, 0.2);
  border-radius: 10px;
  padding: 9px;
  background: rgba(9, 5, 22, 0.38);
}
.menu-section__label {
  font-size: 0.78rem;
  line-height: 1;
  color: #a994d0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 8px;
  text-align: left;
}
.menu-grid {
  display: grid;
  gap: 8px;
}
.menu-grid--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.menu-grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.menu-tile.btn {
  min-height: 42px !important;
  padding: 8px 8px !important;
  font-size: 1rem !important;
  border-width: 2px !important;
  border-radius: 8px !important;
  box-shadow: 3px 3px 0 #4a2a6a !important;
}
@media (max-width: 360px) {
  .menu-grid--three {
    grid-template-columns: 1fr;
  }
}

.multiplayer-panel {
  max-width: min(520px, 96vw);
  width: 100%;
}

.multiplayer-note,
.multiplayer-help {
  white-space: pre-line;
}

.multiplayer-help {
  font-size: 0.92rem !important;
  opacity: 0.75;
  margin-top: 16px;
}

.multiplayer-capacity,
.multiplayer-actions,
.multiplayer-join {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 14px;
}

.multiplayer-capacity label {
  border: 2px solid rgba(201, 160, 255, 0.45);
  border-radius: 8px;
  padding: 8px 12px;
  background: rgba(42, 32, 64, 0.7);
  cursor: pointer;
}

.multiplayer-join input {
  min-width: 150px;
  flex: 1;
  font: inherit;
  font-size: 1.15rem;
  text-transform: uppercase;
  color: #e8d4ff;
  background: #090612;
  border: 2px solid rgba(201, 160, 255, 0.55);
  border-radius: 6px;
  padding: 10px 12px;
  outline: none;
}

.multiplayer-room,
.multiplayer-results {
  margin-top: 16px;
  padding: 12px;
  border: 2px dashed rgba(124, 245, 198, 0.55);
  border-radius: 8px;
  background: rgba(20, 42, 36, 0.45);
  text-align: left;
  white-space: pre-line;
}

.multiplayer-results {
  border-color: rgba(255, 208, 128, 0.62);
  background: rgba(64, 42, 20, 0.42);
}

.settings-anchor {
  pointer-events: auto;
}

.settings-anchor--panel {
  position: absolute;
  z-index: 2;
  top: 8px;
  right: 8px;
}

.settings-anchor--panel .settings-fab {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.settings-fab {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 14px;
  border: 2px solid rgba(201, 160, 255, 0.65);
  background: rgba(18, 10, 30, 0.92);
  color: #ecc8ff;
  cursor: pointer;
  box-shadow:
    3px 3px 0 rgba(74, 42, 106, 0.85),
    inset 0 0 22px rgba(120, 70, 180, 0.12);
  font-family: inherit;
  transition: transform 0.08s ease, background 0.15s ease;
}

.settings-fab:hover {
  background: rgba(34, 22, 52, 0.96);
}

.settings-fab:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(74, 42, 106, 0.85);
}

.settings-fab__glyph {
  font-size: 1.35rem;
  line-height: 1;
  display: block;
  margin-top: -2px;
}

.settings-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: min(260px, calc(100vw - 24px));
  padding: 12px 12px 14px;
  border-radius: 12px;
  border: 2px solid rgba(201, 160, 255, 0.55);
  background: rgba(14, 8, 24, 0.96);
  box-shadow:
    5px 5px 0 rgba(52, 28, 82, 0.55),
    inset 0 0 36px rgba(90, 50, 140, 0.12);
}

.settings-popover__title {
  font-family: "Caveat", "Pangolin", sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: #ff9ecd;
  margin: 0 0 10px;
  text-align: center;
}

.settings-popover__grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sound-toggle {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 8px 10px;
  min-height: 38px;
  border: 2px solid rgba(201, 160, 255, 0.6);
  border-radius: 6px;
  background: rgba(42, 32, 64, 0.9);
  color: #ecc8ff;
  cursor: pointer;
}

.sound-toggle:hover {
  background: rgba(58, 48, 80, 0.95);
}

.btn-secondary {
  border-color: #c9a0ff !important;
  background: #2a2040 !important;
  color: #ecc8ff !important;
  box-shadow: 4px 4px 0 #4a2a6a !important;
}

.btn-secondary:hover {
  background: #3a3050 !important;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 10px;
  max-height: min(62vh, 560px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 2px 10px;
  -webkit-overflow-scrolling: touch;
  text-align: center;
}

.shop-browse-tablist {
  margin: 0 auto 12px;
  max-width: 440px;
}

.shop-browse-pane {
  padding-top: 2px;
}

.shop-iap-mount {
  overflow-x: auto;
  overflow-y: visible;
  max-height: none;
  padding-bottom: 14px;
  -webkit-overflow-scrolling: touch;
}

.shop-grid.shop-grid--iap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
  justify-content: center;
  justify-items: stretch;
  align-content: start;
  /* Наследуется от .shop-grid — иначе донат-вкладка остаётся в прокручиваемой «колонке» монетного грида */
  max-height: none;
  overflow-x: visible;
  overflow-y: visible;
}

/* Если в DOM только одна карточка Троицы (без VIP-ряда) — узкая колонка по центру */
.shop-grid.shop-grid--iap > .shop-card.shop-card--trinity {
  justify-self: center;
  width: min(232px, 100%);
}

.shop-iap-mini-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(200px, 232px));
  gap: 10px;
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
  justify-content: center;
  align-items: stretch;
}

.shop-iap-mini-row > .shop-card.shop-card--trinity {
  align-self: stretch;
  width: 100%;
  max-width: 232px;
  min-width: 0;
  height: 100%;
  min-height: 0;
}

/* VIP / Троица: блок «Скилл» прижимаем к нижнему краю строки одинаковой высоты */
.shop-iap-mini-row > .shop-card--trinity:not(.shop-card--iap-stub) .shop-card__skill {
  margin-top: auto;
}

.shop-iap-mini-row > .shop-card--iap-stub .shop-card__cta {
  margin-top: auto;
}

@media (max-width: 740px) {
  .shop-iap-mini-row {
    grid-template-columns: repeat(3, minmax(168px, 232px));
    gap: 7px;
  }
}

/* Телефон: три колонки не влезают — карточки доната друг под другом */
@media (max-width: 560px) {
  .shop-iap-mini-row {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    gap: 10px;
  }
  .shop-iap-mini-row > .shop-card.shop-card--trinity {
    max-width: none;
    height: auto;
  }
  .shop-iap-mini-row .shop-card--trinity .shop-card__pic,
  .shop-iap-mini-row .shop-card--trinity .shop-card__pic-canvas,
  .shop-iap-mini-row .shop-card--trinity .shop-iap-stub-visual {
    width: min(100%, 160px);
    margin-inline: auto;
  }
}

.shop-card--iap-stub {
  border-style: dashed;
  border-color: rgba(150, 130, 200, 0.35);
  background: rgba(18, 12, 32, 0.88);
}

.shop-card--iap-stub .shop-iap-stub-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: 0.06em;
  color: rgba(200, 180, 255, 0.35);
  border-style: dashed;
  border-color: rgba(180, 160, 230, 0.28);
  background: linear-gradient(
    155deg,
    rgba(52, 40, 78, 0.45),
    rgba(28, 22, 48, 0.35)
  );
}

.shop-card--iap-stub .shop-card__price--stub {
  color: rgba(180, 170, 210, 0.75);
}

.shop-card.shop-card--trinity {
  contain: none;
  max-width: 100%;
  height: auto;
  min-height: 0;
  align-self: start;
}

/* Превью Троицы — фиксированная логическая высота (без height:100% у canvas), иначе в части окружений ломается цепочка % и полоса «на весь экран» */
.shop-card--trinity .shop-card__pic {
  width: min(138px, 88%);
  height: auto;
  aspect-ratio: 1;
  align-self: center;
  flex-shrink: 0;
}

.shop-card--trinity .shop-card__pic-canvas {
  width: 100%;
  height: auto;
  max-height: none;
}

/* Пустой CTA + margin-top:auto при растянутой карточке даёт гигантский зазор; у Троицы тянуть кнопки вниз не нужно */
.shop-card--trinity .shop-card__cta {
  margin-top: 0;
  min-height: 0;
}

.shop-card--trinity .shop-card__name {
  min-height: 0;
}

.shop-card__blurb {
  margin: 0;
  padding: 0;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.35;
  color: rgba(228, 210, 255, 0.9);
  text-align: center;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.shop-trinity-editor {
  width: 100%;
  margin: 4px 0 0;
  padding-top: 8px;
  border-top: 1px solid rgba(201, 160, 255, 0.22);
}

.shop-card__price--iap {
  font-size: 0.78rem;
  line-height: 1.32;
  text-align: center;
}

.shop-trinity-group-title {
  font-size: 0.93rem;
  font-weight: 700;
  color: #cfb8ff;
  margin-top: 12px;
  margin-bottom: 4px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.shop-trinity-slots > .shop-trinity-group-title:first-child {
  margin-top: 0;
}

.shop-trinity-slots {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0;
}

.shop-trinity-slot {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.shop-trinity-slot__lbl {
  font-size: 0.8rem;
  opacity: 0.82;
  text-align: left;
}

.shop-trinity-slot__select {
  font-family: inherit;
  font-size: 0.88rem;
  padding: 8px 10px;
  max-width: 100%;
  border-radius: 8px;
  border: 2px solid rgba(201, 160, 255, 0.45);
  background: #140e22;
  color: #ebd8ff;
}

.shop-trinity__live-save {
  font-size: 0.82rem;
  opacity: 0.75;
  margin: 0 0 4px;
  line-height: 1.35;
  color: #c4a8e8;
}

.shop-trinity-slot__select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.shop-trinity__offline {
  font-size: 0.82rem;
  opacity: 0.65;
  margin-top: 10px;
  line-height: 1.35;
}

.shop-trinity__dev-grant {
  margin-top: 8px;
}

.shop-card {
  border: 2px solid rgba(201, 160, 255, 0.35);
  border-radius: 10px;
  padding: 10px 8px;
  background: rgba(22, 14, 38, 0.92);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  isolation: isolate;
  contain: layout style;
}

.shop-card--equipped {
  border-color: rgba(255, 200, 120, 0.75);
  box-shadow: inset 0 0 14px rgba(255, 180, 80, 0.12);
}

.shop-card__pic {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: #1a1028;
  overflow: hidden;
}
.shop-card__pic-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  vertical-align: top;
}

.shop-card__name {
  font-size: 0.92rem;
  font-weight: 600;
  color: #e8d4ff;
  line-height: 1.22;
  min-height: 3.1em;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  text-align: center;
  padding-block: 2px 0;
}

.shop-card__tier {
  align-self: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.shop-card__tier--normal {
  color: #a8c0d8;
  background: rgba(80, 100, 120, 0.25);
  border-color: rgba(140, 170, 200, 0.35);
}
.shop-card__tier--rare {
  color: #7cfcff;
  background: rgba(40, 120, 180, 0.22);
  border-color: rgba(100, 220, 255, 0.42);
}
.shop-card__tier--epic {
  color: #c898ff;
  background: rgba(120, 60, 200, 0.22);
  border-color: rgba(200, 150, 255, 0.45);
}
.shop-card__tier--legendary {
  color: #ffd870;
  background: rgba(180, 120, 40, 0.25);
  border-color: rgba(255, 200, 100, 0.5);
}
.shop-card__tier--celestial {
  color: #b8f8ff;
  background: rgba(180, 220, 255, 0.12);
  border-color: rgba(200, 255, 255, 0.4);
  box-shadow: 0 0 10px rgba(160, 240, 255, 0.15);
}
.shop-card__tier--unique {
  color: #ff9ec8;
  background: rgba(200, 80, 140, 0.22);
  border-color: rgba(255, 150, 200, 0.45);
}
.shop-card__tier--divine {
  color: #fff8e0;
  background: linear-gradient(
    135deg,
    rgba(255, 215, 120, 0.25),
    rgba(220, 120, 255, 0.2)
  );
  border-color: rgba(255, 230, 180, 0.55);
  box-shadow: 0 0 12px rgba(255, 200, 120, 0.12);
}

.shop-card__price {
  font-size: 0.88rem;
  color: #ffd080;
  min-height: 1.35em;
}

.shop-card__owned {
  color: #9cf8d4;
}

.shop-card__skill {
  font-family: inherit;
  font-size: 0.82rem;
  padding: 6px 8px;
  border-radius: 6px;
  border: 2px dashed rgba(201, 160, 255, 0.55);
  background: rgba(40, 28, 65, 0.6);
  color: #e8c8ff;
  cursor: pointer;
  width: 100%;
}

.shop-card__skill:hover {
  background: rgba(60, 40, 90, 0.75);
}

.shop-card__cta {
  margin-top: auto;
}

.shop-card__cta-btn {
  width: 100%;
  min-height: 38px;
}

.shop-card__cta-done {
  font-size: 0.88rem;
  color: #ffd080;
  display: block;
  padding: 8px 2px;
}

.shop-btn.primary {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 10px;
  min-height: 40px;
  border-radius: 6px;
  border: 2px solid #7cf5c6;
  background: #1e3d32;
  color: #b8ffe8;
  cursor: pointer;
}

.shop-btn.primary:hover {
  background: #2a5244;
}

.shop-btn.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.skill-modal {
  position: fixed;
  inset: 0;
  z-index: 520;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.skill-modal.hidden {
  display: none !important;
}

.skill-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 2, 12, 0.78);
  cursor: pointer;
}

.skill-modal__dialog.panel {
  position: relative;
  z-index: 1;
  max-width: min(440px, 96vw);
  width: 100%;
  margin: 0;
  pointer-events: auto;
}

.skill-modal__title {
  font-family: "Caveat", "Pangolin", sans-serif;
  font-size: 1.65rem;
  color: #ff9ecd;
  margin: 0 0 8px;
  line-height: 1.15;
}

.skill-modal__badge {
  display: inline-block;
  font-size: 0.82rem;
  color: #c9a0ff;
  border: 2px solid rgba(201, 160, 255, 0.5);
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 12px;
}

.skill-modal__badge--tier.skill-modal__badge--normal {
  color: #a8d0f8;
  border-color: rgba(140, 180, 220, 0.45);
}
.skill-modal__badge--tier.skill-modal__badge--rare {
  color: #7cffee;
  border-color: rgba(100, 255, 238, 0.45);
}
.skill-modal__badge--tier.skill-modal__badge--epic {
  color: #d8a8ff;
  border-color: rgba(216, 180, 255, 0.5);
}
.skill-modal__badge--tier.skill-modal__badge--legendary {
  color: #ffd888;
  border-color: rgba(255, 200, 120, 0.55);
}
.skill-modal__badge--tier.skill-modal__badge--celestial {
  color: #d8ffff;
  border-color: rgba(200, 255, 255, 0.5);
  box-shadow: 0 0 14px rgba(180, 255, 255, 0.12);
}
.skill-modal__badge--tier.skill-modal__badge--unique {
  color: #ffacd8;
  border-color: rgba(255, 180, 220, 0.5);
}
.skill-modal__badge--tier.skill-modal__badge--divine {
  color: #fff8dc;
  border-color: rgba(255, 220, 170, 0.58);
  background: rgba(140, 80, 200, 0.12);
  box-shadow: 0 0 16px rgba(255, 200, 120, 0.1);
}

.skill-modal__text {
  font-size: 1.05rem;
  line-height: 1.45;
  color: #dcc8f0;
  white-space: pre-line;
  margin: 0 0 18px;
  text-align: left;
}

.skill-modal__text.skill-modal__text--shop-mode {
  margin-bottom: 0;
}

.skill-modal__shop-section {
  width: 100%;
  margin-bottom: 4px;
}

.skill-modal__tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
  width: 100%;
}

.skill-modal__tab {
  flex: 1;
  min-height: 44px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 8px 6px;
  border-radius: 8px;
  border: 2px solid rgba(201, 160, 255, 0.38);
  background: rgba(28, 18, 48, 0.88);
  color: #c8b8e8;
  cursor: pointer;
}

.skill-modal__tab--active {
  border-color: rgba(124, 245, 198, 0.55);
  color: #b8ffe8;
  background: rgba(24, 48, 40, 0.65);
  box-shadow: 0 0 12px rgba(124, 245, 198, 0.1);
}

.skill-modal__panel {
  width: 100%;
  box-sizing: border-box;
  max-height: min(52vh, 380px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 2px 4px;
  margin-bottom: 10px;
  border-radius: 8px;
  border: 1px solid rgba(201, 160, 255, 0.18);
  background: rgba(8, 4, 20, 0.35);
}

.skill-modal__passive {
  font-size: 0.9rem;
  line-height: 1.43;
  color: #bfb0e8;
  margin: 0 0 16px;
  white-space: pre-line;
  text-align: left;
}

.skill-modal__dialog .btn {
  margin-top: 0;
}

/* Экран «умение перед забегом» */
.pre-run-brief {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  background: rgba(6, 2, 14, 0.78);
  pointer-events: auto;
}
.pre-run-brief.hidden {
  display: none !important;
}
.pre-run-brief__inner.panel {
  max-width: min(440px, 96vw);
  width: 100%;
  padding: 22px 20px 26px;
  text-align: left;
}
.pre-run-brief__kicker {
  font-family: "Caveat", "Pangolin", sans-serif;
  font-size: 1.15rem;
  color: #a890d8;
  margin: 0 0 6px;
  letter-spacing: 0.06em;
}
.pre-run-brief__heading {
  font-family: "Caveat", "Pangolin", sans-serif;
  font-size: 2rem;
  color: #ff9ecd;
  margin: 0 0 8px;
  line-height: 1.1;
  text-align: center;
}
.pre-run-meta {
  font-size: 1.08rem;
  color: #e8cff8;
  margin: 0 0 6px;
  text-align: center;
}
.pre-run-badge {
  display: inline-block;
  width: 100%;
  text-align: center;
  margin: 8px 0 10px;
  font-size: 0.88rem;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid rgba(201, 160, 255, 0.4);
}
.pre-run-scroll {
  max-height: min(42vh, 320px);
  overflow-y: auto;
  overflow-x: hidden;
  border: 2px solid rgba(100, 60, 160, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(8, 4, 20, 0.55);
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}
.pre-run-text {
  font-size: 0.98rem;
  line-height: 1.4;
  color: #dcc8f0;
  white-space: pre-line;
  margin: 0;
}
.pre-run-note {
  font-size: 0.84rem;
  line-height: 1.38;
  color: #9888b8;
  margin: 0 0 8px;
  opacity: 0.95;
}
.pre-run-controls {
  font-size: 0.9rem;
  line-height: 1.38;
  color: #ffd080;
  margin: 0 0 16px;
  opacity: 0.92;
}
.pre-run-brief__inner .btn {
  width: 100%;
}

.mobile-joystick {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  z-index: 6;
  display: none;
  transform: translateX(-50%);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.mobile-joystick--active {
  display: block;
}

.mobile-joystick__ring {
  position: relative;
  width: 92px;
  height: 92px;
  border: 3px solid rgba(201, 160, 255, 0.78);
  border-radius: 50%;
  background: rgba(18, 10, 30, 0.5);
  box-shadow:
    0 0 18px rgba(201, 160, 255, 0.24),
    inset 0 0 24px rgba(80, 40, 120, 0.28);
}

.mobile-joystick__knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 38px;
  height: 38px;
  border: 2px solid rgba(236, 200, 255, 0.9);
  border-radius: 50%;
  background: rgba(42, 32, 64, 0.92);
  box-shadow:
    0 0 14px rgba(236, 200, 255, 0.28),
    inset 0 0 12px rgba(255, 158, 205, 0.18);
  transform: translate(-50%, -50%);
}

@media (hover: hover) and (pointer: fine) and (min-width: 801px) {
  .mobile-joystick--active {
    display: none;
  }
}

@media (max-width: 600px), (max-height: 720px) and (pointer: coarse) {
  #wrap {
    position: fixed;
    inset: 0;
    /* --vg-* задаёт JS из VisualViewport — убирает узкое окно после первого кадра из-за lvh/dvh рассинхрона в iframe браузера. */
    width: min(var(--vg-w, 100vw), calc(var(--vg-h, 100dvh) * 9 / 16));
    height: min(var(--vg-h, 100dvh), calc(var(--vg-w, 100vw) * 16 / 9));
    min-height: 0;
    margin: auto;
  }

  #overlay {
    align-items: flex-start;
    padding:
      max(12px, env(safe-area-inset-top, 0px))
      max(10px, env(safe-area-inset-right, 0px))
      max(12px, env(safe-area-inset-bottom, 0px))
      max(10px, env(safe-area-inset-left, 0px));
  }

  .overlay-stack {
    gap: 6px;
    width: min(100%, calc(var(--vg-h, 100dvh) * 9 / 16));
    min-height: 100%;
    justify-content: center;
  }

  .panel {
    max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    padding: 20px 18px;
    border-width: 2px;
    box-shadow: 4px 4px 0 #4a2a6a, inset 0 0 28px rgba(80, 40, 120, 0.15);
  }

  .panel h1 {
    font-size: clamp(1.75rem, 8vw, 2.15rem);
    margin-bottom: 8px;
  }

  .panel p {
    font-size: 1rem;
    line-height: 1.32;
    margin-bottom: 7px;
  }

  .panel .btn {
    font-size: 1.1rem;
    min-height: 44px;
    padding: 9px 18px;
  }

  .menu-actions {
    gap: 9px;
    margin-top: 12px;
  }

  .settings-anchor--panel {
    top: 7px;
    right: 7px;
  }

  .panel.shop-panel-full {
    max-width: calc(100vw - 20px);
    padding: 14px 12px;
  }

  .shop-panel-head {
    gap: 8px;
    margin-bottom: 10px;
  }

  .shop-panel-heading {
    flex-basis: 100%;
    order: 2;
    font-size: 1.35rem;
  }

  .shop-back-btn {
    order: 1;
    margin-right: auto;
    font-size: 0.95rem;
    min-height: 38px;
    padding: 6px 14px;
  }

  .shop-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-height: calc(100dvh - 150px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  .shop-card {
    gap: 6px;
    padding: 8px 6px;
  }

  .shop-card__name {
    font-size: 0.82rem;
    min-height: 2.9em;
  }

  .shop-card__skill,
  .shop-btn.primary {
    font-size: 0.78rem;
  }

  #hud {
    top: max(8px, env(safe-area-inset-top, 0px));
  }

  #hud .time {
    font-size: 1.65rem;
  }

  #hud .hint {
    font-size: 0.82rem;
    margin-top: 1px;
  }

  .mobile-joystick {
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }

  .mobile-joystick__ring {
    width: 82px;
    height: 82px;
  }

  .mobile-joystick__knob {
    width: 34px;
    height: 34px;
  }
}

body:not(.mountain-active) .mountain-only {
  display: none !important;
}
.obstacle-menu-extras {
  margin: 16px auto 14px;
  max-width: 420px;
  text-align: center;
  padding: 14px 12px 16px;
  border-radius: 10px;
  border: 2px solid rgba(201, 160, 255, 0.28);
  background: rgba(10, 6, 28, 0.45);
}
.obstacle-run-field__label {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #a898d0;
  margin: 0 0 8px;
}
.segmented {
  width: 100%;
}
.segmented.segmented--dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.segmented.segmented--triple {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
}
.segmented__btn {
  margin: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 12px 10px;
  min-height: 48px;
  border: 2px solid rgba(201, 160, 255, 0.45);
  background: rgba(36, 24, 58, 0.95);
  color: #e4d8f8;
  box-shadow: none;
}
.segmented__btn--first {
  border-radius: 10px 0 0 10px;
  border-right-width: 1px;
}
.segmented__btn--last {
  border-radius: 0 10px 10px 0;
  border-left-width: 1px;
}
.segmented__btn:hover {
  background: rgba(50, 36, 78, 0.98);
  color: #f8efff;
}
.segmented__btn.segmented__btn--active {
  border-color: #ffe8a0 !important;
  color: #fff8d0 !important;
  background: #2a4860 !important;
  box-shadow: inset 0 0 0 1px rgba(255, 232, 160, 0.25);
  z-index: 1;
}
.obstacle-ach-btn-full {
  width: 100%;
  margin-top: 14px !important;
  margin-bottom: 0 !important;
  font-size: 1rem !important;
}
.segmented.segmented--tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 14px;
}
/* Три пресета плотности Космоса — не использовать сетку на 4 колонки */
.segmented.segmented--tabs.segmented--density-triple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  justify-items: stretch;
}
@media (max-width: 360px) {
  .segmented.segmented--tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .segmented.segmented--tabs.segmented--density-triple {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.segmented-tab {
  margin: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 6px;
  min-height: 44px;
  border-radius: 8px;
  border: 2px solid rgba(201, 160, 255, 0.5);
  background: rgba(32, 20, 56, 0.92);
  color: #dcc8f0;
  transition: transform 0.06s ease, background 0.12s ease;
}
.segmented-tab:hover {
  background: rgba(46, 32, 72, 0.98);
}
.segmented-tab.segmented-tab--active {
  border-color: #ffe8a0 !important;
  color: #fff8d0 !important;
  background: #2a4860 !important;
  box-shadow: 2px 2px 0 #1a3050;
}

/* Магазин скинов: только «За монеты» / «Донат» — без сетки на 4 колонки от лидерборда */
#shopBrowseTablist.shop-browse-tablist.segmented.segmented--tabs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  max-width: min(440px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.mountain-lb-body {
  text-align: left;
  margin-top: 4px;
  min-height: 120px;
  max-height: min(48vh, 420px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 2px;
  border-radius: 10px;
  border: 1px solid rgba(124, 245, 198, 0.15);
  background: rgba(6, 4, 18, 0.35);
  -webkit-overflow-scrolling: touch;
}
.mountain-lb-msg {
  font-size: 1.02rem;
  line-height: 1.42;
  color: #cbb8e8;
  padding: 12px 10px;
  white-space: pre-line;
}
.mountain-lb-list {
  list-style: none;
  margin: 0;
  padding: 6px 4px;
}
.mountain-lb-row {
  font-size: 1.03rem;
  line-height: 1.42;
  color: #bfffe8;
  padding: 8px 10px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: rgba(18, 12, 40, 0.45);
}
.meta-weekly-event {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 208, 128, 0.28);
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 208, 128, 0.18), transparent 42%),
    rgba(64, 42, 16, 0.28);
  color: #ffdca0;
  text-align: left;
  line-height: 1.35;
  white-space: pre-line;
}

.meta-claim-all-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin-bottom: 2px;
  border-radius: 11px;
  border: 2px solid rgba(124, 245, 198, 0.35);
  background:
    linear-gradient(135deg, rgba(32, 72, 58, 0.42), rgba(14, 10, 36, 0.72)),
    rgba(18, 14, 40, 0.52);
  text-align: center;
}

.meta-claim-all-row__hint {
  margin: 0;
  width: 100%;
  max-width: 36rem;
  font-size: 0.9rem;
  line-height: 1.4;
  font-weight: 600;
  color: rgba(226, 246, 238, 0.95);
  text-align: center;
}

.meta-claim-all-row__btn {
  flex: 0 0 auto;
  width: 100%;
  max-width: 280px;
  min-height: 42px;
  font-weight: 700 !important;
}

.meta-claim-all-row__btn:disabled {
  opacity: 0.62;
  cursor: default;
}

.meta-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.meta-card {
  position: relative;
  padding: 11px 12px;
  border: 2px solid rgba(201, 160, 255, 0.26);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(46, 28, 82, 0.62), rgba(12, 8, 30, 0.78)),
    rgba(18, 12, 40, 0.48);
  overflow: hidden;
}
.meta-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(255,255,255,0.04), transparent 38%);
}
.meta-card--done {
  border-color: rgba(124, 245, 198, 0.38);
  background:
    linear-gradient(135deg, rgba(28, 70, 58, 0.52), rgba(12, 8, 30, 0.78)),
    rgba(18, 12, 40, 0.48);
}
.meta-card__icon {
  float: right;
  min-width: 34px;
  height: 34px;
  margin-left: 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff8d0;
  border: 1px solid rgba(255, 232, 160, 0.38);
  background: rgba(255, 232, 160, 0.1);
  font-weight: 700;
}
.meta-card__title {
  font-weight: 700;
  color: #fff0c8;
  margin-bottom: 4px;
}
.meta-card__body {
  color: #dcc8f0;
  line-height: 1.35;
  white-space: pre-line;
}
.meta-card__bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(8, 4, 20, 0.72);
  overflow: hidden;
  margin: 8px 0;
  border: 1px solid rgba(201, 160, 255, 0.22);
}
.meta-card__fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #7cf5c6, #ffe8a0);
}
.meta-card__btn {
  width: 100%;
  margin-top: 8px !important;
  font-size: 1rem !important;
  min-height: 42px !important;
}
.meta-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 2px solid rgba(255, 208, 128, 0.26);
  background:
    radial-gradient(circle at 16% 12%, rgba(255, 158, 205, 0.18), transparent 36%),
    linear-gradient(135deg, rgba(42, 32, 64, 0.9), rgba(10, 6, 24, 0.82));
}
.meta-hero__icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff8d0;
  border: 2px solid rgba(255, 232, 160, 0.5);
  background: rgba(255, 232, 160, 0.1);
  font-size: 1.35rem;
  flex-shrink: 0;
}
.meta-hero__title {
  color: #ff9ecd;
  font-family: "Caveat", "Pangolin", sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1;
}
.meta-hero__body {
  color: #dcc8f0;
  line-height: 1.25;
  margin-top: 4px;
}
.meta-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.meta-stat {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(124, 245, 198, 0.2);
  background: rgba(7, 28, 24, 0.34);
}
.meta-stat__value {
  color: #bfffe8;
  font-weight: 700;
  font-size: 1.08rem;
}
.meta-stat__label {
  color: #a994d0;
  font-size: 0.82rem;
  line-height: 1.15;
  margin-top: 2px;
}
body.quiet-mode #hud,
body.quiet-mode .panel {
  text-shadow: none;
}
body.color-preset-soft canvas,
body.color-preset-soft #overlay {
  filter: saturate(0.78) contrast(0.94);
}
body.color-preset-contrast canvas,
body.color-preset-contrast #overlay {
  filter: saturate(1.16) contrast(1.18) brightness(1.05);
}
body.color-preset-colorblind canvas,
body.color-preset-colorblind #overlay {
  filter: hue-rotate(24deg) saturate(0.9) contrast(1.12);
}
.mountain-run-stats {
  font-family: "Patrick Hand", "Pangolin", "Comic Sans MS", sans-serif;
  font-size: 0.98rem;
  line-height: 1.48;
  color: #b8f8e8;
  text-align: left;
  white-space: pre-wrap;
  margin: 10px 0 12px !important;
  padding: 12px 14px;
  opacity: 0.95;
  max-height: min(11rem, 32vh);
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid rgba(124, 245, 198, 0.22);
  background: rgba(6, 26, 22, 0.35);
}
.obstacle-tutorial {
  position: fixed;
  inset: 0;
  z-index: 530;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px max(20px, env(safe-area-inset-right))
    calc(28px + env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  pointer-events: auto;
}
.obstacle-tutorial.hidden {
  display: none !important;
}
.obstacle-tutorial__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 2, 10, 0.68);
}
.obstacle-tutorial__card.panel {
  position: relative;
  z-index: 1;
  max-width: min(440px, 96vw);
  margin: auto;
}
.obstacle-tutorial__title {
  font-family: "Caveat", "Pangolin", sans-serif;
  color: #9df5d8;
  font-size: 1.75rem;
  margin-bottom: 10px;
}
.obstacle-tutorial__body {
  text-align: left;
  margin-bottom: 16px !important;
  color: #e4d8f8;
}
.obstacle-tutorial__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.obstacle-tutorial__actions .btn {
  margin-top: 0 !important;
}

/* ─── Telegram Mini App: отступы под шапку/кнопки Telegram в fullscreen ─── */
.tg-app, .tg-app body { overscroll-behavior: none; }
.tg-app #hud {
  top: max(12px, calc(var(--tg-inset-top, 0px) + 6px));
}
.tg-app #overlay {
  padding-top: max(24px, calc(var(--tg-inset-top, 0px) + 12px));
  padding-bottom: max(24px, calc(var(--tg-inset-bottom, 0px) + 12px));
}

/* ─── Общая таблица лидеров (js/leaderboard.js) ─── */
.lb-panel .lb-tabs { margin-bottom: 10px; }
.lb-panel .lb-tabs--sub .segmented-tab {
  min-height: 38px;
  padding: 7px 4px;
  font-size: 0.82rem;
}
.lb-body {
  text-align: left;
  min-height: 140px;
  max-height: min(52vh, 460px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 2px;
  border-radius: 10px;
  border: 1px solid rgba(124, 245, 198, 0.15);
  background: rgba(6, 4, 18, 0.35);
  -webkit-overflow-scrolling: touch;
}
.lb-msg {
  font-size: 1.02rem;
  line-height: 1.42;
  color: #cbb8e8;
  padding: 16px 12px;
  text-align: center;
}
.lb-list {
  list-style: none;
  margin: 0;
  padding: 6px 4px;
}
.lb-row {
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  font-size: 1.02rem;
  line-height: 1.3;
  color: #e4d8f8;
  padding: 8px 10px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: rgba(18, 12, 40, 0.45);
}
.lb-rank {
  text-align: center;
  font-weight: 700;
  color: #a898d0;
}
.lb-row--top1 .lb-rank, .lb-row--top2 .lb-rank, .lb-row--top3 .lb-rank { font-size: 1.25rem; }
.lb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-score {
  font-weight: 700;
  color: #bfffe8;
  white-space: nowrap;
}
.lb-row--top1 { background: rgba(255, 208, 96, 0.14); }
.lb-row--top2 { background: rgba(200, 210, 230, 0.10); }
.lb-row--top3 { background: rgba(210, 140, 80, 0.12); }
.lb-row--me {
  outline: 2px solid #ffe8a0;
  outline-offset: -2px;
  color: #fff8d0;
}
.lb-foot {
  margin: 8px 6px 6px;
  font-size: 0.95rem;
  color: #a898d0;
  text-align: center;
}
.lb-foot--me { color: #ffe8a0; }
