:root {
  --bg: #0b0a12;
  --card: rgba(22, 20, 34, 0.72);
  --border: rgba(255, 255, 255, 0.09);
  --text: #f4f2fb;
  --muted: #a39fb8;
  --error: #ff6b8b;
  --grad: linear-gradient(90deg, #feda75, #fa7e1e, #d62976, #962fbf, #4f5bd5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Space Grotesk", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-x: hidden;
}

/* ---------- animated background ---------- */
.bg-blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; filter: blur(70px); opacity: 0.55; }
.bg-blobs span { position: absolute; border-radius: 50%; animation: float 18s ease-in-out infinite; }
.bg-blobs span:nth-child(1) { width: 420px; height: 420px; background: #d62976; top: -120px; left: -100px; }
.bg-blobs span:nth-child(2) { width: 360px; height: 360px; background: #4f5bd5; bottom: -120px; right: -80px; animation-delay: -6s; }
.bg-blobs span:nth-child(3) { width: 300px; height: 300px; background: #fa7e1e; top: 40%; left: 55%; animation-delay: -12s; opacity: 0.7; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(60px, 40px) scale(1.1); }
  66% { transform: translate(-40px, 60px) scale(0.95); }
}

/* ---------- card ---------- */
.card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 36px 28px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.screen { display: none; }
.screen.active { display: block; animation: pop 0.45s cubic-bezier(.2,.9,.3,1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }

.badge {
  display: inline-block;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  margin-bottom: 18px;
}

h1 { font-size: clamp(2.3rem, 9vw, 3rem); line-height: 1.02; font-weight: 700; letter-spacing: -0.03em; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { color: var(--muted); margin: 14px auto 26px; max-width: 34ch; line-height: 1.5; }

/* ---------- form ---------- */
.input-wrap {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 0 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-wrap:focus-within { border-color: #d62976; box-shadow: 0 0 0 4px rgba(214, 41, 118, 0.18); }
.input-wrap.shake { animation: shake 0.4s; border-color: var(--error); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.at { color: var(--muted); font-size: 1.15rem; font-weight: 500; }
#handle {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  font-size: 1.15rem;
  padding: 16px 8px;
  min-width: 0;
}
#handle::placeholder { color: #5f5a76; }

.error { color: var(--error); font-size: 0.85rem; min-height: 1.3em; margin: 8px 0 4px; text-align: left; padding-left: 4px; }

.btn {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 16px 20px;
  font: inherit;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(90deg, #d62976, #962fbf, #4f5bd5, #962fbf, #d62976, #f0582e, #d62976);
  background-size: 200% 100%;
  animation: shimmer 4s linear infinite;
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 10px 30px rgba(214, 41, 118, 0.35);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(214, 41, 118, 0.5); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-emoji { display: inline-block; transition: transform 0.3s; }
.btn:hover .btn-emoji { transform: rotate(20deg) scale(1.2); }
@keyframes shimmer { to { background-position: 200% 0; } }

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid var(--border);
  animation: none;
  box-shadow: none;
}
.btn-ghost:hover { box-shadow: none; background: rgba(255, 255, 255, 0.1); }

.fineprint { color: #6f6a86; font-size: 0.72rem; margin-top: 18px; line-height: 1.5; }

/* ---------- loader ---------- */
.scanning { color: var(--muted); margin-bottom: 18px; }
.scanning strong { color: var(--text); }

.ring-wrap { position: relative; width: 190px; height: 190px; margin: 0 auto 18px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.07); stroke-width: 9; }
.ring-fg {
  fill: none;
  stroke: url(#ringGrad);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 0.35s ease;
  filter: drop-shadow(0 0 6px rgba(214, 41, 118, 0.6));
}
.pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 2.8rem;
  font-weight: 600;
}
.pct small { font-size: 1.2rem; color: var(--muted); margin-left: 2px; }
.ring-wrap.tense .pct { animation: pulse 0.7s ease-in-out infinite; }
.ring-wrap.tense .ring { animation: wobble 0.15s linear infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
@keyframes wobble { 0% { transform: rotate(-90deg) translate(0,0); } 25% { transform: rotate(-90deg) translate(1px,-1px); } 75% { transform: rotate(-90deg) translate(-1px,1px); } }

.bar { height: 6px; background: rgba(255, 255, 255, 0.07); border-radius: 99px; overflow: hidden; margin-bottom: 16px; }
.bar-fill { height: 100%; width: 0; background: var(--grad); transition: width 0.35s ease; }

.status {
  font-weight: 500;
  min-height: 3em;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.4;
}
.status.swap { animation: swap 0.35s ease; }
@keyframes swap { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.checks {
  list-style: none;
  text-align: left;
  margin-top: 14px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  color: var(--muted);
  max-height: 132px;
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  mask-image: linear-gradient(to bottom, transparent, #000 40%);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 40%);
}
.checks li { display: flex; justify-content: space-between; gap: 10px; animation: swap 0.3s ease; }
.checks li .ok { color: #7cf2a6; white-space: nowrap; }

/* ---------- result ---------- */
.result-for { color: var(--muted); }
.result-for strong { color: var(--text); }
.result-emoji { font-size: 5rem; margin: 18px 0 6px; animation: bounce 1.2s ease infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
.result-text { font-size: clamp(1.6rem, 6.5vw, 2.1rem); line-height: 1.15; letter-spacing: -0.02em; }
.result-sub { color: var(--muted); margin: 12px auto 26px; max-width: 32ch; line-height: 1.5; }
.actions { display: grid; gap: 10px; }
.share-msg { color: #7cf2a6; font-size: 0.85rem; min-height: 1.3em; margin-top: 10px; }

.foot { color: #5f5a76; font-size: 0.72rem; margin-top: 22px; text-align: center; }

/* ---------- live counter (bottom-right) ---------- */
.counter {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(22, 20, 34, 0.8);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 0.8rem;
  color: var(--muted);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: pop 0.45s ease;
}
.counter[hidden] { display: none; }
.counter strong {
  color: var(--text);
  font-family: "JetBrains Mono", monospace;
  font-weight: 600;
  display: inline-block;
}
.counter strong.bump { animation: bump 0.5s ease; }
@keyframes bump { 40% { transform: scale(1.35); color: #ff7ab6; } }
.counter .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7cf2a6;
  box-shadow: 0 0 0 0 rgba(124, 242, 166, 0.6);
  animation: live 2s infinite;
}
@keyframes live { 70% { box-shadow: 0 0 0 7px rgba(124, 242, 166, 0); } 100% { box-shadow: 0 0 0 0 rgba(124, 242, 166, 0); } }

@media (max-width: 480px) {
  body { padding-bottom: 72px; }
  .counter { right: 12px; bottom: 12px; font-size: 0.75rem; }
}

/* ---------- confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.confetti i {
  position: absolute;
  top: -20px;
  font-style: normal;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: 0.8; } }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}