:root {
  --navy: #0d2a4a;
  --cyan: #1b85c4;
  --soft: #eaf5fc;
  --bg: #eef3f8;
  --card: #ffffff;
  --text: #0d2a4a;
  --muted: #5f758a;
  --line: #d5e3ef;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "Vazirmatn", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  overscroll-behavior-y: none;
}

/* —— Intro scenario —— */
.intro {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 24px;
  background: #040d18;
}
.intro.is-done {
  pointer-events: none;
  animation: introFade 0.55s ease forwards;
}
.intro-veil {
  position: absolute; inset: 0;
  background:
    radial-gradient(600px 400px at 50% 40%, rgba(27,133,196,0.28), transparent 60%),
    radial-gradient(500px 300px at 80% 80%, rgba(13,42,74,0.5), transparent 55%);
  animation: veilPulse 3.5s ease-in-out infinite;
}
.intro-line {
  position: relative; z-index: 1;
  margin: 0;
  max-width: 18ch;
  text-align: center;
  font-size: clamp(1.55rem, 7.2vw, 2.15rem);
  font-weight: 800;
  line-height: 1.55;
  color: #fff;
  opacity: 0;
  transform: scale(0.92) translateY(12px);
}
.intro-line.is-in {
  animation: lineIn 0.7s cubic-bezier(.2,.8,.2,1) forwards;
}
.intro-line.is-out {
  animation: lineOut 0.45s ease forwards;
}
.intro-skip {
  position: absolute;
  bottom: calc(18px + var(--safe-b));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.75);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

