:root {
  --bg: #fbf4ea;
  --card: #ffffff;
  --ink: #3b2a24;
  --muted: #8a776c;
  --red: #c8102e;
  --red-dark: #9e0c24;
  --green: #1f6b45;
  --green-soft: #e3f1e8;
  --gold: #e8b04b;
  --line: #efe3d4;
  --shadow: 0 2px 0 rgba(59, 42, 36, 0.05), 0 8px 24px rgba(59, 42, 36, 0.07);
  --radius: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 10% 0%, rgba(200, 16, 46, 0.08), transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(31, 107, 69, 0.08), transparent 40%);
  color: var(--ink);
  font-family: "Fredoka", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.45;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--red); }
h1, h2, h3 { line-height: 1.15; margin: 0 0 0.4em; }
p { margin: 0 0 0.6em; }
.festive { font-family: "Mountains of Christmas", "Fredoka", cursive; font-weight: 700; letter-spacing: 0.5px; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.center { text-align: center; }
.spaced { margin-top: 1rem; }

/* ---------- top bar & nav ---------- */
.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: var(--red);
  color: #fff;
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,0.06) 0 14px, transparent 14px 28px);
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; min-width: 0; }
.brand-icon { font-size: 1.6rem; }
.brand-name { font-family: "Mountains of Christmas", cursive; font-weight: 700; font-size: 1.35rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.whoami { font-size: 0.9rem; opacity: 0.9; }
.logout .link { color: #fff; opacity: 0.85; }
@media (max-width: 520px) { .whoami { display: none; } }

.tabs {
  position: sticky; top: 0; z-index: 3;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 12px; border-radius: 12px;
  color: var(--ink); text-decoration: none; font-size: 0.8rem; font-weight: 500;
  white-space: nowrap;
}
.tabs a.active { background: var(--green-soft); color: var(--green); }
.tab-icon { font-size: 1.25rem; }

.container { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 0 16px 32px; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
}
.card-title { font-size: 1.15rem; }
.section-title { font-size: 1.2rem; margin: 26px 4px 10px; color: var(--green); }
.page-title { font-size: 2.2rem; color: var(--red); text-align: center; margin-top: 4px; }

.hero-card { max-width: 440px; margin: 6vh auto 0; text-align: center; padding: 28px 22px; }
.hero-card h1 { font-size: 2.3rem; color: var(--red); }
.hero-emoji { font-size: 3.4rem; }
.big-emoji { font-size: 2.6rem; }

.welcome h1 { font-size: 2.3rem; color: var(--red); }
.facts { display: grid; gap: 10px; margin-top: 12px; }
.fact { display: flex; gap: 10px; align-items: flex-start; background: var(--bg); padding: 10px 12px; border-radius: 12px; }
.fact-icon { font-size: 1.3rem; }
.countdown { color: var(--green); font-weight: 600; }

.reveal-banner { display: block; text-decoration: none; color: var(--ink); background: linear-gradient(90deg, #fff6dc, #fff); border-color: var(--gold); text-align: center; }

/* ---------- flash ---------- */
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: var(--green-soft); color: var(--green); }
.flash.err { background: #fde8eb; color: var(--red-dark); }
.flash.dev { background: #fff6dc; color: #7a5600; }

/* ---------- forms ---------- */
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 180px; min-width: 0; }
.price { flex: 0 0 110px; }
label { display: grid; gap: 4px; font-weight: 500; font-size: 0.92rem; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink);
  width: 100%; padding: 11px 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fffdfa;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,107,69,0.15); }
textarea { resize: vertical; }
fieldset { border: 1.5px dashed var(--line); border-radius: 12px; padding: 10px 12px; margin: 0; }
legend { font-weight: 600; font-size: 0.92rem; padding: 0 6px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: auto; accent-color: var(--green); transform: scale(1.2); }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.code-input { font-size: 2rem; text-align: center; letter-spacing: 0.4em; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  padding: 10px 18px; border-radius: 999px;
  border: 2px solid var(--green); background: #fff; color: var(--green);
  transition: transform 0.1s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.big { padding: 14px 22px; font-size: 1.05rem; }
.btn.small { padding: 6px 12px; font-size: 0.88rem; }
.btn.ghost { border-color: var(--line); color: var(--muted); }
.btn.done { background: var(--green-soft); border-color: var(--green); }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
button.link { background: none; border: none; font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }
.icon-btn { background: none; border: none; font-size: 1.1rem; cursor: pointer; padding: 6px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0 6px; }

/* ---------- avatars & people ---------- */
.avatar {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line);
  font-size: 1.6rem; line-height: 1;
}
.avatar.sm { width: 30px; height: 30px; font-size: 1rem; vertical-align: middle; }
.avatar.lg { width: 84px; height: 84px; font-size: 3rem; border-color: var(--gold); }
.list-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.person-card { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); margin: 0; padding: 14px; }
.person-card:hover { border-color: var(--gold); }
.person-card > div { flex: 1; min-width: 0; }
.chev { font-size: 1.6rem; color: var(--muted); }
.nudge { color: var(--red); font-size: 0.88rem; }
.badge { display: inline-block; background: #fff6dc; color: #7a5600; border-radius: 999px; padding: 2px 10px; font-size: 0.85rem; font-weight: 600; margin-left: 6px; }

.profile { display: flex; align-items: center; gap: 16px; }
.profile h1 { font-size: 2rem; color: var(--red); margin: 0; }
.profile .badge { margin: 4px 0 0; }
.infos p:last-child { margin: 0; }

/* ---------- wishlist ---------- */
.wish-list { list-style: none; padding: 0; margin: 0; }
.wish { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; padding: 14px 16px; }
.wish-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.wish-title { font-size: 1.05rem; }
.price-tag { display: inline-block; margin-left: 8px; font-size: 0.82rem; background: var(--green-soft); color: var(--green); border-radius: 999px; padding: 1px 9px; font-weight: 600; }
.wish p { margin: 4px 0 0; }

.emoji-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-picker label { display: block; cursor: pointer; }
.emoji-picker input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.emoji-picker span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; font-size: 1.5rem; border: 2px solid transparent; background: var(--bg); }
.emoji-picker input:checked + span { border-color: var(--red); background: #fde8eb; }
.emoji-picker input:focus-visible + span { box-shadow: 0 0 0 3px rgba(31,107,69,0.3); }

/* ---------- picks ---------- */
.pick-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.pick { text-align: center; margin: 0; }
.pick-who { font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; }
.pick.closed { background: linear-gradient(180deg, #fff, #fff6f6); }
.hint { color: var(--muted); font-size: 0.9rem; }

.giftbox {
  position: relative; width: 140px; height: 140px; margin: 16px auto 8px; display: block;
  background: none; border: none; cursor: pointer; padding: 0;
  animation: wiggle 2.4s ease-in-out infinite;
}
.giftbox .box { position: absolute; left: 14px; right: 14px; bottom: 0; height: 88px; background: var(--red); border-radius: 8px; }
.giftbox .lid { position: absolute; left: 4px; right: 4px; top: 30px; height: 28px; background: var(--red-dark); border-radius: 8px; z-index: 2; transition: transform 0.6s cubic-bezier(.3,1.6,.6,1), opacity 0.6s; }
.giftbox .lid::before, .giftbox .lid::after {
  content: ""; position: absolute; top: -26px; width: 34px; height: 30px; border: 7px solid var(--gold); border-radius: 50% 50% 0 50%;
}
.giftbox .lid::before { left: 32px; transform: rotate(-20deg); }
.giftbox .lid::after { right: 32px; transform: scaleX(-1) rotate(-20deg); }
.giftbox .ribbon { position: absolute; left: 50%; transform: translateX(-50%); top: 30px; bottom: 0; width: 18px; background: var(--gold); z-index: 3; }
.giftbox:hover { animation-duration: 0.8s; }
.giftbox.opening { animation: shake 0.5s ease-in-out 2; }
.giftbox.opening .lid { transform: translateY(-60px) rotate(-25deg); opacity: 0; }
.giftbox.opening .ribbon { opacity: 0; transition: opacity 0.3s 0.3s; }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-4deg); } 90% { transform: rotate(4deg); } 95% { transform: rotate(-2deg); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px) rotate(-3deg); } 75% { transform: translateX(6px) rotate(3deg); } }

