/* ---------- BASE ---------- */
* { box-sizing: border-box; margin: 0; }

:root {
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --ok: #22c55e;
  --bad: #f43f5e;
  --text: #f4f3ff;
  --muted: #a9a3c9;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);   /* the column may never grow wider than the screen */
  place-items: center;
  padding: 24px 16px;
  background: #0e0a1f;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
/* ---------- END BASE ---------- */

/* ---------- BACKGROUND BLOBS ---------- */
.blobs { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.blobs i {
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .55;
  animation: drift 18s ease-in-out infinite alternate;
}
.blobs i:nth-child(1) { background: #7c3aed; top: -120px; left: -80px; }
.blobs i:nth-child(2) { background: #0891b2; bottom: -140px; right: -100px; animation-delay: -6s; }
.blobs i:nth-child(3) { background: #db2777; top: 40%; left: 55%; width: 300px; height: 300px; opacity: .35; animation-delay: -12s; }
/* ---------- END BACKGROUND BLOBS ---------- */

/* ---------- CARD ---------- */
.card {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 36px 28px 26px;
  border-radius: 24px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
  backdrop-filter: blur(18px);
  text-align: center;
  animation: rise .7s cubic-bezier(.2, .9, .3, 1.15) both;
}
.view[hidden] { display: none; }
.view { animation: fade .45s ease both; }

h1, h2 { font-size: 26px; margin-bottom: 8px; }
.sub { color: var(--muted); font-size: 14px; line-height: 1.5; margin-bottom: 24px; }
.sub b { color: var(--text); white-space: nowrap; }
/* ---------- END CARD ---------- */

/* ---------- SHIELD BADGE ---------- */
.badge {
  position: relative;
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px rgba(139, 92, 246, .45);
}
.badge svg { width: 38px; height: 38px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.badge .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent-2);
  animation: ping 2.4s ease-out infinite;
}
.badge .ring + .ring { animation-delay: 1.2s; }
/* ---------- END SHIELD BADGE ---------- */

/* ---------- DIGIT BOXES ---------- */
.boxes {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.boxes input {
  width: 50px;
  height: 60px;
  min-width: 0;
  flex: 0 1 50px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  font: 700 26px/1 ui-monospace, "SF Mono", Consolas, monospace;
  text-align: center;
  caret-color: var(--accent-2);
  transition: border-color .2s, box-shadow .2s, background .3s, transform .2s;
}
.boxes input:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, .18), 0 0 24px rgba(34, 211, 238, .25);
  transform: translateY(-3px);
}
.boxes input::selection { background: rgba(34, 211, 238, .3); }
.boxes input.filled { border-color: var(--accent); background: rgba(139, 92, 246, .16); }
.boxes input.pop { animation: pop .28s ease; }
.dash { width: 12px; height: 3px; flex: none; border-radius: 2px; background: rgba(255, 255, 255, .25); }

/* wrong code */
.boxes.bad { animation: shake .45s ease; }
.boxes.bad input { border-color: var(--bad); background: rgba(244, 63, 94, .14); color: #fecdd3; }

/* right code: each box turns green a moment after the one before (--i set in script.js) */
.boxes.good input {
  border-color: var(--ok);
  background: rgba(34, 197, 94, .18);
  animation: flip .5s ease both;
  animation-delay: calc(var(--i) * 70ms);
}

.msg { min-height: 20px; margin-bottom: 14px; font-size: 13px; color: var(--bad); }
/* ---------- END DIGIT BOXES ---------- */

/* ---------- VERIFY BUTTON ---------- */
.verify, .again {
  position: relative;
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  background-size: 200% 100%;
  color: #fff;
  font: 700 15px/1.2 system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(139, 92, 246, .4);
  transition: opacity .3s, transform .15s, background-position .5s;
}
.verify:hover:not(:disabled), .again:hover { background-position: 100% 0; transform: translateY(-1px); }
.verify:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.verify:focus-visible, .again:focus-visible, .resend-btn:focus-visible, .toast-use:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.verify.loading .label { visibility: hidden; }
.verify.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
/* ---------- END VERIFY BUTTON ---------- */

/* ---------- RESEND TIMER ---------- */
.resend { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; font-size: 14px; color: var(--muted); }
.timer { width: 22px; height: 22px; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 4; }
.timer-track { stroke: rgba(255, 255, 255, .12); }
.timer-fill {
  stroke: var(--accent-2);
  stroke-linecap: round;
  stroke-dasharray: 94.25;          /* 2 × π × 15, the full circle */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}
.resend b { color: var(--text); font-variant-numeric: tabular-nums; }
.resend-btn {
  border: 0;
  background: none;
  color: var(--accent-2);
  font: 600 14px/1 system-ui, sans-serif;
  cursor: pointer;
  padding: 4px;
}
.resend-btn:hover { text-decoration: underline; }
/* ---------- END RESEND TIMER ---------- */

/* ---------- SMS TOAST ---------- */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 10;
  width: calc(100% - 32px);
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(30, 27, 52, .92);
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
  backdrop-filter: blur(12px);
  text-align: left;
  transform: translate(-50%, -140%);
  transition: transform .55s cubic-bezier(.2, .9, .3, 1.2);
}
.toast[hidden] { display: none; }
.toast.show { transform: translate(-50%, 0); }
.toast-icon { font-size: 24px; }
.toast-text { flex: 1; font-size: 13px; line-height: 1.4; color: var(--muted); }
.toast-text strong { display: block; color: var(--text); font-size: 12px; }
.toast-code { color: var(--text); letter-spacing: 2px; }
.toast-use {
  flex: none;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: 600 13px/1 system-ui, sans-serif;
  cursor: pointer;
}
/* ---------- END SMS TOAST ---------- */

/* ---------- SUCCESS VIEW ---------- */
.check { width: 96px; height: 96px; margin: 4px auto 18px; display: block; }
.check circle, .check path { fill: none; stroke: var(--ok); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.check circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw .6s ease forwards; }
.check path { stroke-dasharray: 36; stroke-dashoffset: 36; animation: draw .35s ease forwards .55s; }
.success-view h2:focus { outline: none; }
.confetti {
  position: fixed;
  top: 0;
  left: 0;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 20;
}
/* ---------- END SUCCESS VIEW ---------- */

/* ---------- KEYFRAMES ---------- */
@keyframes drift { to { transform: translate(60px, 80px) scale(1.15); } }
@keyframes rise { from { opacity: 0; transform: translateY(30px) scale(.96); } }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } }
@keyframes ping { from { transform: scale(1); opacity: .8; } to { transform: scale(1.7); opacity: 0; } }
@keyframes pop { 50% { transform: translateY(-3px) scale(1.12); } }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
/* ---------- END KEYFRAMES ---------- */

/* ---------- SMALL SCREENS ---------- */
@media (max-width: 400px) {
  .card { padding: 28px 16px 22px; }
  .boxes { gap: 5px; }
  .boxes input { height: 52px; font-size: 22px; border-radius: 12px; }
  .dash { width: 8px; }
}
/* ---------- END SMALL SCREENS ---------- */

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: .01ms !important;
  }
}
/* ---------- END REDUCED MOTION ---------- */
