:root {
  --night: #0b1630;
  --ink: #fdf8ef;
  --muted: #c9d3ea;
  --faint: #93a2c6;
  --red: #d7263d;
  --red-deep: #9e1830;
  --gold: #f4c95d;
  --pine: #2c8c63;
  --glass: rgba(14, 25, 56, 0.74);
  --glass-strong: rgba(14, 24, 52, 0.82);
  --line: rgba(255, 255, 255, 0.16);
  --field: rgba(255, 255, 255, 0.09);
  --radius: 18px;
  --display: 'Fraunces', Georgia, serif;
  --body: 'Nunito', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night);
  color: var(--ink);
  font: 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.shade {
  position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(8, 14, 34, 0) 0%, rgba(8, 14, 34, 0.25) 55%, rgba(6, 10, 26, 0.7) 100%),
    linear-gradient(to bottom, rgba(6, 10, 26, 0.35), rgba(6, 10, 26, 0) 30%, rgba(6, 10, 26, 0) 70%, rgba(6, 10, 26, 0.55));
}

main {
  position: relative; z-index: 1;
  min-height: 100vh; min-height: 100dvh;
  display: flex; justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.view { width: 100%; max-width: 520px; display: none; flex-direction: column; }
.view.on { display: flex; animation: rise 0.45s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* home */
[data-view="home"] { justify-content: center; min-height: calc(100dvh - 44px); gap: 34px; }
.hero { text-align: center; }
.eyebrow { color: var(--gold); letter-spacing: 0.3em; font-size: 13px; font-weight: 800; text-transform: uppercase; }
.title {
  font: italic 700 clamp(40px, 11vw, 68px)/1.02 var(--display);
  margin: 10px 0 10px;
  text-shadow: 0 2px 24px rgba(255, 200, 120, 0.35), 0 2px 2px rgba(0, 0, 0, 0.4);
  text-wrap: balance;
}
.facts { color: var(--muted); margin: 0; font-weight: 700; min-height: 1.5em; }
.facts b { color: var(--gold); font-weight: 800; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.admin-link { align-self: center; color: var(--faint); font-size: 13px; text-decoration: none; opacity: 0.7; padding: 6px 10px; }
.admin-link:hover { opacity: 1; text-decoration: underline; }

/* buttons */
.btn {
  appearance: none; border: 0; cursor: pointer; text-decoration: none;
  font: 800 16px/1 var(--body); color: var(--ink);
  border-radius: 14px; padding: 13px 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-big { font-size: 20px; padding: 20px 22px; border-radius: 18px; }
.btn-wide { width: 100%; }
.btn-red {
  background: linear-gradient(180deg, #e8364c, var(--red-deep));
  box-shadow: 0 8px 26px rgba(215, 38, 61, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-red:not(:disabled):hover { box-shadow: 0 10px 32px rgba(244, 201, 93, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.btn-frost {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.btn-frost:hover { background: rgba(255, 255, 255, 0.2); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.35); }
.btn-small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.ico { font-size: 1.15em; }

/* cards + forms */
.back { color: var(--muted); text-decoration: none; font-weight: 700; margin: 4px 0 12px; align-self: flex-start; }
.card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px;
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.card.center { text-align: center; }
.card h2 { font: italic 700 30px/1.1 var(--display); margin: 0 0 16px; }
.card h3 { font: 800 17px/1.2 var(--body); margin: 0; }
.field { display: block; text-align: left; margin: 0 0 16px; }
.field > span { display: block; font-weight: 800; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.field small, .hint { color: var(--faint); font-size: 14px; }
#gate-hint { margin: -6px 0 14px; }
.field small { display: block; margin-top: 5px; }
input, select {
  width: 100%; font: 600 16px var(--body); color: var(--ink);
  background: var(--field); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 13px; outline: none;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
select option { background: #16244a; color: var(--ink); }
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(244, 201, 93, 0.2); }
input::placeholder { color: rgba(201, 211, 234, 0.5); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .two { grid-template-columns: 1fr; } }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.msg { min-height: 1.4em; margin: 10px 0; font-weight: 700; font-size: 14px; }
.msg.bad { color: #ff9aa6; }
.msg.good { color: #9ff0bf; }
.hint { margin: 12px 0 0; }

/* wish list editor */
.wish-head { margin: 6px 0 10px; }
.wish-head small { color: var(--faint); font-size: 13px; }
.wishes-edit { list-style: none; margin: 0 0 10px; padding: 0; counter-reset: w; display: grid; gap: 10px; }
.wishes-edit li {
  display: grid; grid-template-columns: 26px 1fr 40px; gap: 8px; align-items: start;
  counter-increment: w; animation: rise 0.25s ease both;
}
.wishes-edit li::before {
  content: counter(w); width: 26px; height: 26px; margin-top: 10px; border-radius: 50%;
  background: rgba(244, 201, 93, 0.18); color: var(--gold); font-weight: 800; font-size: 13px;
  display: grid; place-items: center;
}
.wishes-edit .wish-inputs { display: grid; gap: 6px; }
.wishes-edit .link-in { font-size: 14px; padding: 9px 12px; }
.del {
  appearance: none; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); color: var(--muted);
  width: 40px; height: 44px; border-radius: 12px; font-size: 20px; cursor: pointer;
}
.del:hover { color: #ff9aa6; border-color: rgba(255, 154, 166, 0.5); }
.add-wish { width: 100%; margin-bottom: 6px; }
.plus { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--pine); color: #fff; font-size: 18px; }

/* admin */
.tabs { display: flex; gap: 6px; background: var(--glass-strong); border: 1px solid var(--line); border-radius: 14px; padding: 5px; margin-bottom: 12px; overflow-x: auto; }
.tabs button {
  flex: 1; appearance: none; border: 0; background: transparent; color: var(--muted); font: 800 14px var(--body);
  padding: 10px 8px; border-radius: 10px; cursor: pointer; white-space: nowrap;
}
.tabs button.on { background: rgba(255, 255, 255, 0.14); color: var(--ink); }
.rows { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 12px;
}
.row .grow { flex: 1; min-width: 0; }
.row .grow b { display: block; overflow-wrap: anywhere; }
.row .grow small { color: var(--faint); }
.row input { padding: 8px 10px; }
.inline-add { display: flex; gap: 8px; }
.inline-add input { flex: 1; }
.fam-group { margin-bottom: 18px; }
.fam-group > h4 { margin: 0 0 8px; color: var(--gold); font: italic 600 18px var(--display); }
.person { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.person > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 11px 12px; }
.person > summary::-webkit-details-marker { display: none; }
.person > summary .grow { flex: 1; min-width: 0; font-weight: 800; overflow-wrap: anywhere; }
.person > summary small { color: var(--faint); font-weight: 600; }
.person[open] > summary { border-bottom: 1px solid var(--line); }
.person .inner { padding: 12px; }
.badge { font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); color: var(--muted); white-space: nowrap; }
.badge.yes { background: rgba(44, 140, 99, 0.35); color: #b8f5d4; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.danger { color: #ffb3bc; }
.stat { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 14px; }
.stat b { font: italic 700 40px var(--display); color: var(--gold); }
.bar { height: 10px; background: rgba(255, 255, 255, 0.1); border-radius: 99px; overflow: hidden; margin-bottom: 16px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--pine), var(--gold)); border-radius: 99px; transition: width 0.6s ease; }
.pairs { margin: 12px 0; }
.pairs .row { font-weight: 700; }
.pairs .arrow { color: var(--gold); }
.check { padding: 12px 14px; border-radius: 12px; margin: 0 0 14px; font-weight: 700; font-size: 14px; }
.check.ok { background: rgba(44, 140, 99, 0.22); border: 1px solid rgba(159, 240, 191, 0.3); }
.check.no { background: rgba(215, 38, 61, 0.18); border: 1px solid rgba(255, 154, 166, 0.35); }

.switch { display: flex; align-items: center; gap: 12px; margin: 6px 0 14px; font-weight: 700; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { flex: none; width: 46px; height: 28px; border-radius: 99px; background: rgba(255, 255, 255, 0.18); position: relative; transition: background 0.2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked + span { background: var(--pine); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(244, 201, 93, 0.4); }

/* confirm box */
#ask { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(4, 8, 20, 0.6); backdrop-filter: blur(4px); }
#ask[hidden] { display: none; }
.ask-card { max-width: 400px; width: 100%; background: var(--glass-strong); animation: rise 0.25s ease both; }
.ask-card h3 { font: italic 700 24px var(--display); margin-bottom: 8px; }
.ask-card p { color: var(--muted); margin: 0 0 18px; }
.ask-btns { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------------------------------------------------------- the reveal */
#reveal {
  position: fixed; inset: 0; z-index: 10; overflow-y: auto;
  background: radial-gradient(ellipse at 50% 35%, rgba(60, 20, 40, 0.55), rgba(4, 8, 20, 0.92) 70%);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fadein 0.4s ease both;
}
#reveal[hidden] { display: none; }
@keyframes fadein { from { opacity: 0; } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.rays {
  position: fixed; left: 50%; top: 34%; width: 160vmax; height: 160vmax; margin: -80vmax 0 0 -80vmax;
  background: repeating-conic-gradient(from 0deg, rgba(255, 214, 120, 0.1) 0deg 7deg, rgba(255, 214, 120, 0) 7deg 20deg);
  -webkit-mask: radial-gradient(circle, #000 0%, transparent 55%); mask: radial-gradient(circle, #000 0%, transparent 55%);
  opacity: 0; transform: scale(0.4);
}
#reveal.opened .rays { animation: rays-in 0.9s ease-out forwards, spin 40s linear infinite; }
@keyframes rays-in { to { opacity: 1; transform: scale(1); } }
@keyframes spin { to { rotate: 360deg; } }

.gift { position: fixed; left: 50%; top: 34%; width: 150px; height: 150px; margin: -75px 0 0 -75px; z-index: 1; }
.gift .box {
  position: absolute; left: 0; right: 0; bottom: 0; height: 110px; border-radius: 10px;
  background:
    linear-gradient(90deg, transparent 43%, var(--gold) 43%, #ffe08f 50%, var(--gold) 57%, transparent 57%),
    linear-gradient(180deg, #e8364c, #a51a30);
  box-shadow: inset 0 -12px 20px rgba(0, 0, 0, 0.25), 0 20px 40px rgba(0, 0, 0, 0.5);
}
.gift .lid {
  position: absolute; left: -8px; right: -8px; top: 22px; height: 34px; border-radius: 8px; z-index: 2;
  background:
    linear-gradient(90deg, transparent 44%, var(--gold) 44%, #ffe08f 50%, var(--gold) 56%, transparent 56%),
    linear-gradient(180deg, #f04a5f, #c21f37);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
  transform-origin: 20% 100%;
}
.bow { position: absolute; left: 50%; top: -26px; width: 0; height: 0; }
.bow i {
  position: absolute; top: 0; width: 42px; height: 30px; border: 8px solid var(--gold); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}
.bow i:first-child { right: 2px; transform: rotate(-18deg); }
.bow i:last-child { left: 2px; transform: rotate(18deg); }
#reveal.drop .gift { animation: drop 0.7s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
#reveal.shake .gift { animation: shake 0.9s ease-in-out both; }
#reveal.opened .lid { animation: lid-off 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) forwards; }
#reveal.opened .gift { animation: gift-away 1.1s 0.6s ease forwards; }
@keyframes drop { from { transform: translateY(-60vh) rotate(-12deg); } to { transform: none; } }
@keyframes shake {
  0%, 100% { transform: none; }
  15% { transform: rotate(-8deg) scale(1.03); } 30% { transform: rotate(7deg) scale(1.05); }
  45% { transform: rotate(-6deg) scale(1.07); } 60% { transform: rotate(5deg) scale(1.08); }
  75% { transform: rotate(-3deg) scale(1.1); } 90% { transform: rotate(1deg) scale(1.12); }
}
@keyframes lid-off { to { transform: translate(120px, -260px) rotate(130deg); opacity: 0; } }
@keyframes gift-away { to { transform: translateY(40px) scale(0.6); opacity: 0; } }

.result {
  position: relative; z-index: 3; max-width: 520px; margin: 0 auto; text-align: center;
  padding: max(56px, calc(env(safe-area-inset-top) + 40px)) 16px 40px;
  visibility: hidden;
}
#reveal.show .result { visibility: visible; }
.result .for { color: var(--gold); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; font-size: 14px; opacity: 0; }
#reveal.show .result .for { animation: rise 0.5s ease forwards; }
.result .name {
  font: italic 700 clamp(44px, 13vw, 80px)/1.05 var(--display);
  margin: 12px 0 14px; min-height: 1.1em;
  text-shadow: 0 0 30px rgba(255, 200, 120, 0.55), 0 3px 3px rgba(0, 0, 0, 0.4);
  overflow-wrap: anywhere;
}
.name .word { display: inline-block; white-space: nowrap; }
.name .ch { display: inline-block; opacity: 0; transform: translateY(-40px) scale(0.4) rotate(-20deg); }
#reveal.show .name .ch { animation: letter 0.6s cubic-bezier(0.3, 1.6, 0.5, 1) forwards; }
@keyframes letter { to { opacity: 1; transform: none; } }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 22px; opacity: 0; }
#reveal.show .chips { animation: rise 0.5s ease forwards; animation-delay: var(--after, 1s); }
.chip { padding: 7px 13px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); border: 1px solid var(--line); font-weight: 800; font-size: 14px; }
.wishlist {
  background: var(--glass-strong); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 8px; text-align: left; opacity: 0;
}
#reveal.show .wishlist { animation: rise 0.5s ease forwards; animation-delay: var(--after, 1s); }
.wishlist h3 { font: italic 600 20px var(--display); margin: 0 0 12px; color: var(--gold); }
.wishlist ul { list-style: none; margin: 0; padding: 0; }
.wishlist li {
  display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-top: 1px solid var(--line);
  opacity: 0; transform: translateX(-16px);
}
.wishlist li:first-child { border-top: 0; }
#reveal.show .wishlist li { animation: slide 0.45s ease forwards; }
@keyframes slide { to { opacity: 1; transform: none; } }
.wishlist li .n { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--red); font-weight: 800; font-size: 14px; }
.wishlist li a { color: var(--gold); font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.wishlist .none { color: var(--muted); padding-bottom: 12px; }
.secret { color: var(--muted); font-weight: 700; margin: 22px 0 14px; opacity: 0; }
#reveal.show .secret, #reveal.show #res-done { animation: rise 0.5s ease forwards; animation-delay: var(--after2, 1.6s); }
#res-done { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; }
}

@media (prefers-reduced-motion: reduce) { .rays { display: none; } }
