:root {
  --night: #0b1a2e;
  --night-2: #132a46;
  --card: rgba(19, 42, 70, 0.78);
  --line: rgba(255, 255, 255, 0.12);
  --text: #eef3f8;
  --muted: #9fb3c8;
  --gold: #ffd27a;
  --red: #d6403a;
  --red-2: #b3302b;
  --green: #3fa66b;
  --paper: #fff8e7;
  --radius: 20px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--night);
  color: var(--text);
  font: 400 17px/1.55 "Nunito", system-ui, sans-serif;
  overflow-x: hidden;
}
/* Fixed layer instead of background-attachment: fixed, which iOS ignores. */
body::before { content: ""; position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(1200px 700px at 50% -10%, #1f4470 0%, var(--night-2) 40%, var(--night) 100%); }
h1, h2, .btn, .recipient-name, .eyebrow, .steps { font-family: "Fredoka", "Nunito", sans-serif; }
[hidden] { display: none !important; }

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

.wrap { position: relative; z-index: 1; max-width: 680px; margin: 0 auto; padding: 32px 16px 48px; }

.hero { text-align: center; padding: 12px 0 20px; }
.hero-hat { width: 110px; margin: 0 auto; filter: drop-shadow(0 8px 20px rgba(0,0,0,.4)); animation: bob 4s ease-in-out infinite; }
h1 { margin: 6px 0 4px; font-size: clamp(32px, 7vw, 48px); font-weight: 700; color: var(--gold); letter-spacing: .5px;
     text-shadow: 0 2px 24px rgba(255, 210, 122, .35); }
.greeting { margin: 0 0 14px; font-size: 20px; }
.chips { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 0; margin: 0 0 16px; }
.chips li { background: rgba(255,255,255,.08); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 15px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin: 18px 0;
  backdrop-filter: blur(8px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.card.center { text-align: center; }
.card h2 { margin: 0 0 6px; font-size: 24px; font-weight: 600; }
.muted { color: var(--muted); margin: 0 0 16px; }

.steps { display: flex; gap: 8px; padding: 0; margin: 8px 0 0; list-style: none; counter-reset: s; }
.steps li { flex: 1; text-align: center; padding: 8px 4px; border-radius: 12px; background: rgba(255,255,255,.05);
            color: var(--muted); font-size: 15px; counter-increment: s; }
.steps li::before { content: counter(s) ". "; }
.steps li.done { color: var(--text); background: rgba(63,166,107,.25); }
.steps li.active { color: var(--night); background: var(--gold); font-weight: 600; }


input[type=text], textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(5, 14, 26, .55); color: var(--text); font: inherit; resize: vertical;
}
textarea { min-height: 92px; }
input:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.error { color: #ff8b85; font-weight: 700; }

.btn { border: 0; border-radius: 999px; padding: 12px 22px; font-size: 17px; font-weight: 600; cursor: pointer;
       transition: transform .15s, box-shadow .15s, background .15s; color: #fff; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, var(--red), var(--red-2)); box-shadow: 0 8px 24px rgba(214,64,58,.4); }
.btn.primary:hover { box-shadow: 0 10px 30px rgba(214,64,58,.6); }
.btn.ghost { background: rgba(255,255,255,.08); border: 1px solid var(--line); }
.btn.big { font-size: 20px; padding: 16px 30px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Hat */
.hat-stage { position: relative; height: 250px; margin: 8px auto 18px; max-width: 320px; }
.hat { width: 100%; height: 100%; overflow: visible; }
.slip { fill: var(--paper); stroke: #e8dcc0; transform-box: fill-box; transform-origin: center; }
.s1 { transform: rotate(-14deg); } .s3 { transform: rotate(12deg); }
.hat-stage.shake .hat { animation: shake .9s ease-in-out 2; transform-origin: 50% 85%; }
.paper {
  position: absolute; left: 50%; top: 30%; width: 64px; height: 44px; margin-left: -32px;
  background: var(--paper); color: #2a1d10; border-radius: 6px; display: grid; place-items: center;
  font: 700 0px/1.1 "Fredoka", sans-serif; opacity: 0; box-shadow: 0 12px 30px rgba(0,0,0,.35);
  transition: all .9s cubic-bezier(.2, 1.4, .4, 1);
}
.paper.up { opacity: 1; top: -40px; }
.paper.open { width: 260px; height: 120px; margin-left: -130px; top: -10px; font-size: 34px; transform: rotate(-2deg); }

/* Result */
.result { text-align: center; border-color: rgba(255,210,122,.45); }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: 2px; color: var(--gold); font-size: 14px; }
.result .recipient-name { margin: 4px 0 18px; font-size: clamp(40px, 10vw, 60px); line-height: 1.1; font-weight: 700; }
.psst { margin: 20px 0 0; color: var(--muted); }

.kids { border-color: rgba(95, 208, 143, .4); }
.kids p { margin: 0 0 16px; }
.kids .btn { display: inline-block; text-decoration: none; }

.foot { text-align: center; color: var(--muted); font-size: 14px; margin-top: 30px; }

/* Intro modal */
.modal { position: fixed; inset: 0; z-index: 10; background: rgba(3, 8, 16, .8); display: grid; place-items: center; padding: 16px; }
.modal-box { position: relative; width: min(960px, 100%); aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden;
             box-shadow: 0 30px 80px rgba(0,0,0,.6); background: var(--night); }
.modal-box iframe { width: 100%; height: 100%; border: 0; display: block; }
.modal-close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 38px; height: 38px; border-radius: 50%;
               border: 0; background: rgba(0,0,0,.5); color: #fff; font-size: 18px; cursor: pointer; }

/* Confetti */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
.confetto { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: fall linear forwards; }

@keyframes bob { 50% { transform: translateY(-8px) rotate(-3deg); } }
@keyframes shake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-8deg); } 40% { transform: rotate(7deg); }
  60% { transform: rotate(-5deg); } 80% { transform: rotate(4deg); }
}
@keyframes fall { to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--rot)); } }

