:root {
  --night: #141A3F;
  --night-2: #2A2066;
  --dusk: #6B2F86;
  --rose: #C2508A;
  --purple: #5B2DBF;
  --pink: #C2367A;
  --gold: #F7C948;
  --gold-2: #F59E0B;
  --teal: #12827D;
  --ink: #1E2448;
  --cream: #FFF8EC;
  --muted: #4B4F6B;
  --on-dark: #ECE7FA;
  --on-dark-muted: #CFC7EA;
  --line: #EADFCB;
  --field: #FFFDF8;
  --error: #B42318;
  --display: 'Fredoka', 'Trebuchet MS', sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --magic: linear-gradient(135deg, #5B2DBF 0%, #8A2FA8 50%, #C2367A 100%);
  --goldglow: linear-gradient(135deg, #FBD96A 0%, #F7C948 45%, #F59E0B 100%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--night); }
body {
  margin: 0; color: var(--on-dark); font-family: var(--body); font-size: 16px; line-height: 1.55;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(247, 201, 72, 0.18), transparent 60%),
    radial-gradient(900px 600px at -10% 30%, rgba(194, 54, 122, 0.22), transparent 60%),
    linear-gradient(180deg, var(--night) 0%, var(--night-2) 42%, var(--dusk) 78%, var(--rose) 100%);
  background-attachment: fixed;
  min-height: 100vh;
}
/* Starfield */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 120px 80px, rgba(255,255,255,0.8), transparent),
    radial-gradient(1.5px 1.5px at 200px 150px, rgba(255,255,255,0.9), transparent),
    radial-gradient(1px 1px at 60px 190px, rgba(255,255,255,0.7), transparent),
    radial-gradient(2px 2px at 260px 40px, rgba(247,201,72,0.9), transparent),
    radial-gradient(1px 1px at 300px 220px, rgba(255,255,255,0.8), transparent);
  background-size: 320px 260px;
  opacity: 0.7;
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.45; } to { opacity: 0.85; } }
/* Fairytale castle silhouette rising behind the hero (clipped so it never widens the page) */
.castle { position: absolute; left: 0; right: 0; top: 150px; z-index: 0; pointer-events: none; overflow: hidden; padding-top: 140px; margin-top: -140px;
  -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent 97%); mask-image: linear-gradient(to bottom, #000 72%, transparent 97%); }
.castle svg {
  display: block; width: min(980px, 150vw); height: auto; margin-left: 50%; transform: translateX(-50%); opacity: 0.6; overflow: visible;
  filter: drop-shadow(0 0 30px rgba(247, 201, 72, 0.45)) drop-shadow(0 0 70px rgba(194, 54, 122, 0.45));
}
@media (max-width: 640px) { .castle { top: 190px; } .castle svg { width: 175vw; opacity: 0.5; } }
a { color: var(--gold); }
a:hover { color: #fff; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.01em; margin: 0; line-height: 1.08; }
p { margin: 0; }
button, input { font: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.page { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

/* Header */
.site-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding: 16px clamp(16px, 4vw, 56px); background: rgba(20, 26, 63, 0.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid rgba(247, 201, 72, 0.35); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.brand svg { filter: drop-shadow(0 0 10px rgba(247, 201, 72, 0.55)); }
.wordmark { font-family: var(--display); font-weight: 700; font-size: 28px; letter-spacing: -0.01em; color: #fff; }
.wordmark span { background: var(--goldglow); -webkit-background-clip: text; background-clip: text; color: transparent; }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; font-weight: 700; font-size: 15px; }
.site-nav a { color: var(--on-dark); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.site-nav a:hover { color: var(--gold); }
.linkish { background: none; border: none; padding: 0; min-height: 44px; color: var(--on-dark); font-weight: 700; cursor: pointer; }
.linkish:hover { color: var(--gold); }

/* Main */
.main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 44px clamp(16px, 4vw, 40px) 64px; }
.screen { display: flex; flex-direction: column; gap: 26px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 28px; align-items: end; position: relative; }
.hero-text { display: flex; flex-direction: column; gap: 14px; min-width: 0; position: relative; padding-bottom: 24px; }
/* Dr. Oops stands behind the intake form: his shoes tuck under the card below. */
.hero-doc { position: relative; z-index: 0; margin: 0 0 -110px; width: clamp(150px, 22vw, 230px); padding-top: 70px; }
.hero-doc img { display: block; width: 100%; height: auto; max-width: 100%; filter: drop-shadow(0 0 22px rgba(247, 201, 72, 0.35)); }
.speech {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 210px; text-align: center;
  background: var(--cream); color: var(--ink); border-radius: 18px; padding: 9px 14px;
  font-size: 15px; font-weight: 800; line-height: 1.3;
  box-shadow: 0 0 0 2px var(--gold), 0 0 24px rgba(247, 201, 72, 0.55);
}
.speech::after {
  content: ""; position: absolute; left: 50%; bottom: -8px; width: 14px; height: 14px; margin-left: -7px;
  background: var(--cream); transform: rotate(45deg); box-shadow: 2px 2px 0 0 var(--gold);
}
.intake { position: relative; z-index: 1; }
@media (max-width: 900px) { .speech { display: none; } .hero-doc { padding-top: 0; } }
.hero h1 {
  font-size: clamp(36px, 5.2vw, 64px); line-height: 1.04;
  background: linear-gradient(100deg, #FFFFFF 0%, #FFE8A3 40%, #F7C948 60%, #FF9BC8 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 40px rgba(247, 201, 72, 0.25);
}
.hero-text::after {
  content: "✦"; position: absolute; right: 4%; top: -6px; font-size: 34px; color: var(--gold);
  text-shadow: 0 0 18px rgba(247, 201, 72, 0.9); animation: sparkle 2.4s ease-in-out infinite;
}
.hero-text::before {
  content: "✧"; position: absolute; right: 14%; top: 54px; font-size: 22px; color: #FFB3D6;
  text-shadow: 0 0 14px rgba(255, 155, 200, 0.9); animation: sparkle 3s ease-in-out 0.8s infinite;
}
@keyframes sparkle { 0%, 100% { opacity: 0.35; transform: scale(0.85) rotate(0deg); } 50% { opacity: 1; transform: scale(1.15) rotate(20deg); } }
.eyebrow { font-size: 13px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); }
.card .eyebrow { color: var(--purple); }
.card .eyebrow.muted { color: var(--muted); }
.eyebrow.alarm { color: var(--pink) !important; }
.eyebrow.gold { color: var(--gold) !important; }
.lede { font-size: 19px; color: var(--on-dark-muted); max-width: 660px; }
.card .lede { color: var(--muted); }

.card {
  position: relative; background: var(--cream); color: var(--ink); border-radius: 24px; padding: clamp(20px, 3vw, 30px);
  box-shadow: 0 0 0 2px rgba(247, 201, 72, 0.55), 0 18px 40px rgba(10, 8, 40, 0.45), 0 0 60px rgba(194, 54, 122, 0.18);
  display: flex; flex-direction: column; gap: 14px;
}
.card a { color: var(--purple); }
.card h2 { font-size: clamp(28px, 4vw, 38px); color: var(--ink); }
.card.dark { background: linear-gradient(160deg, #1E2448 0%, #2A2066 100%); color: var(--on-dark); }
.card.dark p { color: var(--on-dark-muted); }
.card-title { font-family: var(--display); font-weight: 700; font-size: 24px; line-height: 1.15; color: var(--purple); }
.card.dark .card-title { color: #fff; }

/* Intake form */
.intake { gap: 18px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field label { font-weight: 800; font-size: 16px; }
.field-age { max-width: 160px; }
input[type="text"], input[type="number"] { width: 100%; font-size: 18px; padding: 13px 16px; border: 2px solid #CDBFE8; border-radius: 14px; background: var(--field); color: var(--ink); }
input[type="text"]:focus, input[type="number"]:focus { border-color: var(--purple); outline: 3px solid rgba(91, 45, 191, 0.25); outline-offset: 0; }
#symptoms { flex: 1 1 300px; width: auto; min-width: 0; }
.form-error { font-weight: 700; color: var(--error); }
.small-label { font-size: 14px; font-weight: 800; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; background: #fff; color: var(--ink); border: 2px solid #E3D6F5; border-radius: 999px; cursor: pointer; font-size: 15px; font-weight: 700; transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; }
.chip:hover { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(247, 201, 72, 0.35); transform: translateY(-1px); }

/* Buttons */
.btn { min-height: 52px; padding: 0 26px; font-weight: 800; font-size: 16px; border: none; border-radius: 999px; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s, filter 0.15s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--magic); color: #fff; box-shadow: 0 6px 18px rgba(91, 45, 191, 0.45); }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 8px 24px rgba(194, 54, 122, 0.5); }
.btn-ghost { background: #fff; color: var(--purple); box-shadow: inset 0 0 0 2px var(--purple); }
.btn-alarm { background: var(--goldglow); color: var(--ink); font-size: 17px; box-shadow: 0 0 24px rgba(247, 201, 72, 0.55); }
.btn-alarm:hover { box-shadow: 0 0 34px rgba(247, 201, 72, 0.85); }
.btn-white { background: #fff; color: var(--purple); }
.btn-cream { background: var(--goldglow); color: var(--ink); }
.btn-outline-light { background: transparent; color: #fff; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85); }
.btn-wide { width: 100%; min-height: 56px; font-size: 17px; }
.intake .btn-primary { flex: 0 0 auto; }
@media (prefers-reduced-motion: reduce) {
  body::before, .hero-text::after, .hero-text::before { animation: none; }
  .btn, .chip { transition: none; }
}

/* Loading */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; font-size: 18px; font-weight: 600; }
.steps li { display: flex; align-items: center; gap: 12px; }
.steps li::before { content: "✦"; color: var(--teal); font-size: 18px; width: 18px; text-align: center; flex: 0 0 auto; }
.steps li.active::before { color: var(--pink); animation: pulse 0.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1.15); } 50% { opacity: 0.35; transform: scale(0.85); } }
@media (prefers-reduced-motion: reduce) { .steps li.active::before { animation: none; } }

/* Results */
.result-head { display: flex; flex-direction: column; gap: 8px; }
.result-head h1 { font-size: clamp(28px, 4.5vw, 46px); color: #fff; overflow-wrap: anywhere; }
.result-layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.dx-card { flex: 2 1 420px; min-width: 0; }
.dx-card h2 { font-size: clamp(28px, 4vw, 36px); background: var(--magic); -webkit-background-clip: text; background-clip: text; color: transparent; }
.dx-blurb { font-size: 17px; }
.chart-note { font-size: 15px; color: var(--muted); background: #F4ECFF; border-radius: 14px; padding: 10px 14px; }
.chart-note strong { color: var(--ink); }
.rx { display: flex; gap: 12px; align-items: flex-start; background: #FFF1C9; border-radius: 14px; padding: 14px 16px; font-size: 16px; }
.rx-mark { font-family: var(--display); font-weight: 700; font-size: 22px; line-height: 1; color: #B45309; }
.meter { display: flex; flex-direction: column; gap: 6px; }
.meter-top { display: flex; justify-content: space-between; font-size: 14px; font-weight: 800; }
.meter-bar { height: 10px; background: #EADFF7; border-radius: 99px; overflow: hidden; }
.meter-bar > div { height: 100%; background: linear-gradient(90deg, var(--gold), var(--pink)); width: 0; transition: width 0.6s ease; }
.meter-light .meter-bar { background: rgba(255, 255, 255, 0.25); }
.meter-light .meter-bar > div { background: linear-gradient(90deg, #fff, var(--gold)); }
.side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.fineprint { font-size: 12px; color: var(--on-dark-muted); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.share-status { font-size: 15px; font-weight: 700; color: var(--gold); }
.help-list { margin: 0; padding-left: 22px; font-size: 18px; line-height: 1.6; }

/* Ads */
.ad { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 16px auto 0; width: 100%; padding: 0 clamp(16px, 4vw, 56px); }
.ad-label { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--on-dark-muted); }
.ad-top { max-width: calc(728px + 2 * clamp(16px, 4vw, 56px)); }
.ad-top .adsbygoogle { width: 100%; min-height: 90px; }
.ad-result { margin: 0; padding: 0; }
.ad-result .adsbygoogle { width: 100%; max-width: 300px; min-height: 250px; }
.ad-placeholder { border: 2px dashed rgba(247, 201, 72, 0.6); border-radius: 14px; background: rgba(255, 255, 255, 0.08); justify-content: center; color: var(--on-dark-muted); font-weight: 700; font-size: 14px; text-align: center; }
.ad-top.ad-placeholder { height: 90px; max-width: 728px; padding: 0 12px; }
.ad-result.ad-placeholder { height: 250px; max-width: 300px; align-self: center; }

/* Footer */
.site-footer { border-top: 1px solid rgba(247, 201, 72, 0.35); background: rgba(20, 26, 63, 0.5); padding: 18px clamp(16px, 4vw, 56px); font-size: 14px; color: var(--on-dark-muted); display: flex; flex-direction: column; gap: 4px; }
.site-footer .linkish { min-height: 0; color: var(--gold); text-decoration: underline; }

/* Modals */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(12, 10, 40, 0.78); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.modal { width: 100%; max-width: 560px; margin: auto; border-radius: 26px; padding: clamp(24px, 4vw, 34px); display: flex; flex-direction: column; gap: 16px; position: relative; }
.modal:focus { outline: none; }
.modal h2 { font-size: clamp(32px, 6vw, 42px); }
.modal p { font-size: 17px; }
.modal-cream { background: var(--cream); color: var(--ink); box-shadow: 0 0 0 3px var(--gold), 0 0 60px rgba(247, 201, 72, 0.45); }
.modal-cream h2 { color: var(--purple); }
.modal-alarm { background: var(--magic); color: #fff; box-shadow: 0 0 0 3px var(--gold), 0 0 80px rgba(194, 54, 122, 0.6); }
.modal-alarm .eyebrow { color: #FFE8A3; }
.modal-dark { background: linear-gradient(160deg, #141A3F 0%, #2A2066 100%); color: var(--on-dark); box-shadow: 0 0 0 3px var(--gold), 0 0 80px rgba(247, 201, 72, 0.45); }
.modal-alarm::after, .modal-dark::after { content: "✦"; position: absolute; top: 16px; right: 22px; font-size: 26px; color: var(--gold); text-shadow: 0 0 16px rgba(247, 201, 72, 0.9); }
.doom-name { font-size: clamp(40px, 8.5vw, 64px) !important; line-height: 0.98; }
.modal-alarm .doom-name { color: #fff; text-shadow: 0 0 24px rgba(255, 255, 255, 0.45); }
.modal-dark .doom-name { background: var(--goldglow); -webkit-background-clip: text; background-clip: text; color: transparent; }
.doom-line { font-size: 18px !important; }
.source { font-size: 14px !important; opacity: 0.9; }
.muted-light { color: var(--on-dark-muted); font-size: 15px !important; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.modal-actions .btn { flex: 1 1 200px; }
.modal-actions .btn-outline-light { flex: 0 1 auto; }
.modal-dark .modal-actions .btn-outline-light { flex: 1 1 200px; }
body.modal-open { overflow: hidden; }

/* Content pages (privacy) */
.prose { max-width: 740px; display: flex; flex-direction: column; gap: 14px; }
.prose h1 { font-size: clamp(34px, 5vw, 52px); color: #fff; }
.prose h2 { font-size: 24px; margin-top: 12px; color: var(--gold); }
.prose ul { margin: 0; padding-left: 22px; }

@media (max-width: 520px) {
  .field-age { max-width: none; }
  .intake .btn-primary { width: 100%; }
  .actions .btn { flex: 1 1 100%; }
  .hero-text::before { display: none; }
  .hero { grid-template-columns: minmax(0, 1fr) 100px; gap: 8px 12px; }
  .hero-doc { width: 100px; margin-bottom: -56px; }
  .hero-text { padding-bottom: 8px; }
}
