:root {
  --cream: #f3ede2;
  --paper: #fdfaf4;
  --ink: #3a2c26;
  --muted: #7d6c62;
  --olive: #7a8848;
  --olive-dark: #4f5a2b;
  --berry: #8c1d2c;
  --berry-dark: #6a1220;
  --gold: #c8a96a;
  --script: "Pinyon Script", cursive;
  --serif: "Cormorant Garamond", Georgia, serif;
  --caps: "Cormorant SC", "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  background:
    radial-gradient(120% 70% at 50% 0%, #fbf7ef 0%, var(--cream) 60%, #ebe2d2 100%);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; }

.page {
  max-width: 460px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Type */
.script { font-family: var(--script); font-weight: 400; line-height: 1.05; margin: 0; }
.caps { font-family: var(--caps); letter-spacing: .14em; text-transform: uppercase; margin: 0; }
.tiny { font-size: 13px; }
.small { font-size: 15px; }
.italic { font-style: italic; color: var(--muted); margin: 4px 0 0; }

.venue { text-align: center; }
.venue .script { font-size: 44px; color: var(--ink); }
.venue .caps { color: var(--muted); margin-top: 6px; }

/* Stage: envelope with a card in it */
.stage { position: relative; margin: 14px -8px 0; }
.env { position: relative; width: 100%; aspect-ratio: 360 / 330; }
.env > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.env .front { pointer-events: none; z-index: 3; }
.env .slot {
  position: absolute; z-index: 2;
  left: 50%; top: 1%;
  width: 60%; aspect-ratio: 210 / 262;
  transform: translateX(-50%) rotate(-4deg);
  animation: rise .9s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise { from { transform: translate(-50%, 18%) rotate(-4deg); } }

.doily { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.doily-text {
  position: absolute; inset: 19% 13% 27%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 2px;
}
.doily-text .caps { font-size: 12.5px; color: var(--ink); }
.doily-text .script { font-size: 34px; color: var(--ink); }
.doily-text .amp { font-family: var(--script); font-size: 20px; color: var(--muted); }
.doily-text .surname { font-family: var(--caps); font-size: 12px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }

/* Panel under the stage */
.panel { text-align: center; margin-top: 10px; flex: 1; }
.panel .lead { font-size: 15px; letter-spacing: .16em; }
.panel .script-lg { font-family: var(--script); font-size: 30px; margin: 6px 0 14px; color: var(--ink); }
.btn {
  display: inline-block; border: 0; cursor: pointer;
  background: var(--berry); color: #fbefe9;
  font-family: var(--serif); font-weight: 600; font-size: 14px;
  letter-spacing: .14em; text-transform: uppercase;
  padding: 13px 26px; min-width: 220px;
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 6px 16px -8px rgba(106,18,32,.7);
  transition: background .2s, transform .1s;
}
.btn:hover { background: var(--berry-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.link {
  background: none; border: 0; cursor: pointer; padding: 8px;
  font-style: italic; color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
}
.stack { display: flex; flex-direction: column; align-items: center; gap: 6px; }

/* Name search */
.field { position: relative; max-width: 320px; margin: 4px auto 0; }
.field input {
  width: 100%; border: 0; border-bottom: 1px solid #b7a796; background: transparent;
  font-family: var(--serif); font-size: 22px; text-align: center; color: var(--ink);
  padding: 8px 4px; outline: none; border-radius: 0;
}
.field input:focus { border-bottom-color: var(--berry); }
.field input::placeholder { color: #b3a395; font-style: italic; }
.results { list-style: none; margin: 10px auto 0; padding: 0; max-width: 320px; }
.results button {
  width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  background: var(--paper); border: 1px solid #e3d8c8; margin-top: 6px; padding: 11px 14px;
  cursor: pointer; text-align: left; transition: border-color .15s;
}
.results button:hover, .results button:focus-visible { border-color: var(--berry); outline: none; }
.results .nm { font-size: 19px; }
.results .tm { font-family: var(--caps); font-size: 11.5px; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; white-space: nowrap; }
.hint { font-style: italic; color: var(--muted); font-size: 16px; margin-top: 12px; }

/* Confirm */
.confirm-name { font-family: var(--script); font-size: 40px; margin: 4px 0 0; }
.confirm-team { font-family: var(--caps); letter-spacing: .14em; font-size: 13px; color: var(--muted); text-transform: uppercase; margin: 2px 0 18px; }

/* Spinner reel */
.reel {
  position: absolute; left: 8%; right: 8%; top: 25%; height: 132px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent);
          mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent);
}
.reel ul { list-style: none; margin: 0; padding: 0; will-change: transform; }
.reel li {
  height: 44px; line-height: 50px; text-align: center; white-space: nowrap;
  font-family: var(--script); font-size: 30px; color: var(--ink);
}
.reel-label { position: absolute; left: 14%; right: 14%; top: 13%; text-align: center; font-size: 12px; line-height: 1.35; }
.reel-line { position: absolute; left: 18%; right: 18%; height: 1px; background: #d5c6b2; }

/* Vinyl record = spin button */
.record {
  position: absolute; z-index: 4; right: 3%; bottom: 7%;
  width: 28%; aspect-ratio: 1; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background:
    radial-gradient(circle, var(--berry) 0 17%, #1b1715 17.5% 19%, transparent 19.5%),
    repeating-radial-gradient(circle, #1d1a18 0 2px, #2a2522 2px 3px);
  box-shadow: 0 10px 20px -8px rgba(0,0,0,.55), inset 0 0 0 2px #0f0d0c;
}
.record::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 20deg, transparent 0 12%, rgba(255,255,255,.14) 16%, transparent 22% 62%, rgba(255,255,255,.1) 66%, transparent 72%);
}
.record svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.record { animation: spin 1.8s linear infinite; animation-play-state: paused; }
.record.playing { animation-play-state: running; }
.record .ic-pause { display: none; }
.record.playing .ic-pause { display: inline; }
.record.playing .ic-play { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Carousel */
.carousel { position: relative; touch-action: pan-y; }
.arrow {
  position: absolute; z-index: 6; top: 42%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid #d8cab7; background: rgba(253,250,244,.92); cursor: pointer;
  display: grid; place-items: center; color: var(--berry);
  box-shadow: 0 4px 12px -6px rgba(58,44,38,.4);
}
.arrow svg { width: 18px; height: 18px; }
.arrow.prev { left: 4px; }
.arrow.next { right: 4px; }
.arrow:disabled { opacity: .3; cursor: default; }
.dots { display: flex; justify-content: center; gap: 8px; margin-top: 4px; }
.dots span { width: 7px; height: 7px; border-radius: 50%; background: #d3c4b0; transition: background .2s; }
.dots span.on { background: var(--berry); }

/* Gift box */
.gift {
  position: absolute; z-index: 2; left: 50%; top: 8%;
  width: 46%; aspect-ratio: 1 / 1.05; transform: translateX(-50%);
  border: 0; padding: 0; background: none; cursor: pointer;
  animation: rise-gift .9s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise-gift { from { transform: translate(-50%, 22%); } }
.gift .box {
  position: absolute; left: 6%; right: 6%; bottom: 0; height: 66%;
  background:
    linear-gradient(90deg, transparent 43%, var(--gold) 43% 57%, transparent 57%),
    radial-gradient(circle at 50% 50%, rgba(255,210,200,.18) 0 1.6px, transparent 2px) 0 0 / 14px 14px,
    linear-gradient(160deg, #a12637, var(--berry-dark));
  box-shadow: 0 16px 22px -12px rgba(40,10,10,.7), inset 0 -10px 18px -10px rgba(0,0,0,.35);
}
.gift .lid {
  position: absolute; left: 0; right: 0; top: 22%; height: 18%;
  background:
    linear-gradient(90deg, transparent 43%, #d9bd82 43% 57%, transparent 57%),
    linear-gradient(170deg, #b02c3e, #7a1626);
  box-shadow: 0 6px 10px -6px rgba(0,0,0,.6);
  transition: transform .7s cubic-bezier(.3,1.4,.5,1);
  transform-origin: 10% 100%;
}
.gift .bow { position: absolute; left: 50%; bottom: 100%; width: 60%; height: 70%; transform: translateX(-50%); }
.gift .bow::before, .gift .bow::after {
  content: ""; position: absolute; bottom: -4px; width: 46%; height: 78%;
  border: 7px solid var(--gold); border-radius: 50% 50% 10% 50%;
}
.gift .bow::before { left: 2%; transform: rotate(-28deg); }
.gift .bow::after { right: 2%; transform: scaleX(-1) rotate(-28deg); }
.gift .tag {
  position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%);
  width: 46%; aspect-ratio: 1; border-radius: 50%;
  background: var(--paper); color: var(--berry);
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 500; font-size: 56px; line-height: 1;
  box-shadow: 0 3px 10px -4px rgba(0,0,0,.5), inset 0 0 0 3px #fff, inset 0 0 0 4px #e6d8c2;
}
.gift.wiggle { animation: wiggle .5s ease; }
@keyframes wiggle {
  20% { transform: translateX(-50%) rotate(-6deg); }
  40% { transform: translateX(-50%) rotate(5deg); }
  60% { transform: translateX(-50%) rotate(-3deg); }
  80% { transform: translateX(-50%) rotate(2deg); }
}
.gift.open .lid { transform: translate(-8%, -70%) rotate(-18deg); }
.gift.open .tag { font-size: 0; }
.santa-name {
  position: absolute; z-index: 5; left: 50%; top: 6%; transform: translateX(-50%);
  width: 72%; padding: 14px 10px 12px; text-align: center;
  background: var(--paper); box-shadow: 0 10px 24px -12px rgba(0,0,0,.5);
  opacity: 0; transition: opacity .5s .35s, transform .6s .35s cubic-bezier(.2,.8,.2,1);
}
.santa-name.show { opacity: 1; transform: translateX(-50%) translateY(-6px) rotate(-3deg); }
.santa-name .script { font-size: 34px; }

/* Rules */
.rules { list-style: none; padding: 0; margin: 12px auto 0; max-width: 330px; text-align: left; }
.rules li { display: flex; gap: 14px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid #e1d6c6; font-size: 18px; line-height: 1.35; }
.rules li:last-child { border-bottom: 0; }
.rules .n { font-family: var(--script); font-size: 26px; color: var(--berry); min-width: 18px; }

.foot { text-align: center; margin-top: 26px; padding-top: 18px; border-top: 1px solid #ddd0bd; }
.foot .italic { font-size: 16px; }

.fade-in { animation: fade .5s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Paper-cutout snow and sparkles */
.decor { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.page { position: relative; z-index: 1; }
.cut { position: absolute; }
.cut svg { width: 100%; height: 100%; display: block; overflow: visible;
  filter: drop-shadow(0 1.5px 0 rgba(120,96,70,.18)) drop-shadow(0 3px 4px rgba(80,60,40,.22)); }
.flake { top: -60px; animation-name: fall, sway; animation-timing-function: linear, ease-in-out; animation-iteration-count: infinite; animation-direction: normal, alternate; }
.flake svg { animation: inherit; animation-name: turn; animation-duration: inherit; animation-timing-function: linear; animation-direction: normal; }
@keyframes fall { to { top: calc(100% + 60px); } }
@keyframes sway { from { margin-left: calc(var(--sway) * -1); } to { margin-left: var(--sway); } }
@keyframes turn { to { transform: rotate(var(--spin)); } }
.spark { transform: rotate(var(--tilt)); animation: twinkle ease-in-out infinite alternate; }
@keyframes twinkle { from { transform: rotate(var(--tilt)) scale(.72); } to { transform: rotate(var(--tilt)) scale(1.08); } }
