/* ═══════════════════════════════════════════════════
   Snake Escape — Clean Dark UI  (v20260907d)
   ═══════════════════════════════════════════════════ */

/* ─── Design Tokens ─────────────────────────────── */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-head: 'Space Grotesk', var(--font);

  /* Surfaces */
  --bg:        #0a0e1a;
  --surface:   #111827;
  --surface-2: #1a2236;
  --surface-3: #1e2a40;
  --border:    rgba(255,255,255,0.08);
  --border-2:  rgba(255,255,255,0.14);

  /* Text */
  --t1: #f1f5f9;
  --t2: #94a3b8;
  --t3: #64748b;

  /* Brand */
  --green:     #22c55e;
  --green-dim: rgba(34,197,94,0.15);
  --green-bd:  rgba(34,197,94,0.3);
  --purple:    #a78bfa;
  --purple-dim:rgba(167,139,250,0.15);
  --gold:      #fbbf24;
  --gold-dim:  rgba(251,191,36,0.15);
  --gold-bd:   rgba(251,191,36,0.3);
  --pink:      #ec4899;
  --pink-dim:  rgba(236,72,153,0.12);
  --pink-bd:   rgba(236,72,153,0.3);
  --blue:      #38bdf8;
  --red:       #f87171;

  /* Nav & Safe Areas — JS overrides with summed Telegram insets after init */
  --nav-h: 64px;
  --tg-safe-top: calc(
    var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) +
    var(--tg-content-safe-area-inset-top, 0px)
  );
  --tg-safe-bottom: calc(
    var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) +
    var(--tg-content-safe-area-inset-bottom, 0px)
  );
}

/* Inside Telegram: guarantee clearance under Close / Back / ⋯ until SDK insets arrive */
html.tg-mini-app {
  --tg-safe-top: max(
    44px,
    calc(
      var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) +
      var(--tg-content-safe-area-inset-top, 0px)
    )
  );
}

/* ─── Reset ──────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: var(--app-height, 100%);
  min-height: var(--app-height, 100%);
  overflow: hidden;
  position: fixed;
  font-family: var(--font);
  background: var(--bg);
  color: var(--t1);
}

/* ─── App Root ───────────────────────────────────── */
#app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: var(--app-height, 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  padding: 0;
  contain: paint;
  box-sizing: border-box;
}

/* ─── TOP APP BAR ────────────────────────────────── */
.top-app-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  /* Leave room for Telegram Close / ⋯ / Back chrome */
  padding: calc(var(--tg-safe-top) + 8px) 12px 10px;
  flex-shrink: 0;
  background: var(--bg);
  position: relative;
  z-index: 30;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.2s, transform 0.2s;
  box-sizing: border-box;
  overflow: hidden;
}

#app.in-gameplay .top-app-bar {
  display: none !important;
}

/* User pill */
.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 50px;
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  transition: opacity .15s;
  flex-shrink: 0;
}
.user-pill:active { opacity: .75; }

.user-avatar-wrap {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.user-avatar { font-size: 16px; line-height: 1; }

.user-info-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.user-name {
  font-size: 12px; font-weight: 700;
  color: var(--t1);
  max-width: 72px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-rank-label {
  font-size: 9.5px; font-weight: 600;
  color: var(--t2);
}

/* Header stat pills */
.top-bar-stats {
  display: flex; align-items: center; gap: 5px;
  flex-shrink: 1; min-width: 0;
  overflow: hidden;
}

.hstat {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 11px; font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .15s;
  flex-shrink: 0;
}
.hstat:active { transform: scale(.94); }

.hstat-val { color: var(--t1); }
.hstat-icon { font-size: 12px; }

.cash-stat { border-color: var(--green-bd); background: var(--green-dim); }
.cash-stat .hstat-icon { color: var(--green); font-weight: 900; font-size: 13px; }
.cash-stat .hstat-val  { color: var(--green); }

.coin-stat  { border-color: var(--gold-bd); background: var(--gold-dim); }
.coin-stat .hstat-val  { color: var(--gold); }

.ticket-stat{ border-color: var(--pink-bd); background: var(--pink-dim); }
.ticket-stat .hstat-val { color: var(--pink); }

.star-stat  { border-color: rgba(251,191,36,.3); background: var(--gold-dim); }
.star-stat .hstat-val { color: var(--gold); }

.gift-stat {
  position: relative;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  border-color: var(--purple-dim);
  background: var(--purple-dim);
  flex-shrink: 0;
}
.hstat-svg { width: 18px; height: 18px; }
.gift-dot {
  position: absolute; top: 4px; right: 4px;
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: 50%;
  display: none;
}
.gift-dot.active { display: block; }

@media (max-width: 480px) {
  .star-stat, .ticket-stat { display: none !important; }
  .top-app-bar { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .hstat { padding: 4px 8px; font-size: 11px; }
  .user-pill { padding: 3px 8px 3px 3px; gap: 6px; }
  .user-avatar-wrap { width: 28px; height: 28px; }
  .user-name { max-width: 64px; }
}

@media (max-width: 380px) {
  .user-rank-label { display: none; }
  .user-name { max-width: 48px; }
  .hstat { padding: 4px 6px; font-size: 10px; }
}

/* ─── SCREENS VIEWPORT ───────────────────────────── */
.screens-viewport {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  position: relative;
  overflow: hidden;
  contain: paint;
}

.app-screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
  overflow-x: hidden;
  overflow-x: clip;
  overscroll-behavior-x: none;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  /* Bottom dock already clears home-indicator — only need scroll breathing room */
  padding: 12px 12px 16px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
  pointer-events: none;
}

.app-screen > * {
  flex-shrink: 0;
}

.app-screen.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#screen-play {
  padding: 0;
  overflow: hidden;
}

#screen-play.active {
  display: flex !important;
  flex-direction: column;
  justify-content: space-between;
}

