:root {
  --red: #b3202a;
  --red-dark: #8c1820;
  --green: #1f5133;
  --green-soft: #e3efe6;
  --gold: #d9a440;
  --cream: #fffaf3;
  --paper: #f6efe6;
  --ink: #2b1d14;
  --muted: #7a6656;
  --line: #ead9c3;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(60, 30, 10, .06), 0 8px 24px rgba(60, 30, 10, .07);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #fff6 0 40%, transparent 60%),
    var(--paper);
  background-color: var(--paper);
  overflow-x: hidden;
}
a { color: var(--green); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; margin-top: 1.2em; }
code { background: #f1e6d6; padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.warn { color: var(--red-dark); }

/* ---------- header ---------- */
.top {
  background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-left)) 14px;
  position: relative; z-index: 2;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; line-height: 1.05; font-size: .82rem; letter-spacing: .3px; }
.brand b { font-family: "Mountains of Christmas", Georgia, serif; font-size: 1.55rem; letter-spacing: .5px; display: inline-block; margin-top: 1px; }
.brand-hat { font-size: 2rem; display: inline-block; transform-origin: 50% 90%; animation: wiggle 6s ease-in-out infinite; }
.top nav { display: flex; align-items: center; gap: 14px; font-size: .92rem; }
.top nav a, .top .linkish { color: #fff; text-decoration: none; opacity: .92; }
.top nav a:hover, .top .linkish:hover { opacity: 1; text-decoration: underline; }
.top nav form { margin: 0; }
.linkish { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
@keyframes wiggle { 0%, 88%, 100% { transform: rotate(0); } 91% { transform: rotate(-12deg); } 95% { transform: rotate(10deg); } }

/* string of fairy lights under the header */
.lights { display: flex; justify-content: space-around; height: 18px; margin-top: -2px; position: relative; z-index: 1;
  background: radial-gradient(ellipse at 50% -40%, transparent 60%, #3b2a1e 61%, #3b2a1e 64%, transparent 65%) 0 0 / 5.55% 18px repeat-x; overflow: hidden; }
.lights i { width: 8px; height: 12px; margin-top: 6px; border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%; background: var(--gold); animation: twinkle 2.4s infinite; }
.lights i:nth-child(4n+1) { background: #e8463f; animation-delay: .3s; }
.lights i:nth-child(4n+2) { background: #3fae5f; animation-delay: .9s; }
.lights i:nth-child(4n+3) { background: #4aa3e0; animation-delay: 1.5s; }
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- snow (14 elements, transform-only animation) ---------- */
.snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.snow i { position: absolute; top: -5vh; color: #fff; font-style: normal; text-shadow: 0 0 3px #c9b8a6; opacity: .85;
  animation: fall linear infinite; will-change: transform; }
.snow i:nth-child(1)  { left: 4%;  font-size: 14px; animation-duration: 14s; animation-delay: -2s; }
.snow i:nth-child(2)  { left: 12%; font-size: 10px; animation-duration: 18s; animation-delay: -9s; }
.snow i:nth-child(3)  { left: 20%; font-size: 16px; animation-duration: 16s; animation-delay: -5s; }
.snow i:nth-child(4)  { left: 28%; font-size: 9px;  animation-duration: 20s; animation-delay: -14s; }
.snow i:nth-child(5)  { left: 36%; font-size: 13px; animation-duration: 15s; animation-delay: -1s; }
.snow i:nth-child(6)  { left: 44%; font-size: 11px; animation-duration: 19s; animation-delay: -11s; }
.snow i:nth-child(7)  { left: 52%; font-size: 15px; animation-duration: 17s; animation-delay: -7s; }
.snow i:nth-child(8)  { left: 60%; font-size: 10px; animation-duration: 21s; animation-delay: -3s; }
.snow i:nth-child(9)  { left: 68%; font-size: 14px; animation-duration: 15s; animation-delay: -12s; }
.snow i:nth-child(10) { left: 76%; font-size: 9px;  animation-duration: 18s; animation-delay: -6s; }
.snow i:nth-child(11) { left: 84%; font-size: 16px; animation-duration: 16s; animation-delay: -10s; }
.snow i:nth-child(12) { left: 92%; font-size: 11px; animation-duration: 20s; animation-delay: -4s; }
.snow i:nth-child(13) { left: 8%;  font-size: 12px; animation-duration: 22s; animation-delay: -16s; }
.snow i:nth-child(14) { left: 72%; font-size: 12px; animation-duration: 23s; animation-delay: -19s; }
@keyframes fall { to { transform: translate3d(30px, 110vh, 0) rotate(240deg); } }

/* ---------- layout ---------- */
main { position: relative; z-index: 1; max-width: 640px; margin: 0 auto; padding: 22px 16px 40px; }
main.wide { max-width: 860px; }
.foot { position: relative; z-index: 1; text-align: center; color: var(--muted); font-size: .82rem; padding: 10px 16px 30px; }
.card { background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.card-head h2 { margin: 0; }
.hero { text-align: center; padding: 30px 22px; margin-top: 10px; }
.hero form { text-align: left; }
.hero-icon { font-size: 3.2rem; line-height: 1; margin-bottom: 10px; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.lead { font-size: 1.05rem; color: var(--muted); margin: 0 0 18px; }
.accent { color: var(--red); }
.greeting { margin: 4px 4px 16px; }
.greeting h1 { margin-bottom: 2px; }
.greeting p { margin: 0; }

/* ---------- forms ---------- */
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 5px; font-weight: 600; font-size: .95rem; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink);
  width: 100%; padding: 11px 13px; border: 1.5px solid #dccab3; border-radius: 12px; background: #fff;
  font-size: 16px; /* prevents iOS zoom */
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px #1f513326; }
textarea { resize: vertical; }
fieldset { border: 1.5px dashed #dccab3; border-radius: 14px; padding: 12px 14px 14px; margin: 0; display: grid; gap: 10px; }
legend { font-weight: 700; padding: 0 6px; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 400; }
label.check input { width: 20px; height: 20px; flex: none; accent-color: var(--green); }
label.strong { font-weight: 600; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .row2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  background: var(--green); color: #fff; border: 2px solid var(--green);
  padding: 10px 20px; border-radius: 999px; transition: transform .12s, background .2s;
}
.btn:hover { background: #17402a; }
.btn:active { transform: scale(.97); }
.btn.big { padding: 14px 26px; font-size: 1.05rem; width: 100%; }
.btn.small { padding: 6px 14px; font-size: .88rem; }
.btn.ghost { background: transparent; color: var(--green); }
.btn.ghost:hover { background: var(--green-soft); }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn.festive { background: var(--red); border-color: var(--red); }
.btn.festive:hover { background: var(--red-dark); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { flex: none; width: 40px; height: 44px; border: 0; background: none; color: var(--muted); font-size: 1rem; cursor: pointer; border-radius: 10px; }
.icon-btn:hover { background: #f1e6d6; color: var(--red); }

.notice { padding: 11px 14px; border-radius: 12px; margin: 0 0 16px; font-size: .95rem; }
.notice.ok { background: var(--green-soft); color: var(--green); border: 1px solid #c4dccb; }
.notice.err { background: #fbe7e5; color: var(--red-dark); border: 1px solid #f0c4bf; }

/* ---------- wishlist ---------- */
.wish-rows, .person-rows { display: grid; gap: 10px; }
.wish-row { display: grid; grid-template-columns: 1.3fr 1fr auto; gap: 8px; }
.person-row { display: grid; grid-template-columns: 1fr 1fr 1.5fr auto; gap: 8px; }
@media (max-width: 560px) {
  .wish-row { grid-template-columns: 1fr auto; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
  .wish-row input[name=item_url] { grid-column: 1; grid-row: 2; }
  .wish-row .icon-btn { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
  .person-row { grid-template-columns: 1fr 1fr auto; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
  .person-row input[type=email] { grid-column: 1 / span 2; grid-row: 2; }
  .person-row .icon-btn { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
}
.wishes { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.wishes li { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 10px 40px; position: relative; }
.wishes li::before { content: "🎁"; position: absolute; left: 12px; top: 9px; }
.notes { background: #fff; border-left: 4px solid var(--gold); border-radius: 8px; padding: 10px 14px; white-space: pre-wrap; margin-bottom: 12px; }

/* ---------- the gift reveal ---------- */
.waiting { text-align: center; padding: 10px 0 4px; }
.waiting-icon { font-size: 2.6rem; animation: bob 3s ease-in-out infinite; }
.waiting p { margin: 4px 0; }
.gift { text-align: center; }
.gift-box { position: relative; background: none; border: 0; cursor: pointer; padding: 26px 0 10px; width: 100%; font: inherit; color: var(--ink); }
.gift-box .box { display: block; margin: 0 auto; width: 130px; height: 100px; border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 44%, var(--gold) 44% 56%, transparent 56%),
    var(--red);
  box-shadow: inset 0 -10px 0 #0001; }
.gift-box .lid { display: block; margin: 0 auto -4px; width: 146px; height: 30px; border-radius: 7px; position: relative; z-index: 1;
  background: linear-gradient(90deg, transparent 44%, var(--gold) 44% 56%, transparent 56%), #c92b35;
  transition: transform .6s cubic-bezier(.3, 1.6, .5, 1), opacity .6s; }
.gift-box .lid::before, .gift-box .lid::after { content: ""; position: absolute; top: -22px; width: 30px; height: 26px; border: 6px solid var(--gold); border-radius: 50% 50% 0 50%; }
.gift-box .lid::before { left: 40px; transform: rotate(10deg); }
.gift-box .lid::after { right: 40px; transform: scaleX(-1) rotate(10deg); }
.gift-box:not(.open) { animation: shake 3.5s ease-in-out infinite; }
.gift-box:hover .lid { transform: translateY(-6px) rotate(-3deg); }
.gift-label { display: block; margin-top: 14px; font-weight: 700; color: var(--red); }
.gift-box.open .lid { transform: translate(60px, -60px) rotate(35deg); opacity: 0; }
.gift-box.open .gift-label { visibility: hidden; }
.gift-box.open { display: none; }
@keyframes shake { 0%, 84%, 100% { transform: rotate(0); } 87% { transform: rotate(-4deg); } 90% { transform: rotate(4deg); } 93% { transform: rotate(-3deg); } 96% { transform: rotate(2deg); } }
.gift-inside { text-align: left; animation: pop .5s cubic-bezier(.3, 1.5, .5, 1); }
.gift-inside > .small:first-child { text-align: center; margin: 0; }
.match-name { text-align: center; font-family: "Mountains of Christmas", Georgia, serif; font-size: 2.6rem; color: var(--red); margin: 0 0 6px; line-height: 1.1; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.confetti { position: fixed; top: 0; left: 0; pointer-events: none; z-index: 10; font-size: 22px; animation: burst 1.3s ease-out forwards; }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; } }

/* ---------- admin ---------- */
.admin-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.event-pick { margin: 6px 0 0; }
.event-pick label { font-weight: 600; }
.event-pick select { width: auto; max-width: 100%; padding: 8px 12px; }
.event-title { margin: 10px 4px 14px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.stats div { background: var(--cream); border: 1px solid var(--line); border-radius: 14px; padding: 10px; text-align: center; }
.stats b { display: block; font-size: 1.5rem; color: var(--green); }
.stats span { font-size: .8rem; color: var(--muted); }
.draw-card { border: 2px solid var(--gold); background: linear-gradient(180deg, #fff8ea, var(--cream)); }
.draw-card.is-drawn { border-color: #b9d6c1; background: var(--cream); }
.draw-card form { margin: 0; }
.draw-list { margin: 0 0 14px; }
.draw-list summary { list-style: none; display: inline-flex; }
.draw-list summary::-webkit-details-marker { display: none; }
.draw-list[open] summary { margin-bottom: 10px; }
.draw-list ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.draw-list li { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 9px 14px; }
.people { list-style: none; padding: 0; margin: 0 0 14px; }
.person { display: flex; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.person:last-child { border-bottom: 0; }
.person-main { min-width: 0; flex: 1 1 260px; }
.person-name { font-weight: 700; }
.email { overflow-wrap: anywhere; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.badge { font-size: .76rem; padding: 2px 9px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.badge.yes { background: var(--green-soft); color: var(--green); }
.badge.no { background: #f3ebe0; color: var(--muted); }
.badge.admin { background: #fbe7e5; color: var(--red); vertical-align: 2px; }
.excl { margin-top: 6px; color: var(--muted); }
.person-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; align-content: start; }
.person-actions form { margin: 0; }
.reveal-out { font-weight: 700; color: var(--red); }
.add-person summary { list-style: none; display: inline-flex; }
.add-person summary::-webkit-details-marker { display: none; }
.add-person[open] summary { margin-bottom: 14px; }
details > summary { cursor: pointer; }
h2.inline { display: inline; }
.email-log { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.email-log li { overflow-wrap: anywhere; }
@media (max-width: 480px) {
  h1 { font-size: 1.45rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .brand { font-size: .72rem; }
  .brand b { font-size: 1.3rem; }
  .top nav { gap: 10px; font-size: .85rem; }
  .card { padding: 18px 16px; }
}

/* ---------- test mode bar ---------- */
.devbar { position: relative; z-index: 3; background: #2b1d14; color: #f3e3c8; font-size: .8rem; text-align: center; padding: 5px 10px; }
.devbar a { color: #ffd98a; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .snow { display: none; }
}
