/* =====================================================================
   THEME TOKENS (overwritten at runtime from CONFIG.colors)
   ===================================================================== */
:root {
  --sky-top: #8fd3ff;
  --sky-mid: #cdeeff;
  --sky-bottom: #ffe9d6;
  --hill-back: #9fd8a4;
  --hill-front: #6cc07a;
  --accent: #2f9e8f;
  --accent-dark: #1f7a6e;
  --accent-soft: rgba(47, 158, 143, .16);
  --danger: #e2574c;
  --warning: #f2a33a;
  --success: #3fae5a;
  --ink: #1f3340;
  --ink-soft: #5d7380;
  --card: rgba(255, 255, 255, .82);
  --card-border: rgba(255, 255, 255, .9);
  --field: #f4fbfa;
  --field-border: #d6e8e6;
  --radius: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-bottom) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* =====================================================================
   BACKGROUND SCENE
   ===================================================================== */
.scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.sun {
  position: absolute; top: 7%; right: 11%; width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle, #fffbe0 0%, #ffe68a 55%, rgba(255, 220, 110, 0) 72%);
  animation: sunPulse 6s ease-in-out infinite alternate;
}
@keyframes sunPulse { to { transform: scale(1.08); opacity: .9; } }

.cloud { position: absolute; left: 0; opacity: .95; will-change: transform; animation: cloudDrift linear infinite; }
@keyframes cloudDrift { from { transform: translateX(-260px); } to { transform: translateX(calc(100vw + 60px)); } }

.hills { position: absolute; left: 0; right: 0; bottom: 0; height: 30vh; min-height: 180px; }
.hills svg { position: absolute; bottom: 0; width: 100%; height: 100%; }

.tree { position: absolute; left: max(2vw, 10px); bottom: 12vh; width: 210px; height: 280px; }
.tree .crown { transform-box: fill-box; transform-origin: 50% 100%; animation: crownSway 4.5s ease-in-out infinite alternate; }
@keyframes crownSway { from { transform: rotate(-2.5deg) skewX(-2deg); } to { transform: rotate(3.5deg) skewX(3deg); } }

