:root {
  --primary: #263a85;
  --primary-2: #3b67c9;
  --accent: #d4a017;
  --ok: #059669;
  --bad: #dc2626;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #eef3ff 0%, #fffaf0 55%, #fdf3d8 100%);
  min-height: 100vh;
  position: relative;
  isolation: isolate;
}

.shell { max-width: 640px; margin: 0 auto; padding: 28px 16px 48px; }

.hero { text-align: center; margin-bottom: 20px; }
.badge {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  background: rgba(38,58,133,.1); color: var(--primary);
  font-size: .8rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
.hero h1 { margin: 12px 0 6px; font-size: clamp(1.6rem, 5vw, 2.2rem); line-height: 1.15; }
.hero p { margin: 0; color: var(--muted); }

.card {
  background: var(--card); border-radius: 20px; padding: 24px 20px 20px;
  box-shadow: 0 10px 40px -12px rgba(15,23,42,.18), 0 2px 6px rgba(15,23,42,.05);
}
@media (min-width: 520px) { .card { padding: 32px 32px 26px; } }

/* Progreso */
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress__bar {
  height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary-2), var(--accent));
  transition: width .35s ease, background .3s;
}
.progress__bar.is-done { background: linear-gradient(90deg, #10b981, #059669); }
.progress__label { margin: 8px 0 18px; font-size: .8rem; color: var(--muted); text-align: right; }

/* Campos */
.row { display: grid; gap: 0 14px; }
@media (min-width: 520px) { .row { grid-template-columns: 1fr 1fr; } }

.field { margin-bottom: 18px; position: relative; }
.field > label, .field > #lbl-genero { display: block; margin-bottom: 6px; font-size: .9rem; font-weight: 600; }

.field input[type="text"], .field input[type="email"], .field input[type="tel"], .field input[type="date"] {
  width: 100%; height: 50px; padding: 0 14px; font: inherit; font-size: 1rem; color: var(--ink);
  background: #f8fafc; border: 1.5px solid var(--line); border-radius: 12px; outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
  -webkit-appearance: none; appearance: none;
}
.field input::placeholder { color: #94a3b8; }
.field input:focus {
  background: #fff; border-color: var(--primary-2); box-shadow: 0 0 0 4px rgba(59,103,201,.18);
}
.field.is-valid input[type="text"], .field.is-valid input[type="email"],
.field.is-valid input[type="tel"], .field.is-valid input[type="date"] { border-color: var(--ok); background: #f0fdf4; }
.field.is-invalid input[type="text"], .field.is-invalid input[type="email"],
.field.is-invalid input[type="tel"], .field.is-invalid input[type="date"] { border-color: var(--bad); background: #fef2f2; }

.msg { display: block; min-height: 0; margin-top: 6px; font-size: .82rem; color: var(--bad); }
.msg:empty { display: none; }

.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }

/* Género */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice { cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 50px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #f8fafc;
  font-weight: 600; transition: all .2s;
}
.choice i { font-style: normal; font-size: 1.2rem; }
.choice:hover span { border-color: var(--primary-2); }
.choice input:checked + span {
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff;
  border-color: transparent; box-shadow: 0 8px 18px -8px rgba(38,58,133,.7); transform: translateY(-1px);
}
.choice input:focus-visible + span { box-shadow: 0 0 0 4px rgba(59,103,201,.3); }
.field.is-invalid .choice span { border-color: var(--bad); }

/* Edad */
.age {
  display: flex; align-items: baseline; gap: 10px; margin-top: 12px; padding: 12px 16px;
  border-radius: 12px; background: linear-gradient(135deg, rgba(59,103,201,.1), rgba(6,182,212,.12));
  border: 1px solid rgba(59,103,201,.25);
}
.age__num { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.age__txt { color: var(--muted); font-weight: 600; }
.age.pop { animation: pop .35s ease; }
.age.is-warn { background: #fef2f2; border-color: #fecaca; }
.age.is-warn .age__num { color: var(--bad); }
@keyframes pop { 0% { transform: scale(.92); opacity: .4; } 60% { transform: scale(1.03); } 100% { transform: scale(1); opacity: 1; } }

/* Botones */
.btn {
  position: relative; width: 100%; height: 54px; margin-top: 6px; border: 0; border-radius: 14px;
  font: inherit; font-size: 1.05rem; font-weight: 700; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 12px 24px -10px rgba(38,58,133,.8);
  transition: transform .15s, box-shadow .2s, opacity .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: progress; opacity: .85; transform: none; }
.btn--ghost { background: #fff; color: var(--primary); border: 1.5px solid var(--primary-2); box-shadow: none; }
.btn__spin {
  display: none; width: 22px; height: 22px; margin: auto; position: absolute; inset: 0;
  border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn.is-loading .btn__txt { visibility: hidden; }
.btn.is-loading .btn__spin { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.alert {
  margin: 14px 0 0; padding: 12px 14px; border-radius: 12px; font-size: .92rem;
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
}
.legal { margin: 14px 0 0; text-align: center; font-size: .78rem; color: var(--muted); }

/* Honeypot fuera de pantalla */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Éxito */
.success { text-align: center; padding: 16px 0 6px; }
.success h2 { margin: 14px 0 6px; font-size: 1.6rem; }
.success p { margin: 0 0 20px; color: var(--muted); }
.check { width: 84px; height: 84px; }
.check circle { stroke: var(--ok); stroke-width: 3; stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw .6s ease forwards; }
.check path { stroke: var(--ok); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .4s .5s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } .check circle, .check path { stroke-dashoffset: 0; } }

/* Teléfono con prefijo de Honduras */
.phone { display: flex; align-items: stretch; }
.phone__prefix {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 50px; font-weight: 700;
  background: #eaf0ff; color: var(--primary); border: 1.5px solid var(--line); border-right: 0;
  border-radius: 12px 0 0 12px; white-space: nowrap;
}
.phone__prefix svg { border-radius: 3px; box-shadow: 0 0 0 1px rgba(15,23,42,.15); }
.field .phone input[type="tel"] { border-radius: 0 12px 12px 0; letter-spacing: .06em; }
.field.is-valid .phone__prefix { border-color: var(--ok); }
.field.is-invalid .phone__prefix { border-color: var(--bad); }

/* Logos */
.topbar {
  background: #fff; border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 18px -12px rgba(15,23,42,.35);
  padding: 12px 16px; text-align: center;
}
.topbar img { display: block; width: 100%; max-width: 460px; height: auto; margin: 0 auto; }
.hero__logo { display: block; width: auto; height: 84px; margin: 0 auto 14px; }
@media (min-width: 520px) { .hero__logo { height: 96px; } }

/* Fondo degradado animado (estilo iCloud) */
body::before, body::after {
  content: ""; position: fixed; inset: -25%; z-index: -1; pointer-events: none;
  filter: blur(60px) saturate(1.15); will-change: transform;
}
body::before {
  background:
    radial-gradient(38% 38% at 18% 25%, rgba(38,58,133,.50), transparent 70%),
    radial-gradient(34% 34% at 82% 18%, rgba(212,160,23,.50), transparent 70%),
    radial-gradient(40% 40% at 72% 82%, rgba(59,103,201,.40), transparent 70%);
  animation: drift-a 18s ease-in-out infinite alternate;
}
body::after {
  background:
    radial-gradient(36% 36% at 28% 78%, rgba(240,196,70,.55), transparent 70%),
    radial-gradient(30% 30% at 88% 55%, rgba(96,150,230,.40), transparent 70%),
    radial-gradient(28% 28% at 48% 8%, rgba(184,134,11,.30), transparent 70%);
  animation: drift-b 24s ease-in-out infinite alternate;
}
@keyframes drift-a {
  0%   { transform: translate3d(-4%, -3%, 0) rotate(0deg) scale(1); }
  100% { transform: translate3d(5%, 4%, 0) rotate(14deg) scale(1.15); }
}
@keyframes drift-b {
  0%   { transform: translate3d(5%, 3%, 0) rotate(0deg) scale(1.1); }
  100% { transform: translate3d(-5%, -4%, 0) rotate(-16deg) scale(1); }
}
.card { background: rgba(255,255,255,.88); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border: 1px solid rgba(255,255,255,.7); }
.topbar { background: rgba(255,255,255,.9); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }

/* ---------- Bienvenida con la mascota ---------- */
.welcome { text-align: center; padding-top: 6px; transition: opacity .35s ease, transform .35s ease; }
.welcome.is-leaving { opacity: 0; transform: translateY(-18px) scale(.98); pointer-events: none; }
.welcome h1 { margin: 12px 0 4px; font-size: clamp(1.7rem, 6vw, 2.4rem); line-height: 1.15; }
.welcome__sub { margin: 0 0 20px; color: var(--muted); font-size: 1.02rem; }

.welcome__stage {
  position: relative; display: flex; flex-direction: column; align-items: center;
  margin: 0 auto 10px;
}
.welcome__glow {
  position: absolute; left: 50%; bottom: 4%; width: min(78vw, 360px); aspect-ratio: 1; transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(240,196,70,.75), rgba(240,196,70,0) 70%);
  filter: blur(8px); animation: glow 4s ease-in-out infinite;
}
.welcome__mascot {
  position: relative; z-index: 1; display: block; width: auto; height: min(40vh, 380px);
  filter: drop-shadow(0 18px 22px rgba(15,23,42,.30));
  transform-origin: 50% 100%;
  animation: rise .9s cubic-bezier(.2,.9,.3,1.2) both, float 4.5s ease-in-out .9s infinite;
}
.bubble {
  order: -1; position: relative; z-index: 2; margin-bottom: 16px; padding: 12px 18px; max-width: 320px;
  background: #fff; border-radius: 18px; font-weight: 600; line-height: 1.35; color: var(--ink);
  box-shadow: 0 10px 28px -10px rgba(15,23,42,.35);
  animation: bubble-in .55s .5s cubic-bezier(.2,.9,.3,1.3) both;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -9px; width: 18px; height: 18px; background: #fff;
  transform: translateX(-50%) rotate(45deg); border-radius: 3px;
}

.btn--start {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  max-width: 340px; margin: 0 auto; font-size: 1.15rem; height: 58px;
  animation: ring 2.2s ease-out 1.4s infinite;
}
.btn--start svg { transition: transform .2s; }
.btn--start:hover svg { transform: translateX(4px); }

@keyframes rise { 0% { transform: translateY(60px) scale(.85); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes float { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-12px) rotate(1.2deg); } }
@keyframes glow { 0%,100% { opacity: .75; transform: translateX(-50%) scale(1); } 50% { opacity: 1; transform: translateX(-50%) scale(1.08); } }
@keyframes bubble-in { 0% { opacity: 0; transform: translateY(14px) scale(.8); } 100% { opacity: 1; transform: none; } }
@keyframes ring { 0% { box-shadow: 0 12px 24px -10px rgba(38,58,133,.8), 0 0 0 0 rgba(212,160,23,.55); }
                  70%,100% { box-shadow: 0 12px 24px -10px rgba(38,58,133,.8), 0 0 0 18px rgba(212,160,23,0); } }

/* ---------- Formulario (paso 2) ---------- */
#formView:not([hidden]) { animation: view-in .55s cubic-bezier(.2,.8,.2,1) both; }
@keyframes view-in { 0% { opacity: 0; transform: translateY(26px); } 100% { opacity: 1; transform: none; } }
.hero--compact { margin-bottom: 14px; }
.hero--compact h1 { margin: 10px 0 0; }

.guide { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.guide__avatar {
  position: relative; flex: none; width: 64px; height: 64px; border-radius: 50%; overflow: hidden;
  background: linear-gradient(160deg, #fde68a, #d4a017); border: 3px solid #fff;
  box-shadow: 0 6px 16px -6px rgba(15,23,42,.45);
}
.guide__avatar picture { display: block; }
.guide__avatar img { position: absolute; width: 150%; max-width: none; height: auto; left: -25%; top: 3px; }
.guide__msg {
  position: relative; flex: 1; margin: 0; padding: 10px 14px; font-weight: 600; font-size: .95rem; line-height: 1.3;
  background: #eef3ff; border-radius: 4px 14px 14px 14px; color: var(--primary);
  transition: opacity .2s, transform .2s;
}
.guide__msg.is-swap { opacity: 0; transform: translateY(4px); }

/* ---------- Éxito ---------- */
.success__stage { position: relative; display: inline-block; }
.success__mascot { display: block; height: 220px; width: auto; filter: drop-shadow(0 14px 18px rgba(15,23,42,.28)); animation: rise .7s cubic-bezier(.2,.9,.3,1.3) both, float 4.5s ease-in-out .8s infinite; transform-origin: 50% 100%; }
.confetti { position: absolute; inset: -10px -50px 0; pointer-events: none; overflow: visible; }
.confetti span {
  position: absolute; top: -10px; left: var(--x); width: 8px; height: 14px; background: var(--c); border-radius: 2px;
  opacity: 0; animation: fall var(--d) var(--delay) ease-in forwards;
}
@keyframes fall {
  0% { opacity: 1; transform: translateY(0) rotate(0); }
  100% { opacity: 0; transform: translateY(300px) translateX(var(--dx)) rotate(var(--r)); }
}

/* Dispositivo que ya se registró: no mostrar la bienvenida mientras carga el script */
.ya-registrado #welcome { display: none; }
