* {
  box-sizing: border-box;
}

:root {
  --bg: #040816;
  --bg-2: #071326;
  --panel: #0d1728;
  --panel-soft: #13223a;
  --panel-border: rgba(127, 176, 255, 0.2);
  --text: #f8fbff;
  --muted: #b4c0d4;
  --muted-soft: #7f8ca3;
  --accent: #3b82f6;
  --accent-2: #67e8f9;
  --accent-3: #c9a85d;
  --success: #4ade80;
  --shadow: rgba(0, 0, 0, 0.48);
}

html {
  background: var(--bg);
  overscroll-behavior: none;
  /* Always reserve the scrollbar gutter so pages with/without a vertical
     scrollbar (e.g. long region page vs short cart) keep the same content
     width. Otherwise the centered fixed bottom nav shifts left/right when
     switching between them on desktop (classic scrollbars). */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  overflow-x: hidden;
  overscroll-behavior: none;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% -4%, rgba(59, 130, 246, 0.22), transparent 32%),
    radial-gradient(circle at 88% 6%, rgba(103, 232, 249, 0.11), transparent 28%),
    radial-gradient(circle at 50% 105%, rgba(201, 168, 93, 0.08), transparent 34%),
    linear-gradient(180deg, #050a18, #040816 58%, #030610);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
}

.app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  /* Top padding includes Telegram safe-area insets (0 when not fullscreen),
     so content always clears the iOS status bar + Telegram header buttons. */
  padding:
    calc(18px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px))
    14px 32px;
}

/* MAIN MENU */

.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(103, 232, 249, 0.22);
  border-radius: 32px;
  padding: 32px 18px 30px;
  margin-bottom: 24px;
  text-align: center;
  background:
    radial-gradient(circle at 88% 0%, rgba(103, 232, 249, 0.18), transparent 26%),
    linear-gradient(145deg, rgba(35, 62, 112, 0.92), rgba(11, 20, 36, 0.96) 62%),
    #0d1728;
  box-shadow:
    0 22px 70px var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.hero::before {
  content: "";
  position: absolute;
  inset: -92px -82px auto auto;
  width: 210px;
  height: 210px;
  border-radius: 999px;
  background: rgba(103, 232, 249, 0.14);
  filter: blur(1px);
}

.hero::after {
  content: "";
  position: absolute;
  left: 44px;
  right: 44px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201, 168, 93, 0.55), transparent);
}

.hero-title {
  position: relative;
  margin: 0 0 10px;
  color: var(--text);
  font-size: 30px;
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: -0.9px;
  text-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}

.hero-title::after {
  content: "";
  display: block;
  width: 118px;
  height: 3px;
  margin: 12px auto 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
}

.hero-subtitle {
  position: relative;
  max-width: 390px;
  margin: 0 auto;
  color: #dce6f7;
  font-size: 14px;
  line-height: 1.45;
}

/* Анимацию появления УБРАЛИ: она проигрывалась заново при каждой перерисовке/клоне
   карточки и пересборке карусели → читалось как мерцание при загрузке. Элементы
   появляются сразу, без повторного fade. */
.hero-slide-img {
  opacity: 1;
}
.parser-game-card {
  opacity: 1;
}

/* На F5-восстановлении прячем #app, пока полки не наполнятся, — показываем страницу
   уже готовой (см. render() → ps-restoring). Фон приложения (body::before) остаётся
   виден, экран не белый. visibility сохраняет раскладку, поэтому замеры не ломаются. */
#app.ps-restoring {
  visibility: hidden;
}

/* TIM ▶ PLAY rebrand hero */
.hero--rebrand {
  padding: 0;
  min-height: 0;
  aspect-ratio: 1618 / 822;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 20px;
}

.hero--rebrand::before,
.hero--rebrand::after {
  display: none;
}

.hero-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left center;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
}

.hero-rebrand-overlay {
  display: none;
}

.hero-rebrand-content {
  position: absolute;
  left: 52%;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  text-align: left;
}

.hero-brand-logo {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  font-size: 34px;
  font-weight: 300;
  letter-spacing: 5px;
  color: #fff;
  line-height: 1;
}

.hero-brand-play-icon {
  display: inline-block;
  width: 22px;
  height: 26px;
  flex-shrink: 0;
  background: linear-gradient(160deg, var(--accent-2) 0%, var(--accent) 100%);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.hero-brand-line {
  height: 3px;
  width: 110px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent) 60%, transparent);
  margin: 10px auto 10px 0;
  box-shadow: 0 0 10px rgba(103,232,249,0.4);
}

.hero--rebrand .hero-subtitle {
  margin: 0;
  font-size: 12px;
  text-align: left;
  max-width: none;
  color: rgba(220,230,244,0.9);
}

