.otp-card {
  --accent: var(--cyan);
  position: relative;
  width: min(420px, 100%);
  padding: 34px 32px 26px;
  border-radius: 28px;
  text-align: center;
  background:
    linear-gradient(160deg, rgb(255 255 255 / 0.1), rgb(255 255 255 / 0.03) 45%),
    rgb(14 16 40 / 0.55);
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.12),
    0 30px 60px rgb(0 0 0 / 0.45),
    0 0 0 0 transparent;
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  transition: box-shadow 0.6s ease, border-color 0.6s ease;
}

.otp-card[data-state="success"] {
  --accent: var(--green);
  border-color: rgb(34 227 154 / 0.45);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.12), 0 30px 60px rgb(0 0 0 / 0.45), 0 0 60px rgb(34 227 154 / 0.25);
}

.otp-card[data-state="error"] { --accent: var(--red); animation: otp-shake 0.5s; }

/* Overlay that hosts the flying digits; never blocks clicks. */
.otp-fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

.otp-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  transition: color 0.5s, background 0.5s, border-color 0.5s;
}

.otp-title { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.4px; }
.otp-title span { color: var(--accent); transition: color 0.5s; }
.otp-title.bad span { color: var(--red); }
.otp-sub { margin: 8px 0 26px; color: var(--muted); font-size: 14px; }
.otp-sub b { color: var(--text); font-weight: 600; }

.otp-inputs {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 14px;
  height: 72px;
}

.otp-digit {
  width: 60px;
  height: 72px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  background: rgb(255 255 255 / 0.05);
  color: var(--text);
  font: 700 30px/1 var(--font);
  text-align: center;
  caret-color: var(--cyan);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s, opacity 0.25s, transform 0.25s;
}

.otp-digit:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgb(0 229 255 / 0.18), 0 0 24px rgb(0 229 255 / 0.25);
  background: rgb(0 229 255 / 0.06);
}

.otp-digit.filled { border-color: rgb(123 92 255 / 0.7); background: rgb(123 92 255 / 0.12); }
.otp-digit.emptied { color: transparent; opacity: 0.25; transform: scale(0.92); }
.otp-card[data-state="success"] .otp-digit { opacity: 0; transform: scale(0.8); }

/* A digit while it flies around the orbit */
.otp-orbit { position: absolute; width: 0; height: 0; }

.otp-chip {
  position: absolute;
  left: -24px;
  top: -28px;
  width: 48px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font: 700 28px/1 var(--font);
  color: #fff;
  background: linear-gradient(160deg, rgb(123 92 255 / 0.55), rgb(0 229 255 / 0.35));
  border: 1px solid rgb(255 255 255 / 0.35);
  box-shadow: 0 0 22px rgb(123 92 255 / 0.55);
}

/* Centre badge: spinner -> check or cross */
.otp-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.3s, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.4s;
}

.otp-badge::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(from 0deg, transparent 0 25%, var(--violet), var(--cyan));
  /* Cut the middle out so only a 4px ring remains. */
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: otp-spin 0.8s linear infinite;
  transition: opacity 0.3s;
}

.otp-badge svg {
  position: absolute;
  width: 38px;
  height: 38px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
}

.otp-badge.spinning, .otp-badge.ok, .otp-badge.error { opacity: 1; transform: scale(1); }
.otp-badge.ok, .otp-badge.error { transform: scale(1.12); }
.otp-badge.ok { background: linear-gradient(140deg, #22e39a, #00b8d9); box-shadow: 0 0 40px rgb(34 227 154 / 0.6); }
.otp-badge.error { background: linear-gradient(140deg, #ff4d6d, #ff8a5c); box-shadow: 0 0 40px rgb(255 77 109 / 0.55); }
.otp-badge.ok::before, .otp-badge.error::before { opacity: 0; }
.otp-badge.ok .otp-check, .otp-badge.error .otp-cross { animation: otp-draw 0.45s 0.15s ease-out forwards; }

.otp-spark {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
}

.otp-resend { margin: 22px 0 18px; color: var(--muted); font-size: 13px; transition: opacity 0.3s; }
.otp-card[data-state="success"] .otp-resend { opacity: 0; visibility: hidden; }

.otp-resend-btn {
  border: 0;
  background: none;
  padding: 4px;
  font: inherit;
  font-weight: 600;
  color: var(--cyan);
  cursor: pointer;
}

.otp-resend-btn:disabled { color: var(--muted); cursor: default; }
.otp-timer { font-variant-numeric: tabular-nums; }

.otp-submit {
  position: relative;
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font: 700 16px/1 var(--font);
  color: #fff;
  cursor: pointer;
  background: linear-gradient(100deg, var(--violet), #4d7cff 55%, var(--cyan));
  box-shadow: 0 12px 30px rgb(123 92 255 / 0.35);
  transition: filter 0.2s, transform 0.15s, opacity 0.2s, background 0.5s, box-shadow 0.5s;
}

.otp-submit:hover:not(:disabled) { filter: brightness(1.1); }
.otp-submit:active:not(:disabled) { transform: scale(0.98); }
.otp-submit:disabled { opacity: 0.45; cursor: not-allowed; }
.otp-submit:focus-visible { outline: 3px solid rgb(0 229 255 / 0.6); outline-offset: 3px; }

.otp-card[data-state="verifying"] .otp-submit { opacity: 1; cursor: progress; }
.otp-card[data-state="success"] .otp-submit {
  opacity: 1;
  background: linear-gradient(100deg, #12b886, var(--green));
  box-shadow: 0 12px 30px rgb(34 227 154 / 0.35);
}

.otp-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgb(255 255 255 / 0.35);
  border-top-color: #fff;
  animation: otp-spin 0.7s linear infinite;
}

.otp-card[data-state="verifying"] .otp-spinner { display: block; }

.otp-hint { margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.otp-hint code { color: var(--text); font-family: var(--mono); letter-spacing: 2px; }

.otp-status { min-height: 18px; margin: 10px 0 0; font-size: 13px; color: var(--accent); }

@keyframes otp-spin { to { transform: rotate(360deg); } }
@keyframes otp-draw { to { stroke-dashoffset: 0; } }

@keyframes otp-shake {
  0%, 100% { translate: 0; }
  20% { translate: -10px; }
  40% { translate: 9px; }
  60% { translate: -6px; }
  80% { translate: 4px; }
}