/* ─── SCREEN HEADER ──────────────────────────────── */
.screen-header {
  text-align: center;
  padding: 4px 0 12px;
  flex-shrink: 0;
}
.screen-title {
  font-family: var(--font-head);
  font-size: 20px; font-weight: 800;
  color: var(--t1);
}
.screen-subtitle {
  font-size: 12px; color: var(--t2);
  margin-top: 3px;
}

/* ─── HERO GAME CARD ─────────────────────────────── */
.hero-game-card {
  background: linear-gradient(145deg, #18233a 0%, #111827 100%);
  border: 1px solid rgba(34, 197, 94, 0.3);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 16px 16px 16px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  display: block;
  box-sizing: border-box;
}
.hero-game-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(34, 197, 94, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(34,197,94,.18);
  border: 1px solid rgba(34,197,94,.4);
  color: var(--green);
  font-size: 11px; font-weight: 800;
  letter-spacing: .8px;
  padding: 5px 12px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.hero-game-title {
  font-family: var(--font-head);
  font-size: 26px; font-weight: 900;
  letter-spacing: .6px;
  color: #ffffff;
  line-height: 1.15;
  margin-bottom: 6px;
}

.hero-game-sub {
  font-size: 12.5px; color: var(--t2);
  line-height: 1.45;
  margin-bottom: 12px;
}

.hero-level-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 8px;
}
.level-indicator {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 20px;
  padding: 6px 12px;
  flex: 1;
  min-width: 0;
}
.level-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  flex-shrink: 0;
}
.level-text {
  font-size: 11px; font-weight: 700;
  color: var(--t1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: .4px;
}
.hero-stars-pill {
  background: var(--surface-3);
  border: 1px solid var(--gold-bd);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 11.5px; font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Hero Play Button */
.hero-play-btn {
  width: 100%;
  height: 52px;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  border: none;
  border-radius: 14px;
  font-family: var(--font-head);
  font-size: 16px; font-weight: 900;
  color: #fff;
  letter-spacing: .6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(34,197,94,.45);
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.hero-play-btn:hover,
.hero-play-btn:focus-visible {
  filter: brightness(1.08);
  box-shadow: 0 8px 30px rgba(34,197,94,.55);
  outline: none;
}
.hero-play-btn:active {
  transform: scale(.97);
  box-shadow: 0 2px 10px rgba(34,197,94,.3);
}
.play-btn-arrow {
  margin-left: 9px;
  font-size: 13px;
  transition: transform .15s;
}
.hero-play-btn:hover .play-btn-arrow,
.hero-play-btn:focus-visible .play-btn-arrow {
  transform: translateX(3px);
}
.play-btn-shine {
  position: absolute;
  top: 0; left: -60%;
  width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.22), transparent);
  animation: btnShine 2.5s ease infinite;
}
@keyframes btnShine {
  0% { left: -60%; }
  100% { left: 120%; }
}

/* ─── WHEEL SCREEN & PRIZE TIERS ────────────────── */
.wheel-screen-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 14px 20px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 20px;
  margin-bottom: 12px;
}
.wheel-stage {
  position: relative;
  width: 270px;
  height: 270px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wheel-pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 26px;
  color: #fbbf24;
  z-index: 10;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.9));
}
#wheel-canvas {
  width: 270px;
  height: 270px;
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(0,0,0,0.6), 0 0 0 4px var(--border-2);
}
.spin-action-btn {
  width: 100%;
  height: 50px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  border: none;
  border-radius: 14px;
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 900;
  color: #111827;
  letter-spacing: .5px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
  transition: transform .15s, opacity .15s;
}
.spin-action-btn:active {
  transform: scale(.96);
  opacity: .9;
}
.prize-tiers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tier-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.tier-icon { font-size: 20px; flex-shrink: 0; }
.tier-name { flex: 1; font-size: 12.5px; font-weight: 700; color: var(--t1); }
.tier-val { font-size: 12.5px; font-weight: 800; }
.green-val { color: var(--green); }
.pink-val { color: var(--pink); }
.gold-val { color: var(--gold); }
.blue-val { color: var(--blue); }