.grass { position: absolute; left: 0; right: 0; bottom: 0; height: 70px; display: flex; justify-content: space-around; align-items: flex-end; }
.blade {
  width: 6px; border-radius: 6px 6px 0 0; background: linear-gradient(#5bb36a, #3f8f4f);
  transform-origin: 50% 100%; animation: bladeSway ease-in-out infinite alternate;
}
@keyframes bladeSway { from { transform: rotate(-4deg); } to { transform: rotate(16deg); } }

.windmill { position: absolute; right: 8vw; bottom: 22vh; width: 90px; height: 150px; }
.windmill .rotor { transform-box: fill-box; transform-origin: 50% 50%; animation: spin 4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#windCanvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }

/* storm layer (lockout) */
.storm { position: fixed; inset: 0; z-index: 2; pointer-events: none; opacity: 0;
  background: linear-gradient(180deg, rgba(30, 38, 58, .88), rgba(48, 58, 80, .72) 55%, rgba(30, 36, 50, .8)); }
.flash { position: fixed; inset: 0; z-index: 3; pointer-events: none; opacity: 0; background: #f4f8ff; }
.storm-clouds { position: fixed; left: 0; right: 0; top: 0; height: 40vh; z-index: 2; pointer-events: none; opacity: 0; transform: translateY(-100%); }
.storm-clouds svg { width: 100%; height: 100%; }

/* =====================================================================
   LAYOUT + CARD
   ===================================================================== */
.stage {
  position: relative; z-index: 5; min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 120px 16px 40px;
}
.card-wrap { position: relative; width: min(410px, 100%); }
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 40px 30px 26px;
  box-shadow: 0 30px 60px -20px rgba(24, 60, 80, .35), 0 2px 0 rgba(255, 255, 255, .6) inset;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  transition: background-color .6s ease, box-shadow .6s ease;
}
body[data-state="locked"] .card { background: rgba(232, 238, 248, .9); }

.panel[hidden] { display: none !important; }
h1 { font-family: 'Fredoka', 'Nunito', sans-serif; font-weight: 600; font-size: 28px; text-align: center; letter-spacing: .2px; }
.sub { text-align: center; color: var(--ink-soft); font-size: 14px; margin: 4px 0 22px; }

fieldset { border: 0; min-width: 0; }
.field { position: relative; margin-bottom: 16px; }
.field > label { display: block; font-weight: 700; font-size: 13.5px; margin-bottom: 6px; }
.control { position: relative; }
.control .icon {
  position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; margin-top: -9px; color: var(--ink-soft); pointer-events: none;
}
.control input {
  width: 100%; height: 48px; padding: 0 48px 0 42px;
  border: 2px solid var(--field-border); border-radius: 14px; background: var(--field);
  font: 600 15px 'Nunito', sans-serif; color: var(--ink); outline: none;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.control input::placeholder { color: #9bb0b8; font-weight: 400; }
.control input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
.control input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(226, 87, 76, .14); }
.control input.valid { border-color: var(--success); }
.control input:disabled { opacity: .55; cursor: not-allowed; }

/* email status: sprout (valid) / wilted leaf (invalid) */
.status { position: absolute; right: 12px; top: 50%; width: 26px; height: 26px; margin-top: -13px; pointer-events: none; }
.status svg { position: absolute; inset: 0; opacity: 0; transform: scale(.2) rotate(-40deg); transition: transform .45s cubic-bezier(.3, 1.6, .5, 1), opacity .25s; }
.status.ok svg.ok, .status.bad svg.bad { opacity: 1; transform: none; }

.toggle {
  position: absolute; right: 6px; top: 50%; width: 38px; height: 38px; margin-top: -19px;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-soft); cursor: pointer; display: grid; place-items: center;
}
.toggle:hover { background: var(--accent-soft); color: var(--accent-dark); }
.toggle svg { width: 22px; height: 22px; }
.toggle .eye-closed { display: none; }
.toggle[aria-pressed="true"] .eye-open { display: none; }
.toggle[aria-pressed="true"] .eye-closed { display: block; }

.hint { font-size: 12.5px; min-height: 18px; margin-top: 5px; color: var(--ink-soft); }
.hint.error { color: var(--danger); font-weight: 700; }
.hint.good { color: var(--success); font-weight: 700; }

.caps {
  position: absolute; right: 0; top: -3px;
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 30px;
  background: #fff4e0; color: #9a5b00; font-size: 12px; font-weight: 800;
  opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .2s;
}
.caps.on { opacity: 1; transform: none; }

/* strength meter: windsock + 4 bars */
.strength { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.windsock { width: 58px; height: 34px; flex: none; }
.windsock .sock { transform-box: fill-box; transform-origin: 0% 50%; transform: scaleX(.12); transition: transform .6s cubic-bezier(.3, 1.5, .5, 1); }
.windsock .flutter { transform-box: fill-box; transform-origin: 0% 50%; animation: flutter var(--flutter, 1.4s) ease-in-out infinite alternate; }
@keyframes flutter { from { transform: skewY(-4deg); } to { transform: skewY(5deg); } }
.meter { flex: 1; }
.bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.bar { height: 7px; border-radius: 6px; background: #e3eef0; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; transform: scaleX(0); transform-origin: left; transition: transform .45s ease, background-color .3s; }
.meter-label { font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-top: 4px; }

.row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13.5px; margin: 4px 0 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
a { color: var(--accent-dark); font-weight: 700; text-decoration: none; border-radius: 4px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.control input:focus-visible { outline: none; }

/* attempts */
.attempts { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 14px; font-size: 12.5px; color: var(--ink-soft); font-weight: 700; }
.attempt-icons { display: flex; gap: 6px; }
.attempt-icons svg { width: 22px; height: 22px; }
.attempt-icons svg.gone { visibility: hidden; }

/* button + pinwheel loader */
.btn {
  position: relative; width: 100%; height: 50px; border: 0; border-radius: 14px; cursor: pointer;
  font: 800 16px 'Nunito', sans-serif; color: #fff; letter-spacing: .3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 12px 24px -10px var(--accent-dark);
  display: flex; align-items: center; justify-content: center; gap: 10px; overflow: hidden;
  transition: transform .15s ease, filter .2s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.98); }
.btn:disabled { cursor: not-allowed; filter: grayscale(.4) brightness(.95); }
.btn .pinwheel { width: 26px; height: 26px; display: none; }
.btn .pinwheel g { transform-box: fill-box; transform-origin: 50% 50%; animation: spin .7s linear infinite; }
.btn[aria-busy="true"] .pinwheel { display: block; }
.btn::after { /* soft gust sweep while loading */
  content: ''; position: absolute; inset: 0; opacity: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, .35) 50%, transparent 80%);
  transform: translateX(-100%);
}
.btn[aria-busy="true"]::after { opacity: 1; animation: sweep 1.1s ease-in-out infinite; }
@keyframes sweep { to { transform: translateX(100%); } }

.alt { text-align: center; font-size: 13.5px; margin-top: 16px; color: var(--ink-soft); }

/* lockout panel */
.lock { display: none; margin: 4px 0 14px; padding: 14px 16px; border-radius: 16px; background: #2b3550; color: #e9f0ff; text-align: center; }
body[data-state="locked"] .lock { display: block; }
.lock .title { font-family: 'Fredoka', sans-serif; font-size: 17px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.lock .clock { font-family: 'Fredoka', sans-serif; font-size: 34px; letter-spacing: 1px; margin: 4px 0; font-variant-numeric: tabular-nums; }
.lock .track { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.lock .track i { display: block; height: 100%; background: linear-gradient(90deg, #8fd3ff, #c8f1ff); transform-origin: left; }
.lock p { font-size: 12.5px; opacity: .85; margin-top: 8px; }
.tornado { width: 22px; height: 22px; }
.tornado g { transform-box: fill-box; transform-origin: 50% 50%; animation: wobble .6s ease-in-out infinite alternate; }
@keyframes wobble { from { transform: skewX(-10deg); } to { transform: skewX(10deg); } }

/* OTP */
.otp-boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 6px 0 10px; }
.otp-boxes input {
  width: 100%; aspect-ratio: 1 / 1.15; min-height: 46px; text-align: center;
  font: 700 24px 'Fredoka', sans-serif; color: var(--ink);
  border: 2px solid var(--field-border); border-radius: 14px 14px 14px 4px; background: var(--field); outline: none;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.otp-boxes input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
.otp-boxes input.filled { border-color: var(--accent); background: #effaf7; }
.otp-boxes input[aria-invalid="true"] { border-color: var(--danger); }
.otp-meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; margin-bottom: 14px; }
.linkbtn { background: none; border: 0; font: 700 13.5px 'Nunito', sans-serif; color: var(--accent-dark); cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.linkbtn:disabled { color: var(--ink-soft); cursor: default; }
.demo-note { text-align: center; font-size: 12.5px; color: var(--ink-soft); margin-top: 10px; }
.demo-note code { background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; font-weight: 800; color: var(--accent-dark); }

/* =====================================================================
   MASCOT (bird perched on the card)
   ===================================================================== */
.bird { position: absolute; left: 50%; top: -106px; width: 130px; height: 122px; margin-left: -65px; z-index: 6; pointer-events: none; }
.bird svg { width: 100%; height: 100%; overflow: visible; }
.bird .eye { transform-box: fill-box; transform-origin: 50% 50%; animation: blink 5s infinite; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.08); } }

/* flying letters (leaves) */
.flyer {
  position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none;
  width: 28px; height: 28px; display: grid; place-items: center;
  font: 800 14px 'Nunito', sans-serif; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
  will-change: transform, opacity;
}
.flyer::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: var(--leaf, #6cc07a); border-radius: 0 80% 0 80%;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, .12);
}
.feather { position: fixed; left: 0; top: 0; z-index: 30; width: 14px; height: 6px; border-radius: 50%; background: #5b8def; pointer-events: none; }

/* =====================================================================
   SUCCESS: cloud gate
   ===================================================================== */
.gate { position: fixed; inset: 0; z-index: 40; pointer-events: none; visibility: hidden; }
.gate .half { position: absolute; top: 0; bottom: 0; width: 56%; }
.gate .half.l { left: 0; transform: translateX(-102%); }
.gate .half.r { right: 0; transform: translateX(102%); }
.gate .half svg { width: 100%; height: 100%; display: block; }
.welcome {
  position: fixed; inset: 0; z-index: 41; display: grid; place-items: center; text-align: center; pointer-events: none;
  opacity: 0; color: var(--ink);
}
.welcome h2 { font-family: 'Fredoka', sans-serif; font-size: clamp(28px, 7vw, 46px); }
.welcome p { color: var(--ink-soft); margin-top: 6px; font-weight: 700; }
.welcome .pin { width: 64px; height: 64px; margin: 0 auto 12px; }
.welcome .pin g { transform-box: fill-box; transform-origin: 50% 50%; animation: spin 1s linear infinite; }
.welcome a, .welcome button { pointer-events: auto; }
.replay { margin-top: 18px; padding: 10px 20px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font: 800 14px 'Nunito'; cursor: pointer; display: none; }

/* =====================================================================
   RESPONSIVE + REDUCED MOTION
   ===================================================================== */
@media (max-width: 720px) {
  .tree { width: 150px; height: 200px; left: -30px; }
  .windmill { right: 2vw; transform: scale(.75); transform-origin: bottom right; }
}
@media (max-width: 420px) {
  .card { padding: 36px 18px 22px; }
  h1 { font-size: 24px; }
  .otp-boxes { gap: 6px; }
  .otp-boxes input { font-size: 20px; }
  .tree, .windmill { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