@media (max-width: 430px) {
  .hero--rebrand {
    min-height: 0;
  }

  .hero-rebrand-content {
    left: 51%;
    right: 12px;
  }

  .hero-brand-logo {
    font-size: 26px;
    letter-spacing: 3px;
    gap: 8px;
  }

  .hero-brand-play-icon {
    width: 17px;
    height: 21px;
  }

  .hero-brand-line {
    width: 95px;
    margin: 9px auto 9px 0;
  }

  .hero--rebrand .hero-subtitle {
    font-size: 13px;
  }
}

.section {
  margin-top: 24px;
  transform: translate3d(0, 0, 0);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: #b9c8e6;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.9px;
  text-transform: uppercase;
}

.section-title::before {
  content: "";
  width: 4px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.85);
}

.cards {
  display: grid;
  gap: 12px;
}

.card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 16px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0)),
    rgba(13, 23, 40, 0.94);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow:
    0 14px 38px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.035);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.card:active {
  transform: scale(0.985);
  border-color: rgba(103, 232, 249, 0.62);
  background: rgba(18, 34, 58, 0.98);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.26);
}

.card-icon {
  position: relative;
  min-width: 58px;
  height: 58px;
  border-radius: 19px;
  background:
    linear-gradient(145deg, rgba(59, 130, 246, 0.32), rgba(103, 232, 249, 0.13)),
    #162642;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e7fbff;
  font-size: 25px;
  font-weight: 900;
  line-height: 1;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    0 12px 26px rgba(0, 0, 0, 0.22);
}

.card-icon span {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(1px);
}

.card-icon::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 45%);
  pointer-events: none;
}

.card-icon-turkey {
  background:
    radial-gradient(circle at 34% 35%, rgba(255, 255, 255, 0.26), transparent 18%),
    linear-gradient(145deg, #d9252e, #8b121b);
}

.card-icon-cis {
  background:
    radial-gradient(circle at 50% 35%, rgba(103, 232, 249, 0.32), transparent 24%),
    linear-gradient(145deg, #255d9f, #14284d);
  font-size: 23px;
}

.card-icon-india {
  background:
    linear-gradient(180deg, #f7a93b 0 33%, #ffffff 33% 66%, #168850 66% 100%);
  color: #1c3b7a;
}

.card-icon-roblox {
  background:
    linear-gradient(145deg, #e7f0ff, #94b9ff 45%, #3155a4);
  color: #0d1728;
  font-size: 34px;
}

.card-icon-appstore {
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.62), transparent 18%),
    linear-gradient(145deg, #6ee7ff, #3b82f6 58%, #172554);
  font-size: 27px;
}

.card-content {
  min-width: 0;
  flex: 1;
}

.card-title {
  margin: 0 0 4px;
  font-size: 21px;
  line-height: 1.12;
  font-weight: 900;
  letter-spacing: -0.35px;
}

.card-description {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.card-arrow {
  color: var(--accent-2);
  font-size: 28px;
  line-height: 1;
  font-weight: 400;
  text-shadow: 0 0 14px rgba(103, 232, 249, 0.45);
}

.benefits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.benefit {
  border: 1px solid rgba(103, 232, 249, 0.18);
  border-radius: 999px;
  padding: 9px 12px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)),
    rgba(13, 23, 40, 0.9);
  color: #dce6f7;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
}

/* REGION PAGE */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.back-button {
  min-width: 88px;
  border: 1px solid rgba(103, 232, 249, 0.18);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(13, 23, 40, 0.92);
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.back-button:active {
  transform: scale(0.98);
}

.page-title {
  margin: 0;
  color: var(--text);
  font-size: 26px;
  line-height: 1.1;
  font-weight: 900;
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

/* HERO CAROUSEL */

.region-hero {
  margin: 8px -14px 24px;
}

.hero-track {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0 14px 12px;
  scrollbar-width: none;
}

.hero-track::-webkit-scrollbar {
  display: none;
}

.hero-slide {
  position: relative;
  min-width: 86%;
  height: 260px;
  scroll-snap-align: center;
  overflow: hidden;
  border: 1px solid rgba(103, 232, 249, 0.32);
  border-radius: 26px;
  background:
    radial-gradient(circle at 30% 20%, rgba(103, 232, 249, 0.22), transparent 24%),
    linear-gradient(135deg, rgba(59, 130, 246, 0.38), rgba(18, 18, 28, 0.96)),
    #101827;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}

.hero-slide::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.72)),
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.05) 0,
      rgba(255, 255, 255, 0.05) 1px,
      transparent 1px,
      transparent 14px
    );
}

.hero-slide-content {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 2;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 10px;
  margin-bottom: 10px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #ffffff;
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.region-hero-title {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.1;
  font-weight: 900;
}

.region-hero-subtitle {
  margin: 0;
  color: #e7eefc;
  font-size: 14px;
  line-height: 1.35;
}

.hero-slide--image {
  padding: 0;
  background: #0b0b18;
}

.hero-slide--image::before {
  display: none;
}

.hero-slide-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 26px;
  pointer-events: none;
}