/* ─── SECTION CARD (generic) ─────────────────────── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
}
.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-card-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 800;
  letter-spacing: .7px;
  color: var(--t1);
  text-transform: uppercase;
}
.section-icon { font-size: 14px; }

.streak-badge {
  background: rgba(34,197,94,.15);
  border: 1px solid rgba(34,197,94,.3);
  color: var(--green);
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 20px;
}

/* ─── DAILY STREAK ROW ───────────────────────────── */
.streak-row {
  display: flex;
  gap: 5px;
  justify-content: space-between;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.streak-day {
  display: flex; flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 38px;
  flex: 1;
}
.streak-day-label {
  font-size: 9px; font-weight: 700;
  color: var(--t3);
  text-transform: uppercase;
}
.streak-day-box {
  width: 38px; height: 44px;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  position: relative;
  transition: transform .2s;
}
.streak-day-box .streak-emoji { font-size: 16px; }
.streak-day-box .streak-val {
  font-size: 8.5px; font-weight: 800;
  color: var(--t2);
}

.streak-day.claimed .streak-day-box {
  background: rgba(34,197,94,.1);
  border-color: rgba(34,197,94,.35);
}
.streak-day.claimed .streak-day-label { color: var(--green); }
.streak-day.claimed .streak-val { color: var(--green); }

.streak-day.active-today .streak-day-box {
  background: rgba(251,191,36,.12);
  border-color: rgba(251,191,36,.4);
  box-shadow: 0 0 12px rgba(251,191,36,.2);
  transform: scale(1.05);
}
.streak-day.active-today .streak-day-label { color: var(--gold); }
.streak-day.active-today .streak-val { color: var(--gold); }

.streak-claimed-badge {
  position: absolute;
  bottom: -4px;
  background: var(--green);
  color: #fff;
  font-size: 7px; font-weight: 800;
  padding: 1px 4px;
  border-radius: 4px;
  letter-spacing: .3px;
}

.claim-streak-btn {
  width: 100%;
  height: 40px;
  background: linear-gradient(135deg, var(--gold), #d97706);
  border: none; border-radius: 10px;
  font-size: 13px; font-weight: 800;
  color: #0a0e1a;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
}
.claim-streak-btn:active { transform: scale(.97); opacity: .85; }
.claim-streak-btn:disabled { opacity: .4; cursor: default; }

/* ─── SECTION LABEL ROW ──────────────────────────── */
.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 8px;
}
.section-label {
  font-size: 11px; font-weight: 800;
  letter-spacing: .7px;
  color: var(--t2);
  text-transform: uppercase;
}
.view-all-btn {
  background: none; border: none;
  font-size: 11px; font-weight: 600;
  color: var(--blue);
  cursor: pointer;
  padding: 2px 0;
}

/* ─── SHORTCUT CARDS ─────────────────────────────── */
.shortcut-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background .15s, transform .15s;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.shortcut-card:active { background: var(--surface-2); transform: scale(.98); }

.shortcut-icon-box {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.spin-icon-box   { background: rgba(167,139,250,.15); }
.rank-icon-box   { background: rgba(251,191,36,.12); }
.raffle-icon-box { background: rgba(236,72,153,.12); }
.wallet-icon-box { background: rgba(56,189,248,.12); }

.shortcut-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.shortcut-title {
  font-size: 13px; font-weight: 700;
  color: var(--t1);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 2px;
}
.shortcut-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.spin-dot { background: var(--purple); box-shadow: 0 0 6px var(--purple); }
.shortcut-sub {
  font-size: 11px;
  color: var(--t2);
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.gold-sub { color: var(--gold); }

/* Instant tag */
.instant-tag {
  background: rgba(34,197,94,.15);
  border: 1px solid rgba(34,197,94,.3);
  color: var(--green);
  font-size: 8.5px; font-weight: 800;
  padding: 1.5px 5px; border-radius: 5px;
  letter-spacing: .3px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Action pills on shortcut cards */
.action-pill {
  flex-shrink: 0;
  height: 30px;
  min-width: 58px;
  padding: 0 12px;
  border-radius: 20px;
  border: none;
  font-size: 11px; font-weight: 800;
  letter-spacing: .4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  transition: opacity .15s, transform .15s;
}
.action-pill:active { transform: scale(.94); opacity: .85; }
.spin-pill  { background: #7c3aed; color: #fff; }
.dark-pill  { background: var(--surface-3); border: 1px solid var(--border-2); color: var(--t1); }
.green-pill { background: linear-gradient(135deg, var(--green), #16a34a); color: #fff; }

/* ─── MISSIONS CARD ──────────────────────────────── */
.missions-card { margin-top: 2px; }
.missions-done-badge {
  background: rgba(56,189,248,.12);
  border: 1px solid rgba(56,189,248,.25);
  color: var(--blue);
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 20px;
}
.missions-list { display: flex; flex-direction: column; gap: 8px; }
.mission-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.mission-icon { font-size: 20px; flex-shrink: 0; }
.mission-info { flex: 1; min-width: 0; }
.mission-title { font-size: 13px; font-weight: 700; color: var(--t1); margin-bottom: 2px; }
.mission-reward { font-size: 11px; color: var(--gold); font-weight: 600; }

.mission-btn {
  flex-shrink: 0;
  height: 30px; padding: 0 12px;
  border-radius: 20px; border: none;
  font-size: 11px; font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.mission-btn:active { opacity: .75; }
.claimed-btn { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); color: var(--green); }
.go-btn { background: var(--surface-3); border: 1px solid var(--border-2); color: var(--t1); }

/* ─── GAME PLAY SCREEN ───────────────────────────── */
#screen-play {
  justify-content: space-between;
  padding: 0;
}

.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(var(--tg-safe-top) + 8px) 12px 8px;
  flex-shrink: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.hud-left { display: flex; gap: 6px; }
.hud-circle-btn {
  width: 34px; height: 34px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--t1);
  transition: transform .15s;
}
.hud-circle-btn:active { transform: scale(.9); }

.hud-center { display: flex; flex-direction: column; align-items: center; }
.level-badge { font-size: 14px; font-weight: 800; color: var(--t1); letter-spacing: .6px; }
.difficulty-tag {
  font-size: 9px; font-weight: 700;
  padding: 1px 7px; border-radius: 6px;
  background: var(--green); color: #fff;
  margin-top: 2px; letter-spacing: .5px;
}
.difficulty-tag.medium { background: #f59e0b; }
.difficulty-tag.hard   { background: var(--red); }
.difficulty-tag.expert { background: #a855f7; }

.lives-pill {
  display: flex; align-items: center; gap: 5px;
  background: rgba(248,113,113,.12);
  border: 1px solid rgba(248,113,113,.3);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px; font-weight: 800;
}
.heart-svg-icon { width: 18px; height: 18px; }

.damage-flash { animation: dmgFlash .45s ease; }
@keyframes dmgFlash {
  0%,100% { transform: scale(1); }
  25% { transform: scale(1.25); background: rgba(248,113,113,.4); }
  75% { transform: scale(1.08); }
}

/* Progress */
.progress-container {
  display: flex; flex-direction: column; align-items: center;
  margin: 0 8px 2px; flex-shrink: 0;
}
.progress-bar-bg {
  width: 100%; height: 5px;
  background: rgba(255,255,255,.1);
  border-radius: 6px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, var(--green));
  border-radius: 6px;
  transition: width .3s ease;
}
.progress-label {
  font-size: 10.5px; font-weight: 600;
  color: var(--t2); margin-top: 3px;
}

/* Combo Banner */
.combo-banner {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translate(-50%, -50%) scale(.5);
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 16px; font-weight: 900;
  box-shadow: 0 6px 20px rgba(239,68,68,.5);
  opacity: 0; pointer-events: none;
  transition: transform .2s cubic-bezier(.175,.885,.32,1.275), opacity .2s;
  z-index: 100;
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.combo-banner.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

/* Game Arena */
.canvas-wrapper {
  flex: 1 1 auto;
  width: 100%;
  min-height: 200px;
  height: 0;
  position: relative;
  background: #090d16;
  overflow: hidden;
  touch-action: none;
  margin: 2px 0;
}
.dom-board {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100% !important;
  height: 100% !important;
  pointer-events: auto;
}
.dom-board-card {
  position: absolute;
  border-radius: 12px;
  background: #090d16;
  border: 2px solid rgba(255,255,255,.1);
}
.dom-dot {
  position: absolute;
  width: 4px; height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: #1e293b;
  pointer-events: none;
}
.dom-snakes-svg {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: visible;
}
.organic-snake { filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)); }
#game-canvas {
  position: absolute;
  width: 1px !important; height: 1px !important;
  opacity: 0; pointer-events: none; visibility: hidden;
}

/* Powerups Bar */
.powerups-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  padding: 6px 4px 8px;
  flex-shrink: 0;
}
.powerup-btn {
  display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  background: none; border: none;
  cursor: pointer; color: var(--t2);
  padding: 4px 8px;
  border-radius: 10px;
  transition: background .15s, color .15s;
}
.powerup-btn:active, .powerup-btn.active {
  background: rgba(56,189,248,.12);
  color: var(--blue);
}
.powerup-icon-wrap { position: relative; }
.pu-svg { width: 24px; height: 24px; }
.pu-badge {
  position: absolute;
  top: -5px; right: -7px;
  background: #1e293b;
  border: 1px solid rgba(255,255,255,.15);
  color: var(--t1);
  font-size: 8.5px; font-weight: 800;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}
.pu-label { font-size: 10px; font-weight: 600; }

/* Tool Banner */
.tool-banner {
  position: absolute;
  top: 56px; left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(56,189,248,.15);
  border: 1px solid rgba(56,189,248,.35);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px; font-weight: 700;
  color: var(--blue);
  display: flex; align-items: center; gap: 8px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50; white-space: nowrap;
}
.tool-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.cancel-tool-btn {
  background: none; border: none;
  color: var(--blue); font-size: 14px;
  cursor: pointer; padding: 0;
}

/* ─── LEADERBOARD SCREEN ─────────────────────────── */
.prize-pool-card {
  background: linear-gradient(135deg, #1a2040, #111827);
  border: 1px solid rgba(251,191,36,.2);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
}
.prize-pool-badge {
  display: inline-flex;
  background: rgba(251,191,36,.12);
  border: 1px solid rgba(251,191,36,.3);
  color: var(--gold);
  font-size: 10px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
  margin-bottom: 8px; letter-spacing: .5px;
}
.prize-pool-amount {
  font-family: var(--font-head);
  font-size: 28px; font-weight: 900;
  color: var(--gold);
  margin-bottom: 8px;
}
.prize-currency { font-size: 14px; color: var(--t2); font-weight: 600; }
.prize-countdown-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--t2);
  margin-bottom: 10px;
}
.prize-countdown-row b { color: var(--t1); font-weight: 800; }
.prize-tiers-row {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin-bottom: 12px;
}
.tier-chip {
  font-size: 10px; font-weight: 700;
  padding: 4px 8px; border-radius: 10px;
  white-space: nowrap;
}
.tier-chip.gold   { background: rgba(251,191,36,.15); color: var(--gold); }
.tier-chip.silver { background: rgba(148,163,184,.1); color: #94a3b8; }
.tier-chip.bronze { background: rgba(251,146,60,.12); color: #fb923c; }
.tier-chip.raffle { background: rgba(236,72,153,.12); color: var(--pink); }
.prize-action-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.ticket-count-pill {
  font-size: 12px; color: var(--t2);
}
.ticket-count-pill b { color: var(--pink); }
.spin-win-btn {
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  border: none; border-radius: 20px;
  padding: 8px 16px;
  font-size: 12px; font-weight: 800;
  color: #fff; cursor: pointer;
  transition: opacity .15s;
}
.spin-win-btn:active { opacity: .8; }

/* Podium */
.podium-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 0 8px;
}
.podium-step {
  display: flex; flex-direction: column; align-items: center;
  flex: 1;
}
.podium-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin-bottom: 4px;
}
.step-1 .podium-avatar { width: 52px; height: 52px; font-size: 26px; border-color: var(--gold); }
.podium-crown { font-size: 18px; margin-bottom: 2px; }
.podium-name { font-size: 11px; font-weight: 700; color: var(--t1); margin-bottom: 2px; text-align: center; }
.podium-stars { font-size: 10px; color: var(--gold); margin-bottom: 4px; }
.podium-block {
  width: 100%;
  border-radius: 8px 8px 0 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 900;
  padding: 8px 0;
}
.step-1 .podium-block { background: linear-gradient(180deg,#fbbf24,#d97706); color: #0a0e1a; min-height: 52px; }
.step-2 .podium-block { background: linear-gradient(180deg,#94a3b8,#64748b); color: #fff; min-height: 36px; }
.step-3 .podium-block { background: linear-gradient(180deg,#fb923c,#ea580c); color: #fff; min-height: 28px; }

/* My Rank Bar */
.my-rank-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(56,189,248,.08);
  border: 1px solid rgba(56,189,248,.25);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 10px;
}
.my-rank-left { display: flex; align-items: center; gap: 10px; }
.my-rank-num { font-size: 16px; font-weight: 900; color: var(--blue); }
.sm-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.my-rank-info { display: flex; flex-direction: column; }
.my-rank-name { font-size: 13px; font-weight: 700; color: var(--t1); }
.my-rank-sub  { font-size: 11px; color: var(--t2); }
.my-rank-stars { font-size: 13px; font-weight: 800; color: var(--gold); }

/* Leaderboard list */
.leaderboard-list { display: flex; flex-direction: column; gap: 6px; }
.lb-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.lb-rank { width: 22px; text-align: center; font-size: 13px; font-weight: 800; color: var(--t2); }
.lb-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.lb-info { flex: 1; }
.lb-name { font-size: 13px; font-weight: 700; color: var(--t1); }
.lb-level { font-size: 11px; color: var(--t2); }
.lb-score { font-size: 13px; font-weight: 800; color: var(--gold); }

/* ─── QUESTS SCREEN ──────────────────────────────── */
.quests-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.quest-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}
.quest-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.quest-info { flex: 1; }
.quest-title { font-size: 13px; font-weight: 700; color: var(--t1); margin-bottom: 2px; }
.quest-reward { font-size: 11px; color: var(--gold); font-weight: 600; }
.quest-progress { font-size: 10.5px; color: var(--t2); margin-top: 2px; }
.quest-btn {
  flex-shrink: 0;
  height: 32px; padding: 0 12px;
  border-radius: 20px; border: 1px solid var(--border-2);
  background: var(--surface-3);
  font-size: 11px; font-weight: 700;
  color: var(--t1); cursor: pointer;
  transition: opacity .15s;
}
.quest-btn:active { opacity: .75; }
.quest-btn.done-btn { background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.3); color: var(--green); }

/* Invite Card */
.invite-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.invite-card-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.invite-icon { font-size: 22px; flex-shrink: 0; }
.invite-title { font-size: 13px; font-weight: 700; color: var(--t1); margin-bottom: 2px; }
.invite-sub { font-size: 11px; color: var(--t2); }
.invite-btn {
  flex-shrink: 0;
  height: 34px; padding: 0 14px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--blue), #0284c7);
  border: none;
  font-size: 12px; font-weight: 800;
  color: #fff; cursor: pointer;
  transition: opacity .15s;
}
.invite-btn:active { opacity: .8; }

/* ─── RAFFLES SCREEN ─────────────────────────────── */
.raffle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}
.raffle-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.raffle-prize-badge {
  display: inline-block;
  background: rgba(34,197,94,.15);
  border: 1px solid rgba(34,197,94,.3);
  color: var(--green);
  font-size: 11px; font-weight: 800;
  padding: 3px 10px; border-radius: 6px;
  margin-bottom: 6px;
  letter-spacing: .3px;
}
.mega-badge {
  background: rgba(251,191,36,.12);
  border-color: rgba(251,191,36,.3);
  color: var(--gold);
}
.raffle-prize-amount {
  font-size: 20px; font-weight: 900;
  color: var(--t1); margin-bottom: 4px;
}
.raffle-ton { font-size: 12px; color: var(--t2); font-weight: 600; }
.raffle-timer { font-size: 11px; color: var(--t2); }
.raffle-ton-badge {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 8px 12px;
  text-align: center;
}
.raffle-ton-text { font-size: 14px; font-weight: 900; color: var(--blue); }
.raffle-instant { font-size: 8px; color: var(--t3); font-weight: 700; letter-spacing: .5px; }

.lucky-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
  margin-bottom: 10px;
}
.lucky-box {
  aspect-ratio: 1;
  background: var(--surface-3);
  border: 1.5px dashed rgba(255,255,255,.18);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  color: var(--t3);
  transition: all .2s;
}
.lucky-box.revealed {
  background: rgba(34,197,94,.1);
  border-color: var(--green);
  color: var(--green);
}
.raffle-notice { font-size: 11px; color: var(--t2); margin-bottom: 10px; line-height: 1.4; }
.raffle-flip-btn {
  width: 100%;
  height: 42px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  font-size: 13px; font-weight: 700;
  color: var(--t1); cursor: pointer;
  transition: opacity .15s;
}
.raffle-flip-btn:active { opacity: .75; }

/* ─── WALLET SCREEN ──────────────────────────────── */
.wallet-balance-card {
  background: linear-gradient(135deg, #1a2040, #111827);
  border: 1px solid rgba(56,189,248,.15);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 12px;
  text-align: center;
}
.balance-label-text {
  font-size: 10px; font-weight: 700;
  color: var(--t3);
  letter-spacing: .8px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.balance-amount {
  font-family: var(--font-head);
  font-size: 36px; font-weight: 900;
  color: var(--t1);
  margin-bottom: 4px;
}
.balance-currency { font-size: 18px; color: var(--t2); }
.balance-ton-sub { font-size: 13px; color: var(--t2); margin-bottom: 14px; }

.withdrawal-progress-wrap { margin-bottom: 12px; }
.withdrawal-progress-info {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--t2);
  margin-bottom: 6px;
}
.withdrawal-notice {
  font-size: 11.5px; color: var(--blue);
  font-weight: 600; line-height: 1.4;
}

.wallet-input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}
.wallet-input-label {
  font-size: 13px; font-weight: 700;
  color: var(--t1); margin-bottom: 10px;
}
.ton-address-input {
  width: 100%;
  height: 44px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  color: var(--t1);
  font-size: 13px;
  padding: 0 12px;
  outline: none;
  margin-bottom: 12px;
  user-select: text;
  -webkit-user-select: text;
  font-family: var(--font);
}
.ton-address-input::placeholder { color: var(--t3); }
.ton-address-input:focus { border-color: rgba(56,189,248,.4); }
.wallet-deposit-note {
  color: var(--t2);
  font-size: 11px;
  line-height: 1.45;
  margin: -3px 0 10px;
  overflow-wrap: anywhere;
}
.deposit-btn {
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  margin-bottom: 4px;
}
.withdraw-btn {
  width: 100%;
  height: 46px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border: none; border-radius: 12px;
  font-size: 13px; font-weight: 800;
  color: #fff; cursor: pointer;
  transition: opacity .15s, transform .15s;
}
.withdraw-btn:active { transform: scale(.97); opacity: .85; }

/* ─── PROFILE SCREEN ─────────────────────────────── */
.profile-hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px 16px;
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
}
.profile-avatar-xl {
  width: 70px; height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px;
  margin-bottom: 10px;
  box-shadow: 0 6px 20px rgba(139,92,246,.3);
}
.profile-hero-name { font-size: 20px; font-weight: 800; color: var(--t1); margin-bottom: 4px; }
.profile-tg-id { font-size: 11px; color: var(--t2); margin-bottom: 4px; }
.profile-rank-tag {
  display: inline-block;
  background: rgba(167,139,250,.15);
  border: 1px solid rgba(167,139,250,.3);
  color: var(--purple);
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
  margin-bottom: 16px;
}
.profile-stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; width: 100%;
}
.prof-stat-box {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 4px;
  display: flex; flex-direction: column;
  align-items: center; gap: 3px;
}
.prof-stat-val { font-size: 16px; font-weight: 900; color: var(--t1); }
.prof-stat-lbl { font-size: 9px; color: var(--t2); font-weight: 600; text-align: center; }

