:root {
  --bg: #0a0910;
  --fg: #ffffff;
  --dim: rgba(255, 255, 255, .72);
  --dimmer: rgba(255, 255, 255, .5);
  --glass: rgba(255, 255, 255, .09);
  --glass-b: rgba(255, 255, 255, .16);
  --safe-top: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px)));
  --h: var(--tg-viewport-stable-height, 100vh);
  --head: 'Unbounded', 'Manrope', system-ui, sans-serif;
  --body: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font-family: var(--body); overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#app { position: fixed; inset: 0; overflow: hidden; touch-action: none; }

/* ---------- themes ---------- */
.t-violet { --c1: #7c3aed; --c2: #d946ef; --c3: #4c1d95; }
.t-yellow { --c1: #f59e0b; --c2: #facc15; --c3: #b45309; }
.t-blue   { --c1: #2563eb; --c2: #06b6d4; --c3: #1e3a8a; }
.t-red    { --c1: #dc2626; --c2: #fb7185; --c3: #7f1d1d; }
.t-orange { --c1: #ea580c; --c2: #fbbf24; --c3: #9a3412; }
.t-indigo { --c1: #4338ca; --c2: #a78bfa; --c3: #1e1b4b; }
.t-green  { --c1: #16a34a; --c2: #a3e635; --c3: #14532d; }
.t-teal   { --c1: #0d9488; --c2: #22d3ee; --c3: #134e4a; }
.t-pink   { --c1: #db2777; --c2: #a855f7; --c3: #831843; }

/* ---------- background ---------- */
.bg {
  position: absolute; inset: -10%; opacity: 0; transition: opacity 1s ease;
  background:
    radial-gradient(95% 42% at 50% 104%, var(--c2) 0%, transparent 62%),
    radial-gradient(130% 62% at 50% 112%, var(--c1) 0%, transparent 72%),
    radial-gradient(70% 38% at 100% -2%, var(--c2) 0%, transparent 70%),
    radial-gradient(55% 34% at -8% 48%, var(--c3) 0%, transparent 78%),
    var(--bg);
  animation: breathe 9s ease-in-out infinite alternate;
}
.bg.on { opacity: 1; }
@keyframes breathe {
  0% { transform: scale(1) translate3d(0, 0, 0); filter: saturate(1); }
  100% { transform: scale(1.08) translate3d(0, -2%, 0); filter: saturate(1.25); }
}
.grain {
  position: absolute; inset: 0; pointer-events: none; opacity: .09; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.sparks { position: absolute; inset: 0; pointer-events: none; }
.spark {
  position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #fff;
  opacity: 0; animation: float 7s linear infinite; box-shadow: 0 0 10px 2px rgba(255,255,255,.6);
}
@keyframes float {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  15% { opacity: .8; }
  100% { transform: translateY(-60vh) scale(1.2); opacity: 0; }
}

/* ---------- progress ---------- */
.progress {
  position: absolute; z-index: 5; left: 12px; right: 12px;
  top: calc(var(--safe-top) + 10px);
  display: flex; gap: 4px; transition: opacity .4s;
}
.progress.hidden { opacity: 0; }
.seg { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.25); overflow: hidden; }
.seg i { display: block; height: 100%; width: 0; background: #fff; border-radius: 3px; }
.seg.done i { width: 100%; }
.seg.cur i { animation: fill var(--dur, 7s) linear forwards; }
.paused .seg.cur i { animation-play-state: paused; }
@keyframes fill { to { width: 100%; } }

/* ---------- slides ---------- */
.slides { position: absolute; inset: 0; }
.slide {
  position: absolute; inset: 0;
  padding: calc(var(--safe-top) + 44px) 24px calc(var(--safe-bottom) + 28px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  transition: transform .55s cubic-bezier(.2,.8,.2,1), opacity .45s ease, filter .45s ease;
}
.slide.enter { opacity: 0; transform: translateX(14%) scale(.96); }
.slide.enter.back { transform: translateX(-14%) scale(.96); }
.slide.leave { opacity: 0; transform: translateX(-12%) scale(.94); filter: blur(6px); pointer-events: none; }
.slide.leave.back { transform: translateX(12%) scale(.94); }

.r { opacity: 0; transform: translateY(18px); }
.slide.live .r { animation: rise .7s cubic-bezier(.2,.8,.2,1) forwards; animation-delay: calc(var(--d, 0) * 110ms + 120ms); }
@keyframes rise { to { opacity: 1; transform: none; } }

.title {
  font-family: var(--head); font-weight: 700; font-size: clamp(21px, 6vw, 27px); line-height: 1.15;
  letter-spacing: -.01em; margin: 0 0 12px; text-wrap: balance;
}
.sub { font-size: clamp(14px, 3.9vw, 16px); line-height: 1.4; color: var(--dim); max-width: 340px; margin: 0 auto; font-weight: 600; text-wrap: balance; }

.sticker { width: min(58vw, 260px); aspect-ratio: 1; margin: 18px auto 14px; position: relative; }
.sticker::after {
  content: ''; position: absolute; left: 15%; right: 15%; bottom: -2%; height: 12%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0,0,0,.45), transparent); z-index: -1;
}
.slide.live .sticker { animation: pop .8s cubic-bezier(.2,1.4,.3,1) .1s both; }
@keyframes pop { 0% { transform: scale(.4) rotate(-8deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.sticker svg { filter: drop-shadow(0 12px 30px rgba(0,0,0,.35)); }

.label { font-size: 15px; color: var(--dim); font-weight: 700; max-width: 320px; margin: 4px auto 4px; text-wrap: balance; }
.value {
  font-family: var(--head); font-weight: 800; font-size: clamp(46px, 15vw, 72px); line-height: 1.02;
  letter-spacing: -.03em; font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff 30%, rgba(255,255,255,.78));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 40px rgba(255,255,255,.12);
}
.suffix { font-family: var(--head); font-weight: 700; font-size: clamp(18px, 5.4vw, 24px); margin-top: 2px; }
.note {
  margin-top: 18px; display: inline-block; padding: 10px 16px; border-radius: 16px;
  background: var(--glass); border: 1px solid var(--glass-b); font-size: 14px; font-weight: 700;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); max-width: 340px; line-height: 1.35;
}

/* intro */
.kicker { font-family: var(--head); font-size: 13px; letter-spacing: .24em; text-transform: uppercase; color: var(--dim); margin-bottom: 8px; }
.big-year {
  font-family: var(--head); font-weight: 900; font-size: clamp(84px, 28vw, 128px); line-height: .9; letter-spacing: -.05em;
  background: linear-gradient(120deg, #fff, var(--c2) 45%, #fff 90%); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 4s linear infinite;
}
@keyframes shine { to { background-position: -200% 0; } }
.intro-title { font-family: var(--head); font-weight: 700; font-size: clamp(20px, 5.6vw, 25px); margin: 10px 0 10px; text-wrap: balance; }

.btn {
  appearance: none; border: 0; cursor: pointer; font-family: var(--head); font-weight: 700; font-size: 16px;
  padding: 17px 28px; border-radius: 999px; background: #fff; color: #120f1d; min-width: 220px;
  box-shadow: 0 10px 40px rgba(255,255,255,.18); transition: transform .15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.96); }
.btn.ghost { background: var(--glass); color: #fff; border: 1px solid var(--glass-b); box-shadow: none; }
.btn.small { padding: 12px 18px; font-size: 14px; min-width: 0; font-family: var(--body); font-weight: 800; white-space: nowrap; }
.btn[disabled] { opacity: .6; }
.cta { margin-top: 28px; }
.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 10px 50px rgba(255,255,255,.35), 0 0 0 8px rgba(255,255,255,.08); } }
.hint { margin-top: 14px; font-size: 13px; color: var(--dimmer); font-weight: 600; }

/* facts */
.facts { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 10px; margin-top: 6px; text-align: left; }
.fact {
  display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 20px;
  background: var(--glass); border: 1px solid var(--glass-b); font-size: 14.5px; line-height: 1.35; font-weight: 700;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.fact b { font-size: 26px; flex: none; }
.slide .sticker.sm { width: min(40vw, 170px); margin: 6px auto 10px; }

/* persona */
.persona {
  font-family: var(--head); font-weight: 900; font-size: clamp(32px, 10vw, 46px); line-height: 1.02; letter-spacing: -.03em;
  margin: 2px 0 12px; text-wrap: balance;
  background: linear-gradient(100deg, #fff 10%, var(--c2) 60%, #fff); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; max-width: 360px; }
.tag { padding: 8px 13px; border-radius: 999px; background: rgba(255,255,255,.14); font-size: 13px; font-weight: 800; }

/* final */
.final-head { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; max-width: 380px; margin-bottom: 14px; }
.final-head .sticker { width: 92px; margin: 0; flex: none; }
.final-head .k { font-size: 12px; color: var(--dim); font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.final-head .p { font-family: var(--head); font-weight: 800; font-size: 24px; line-height: 1.05; margin-top: 4px; }
.final-head .w { font-size: 13px; color: var(--dim); font-weight: 700; margin-top: 6px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 380px; }
.tile {
  padding: 14px 16px; border-radius: 20px; background: var(--glass); border: 1px solid var(--glass-b); text-align: left;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.tile .v { font-family: var(--head); font-weight: 800; font-size: clamp(20px, 6vw, 26px); letter-spacing: -.02em; }
.tile .l { font-size: 13px; color: var(--dim); font-weight: 700; margin-top: 2px; }
.final-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 380px; margin-top: 18px; }
.final-actions .btn { width: 100%; white-space: nowrap; }
.final-actions .btn:first-child { font-size: 15px; padding: 17px 16px; }
.row2 { display: flex; gap: 10px; }
.row2 .btn { flex: 1; }

/* ---------- full screens (loading / subscribe / disabled) ---------- */
.screen { position: absolute; inset: 0; z-index: 6; display: none; }
.screen.on { display: flex; }
.screen .slide { position: relative; flex: 1; }
.loader-dots { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }
.loader-dots span, .card-loading span { width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: dot 1.1s infinite ease-in-out; }
.loader-dots span:nth-child(2), .card-loading span:nth-child(2) { animation-delay: .15s; }
.loader-dots span:nth-child(3), .card-loading span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

.channels { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 10px; margin: 18px 0 6px; }
.chan {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; border-radius: 20px;
  background: var(--glass); border: 1px solid var(--glass-b); text-align: left;
}
.chan .n { flex: 1; font-weight: 800; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan .ok { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #22c55e; font-size: 16px; flex: none; }
.chan.need { border-color: rgba(255,255,255,.35); }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---------- share sheet ---------- */
.sheet-wrap { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); opacity: 0; transition: opacity .3s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 18px calc(var(--safe-bottom) + 18px);
  background: #17141f; border-radius: 26px 26px 0 0; transform: translateY(105%);
  transition: transform .45s cubic-bezier(.2,.9,.2,1); max-height: 92%; overflow-y: auto;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sheet-wrap.on { pointer-events: auto; }
.sheet-wrap.on .sheet-backdrop { opacity: 1; }
.sheet-wrap.on .sheet { transform: none; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.2); margin: 0 auto 12px; }
.sheet-title { font-family: var(--head); font-weight: 700; font-size: 18px; text-align: center; margin-bottom: 14px; }
.card-preview {
  width: min(46vw, 200px); aspect-ratio: 9 / 16; margin: 0 auto 16px; border-radius: 18px; overflow: hidden;
  background: rgba(255,255,255,.06); display: grid; place-items: center; box-shadow: 0 20px 50px rgba(0,0,0,.5);
}
.card-preview img { width: 100%; height: 100%; object-fit: cover; display: block; animation: fadein .5s; }
@keyframes fadein { from { opacity: 0; transform: scale(.96); } }
.card-loading { display: flex; gap: 6px; }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.share-grid .btn { width: 100%; min-width: 0; font-family: var(--body); font-weight: 800; font-size: 15px; padding: 15px 10px; white-space: nowrap; }
.share-grid .btn.wide { grid-column: 1 / -1; }

.toast {
  position: absolute; z-index: 30; left: 50%; bottom: calc(var(--safe-bottom) + 24px); transform: translate(-50%, 30px);
  background: #fff; color: #111; padding: 12px 18px; border-radius: 14px; font-weight: 800; font-size: 14px;
  opacity: 0; transition: all .3s; pointer-events: none; white-space: nowrap;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 700px) {
  .sticker { width: min(46vw, 190px); margin: 10px auto 8px; }
  .slide .sticker.sm { width: 120px; }
  .note { margin-top: 12px; }
  .final-head .sticker { width: 72px; }
  .tile { padding: 11px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .bg, .big-year, .pulse { animation: none; }
}