.secret {
  display: grid; justify-items: center; gap: 4px; width: 100%;
  background: var(--bg); border: 2px dashed var(--gold); border-radius: var(--radius);
  padding: 16px; margin: 10px 0; cursor: pointer; font: inherit; color: var(--ink);
}
.secret-name { font-size: 2.4rem; color: var(--red); line-height: 1.1; }
.secret .avatar, .secret .secret-name, .secret .muted { filter: blur(14px); transition: filter 0.35s ease; }
.secret.shown .avatar, .secret.shown .secret-name, .secret.shown .muted { filter: none; }
.secret-hint { font-size: 0.82rem; color: var(--muted); }
.secret.shown .secret-hint { visibility: hidden; }
.just-opened .secret { animation: pop 0.7s cubic-bezier(.3,1.6,.6,1); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.ready-form { margin-top: 6px; }

/* ---------- questions ---------- */
.qa-list { list-style: none; padding: 0; margin: 10px 0 0; }
.qa { border-top: 1px dashed var(--line); padding: 12px 0; }
.qa:first-child { border-top: none; }
.qa .q { font-size: 1.05rem; font-weight: 500; margin: 2px 0 6px; overflow-wrap: anywhere; }
.qa .a { background: var(--green-soft); border-radius: 12px; padding: 8px 12px; margin: 0; overflow-wrap: anywhere; }

/* ---------- reveal ---------- */
.chain { list-style: none; padding: 0; display: grid; gap: 10px; }
.chain-link { display: flex; align-items: center; gap: 12px; margin: 0; }
.chain-link .arrow { margin-left: auto; color: var(--green); font-weight: 600; text-align: right; }

/* ---------- admin ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { display: grid; text-align: center; margin: 0; padding: 14px 8px; }
.stat strong { font-size: 1.6rem; color: var(--red); }
.stat span { font-size: 0.82rem; color: var(--muted); }
.rules { padding-left: 0; list-style: none; }
.status-list { columns: 2 220px; padding-left: 18px; }
.people-admin { display: grid; gap: 8px; margin-bottom: 8px; }
.person-admin { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.person-admin summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.person-admin summary::-webkit-details-marker { display: none; }
.person-admin[open] summary { margin-bottom: 12px; }
.person-form { margin-bottom: 10px; }
details > summary.btn { list-style: none; }
details > summary.btn::-webkit-details-marker { display: none; }
details[open] > summary.btn { margin-bottom: 12px; }
.household-admin { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.household-admin li { display: flex; align-items: center; gap: 8px; }
.household-admin li > form.row { flex: 1; align-items: center; }

/* ---------- snow & confetti ---------- */
.snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.flake { position: absolute; top: -10px; color: #fff; text-shadow: 0 0 2px rgba(120, 150, 180, 0.6); animation: fall linear infinite; opacity: 0.85; }
@keyframes fall { to { transform: translateY(110vh) translateX(var(--drift, 20px)) rotate(360deg); } }
.confetti { position: fixed; top: -12px; width: 9px; height: 14px; z-index: 10; pointer-events: none; border-radius: 2px; animation: confetti 2.6s ease-in forwards; }
@keyframes confetti { to { transform: translateY(105vh) translateX(var(--dx)) rotate(var(--rot)); opacity: 0.6; } }

@media (prefers-reduced-motion: reduce) {
  .snow, .confetti { display: none; }
  .giftbox { animation: none; }
}