/* Theme Choices */
.theme-choices { display: flex; flex-direction: column; gap: 6px; }
.theme-choice-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px; font-weight: 600;
  color: var(--t2); cursor: pointer;
  transition: border-color .15s, color .15s;
  text-align: left;
}
.theme-choice-btn.active { border-color: var(--blue); color: var(--t1); }
.theme-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.obsidian-dot  { background: linear-gradient(135deg,#38bdf8,#34d399); }
.cyberpunk-dot { background: linear-gradient(135deg,#06b6d4,#ec4899); }
.emerald-dot   { background: linear-gradient(135deg,#10b981,#22c55e); }
.golden-dot    { background: linear-gradient(135deg,#fbbf24,#f59e0b); }

/* ─── BOTTOM NAV ─────────────────────────────────── */
.bottom-nav {
  width: 100%;
  /* Content height + home-indicator inset — never squeeze labels */
  height: calc(var(--nav-h) + var(--tg-safe-bottom));
  min-height: calc(var(--nav-h) + var(--tg-safe-bottom));
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border-2);
  display: flex;
  align-items: stretch;
  position: relative;
  z-index: 50;
  padding-bottom: var(--tg-safe-bottom);
  box-sizing: border-box;
}

#app.in-gameplay .bottom-nav {
  /* Keep dock visible but ensure it clears the home indicator */
  height: calc(var(--nav-h) + var(--tg-safe-bottom));
  padding-bottom: var(--tg-safe-bottom);
}

.nav-btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--t3);
  cursor: pointer;
  padding: 8px 2px;
  min-height: 48px;
  touch-action: manipulation;
  transition: color .15s, transform .12s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn.active {
  color: var(--green);
}
.nav-btn:active {
  transform: scale(.92);
}
.nav-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 18%;
  right: 18%;
  height: 2.5px;
  background: var(--green);
  border-radius: 0 0 3px 3px;
  box-shadow: 0 1px 8px var(--green);
}

.nav-icon { width: 22px; height: 22px; transition: transform .2s; }
.nav-btn.active .nav-icon { transform: translateY(-1px); }
.nav-label { font-size: 10px; font-weight: 600; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

@media (max-width: 390px) {
  .nav-btn { padding-left: 0; padding-right: 0; }
  .nav-label { font-size: 8px; }
  .nav-icon { width: 20px; height: 20px; }
}

/* ─── CENTER HIGHLIGHTED PLAY FAB BUTTON ─────────── */
.nav-btn-play-fab {
  flex: 1 1 0;
  min-width: 0;
  position: relative;
  overflow: visible;
  padding-top: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.play-fab-inner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22c55e 0%, #10b981 50%, #059669 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -24px;
  box-shadow: 0 4px 18px rgba(34, 197, 94, 0.45), 0 0 0 4px var(--surface);
  position: relative;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s;
  flex-shrink: 0;
}

.play-fab-halo {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 197, 94, 0.45) 0%, transparent 70%);
  animation: fabPulse 2.4s infinite ease-in-out;
  pointer-events: none;
}

@keyframes fabPulse {
  0%, 100% { transform: scale(1); opacity: 0.65; }
  50% { transform: scale(1.22); opacity: 0.12; }
}

.play-fab-icon {
  width: 24px;
  height: 24px;
  color: #fff;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
  margin-left: 2px;
}

.play-fab-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: 0.6px;
  margin-top: 2px;
}

.nav-btn-play-fab:active .play-fab-inner {
  transform: scale(0.92) translateY(2px);
  box-shadow: 0 2px 10px rgba(34, 197, 94, 0.35), 0 0 0 3px var(--surface);
}

.nav-btn-play-fab.active .play-fab-inner {
  box-shadow: 0 6px 24px rgba(34, 197, 94, 0.65), 0 0 0 4px var(--surface);
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.nav-btn-play-fab.active::before {
  display: none;
}

/* ─── REFERRALS SCREEN ────────────────────────────── */
#screen-referrals {
  padding-bottom: 24px;
}

.referral-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: #f472b6;
  background: rgba(236, 72, 153, 0.15);
  border: 1px solid rgba(236, 72, 153, 0.3);
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 6px;
}

.ref-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.ref-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.ref-stat-card.highlight-card {
  border-color: rgba(34, 197, 94, 0.35);
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.08) 0%, var(--surface) 100%);
}