@media (prefers-reduced-motion: reduce) {
  .hero-hat, .hat-stage.shake .hat { animation: none; }
  .paper { transition: none; }
}

/* ---------- Question wizard ---------- */
.wizard { overflow: hidden; }
.wz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.wz-count { flex: none; font: 600 14px "Fredoka", sans-serif; color: var(--gold); letter-spacing: .5px; }
.wz-bar { flex: 1; height: 8px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
#wz-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--gold), #ffb347); transition: width .4s ease; }
.wz-screen { min-height: 230px; }
.wz-screen.in-right { animation: inRight .35s ease both; }
.wz-screen.in-left { animation: inLeft .35s ease both; }
.wz-head { text-align: center; margin-bottom: 18px; }
.wz-head h2 { font-size: clamp(22px, 5.5vw, 28px); margin: 6px 0; }
.wz-head .muted { margin: 0; }
.wz-emoji { font-size: 56px; line-height: 1.1; animation: popIn .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.wz-input { width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line);
            background: rgba(5, 14, 26, .55); color: var(--text); font: inherit; font-size: 18px; resize: vertical; }
.wz-input.small { font-size: 15px; padding: 10px 14px; }
.wz-input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.wz-nav { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.wz-nav .btn { white-space: nowrap; }
@media (max-width: 420px) { .wz-nav .btn { padding: 11px 15px; font-size: 16px; } .wz-nav .btn.text { padding: 11px 4px; } }
.wz-nav #wz-next { margin-left: auto; }
.btn.text { background: none; color: var(--muted); padding: 12px 8px; text-decoration: underline; text-underline-offset: 3px; }

.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.choices.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 480px) { .choices.three { grid-template-columns: 1fr; } .choices.three .choice { flex-direction: row; justify-content: center; padding: 14px; } }
.choice { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 10px; border-radius: 18px;
          border: 2px solid var(--line); background: rgba(255,255,255,.06); color: var(--text); cursor: pointer;
          font: 600 18px "Fredoka", sans-serif; transition: transform .15s, border-color .15s, background .15s; }
.choice:hover { transform: translateY(-3px); border-color: rgba(255,210,122,.5); }
.choice.sel { border-color: var(--gold); background: rgba(255,210,122,.16); }
.choice.pop { animation: choicePop .38s ease; }
.choice-emoji { font-size: 44px; line-height: 1; }
.choices.three .choice-emoji { font-size: 36px; }

.slider-big { text-align: center; font-size: 40px; height: 60px; line-height: 60px; transition: transform .15s, opacity .15s; }
.slider-num { text-align: center; font: 700 44px "Fredoka", sans-serif; color: var(--gold); }
.wz-range { width: 100%; accent-color: var(--gold); height: 32px; cursor: pointer; }
.slider-ends { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 14px; }
.slider-ends span:last-child { text-align: right; }

.wish-edit { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.wish-edit li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px;
                background: rgba(255,255,255,.07); border: 1px solid var(--line); cursor: grab; }
.wish-edit li.dragging { opacity: .4; }
.wish-edit li.over { border-color: var(--gold); }
.wish-ctrl { display: flex; gap: 4px; flex: none; }
.wish-ctrl button { width: 32px; height: 32px; border-radius: 10px; border: 0; background: rgba(255,255,255,.1);
                    color: var(--text); cursor: pointer; font-size: 15px; }
.wish-ctrl button:disabled { opacity: .3; cursor: default; }
.wish-add { display: grid; gap: 8px; }
.wish-add .add { justify-self: start; }
.rank { flex: none; width: 30px; text-align: center; font: 700 18px "Fredoka", sans-serif; color: var(--muted); }
.wish-body { flex: 1; min-width: 0; word-break: break-word; }
.wish-text, .wish-link { display: block; }
.wish-link { font-size: 14px; color: var(--muted); }

/* ---------- Answers (summary + recipient) ---------- */
.qa { display: grid; gap: 10px; text-align: left; }
.qa-item { display: block; width: 100%; text-align: left; background: rgba(255,255,255,.05); border: 1px solid transparent;
           border-radius: 14px; padding: 12px 16px; color: var(--text); font: inherit; }
.qa-item.editable { cursor: pointer; position: relative; }
.qa-item.editable:hover { border-color: rgba(255,210,122,.45); }
.qa-item.editable::after { content: "✎"; position: absolute; top: 10px; right: 14px; color: var(--muted); }
.qa-q { display: block; color: var(--muted); font-size: 14px; font-weight: 700; padding-right: 20px; }
.qa-a { display: block; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.qa a, .wish-link a { color: var(--gold); text-underline-offset: 3px; }
.wish-view { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 6px; }
.wish-view li { display: flex; gap: 8px; align-items: flex-start; }
.wish-view .rank { width: 26px; font-size: 17px; }
.choice-view { font: 600 18px "Fredoka", sans-serif; }
.slider-view { display: flex; align-items: center; gap: 10px; }
.meter { flex: 1; max-width: 220px; height: 10px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #ffb347); }

@keyframes inRight { from { opacity: 0; transform: translateX(40px); } }
@keyframes inLeft { from { opacity: 0; transform: translateX(-40px); } }
@keyframes popIn { from { transform: scale(.3) rotate(-15deg); opacity: 0; } }
@keyframes choicePop { 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) {
  .wz-screen.in-right, .wz-screen.in-left, .wz-emoji, .choice.pop { animation: none; }
}