@keyframes lineIn {
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes lineOut {
  to { opacity: 0; transform: scale(1.04) translateY(-10px); }
}
@keyframes introFade {
  to { opacity: 0; visibility: hidden; }
}
@keyframes veilPulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

.app {
  width: min(100%, 430px);
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(12px + var(--safe-t)) 14px calc(20px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.app.is-hidden { visibility: hidden; }
.app.is-ready { animation: appIn 0.55s ease both; }
@keyframes appIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.bar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand img {
  width: 40px; height: 40px; border-radius: 50%; background: #fff;
  box-shadow: 0 6px 16px rgba(13,42,74,.12);
}
.brand strong { display: block; font-size: 0.98rem; }
.brand span { color: var(--cyan); font-size: 0.72rem; font-weight: 700; }

.countdown {
  background: linear-gradient(120deg, var(--navy), var(--cyan));
  color: #fff;
  border-radius: 14px;
  padding: 11px 14px;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.7;
  box-shadow: 0 8px 20px rgba(27,133,196,.22);
}

.hero-copy {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px 14px 14px;
  box-shadow: 0 10px 28px rgba(13,42,74,.05);
  text-align: center;
}
.eyebrow {
  margin: 0 0 4px; color: var(--cyan); font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.02em;
}
.hero-copy h1 {
  margin: 0 0 8px; font-size: clamp(1.55rem, 7vw, 2rem); font-weight: 800;
}
.highlight {
  margin: 0 0 8px;
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(13,42,74,.08), rgba(27,133,196,.14));
  color: var(--navy);
  font-size: 0.95rem;
  font-weight: 700;
}
.highlight b { color: var(--cyan); font-size: 1.05em; }
.lede {
  margin: 0 0 10px; color: var(--muted); font-size: 0.86rem; line-height: 1.8;
}
.lede b { color: var(--navy); }
.rules {
  margin: 0; padding: 0;
  list-style: none;
  display: grid; gap: 6px;
  text-align: right;
}
.rules li {
  position: relative;
  padding: 8px 28px 8px 10px;
  border-radius: 12px;
  background: var(--soft);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.5;
}
.rules li::before {
  content: "";
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%) rotate(45deg);
  width: 8px; height: 8px; background: var(--cyan);
}

.wheel-block {
  background: linear-gradient(180deg, #fff, #f4f9fd);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 14px 12px 16px;
  box-shadow: 0 10px 28px rgba(13,42,74,.06);
  text-align: center;
}
.wheel-box {
  position: relative;
  width: min(82vw, 320px);
  aspect-ratio: 1;
  margin: 0 auto 12px;
}
#wheel { width: 100%; height: 100%; display: block; filter: drop-shadow(0 12px 18px rgba(13,42,74,.12)); }
.needle {
  position: absolute; top: -2px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; z-index: 3;
  border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-top: 16px solid var(--cyan);
}
.hub {
  position: absolute; inset: 37%; border: 0; border-radius: 50%;
  background: #fff; cursor: pointer; z-index: 4;
  display: grid; place-items: center;
  box-shadow: 0 8px 18px rgba(13,42,74,.18), inset 0 0 0 3px var(--navy);
}
.hub img { width: 58%; height: 58%; object-fit: contain; border-radius: 50%; }

.cta {
  width: 100%; border: 0; border-radius: 16px; padding: 14px 16px;
  font-family: var(--font); font-size: 1.05rem; font-weight: 800; color: #fff;
  cursor: pointer;
  background: linear-gradient(120deg, var(--navy), var(--cyan));
  box-shadow: 0 12px 24px rgba(27,133,196,.28);
}
.cta:disabled { opacity: .45; cursor: not-allowed; }
.hint { margin: 10px 0 0; color: var(--muted); font-size: 0.78rem; min-height: 1.2em; }

.prize {
  margin-top: 12px; padding: 14px 12px; border-radius: 16px;
  background: linear-gradient(180deg, #f7fbfe, var(--soft));
  border: 1px solid rgba(27,133,196,.28);
  animation: appIn .35s ease;
}
.prize.hidden { display: none; }
.pct {
  font-size: 2.15rem; font-weight: 800; color: var(--cyan);
  letter-spacing: 0.02em;
}
.scratch-hint {
  margin: 2px 0 10px; color: var(--muted); font-size: 0.78rem; font-weight: 600;
}
.scratch-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  min-height: 64px;
  margin-bottom: 10px;
  user-select: none;
  touch-action: none;
}
.code {
  display: grid; place-items: center;
  min-height: 64px;
  font-size: 1.15rem; font-weight: 800;
  letter-spacing: .08em; color: var(--navy);
  padding: 14px 10px;
}
#scratch {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  cursor: crosshair;
  z-index: 2;
}
.copy {
  border: 1px solid rgba(27,133,196,.35); background: #fff; color: var(--cyan);
  border-radius: 999px; padding: 8px 16px; font-family: var(--font); font-weight: 700; cursor: pointer;
}
.copy:disabled { opacity: 0.4; cursor: not-allowed; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 6px; text-align: center;
}
.stat span { display: block; color: var(--muted); font-size: 0.66rem; margin-bottom: 4px; }
.stat b { font-size: 1rem; }

.dist {
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px;
}
.dist-title { margin: 0 0 10px; font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.bar-row {
  display: grid; grid-template-columns: 4.4rem 1fr 1.8rem; gap: 6px;
  align-items: center; margin-bottom: 7px;
}
.bar-row span, .bar-row b { font-size: 0.72rem; color: var(--muted); }
.bar-row b { text-align: left; color: var(--text); }
.bar-track { height: 7px; border-radius: 99px; background: #e7eef5; overflow: hidden; }
.bar-fill {
  height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--navy), var(--cyan));
  transition: width .7s ease;
}
.foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 10px 6px;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.foot .tg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  direction: ltr;
  text-decoration: none;
  color: var(--navy);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid rgba(27,133,196,0.18);
  min-width: min(100%, 260px);
}
.foot .tg-inline {
  min-width: auto;
  padding: 8px 12px;
}
.foot .tg-plain {
  background: transparent;
  border-color: transparent;
  color: var(--cyan);
  padding-inline: 4px;
}
.foot .star { font-size: 1rem; line-height: 1; }
.foot .handle { letter-spacing: 0.01em; unicode-bidi: isolate; }
.foot .sep {
  color: #b0c0ce;
  font-weight: 700;
  line-height: 1;
}
.foot-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}