.ref-stat-card.claim-box-card {
  grid-column: 1 / -1;
  justify-content: space-between;
  border-color: rgba(251, 191, 36, 0.35);
  background: linear-gradient(145deg, rgba(251, 191, 36, 0.08) 0%, var(--surface) 100%);
}

.ref-stat-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.ref-stat-content {
  display: flex;
  flex-direction: column;
}

.ref-stat-label {
  font-size: 11px;
  color: var(--t2);
  font-weight: 600;
}

.ref-stat-val {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 800;
  color: var(--t1);
  margin-top: 2px;
}

.ref-stat-val small {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  opacity: 0.85;
}

.ref-green { color: var(--green); }
.ref-gold { color: var(--gold); }

.ref-claim-btn {
  background: linear-gradient(135deg, var(--gold) 0%, #d97706 100%);
  color: #111827;
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 800;
  padding: 8px 16px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
  transition: transform 0.15s, opacity 0.15s;
  flex-shrink: 0;
}

.ref-claim-btn:active {
  transform: scale(0.94);
}

.ref-claim-btn:disabled {
  background: var(--surface-3);
  color: var(--t3);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Actions Card */
.ref-actions-card {
  background: linear-gradient(145deg, #18233a 0%, #111827 100%);
  border: 1px solid rgba(236, 72, 153, 0.35);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.ref-actions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.ref-action-title {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}

.ref-bonus-tag {
  font-size: 10px;
  font-weight: 700;
  color: #f472b6;
  background: rgba(236, 72, 153, 0.18);
  padding: 2px 8px;
  border-radius: 6px;
}

.ref-link-box {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.ref-link-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 11.5px;
  font-family: monospace;
  color: var(--t2);
  outline: none;
}

.ref-copy-btn {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  color: var(--t1);
  font-size: 11px;
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.ref-copy-btn:active {
  transform: scale(0.95);
  background: var(--green-dim);
}

.ref-tg-share-btn {
  width: 100%;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.4px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.4);
  transition: transform 0.15s, opacity 0.15s;
}

.ref-tg-share-btn:active {
  transform: scale(0.97);
  opacity: 0.9;
}

/* Milestones */
.ref-tiers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ref-tier-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ref-tier-badge { font-size: 20px; flex-shrink: 0; }

.ref-tier-info {
  flex: 1;
}

.ref-tier-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--t1);
  display: flex;
  justify-content: space-between;
}

.ref-tier-bonus {
  color: var(--gold);
  font-weight: 800;
}

.ref-tier-bar {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  margin-top: 5px;
  overflow: hidden;
}

.ref-tier-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), #38bdf8);
  border-radius: 5px;
}

