/* Benefit мини-апп. Цвета бренда отдельно от themeParams Telegram, чтобы позже добавить светлую тему. */
:root {
  --bg: #0A0E1F;
  --bar: #0D1226;
  --surface: #131935;
  --surface-2: #1A2147;
  --line: #263061;
  --line-soft: #1E2650;
  --text: #F2F5FF;
  --text-2: #AEB8DC;
  --text-3: #8B95BD;
  --tile-text: #DCE2F7;
  --accent: #3FE0FF;
  --accent-ink: #06202A;
  --accent-soft: rgba(63, 224, 255, 0.12);
  --gold: #F5C451;
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --display: Unbounded, "Segoe UI", system-ui, sans-serif;
  --body: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.app { max-width: 480px; margin: 0 auto; min-height: var(--tg-viewport-stable-height, 100vh); position: relative; }
.screen { padding-bottom: calc(110px + var(--safe-bottom)); }

/* ---------- Верх ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 0; }
.profile { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; min-height: 44px; }
.avatar {
  width: 36px; height: 36px; border-radius: 18px; background: var(--surface-2); color: var(--accent);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  font-family: var(--display); font-size: 14px; font-weight: 600;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 15px; font-weight: 700; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--text-3); }
.topbar-right { display: flex; gap: 8px; }
.pill-btn, .round-btn {
  height: 44px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
.pill-btn { padding: 0 14px; font-size: 13px; font-weight: 700; }
.round-btn { width: 44px; padding: 0; }

.test-note {
  margin: 10px 16px 0; padding: 8px 12px; border-radius: 12px;
  background: rgba(245, 196, 81, 0.10); border: 1px solid rgba(245, 196, 81, 0.25); color: #F7D27A;
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600;
}

/* ---------- Баланс ---------- */
.balance { padding: 18px 20px 0; }
.balance-label { display: flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 500; color: var(--text-2); }
.eye-btn { width: 36px; height: 36px; background: none; border: 0; color: var(--text-2); display: flex; align-items: center; justify-content: center; padding: 0; }
.eye-btn.off { color: var(--text-3); }
.balance-amount { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; }
#balanceValue {
  font-family: var(--display); font-size: 44px; font-weight: 600; letter-spacing: -1.5px; line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.balance-cur { font-family: var(--display); font-size: 26px; font-weight: 500; color: var(--text-2); }
.balance-hint { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.star-gold { fill: var(--gold); }

/* ---------- Действия ---------- */
.actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 0 12px; margin-top: 20px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 8px; background: none; border: 0; padding: 0; font-size: 13px; font-weight: 600; }
.action-circle {
  width: 56px; height: 56px; border-radius: 28px; background: var(--surface); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; transition: transform .12s ease;
}
.action-circle.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.action:active .action-circle { transform: scale(0.94); }

/* ---------- Промо: листается только пальцем, край следующей карточки виден ---------- */
.promo { margin-top: 22px; }
.promo-track {
  display: flex; gap: 12px; overflow-x: auto; padding: 0 16px;
  scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.promo-track::-webkit-scrollbar { display: none; }
.promo-card {
  flex: 0 0 calc(100% - 56px); max-width: 360px; height: 164px; scroll-snap-align: start; scroll-margin-left: 16px;
  border-radius: 22px; background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden;
}
.promo-card-plain { background: #161C3D; }
.promo-img { position: absolute; top: -6px; right: -62px; width: 270px; height: 176px; object-fit: cover; }
.promo-img-steam { object-position: 30% 50%; right: -52px; }
.promo-fade {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--surface) 46%, rgba(19, 25, 53, 0.6) 66%, rgba(19, 25, 53, 0) 88%);
}
.promo-body { position: relative; padding: 18px 18px 0; display: flex; flex-direction: column; align-items: flex-start; }
.promo-title { margin: 0; font-family: var(--display); font-size: 21px; font-weight: 600; line-height: 1.15; }
.accent { color: var(--accent); }
.promo-pill {
  margin-top: 10px; padding: 5px 10px; border-radius: 999px; background: #173049; color: #BDF4FF;
  font-size: 12px; font-weight: 600; position: relative;
}
.promo-cta {
  margin-top: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; min-height: 34px;
  border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 700;
}
.dots { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
.dot { width: 6px; height: 6px; border-radius: 3px; background: #3A4475; transition: width .2s ease, background .2s ease; }
.dot.active { width: 18px; background: var(--accent); }

/* ---------- Каталог ---------- */
.catalog { padding: 0 16px; margin-top: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; }
.section-title { margin: 0; font-family: var(--display); font-size: 17px; font-weight: 600; }
.link-btn { display: flex; align-items: center; gap: 2px; min-height: 44px; background: none; border: 0; color: var(--accent); font-size: 13px; font-weight: 700; padding: 0; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 4px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 2px; background: none; border: 0;
  color: var(--tile-text); font-size: 12px; font-weight: 600; text-align: center; line-height: 1.2; border-radius: 16px;
}
.tile:active { background: var(--surface); }
.tile-icon { width: 50px; height: 50px; border-radius: 16px; display: flex; align-items: center; justify-content: center; }
.c-stars { background: rgba(245, 196, 81, 0.14); color: #F5C451; }
.c-premium { background: rgba(179, 157, 255, 0.14); color: #B39DFF; }
.c-steam { background: rgba(110, 197, 245, 0.14); color: #6EC5F5; }
.c-give { background: rgba(244, 143, 192, 0.14); color: #F48FC0; }
.c-keys { background: rgba(255, 162, 92, 0.14); color: #FFA25C; }
.c-esim { background: rgba(61, 219, 193, 0.14); color: #3DDBC1; }
.c-cards { background: rgba(111, 227, 154, 0.14); color: #6FE39A; }
.c-pay { background: var(--accent-soft); color: var(--accent); }

/* ---------- Нижнее меню ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 480px; z-index: 10;
  background: var(--bar); border-top: 1px solid var(--line-soft);
  padding: 8px 8px calc(10px + var(--safe-bottom));
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: start;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0 0; background: none; border: 0;
  color: var(--text-3); font-size: 11px; font-weight: 600; min-height: 44px;
}
.tab.active { color: var(--accent); font-weight: 700; }
.tab-qr { color: var(--tile-text); font-weight: 700; padding-top: 0; }
.qr-circle {
  width: 60px; height: 60px; border-radius: 30px; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; margin-top: -26px; border: 4px solid var(--bg);
  box-sizing: content-box;
}

/* ---------- Состояния и загрузка ---------- */
.state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 22vh 28px 40px; }
.state-icon {
  width: 64px; height: 64px; border-radius: 20px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.state-title { margin: 18px 0 0; font-family: var(--display); font-size: 20px; font-weight: 600; line-height: 1.25; }
.state-text { margin: 10px 0 0; font-size: 15px; line-height: 1.5; color: var(--text-2); max-width: 320px; }
.btn-primary {
  margin-top: 24px; min-height: 52px; padding: 0 28px; border-radius: 14px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-size: 16px; font-weight: 800;
}

.sk { background: var(--surface); border-radius: 18px; margin: 0 16px; animation: pulse 1.2s ease-in-out infinite; }
.sk-top { height: 44px; width: 140px; margin-top: 12px; border-radius: 22px; }
.sk-balance { height: 70px; width: 200px; margin-top: 24px; }
.sk-actions { height: 80px; margin-top: 20px; }
.sk-promo { height: 164px; margin-top: 22px; border-radius: 22px; }
.sk-grid { height: 200px; margin-top: 22px; }
@keyframes pulse { 50% { opacity: 0.55; } }

.toast {
  position: fixed; left: 50%; bottom: calc(108px + var(--safe-bottom)); transform: translate(-50%, 12px);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 14px; z-index: 20;
  background: #232B57; border: 1px solid #34407A; color: var(--text); font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