.hero-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: -4px;
}

.hero-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.hero-dot.is-active {
  width: 20px;
  background: var(--accent-2);
}

/* HORIZONTAL SHELVES */

.shelf {
  margin: 26px -14px 0;
}

.shelf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  margin-bottom: 12px;
}

.shelf-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  font-size: 22px;
  line-height: 1.15;
  font-weight: 900;
}

.shelf-title::before {
  content: "";
  width: 4px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 18px rgba(59, 130, 246, 0.8);
}

.shelf-more {
  border: 0;
  background: transparent;
  color: var(--accent-2);
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
}

.shelf-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0 14px 4px;
  scrollbar-width: none;
}

.shelf-row::-webkit-scrollbar {
  display: none;
}

.game-card {
  min-width: 148px;
  width: 148px;
  scroll-snap-align: start;
  cursor: pointer;
}

.game-card:active {
  transform: scale(0.985);
}

.game-cover {
  position: relative;
  height: 214px;
  overflow: hidden;
  border: 1px solid rgba(103, 232, 249, 0.24);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 25%, rgba(103, 232, 249, 0.18), transparent 24%),
    linear-gradient(145deg, #263b66, #101827 62%);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.25);
}

.game-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.34)),
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.05) 0,
      rgba(255, 255, 255, 0.05) 1px,
      transparent 1px,
      transparent 16px
    );
}

.game-cover-text {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  color: #ffffff;
  text-align: center;
  font-size: 22px;
  line-height: 1.05;
  font-weight: 900;
  text-transform: uppercase;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
}

.game-cover-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  border-radius: 8px;
  padding: 5px 7px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #ffffff;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.game-price {
  margin: 10px 0 4px;
  color: var(--text);
  font-size: 17px;
  line-height: 1.1;
  font-weight: 900;
}

.game-name {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.22;
  font-weight: 800;
}

.game-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 5px 8px;
  margin-top: 8px;
  background: rgba(103, 232, 249, 0.1);
  color: #d9f8ff;
  font-size: 11px;
  font-weight: 800;
}

.game-meta {
  margin: 8px 0 0;
  color: var(--muted-soft);
  font-size: 12px;
  line-height: 1.35;
}

/* SUBSCRIPTIONS */

.subscriptions {
  margin-top: 28px;
}

.sub-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: rgba(13, 23, 40, 0.95);
  margin-bottom: 12px;
}

.sub-tab {
  border: 0;
  padding: 14px 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.sub-tab.is-active {
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #ffffff;
}

.sub-list {
  display: grid;
  gap: 10px;
}

.sub-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 14px;
  background: rgba(13, 23, 40, 0.92);
}

.sub-title {
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
  font-weight: 900;
}

.sub-meta {
  margin-top: 4px;
  color: var(--muted-soft);
  font-size: 13px;
}

.sub-price {
  color: var(--accent-2);
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
}

/* SIMPLE PRODUCT ROWS / FALLBACK */

.offer-card {
  border: 1px solid rgba(103, 232, 249, 0.24);
  border-radius: 22px;
  padding: 18px;
  margin-bottom: 12px;
  background:
    linear-gradient(135deg, rgba(59, 130, 246, 0.16), rgba(103, 232, 249, 0.04)),
    var(--panel);
}

.offer-title {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 19px;
  line-height: 1.2;
  font-weight: 900;
}

.offer-description {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.product-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 10px;
  background: rgba(13, 23, 40, 0.92);
}

.product-title {
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
  font-weight: 800;
}

.product-meta {
  margin-top: 4px;
  color: var(--muted-soft);
  font-size: 13px;
  line-height: 1.25;
}

.product-price {
  color: var(--accent-2);
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
}

/* STATES */

.loading,
.error {
  padding: 20px;
  color: #cfcfcf;
  text-align: center;
}

.error {
  color: #ff8c8c;
}

@media (max-width: 380px) {
  .app {
    padding-left: 12px;
    padding-right: 12px;
  }

  .hero-title {
    font-size: 27px;
  }

  .hero-subtitle {
    font-size: 13px;
  }

  .page-title {
    font-size: 23px;
  }

  .hero-slide {
    height: 236px;
  }

  .game-card {
    min-width: 136px;
    width: 136px;
  }

  .game-cover {
    height: 198px;
  }
}

/* Убираем ВСЕ верхние кнопки «Назад» (над главной картинкой) во всех разделах и
   деталях, во всех регионах. Возврат остаётся только через нижнее меню
   (.region-nav-back). JS не трогаем — кнопки просто скрыты. */
.parsed-section-back,
.game-detail-back,
.subscription-detail-back {
  display: none !important;
}