.ref-tier-item.completed {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.06);
}

/* Friends list */
.friends-count-pill {
  font-size: 10px;
  font-weight: 700;
  color: var(--t2);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 10px;
}

.ref-friends-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ref-friend-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ref-friend-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ref-friend-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.ref-friend-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--t1);
}

.ref-friend-level {
  font-size: 10px;
  color: var(--t3);
  margin-top: 1px;
}

.ref-friend-earned {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 800;
  color: var(--green);
}

.ref-empty-state {
  text-align: center;
  padding: 24px 16px;
}

.ref-empty-icon { font-size: 32px; margin-bottom: 6px; }
.ref-empty-state h4 { font-size: 14px; font-weight: 700; color: var(--t1); margin-bottom: 4px; }
.ref-empty-state p { font-size: 11.5px; color: var(--t3); line-height: 1.4; max-width: 280px; margin: 0 auto; }

/* ─── MODALS ─────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }

.modal-card {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px 36px;
  width: 100%;
  max-width: 520px;
  text-align: center;
  transform: translateY(40px);
  transition: transform .28s cubic-bezier(.175,.885,.32,1.275);
  position: relative;
}
.modal-overlay.show .modal-card { transform: translateY(0); }

.modal-icon { font-size: 40px; margin-bottom: 10px; }
.modal-title {
  font-family: var(--font-head);
  font-size: 22px; font-weight: 900;
  color: var(--t1); margin-bottom: 6px;
}
.modal-stars { font-size: 24px; margin-bottom: 14px; }
.modal-sub-text { font-size: 13px; color: var(--t2); line-height: 1.5; margin-bottom: 16px; }

.modal-stats-grid {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 8px; margin-bottom: 18px;
}
.stat-card {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.stat-card-lbl { font-size: 9px; color: var(--t2); font-weight: 700; text-transform: uppercase; }
.stat-card-val { font-size: 13px; font-weight: 800; color: var(--t1); }

.modal-actions { display: flex; flex-direction: column; gap: 8px; }
.modal-btn {
  width: 100%; height: 48px;
  border-radius: 12px; border: none;
  font-size: 14px; font-weight: 800;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
}
.modal-btn:active { transform: scale(.97); opacity: .85; }
.primary-btn { background: linear-gradient(135deg,var(--green),#16a34a); color: #fff; }
.ghost-btn   { background: var(--surface-3); border: 1px solid var(--border-2); color: var(--t1); }

/* Modal close */
.modal-close-btn {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 50%;
  color: var(--t2); font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s;
}
.modal-close-btn:hover { background: var(--surface); }

