:root {
  color-scheme: dark;
  --bg: #070914;
  --surface: rgba(20, 22, 43, 0.78);
  --surface-solid: #14162a;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f7f4ff;
  --muted: #9d9ab3;
  --violet: #7c4dff;
  --violet-bright: #a779ff;
  --pink: #ef62d0;
  --gold: #ffd36b;
  --green: #46e6a5;
  --safe-top: max(14px, env(safe-area-inset-top));
  --safe-bottom: max(12px, env(safe-area-inset-bottom));
  font-family: "Vazirmatn", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body { height: var(--tg-viewport-stable-height, 100svh); min-height: 0; }
button { font: inherit; color: inherit; }
button:focus-visible { outline: 3px solid rgba(167, 121, 255, .55); outline-offset: 3px; }

body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .22;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
}

.ambient { position: fixed; width: 320px; height: 320px; border-radius: 50%; filter: blur(90px); opacity: .17; pointer-events: none; }
.ambient-one { background: #782dff; top: -170px; right: -120px; }
.ambient-two { background: #e448b0; bottom: 10%; left: -230px; }

.app-shell { width: min(100%, 520px); height: 100%; min-height: 0; margin: 0 auto; padding: var(--safe-top) 18px calc(76px + var(--safe-bottom)); position: relative; overflow: hidden; }
.topbar { height: 54px; display: flex; align-items: center; direction: ltr; gap: 10px; }
.brand-mark { width: 39px; height: 39px; border-radius: 13px; display: grid; place-items: center; position: relative; overflow: hidden; transform: rotate(-7deg); background: linear-gradient(145deg, #a672ff, #5e2ad2); box-shadow: 0 8px 25px rgba(108, 55, 242, .3); }
.brand-mark::after { content: ""; position: absolute; inset: -10px 12px; transform: rotate(35deg); background: rgba(255,255,255,.24); }
.brand-mark span { font-size: 13px; font-weight: 900; position: relative; z-index: 1; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.05; letter-spacing: .03em; }
.brand-copy span { color: var(--muted); font-size: 9px; }
.brand-copy strong { font-size: 15px; letter-spacing: .12em; }
.sound-toggle { margin-left: auto; width: 35px; height: 35px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(25, 28, 51, .82); color: #bfa8f2; display: grid; place-items: center; position: relative; cursor: pointer; transition: .2s ease; }
.sound-toggle svg { width: 19px; height: 19px; overflow: visible; }
.sound-toggle path { fill: currentColor; }
.sound-toggle .sound-wave { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.sound-toggle.muted { color: #77758c; }
.sound-toggle.muted .sound-wave { opacity: 0; }
.sound-toggle.muted::after { content: ""; position: absolute; width: 20px; height: 2px; border-radius: 2px; background: #9c91b2; transform: rotate(-45deg); }
.sound-toggle:active { transform: scale(.92); }
.profile-pill { width: 39px; height: 39px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: linear-gradient(145deg, #292c4f, #15172d); display: grid; place-items: center; position: relative; cursor: pointer; }
.profile-pill > span { font-weight: 800; color: #d8ccff; }
.status-dot { width: 10px; height: 10px; position: absolute; right: -1px; bottom: 1px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg); }

.screen { display: none; animation: screen-in .35s ease both; }
.screen.active { display: block; height: 100%; }
#homeScreen.active { overflow: hidden; }
.screen:not(#homeScreen).active { overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }
.hero-copy { text-align: center; padding: 27px 0 17px; }
.eyebrow { font-size: 11px; font-weight: 600; color: #b8b4ca; display: inline-flex; align-items: center; gap: 6px; }
.eyebrow i { width: 5px; height: 5px; border-radius: 50%; background: var(--violet-bright); box-shadow: 0 0 12px var(--violet-bright); }
.hero-copy h1 { margin: 6px 0 3px; font-size: clamp(29px, 8vw, 39px); line-height: 1.32; font-weight: 900; letter-spacing: -.04em; }
.hero-copy h1 em { font-style: normal; color: transparent; background: linear-gradient(90deg, #a978ff, #ef75d2); background-clip: text; -webkit-background-clip: text; }
.hero-copy p, .section-heading p { margin: 0; color: var(--muted); font-size: 12px; }

.stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 10px; }
.stat-card { min-height: 61px; border: 1px solid var(--line); background: linear-gradient(140deg, rgba(31,34,62,.9), rgba(16,18,35,.84)); border-radius: 17px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; box-shadow: 0 12px 35px rgba(0,0,0,.16); }
.primary-stat { border-color: rgba(139, 89, 255, .22); }
.stat-icon { width: 35px; height: 35px; display: grid; place-items: center; background: rgba(124,77,255,.13); border: 1px solid rgba(167,121,255,.14); border-radius: 12px; font-size: 16px; }
.stat-card div { display: flex; flex-direction: column; }
.stat-card small { color: var(--muted); font-size: 9px; }
.stat-card strong { font-size: 19px; line-height: 1.2; }

.membership-card { padding: 11px; display: flex; gap: 9px; align-items: center; border: 1px solid rgba(255, 211, 107, .18); border-radius: 15px; background: rgba(255, 211, 107, .06); margin-bottom: 10px; }
.membership-card.hidden { display: none; }
.membership-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: rgba(255,211,107,.12); }
.membership-card > div:nth-child(2) { flex: 1; }
.membership-card strong { display: block; font-size: 11px; }
.membership-card p { margin: 1px 0 0; font-size: 9px; color: var(--muted); }
.membership-card button { border: 0; border-radius: 10px; background: #f2c85d; color: #201600; padding: 7px 11px; font-size: 10px; font-weight: 800; cursor: pointer; }

.wheel-stage { width: min(88vw, 390px); aspect-ratio: 1; margin: 5px auto 0; position: relative; display: grid; place-items: center; }
.wheel-aura { position: absolute; inset: 8%; border-radius: 50%; background: rgba(126, 73, 255, .18); filter: blur(32px); animation: aura 3.5s ease-in-out infinite; }
@keyframes aura { 50% { transform: scale(1.08); opacity: .65; } }
#wheelCanvas { width: 100%; height: 100%; position: relative; filter: drop-shadow(0 20px 32px rgba(0,0,0,.48)); }
.pointer { position: absolute; z-index: 4; top: -1px; left: 50%; transform: translateX(-50%); width: 39px; height: 48px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.6)); }
.pointer::before { content: ""; position: absolute; inset: 0 5px 13px; border-radius: 11px 11px 14px 14px; background: linear-gradient(145deg, #fff2a5, #e8a62c); border: 2px solid #fff4ba; }
.pointer span { position: absolute; left: 50%; top: 28px; transform: translateX(-50%); width: 0; height: 0; border-left: 13px solid transparent; border-right: 13px solid transparent; border-top: 18px solid #e8a62c; }
.pointer.tick { animation: pointer-tick .11s ease-out; }
@keyframes pointer-tick { 45% { transform: translateX(-50%) rotate(-8deg); } }
.wheel-hub { position: absolute; z-index: 3; width: 94px; height: 94px; border: 5px solid rgba(255,255,255,.2); border-radius: 50%; cursor: pointer; background: radial-gradient(circle at 34% 26%, #b489ff 0, #7d4cff 30%, #5d2bc5 75%); box-shadow: 0 0 0 7px rgba(10,10,23,.62), 0 10px 28px rgba(0,0,0,.48), inset 0 2px 4px rgba(255,255,255,.35); display: flex; flex-direction: column; align-items: center; justify-content: center; transition: transform .18s ease, filter .18s ease; }
.wheel-hub:active { transform: scale(.94); }
.wheel-hub:disabled { cursor: wait; filter: saturate(.45); }
.wheel-hub span { font-weight: 900; font-size: 16px; }
.wheel-hub small { font-size: 8px; font-weight: 700; color: #dcd1ff; letter-spacing: .14em; }
.spin-caption { min-height: 25px; display: flex; align-items: center; justify-content: center; gap: 7px; color: #bbb6cc; font-size: 10px; margin-top: -2px; }
.pulse-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 9px var(--green); animation: pulse 1.5s ease infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }

.invite-banner { width: 100%; border: 1px solid rgba(152,101,255,.17); border-radius: 18px; padding: 12px 13px; display: flex; align-items: center; gap: 11px; text-align: right; background: linear-gradient(105deg, rgba(77,39,150,.34), rgba(31,27,64,.68)); cursor: pointer; box-shadow: 0 14px 35px rgba(0,0,0,.15); }
.gift-orb { width: 43px; height: 43px; border-radius: 14px; background: linear-gradient(145deg, #7848e7, #452585); display: grid; place-items: center; font-size: 19px; box-shadow: inset 0 1px 1px rgba(255,255,255,.25); }
.invite-banner > span:nth-child(2) { flex: 1; }
.invite-banner strong, .invite-banner small { display: block; }
.invite-banner strong { font-size: 12px; }
.invite-banner small { font-size: 9px; color: var(--muted); margin-top: 2px; }
.invite-banner i { font-size: 27px; font-style: normal; color: #8d82af; transform: rotate(180deg); }

.bottom-nav { position: fixed; z-index: 10; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 520px); height: calc(71px + var(--safe-bottom)); padding: 8px 38px var(--safe-bottom); display: flex; justify-content: space-around; background: linear-gradient(180deg, rgba(10,11,25,.87), rgba(10,11,25,.98)); border-top: 1px solid var(--line); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); }
.nav-item { width: 65px; padding: 0; border: 0; background: transparent; color: #77758c; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; position: relative; }
.nav-item span { font-size: 22px; line-height: 1; }
.nav-item small { font-size: 9px; font-weight: 600; }
.nav-item.active { color: #ae84ff; }
.nav-item.active::before { content: ""; position: absolute; top: -9px; width: 32px; height: 3px; border-radius: 0 0 5px 5px; background: #9a6cff; box-shadow: 0 2px 13px #9a6cff; }

.section-heading { padding: 31px 2px 22px; text-align: center; }
.section-heading h2 { font-size: 29px; margin: 6px 0 4px; font-weight: 900; }
.reward-summary { min-height: 85px; border: 1px solid rgba(255,211,107,.15); border-radius: 20px; padding: 15px 18px; display: flex; align-items: center; gap: 13px; background: linear-gradient(120deg, rgba(111,72,22,.21), rgba(30,28,48,.8)); }
.reward-summary > span { width: 48px; height: 48px; border-radius: 15px; background: rgba(255,211,107,.1); display: grid; place-items: center; font-size: 23px; }
.reward-summary div { display: flex; flex-direction: column; }
.reward-summary small { color: var(--muted); font-size: 10px; }
.reward-summary strong { font-size: 23px; }
.history-list { display: grid; gap: 9px; margin-top: 14px; }
.history-item { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 11px 12px; display: grid; grid-template-columns: 43px 1fr auto; align-items: center; gap: 10px; }
.history-icon { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 13px; background: rgba(124,77,255,.12); font-size: 20px; }
.history-icon img { width: 28px; height: 28px; object-fit: contain; filter: drop-shadow(0 3px 7px rgba(0,0,0,.28)); }
.history-copy strong, .history-copy small { display: block; }
.history-copy strong { font-size: 12px; }
.history-copy small { color: var(--muted); font-size: 9px; direction: ltr; text-align: right; }
.claim-button { border: 1px solid rgba(167,121,255,.25); border-radius: 10px; background: rgba(124,77,255,.12); color: #c8adff; font-size: 9px; padding: 6px 8px; cursor: pointer; }
.claim-button:disabled { color: var(--muted); border-color: var(--line); background: transparent; }
.empty-state { padding: 74px 0; text-align: center; color: var(--muted); }
.empty-state.hidden { display: none; }
.empty-state > span { width: 60px; height: 60px; display: grid; place-items: center; margin: 0 auto 11px; border-radius: 20px; font-size: 25px; color: #aa82ff; background: rgba(124,77,255,.1); }
.empty-state strong { display: block; color: #dcd9e7; font-size: 13px; }
.empty-state p { margin: 4px 0; font-size: 10px; }

.invite-visual { height: 160px; display: grid; place-items: center; position: relative; }
.invite-main-icon { width: 108px; height: 108px; display: grid; place-items: center; font-size: 43px; border-radius: 34px; transform: rotate(-4deg); background: linear-gradient(145deg, #a172ff, #5127b8); box-shadow: 0 22px 55px rgba(102,51,220,.32), inset 0 1px 2px rgba(255,255,255,.32); }
.coin { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; position: absolute; color: #382300; font-weight: 900; font-size: 12px; background: linear-gradient(145deg, #ffeaa0, #dca52c); border: 3px solid #fff0a3; box-shadow: 0 12px 22px rgba(0,0,0,.35); }
.coin-a { right: 18%; top: 14px; transform: rotate(12deg); }
.coin-b { left: 19%; bottom: 11px; transform: rotate(-15deg); }
.referral-card { margin-top: 9px; border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 15px; }
.referral-card > small { color: var(--muted); font-size: 10px; }
.link-box { direction: ltr; margin: 7px 0 10px; min-height: 43px; border-radius: 12px; background: rgba(5,6,15,.55); border: 1px solid var(--line); padding: 6px 7px 6px 11px; display: flex; align-items: center; gap: 8px; }
.link-box span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 10px; color: #bab5cc; }
.link-box button { width: 31px; height: 31px; border: 0; border-radius: 9px; background: rgba(124,77,255,.18); color: #bd9bff; cursor: pointer; }
.share-button { width: 100%; min-height: 44px; border: 0; border-radius: 12px; background: linear-gradient(100deg, #7f4fff, #a35de8); font-size: 12px; font-weight: 800; cursor: pointer; box-shadow: 0 10px 25px rgba(105,58,210,.26); }
.share-button span { display: inline-block; margin-left: 6px; }
.steps-card { margin-top: 11px; border: 1px solid var(--line); border-radius: 20px; background: rgba(18,20,39,.72); padding: 17px; }
.steps-card > div { display: flex; align-items: center; gap: 11px; }
.steps-card b { width: 29px; height: 29px; border-radius: 9px; display: grid; place-items: center; background: rgba(124,77,255,.16); color: #bd9bff; font-size: 11px; }
.steps-card span { display: flex; flex-direction: column; }
.steps-card strong { font-size: 11px; }
.steps-card small { font-size: 9px; color: var(--muted); }
.steps-card > i { display: block; height: 17px; width: 1px; margin: 2px 14px; background: rgba(167,121,255,.18); }

.modal-backdrop { position: fixed; z-index: 30; inset: 0; padding: 20px; display: grid; place-items: center; background: rgba(3,4,11,.78); backdrop-filter: blur(9px); opacity: 0; visibility: hidden; transition: .25s ease; }
.modal-backdrop.visible { opacity: 1; visibility: visible; }
.result-modal { width: min(100%, 350px); border-radius: 28px; border: 1px solid rgba(255,255,255,.12); padding: 33px 24px 22px; position: relative; text-align: center; background: radial-gradient(circle at 50% 0, rgba(126,74,255,.24), transparent 48%), #15172b; box-shadow: 0 30px 80px rgba(0,0,0,.55); transform: translateY(20px) scale(.94); transition: .32s cubic-bezier(.2,.8,.2,1); overflow: hidden; }
.visible .result-modal { transform: none; }
.modal-close { position: absolute; top: 12px; left: 12px; width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--muted); font-size: 20px; cursor: pointer; }
.result-icon { width: 80px; height: 80px; margin: 0 auto 13px; border-radius: 27px; display: grid; place-items: center; font-size: 39px; background: linear-gradient(145deg, rgba(163,104,255,.28), rgba(96,51,190,.15)); border: 1px solid rgba(190,151,255,.2); box-shadow: 0 13px 35px rgba(80,42,171,.3); }
.result-icon img { width: 50px; height: 50px; object-fit: contain; filter: drop-shadow(0 6px 12px rgba(0,0,0,.34)); }
.result-kicker { font-size: 10px; color: var(--gold); font-weight: 700; }
.result-modal h2 { margin: 3px 0 4px; font-size: 25px; }
.result-modal p { color: var(--muted); margin: 0 0 19px; font-size: 11px; }
.modal-action { width: 100%; min-height: 44px; border: 0; border-radius: 13px; background: linear-gradient(100deg, #7f4fff, #a35de8); font-weight: 800; font-size: 12px; cursor: pointer; }
.confetti::before, .confetti::after { content: "✦  ·  ✧  ·  ✦"; position: absolute; top: 17px; color: var(--gold); font-size: 13px; opacity: .8; letter-spacing: 10px; }
.confetti::before { right: -2px; transform: rotate(32deg); }
.confetti::after { left: 8px; transform: rotate(-32deg); }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(83px + var(--safe-bottom)); transform: translate(-50%, 18px); width: max-content; max-width: calc(100% - 34px); padding: 10px 15px; border: 1px solid var(--line); border-radius: 12px; background: rgba(31,33,55,.96); color: #eeeaf7; font-size: 10px; box-shadow: 0 13px 35px rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 720px) {
  .hero-copy { padding: 5px 0 8px; }
  .hero-copy h1 { margin-top: 3px; font-size: clamp(27px, 7vw, 34px); line-height: 1.22; }
  .stats-row { gap: 7px; margin-bottom: 6px; }
  .stat-card { min-height: 52px; padding-block: 7px; }
  .membership-card { margin-bottom: 6px; padding-block: 8px; }
  .wheel-stage { width: min(82vw, 340px, calc(var(--tg-viewport-stable-height, 100svh) - 320px)); margin-top: 0; }
  .spin-caption { min-height: 19px; }
  .invite-banner { display: none; }
}

@media (min-height: 721px) and (max-height: 860px) {
  .hero-copy { padding: 12px 0 10px; }
  .wheel-stage { width: min(82vw, 370px, calc(var(--tg-viewport-stable-height, 100svh) - 330px)); }
  .invite-banner { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