/* Fortune Wheel Modal */
.wheel-modal-card { padding-top: 16px; }
.wheel-header { margin-bottom: 14px; }
.wheel-title {
  font-family: var(--font-head);
  font-size: 18px; font-weight: 800;
  color: var(--gold); margin-bottom: 4px;
}
.wheel-subtitle { font-size: 12px; color: var(--t2); }
.wheel-stage {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  width: 280px; height: 280px;
  isolation: isolate;
}
.wheel-screen-card {
  position: relative;
  overflow: hidden;
  padding: 20px 16px 18px;
  margin-bottom: 14px;
  border: 1px solid rgba(251,191,36,.34);
  border-radius: 22px;
  background: radial-gradient(circle at 50% 34%, rgba(251,191,36,.2), transparent 38%), linear-gradient(145deg, rgba(31,41,73,.98), rgba(10,14,26,.98));
  box-shadow: 0 16px 34px rgba(2,6,23,.34), inset 0 1px rgba(255,255,255,.1);
}
.wheel-screen-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 22%, rgba(255,255,255,.1) 42%, transparent 57%);
  transform: translateX(-120%);
  animation: wheel-card-shine 5s ease-in-out infinite;
  pointer-events: none;
}
.wheel-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(18px);
  opacity: .6;
  pointer-events: none;
  z-index: -1;
}
.wheel-glow-one { width: 190px; height: 190px; background: rgba(251,191,36,.38); }
.wheel-glow-two { width: 120px; height: 120px; background: rgba(56,189,248,.25); transform: translate(72px, 82px); }
.wheel-pointer {
  position: absolute;
  top: -7px; left: 50%;
  transform: translateX(-50%);
  font-size: 28px;
  color: #fff7c2;
  text-shadow: 0 0 4px #fbbf24, 0 3px 10px rgba(251,191,36,.85);
  z-index: 2;
}
#wheel-canvas { border-radius: 50%; box-shadow: 0 0 0 5px rgba(255,255,255,.12), 0 0 0 9px rgba(251,191,36,.7), 0 0 30px rgba(251,191,36,.55); }
.wheel-center-badge {
  position: absolute;
  display: grid;
  place-content: center;
  width: 56px; height: 56px;
  border: 3px solid #fff7c2;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #fff7c2, #fbbf24 42%, #d97706 100%);
  color: #713f12;
  font-size: 8px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 1px;
  text-align: center;
  box-shadow: 0 3px 12px rgba(15,23,42,.45), inset 0 1px 3px rgba(255,255,255,.9);
  pointer-events: none;
}
.wheel-center-badge strong { font-size: 13px; }

.spin-action-btn {
  width: 100%; height: 50px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(110deg,#fef3a7 0%,#fbbf24 32%,#f97316 70%,#facc15 100%);
  border: 1px solid rgba(255,255,255,.55); border-radius: 14px;
  font-size: 15px; font-weight: 900;
  color: #0a0e1a; cursor: pointer;
  transition: opacity .15s, transform .15s;
  box-shadow: 0 7px 20px rgba(251,191,36,.35), inset 0 1px rgba(255,255,255,.7);
}
.spin-action-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 25%, rgba(255,255,255,.7) 48%, transparent 70%);
  transform: translateX(-120%);
  animation: button-shine 3.2s ease-in-out infinite;
  pointer-events: none;
}
.spin-action-btn:active { transform: scale(.97); opacity: .85; }
.spin-action-btn:disabled { opacity: .5; }

@keyframes wheel-card-shine {
  0%, 55% { transform: translateX(-120%); }
  78%, 100% { transform: translateX(120%); }
}
@keyframes button-shine {
  0%, 45% { transform: translateX(-120%); }
  75%, 100% { transform: translateX(120%); }
}

/* Onboarding Modal */
.onboarding-card { padding: 28px 20px 36px; }
.onboard-step { margin-bottom: 20px; }
.onboard-icon { font-size: 48px; margin-bottom: 12px; }
.onboard-title { font-size: 20px; font-weight: 800; color: var(--t1); margin-bottom: 8px; }
.onboard-desc { font-size: 14px; color: var(--t2); line-height: 1.6; }

/* ─── TOAST ──────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--tg-safe-bottom) + 12px);
  left: 50%; transform: translateX(-50%);
  z-index: 300;
  pointer-events: none;
}
.toast-popup {
  background: rgba(30,40,60,.95);
  border: 1px solid var(--border-2);
  border-radius: 24px;
  padding: 10px 18px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600;
  color: var(--t1);
  white-space: nowrap;
  backdrop-filter: blur(12px);
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .22s ease, transform .22s ease;
}
.toast-popup.show { opacity: 1; transform: translateY(0); }
.toast-icon { font-size: 16px; }
