:root {
  --ink: #1a1a1a;
  --red: #c8102e;
  --red-dark: #9c0c24;
  --green: #2e6b3a;
  --yellow: #f4c430;
  --paper: #fbf6e9;
  --night: #27406b;
  --snow: #eaf2fa;
  --wobble: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --wobble2: 15px 225px 15px 255px / 255px 15px 225px 15px;
}

* { box-sizing: border-box; }

/* Christmas tree mouse cursor (hotspot at the star on top) */
html, body, a, button, label, summary, select, [role="button"], [class]:not(input):not(textarea),
.combo li, :disabled {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Crect x='14' y='26' width='4' height='5' fill='%238b5a2b'/%3E%3Cpath d='M16 6 L24 15 H19 L27 24 H5 L13 15 H8 Z' fill='%232e6b3a' stroke='%231a1a1a' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M16 1 L17.5 4.5 L21 4.8 L18.4 7 L19.2 10.4 L16 8.6 L12.8 10.4 L13.6 7 L11 4.8 L14.5 4.5 Z' fill='%23f4c430' stroke='%231a1a1a' stroke-width='1'/%3E%3Ccircle cx='15' cy='15' r='1.4' fill='%23c8102e'/%3E%3Ccircle cx='20' cy='21' r='1.4' fill='%23c8102e'/%3E%3Ccircle cx='11' cy='21' r='1.4' fill='%23f4c430'/%3E%3C/svg%3E") 16 2, auto !important;
}

html { background: var(--night); }

body {
  margin: 0;
  font-family: "Patrick Hand", "Comic Sans MS", "Chalkboard SE", cursive;
  font-size: 1.2rem;
  color: var(--ink);
  background: linear-gradient(var(--night) 0, #3d5a8c 360px, var(--snow) 361px) no-repeat, var(--snow);
  min-height: 100vh;
}

h1, h2, .bubble, .label, .submit {
  font-family: "Schoolbell", "Patrick Hand", "Comic Sans MS", cursive;
}

/* ---------- falling snow ---------- */
.snow {
  position: fixed; inset: 0; pointer-events: none; z-index: 10;
  background-image:
    radial-gradient(3px 3px at 20px 30px, #fff, transparent),
    radial-gradient(2px 2px at 90px 120px, #fff, transparent),
    radial-gradient(3px 3px at 160px 60px, #fff, transparent),
    radial-gradient(2px 2px at 230px 200px, #fff, transparent),
    radial-gradient(3px 3px at 310px 100px, #fff, transparent),
    radial-gradient(2px 2px at 60px 240px, #fff, transparent);
  background-size: 340px 280px;
  opacity: .85;
  animation: fall 14s linear infinite;
}
@keyframes fall { to { background-position: 40px 280px; } }
@media (prefers-reduced-motion: reduce) { .snow { animation: none; } }

/* ---------- header ---------- */
.sky {
  display: flex; align-items: flex-end; justify-content: center; gap: 1.5rem;
  max-width: 900px; margin: 0 auto; padding: 2rem 1rem 0;
}
.tree { width: clamp(130px, 24vw, 210px); flex: none; margin-bottom: -8px; }
.title-block { color: #fff; padding-bottom: 1.5rem; }
h1 {
  margin: .5rem 0 0; font-size: clamp(2rem, 6vw, 3.6rem); line-height: 1.05; font-weight: 400;
  text-shadow: 3px 3px 0 var(--ink);
}
.bubble {
  display: inline-block; position: relative; margin: 0; padding: .55rem 1rem;
  background: #fff; color: var(--ink); border: 3px solid var(--ink); border-radius: var(--wobble);
  font-size: 1.15rem; max-width: 22rem;
}
.bubble::after { /* speech-bubble tail */
  content: ""; position: absolute; left: -16px; bottom: 8px; width: 18px; height: 18px;
  background: #fff; border-left: 3px solid var(--ink); border-bottom: 3px solid var(--ink);
  transform: skewY(40deg) rotate(8deg);
}

/* Charlie Brown's shirt zigzag */
.zigzag {
  height: 26px; border-top: 3px solid var(--ink); border-bottom: 3px solid var(--ink);
  background:
    linear-gradient(135deg, var(--ink) 25%, transparent 25%) 0 0 / 26px 26px,
    linear-gradient(225deg, var(--ink) 25%, transparent 25%) 0 0 / 26px 26px,
    var(--yellow);
}

/* ---------- layout ---------- */
main {
  position: relative; z-index: 1;
  max-width: 720px; margin: 0 auto; padding: 1.5rem 1rem 2rem;
  display: grid; gap: 1.5rem;
}

.card {
  background: var(--paper);
  border: 3px solid var(--ink); border-radius: var(--wobble);
  padding: 1.6rem 1.8rem; box-shadow: 6px 6px 0 rgba(26, 26, 26, .85);
}
.card:nth-child(even) { border-radius: var(--wobble2); }
h2 { margin: 0 0 1rem; font-size: 1.9rem; font-weight: 400; color: var(--red); }

.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; text-align: center; }
.details span { display: block; font-family: "Schoolbell", cursive; color: var(--green); font-size: 1rem; text-transform: uppercase; letter-spacing: .08em; }
.details strong { display: block; font-weight: 400; font-size: 1.3rem; }
.details em { font-style: normal; }

/* ---------- form ---------- */
.label { display: block; font-size: 1.15rem; margin-bottom: .35rem; color: var(--green); }
.field { display: block; margin-bottom: 1.2rem; }

input[type="text"], textarea {
  width: 100%; padding: .65rem .9rem; font: inherit; color: var(--ink);
  background: #fff; border: 3px solid var(--ink); border-radius: 14px 6px 12px 8px / 8px 12px 6px 14px;
}
textarea { resize: vertical; min-height: 5rem; }
input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 4px rgba(200, 16, 46, .18); }

.attend { border: 0; padding: 0; margin: 0 0 1.2rem; display: flex; flex-wrap: wrap; gap: .6rem; }
.attend legend { padding: 0; width: 100%; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span {
  display: inline-block; padding: .5rem 1rem; cursor: pointer; background: #fff;
  border: 3px solid var(--ink); border-radius: 999px;
}
.pill input:checked + span { background: var(--green); color: #fff; }
.pill input[value="no"]:checked + span { background: var(--red); }
.pill input:focus-visible + span { outline: 3px dashed var(--red); outline-offset: 3px; }

.counters { display: flex; flex-wrap: wrap; gap: 1.5rem 2.5rem; margin-bottom: 1rem; }
.stepper { display: inline-flex; align-items: center; gap: .6rem; }
.stepper button {
  width: 2.4rem; height: 2.4rem; font: inherit; font-size: 1.5rem; line-height: 1; cursor: pointer;
  background: var(--yellow); color: var(--ink); border: 3px solid var(--ink); border-radius: 50%;
}
.stepper button:hover { background: #ffd95a; }
.stepper button:active { transform: translateY(2px); }
.stepper output { min-width: 2ch; text-align: center; font-size: 1.6rem; font-family: "Schoolbell", cursive; }

.names { display: grid; gap: .8rem; }
.names:not(:empty) { margin-bottom: 1rem; }
.name-row { animation: pop .25s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
.name-row .label { font-size: 1rem; }
.kid .label { color: var(--red); }

/* ---------- type-ahead ---------- */
.combo { position: relative; }
.combo ul {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  margin: 0; padding: .3rem; list-style: none; max-height: 14rem; overflow: auto;
  background: #fff; border: 3px solid var(--ink); border-radius: 10px; box-shadow: 4px 4px 0 rgba(26, 26, 26, .85);
}
.combo li { padding: .4rem .7rem; cursor: pointer; border-radius: 6px; }
.combo li[aria-selected="true"], .combo li:hover { background: var(--yellow); }
.combo li b { font-weight: 400; text-decoration: underline wavy var(--red) 1.5px; text-underline-offset: 3px; }

.error { color: var(--red-dark); margin: 0 0 .8rem; }
.submit {
  display: block; width: 100%; padding: .8rem 1rem; font-size: 1.5rem; cursor: pointer;
  color: #fff; background: var(--red); border: 3px solid var(--ink); border-radius: var(--wobble);
  box-shadow: 4px 4px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.submit:hover { background: var(--red-dark); }
.submit:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.submit:disabled { opacity: .6; cursor: wait; }

/* ---------- thank-you ---------- */
.thanks h2 { font-size: 2.2rem; }
#responses { display: grid; gap: 1rem; margin: 1.2rem 0; }
.response { background: #fff; border: 3px solid var(--ink); border-radius: var(--wobble); padding: .9rem 1.2rem; }
.response b { display: block; font-family: "Schoolbell", cursive; font-weight: 400; color: var(--green); margin-bottom: .2rem; }
.link { font: inherit; background: none; border: 0; color: var(--red); text-decoration: underline; cursor: pointer; padding: 0; }

footer { position: relative; z-index: 1; text-align: center; padding: 0 1rem 2rem; color: var(--green); }

[hidden] { display: none !important; }

@media (max-width: 560px) {
  .sky { flex-direction: column; align-items: center; text-align: center; }
  .tree { margin-bottom: 0; order: 2; }
  .title-block { padding-bottom: 0; }
  .bubble::after { display: none; }
  .card { padding: 1.2rem; }
}

/* Background music toggle */
.music-toggle {
  position: fixed; top: 14px; right: 14px; z-index: 1000;
  width: 48px; height: 48px; padding: 0; cursor: pointer;
  display: grid; place-items: center;
  background: var(--yellow); color: var(--ink);
  border: 3px solid var(--ink); border-radius: var(--wobble);
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .1s;
}
.music-toggle:hover { transform: rotate(-6deg) scale(1.06); }
.music-toggle:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
.music-toggle svg { width: 24px; height: 24px; fill: currentColor; }
.music-toggle .icon-play { display: none; }
.music-toggle[aria-pressed="false"] .icon-pause { display: none; }
.music-toggle[aria-pressed="false"] .icon-play { display: block; }

/* ---------- celebratory jumper on the thanks card ---------- */
.jumper { position: relative; display: flex; justify-content: center; margin: -0.5rem auto 0.5rem; width: 180px; height: 180px; }
.jumper .kid { overflow: visible; }
.jumper .kid-body { transform-box: view-box; transform-origin: 60px 158px; }
.jumper .arm-l { transform-box: view-box; transform-origin: 44px 92px; }
.jumper .arm-r { transform-box: view-box; transform-origin: 76px 92px; }
.jumper .kid-shadow { transform-box: fill-box; transform-origin: center; }
.jumper .spark { position: absolute; font-size: 1.3rem; color: var(--yellow); opacity: 0; pointer-events: none; }
.jumper .spark:nth-child(even) { color: var(--red); }
.jumper .s1 { left: 8%;  top: 30%; }
.jumper .s2 { right: 6%; top: 20%; }
.jumper .s3 { right: 12%; top: 55%; }
.jumper .s4 { left: 14%; top: 60%; }

.jumper.go .kid-body   { animation: kid-jump .6s cubic-bezier(.3,0,.4,1) 6, kid-bob 1.6s ease-in-out 3.6s infinite; }
.jumper.go .kid-shadow { animation: kid-shadow .6s cubic-bezier(.3,0,.4,1) 6; }
.jumper.go .arm-l      { animation: arm-l .3s ease-in-out 12 alternate; }
.jumper.go .arm-r      { animation: arm-r .3s ease-in-out 12 alternate; }
.jumper.go .spark      { animation: spark 1.2s ease-out 3; }
.jumper.go .s2 { animation-delay: .3s; }
.jumper.go .s3 { animation-delay: .6s; }
.jumper.go .s4 { animation-delay: .9s; }

@keyframes kid-jump {
  0%   { transform: translateY(0) scale(1.08, .9); }
  15%  { transform: translateY(0) scale(.94, 1.08); }
  50%  { transform: translateY(-42px) scale(1, 1); }
  85%  { transform: translateY(0) scale(.96, 1.04); }
  100% { transform: translateY(0) scale(1.08, .9); }
}
@keyframes kid-shadow {
  0%, 15%, 85%, 100% { transform: scale(1); opacity: .18; }
  50% { transform: scale(.55); opacity: .08; }
}
@keyframes kid-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes arm-l { from { transform: rotate(8deg); }  to { transform: rotate(-14deg); } }
@keyframes arm-r { from { transform: rotate(-8deg); } to { transform: rotate(14deg); } }
@keyframes spark {
  0%   { opacity: 0; transform: translateY(10px) scale(.4) rotate(0); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-30px) scale(1.2) rotate(90deg); }
}

@media (prefers-reduced-motion: reduce) {
  .jumper.go .kid-body, .jumper.go .kid-shadow, .jumper.go .arm-l,
  .jumper.go .arm-r, .jumper.go .spark { animation: none; }
}

/* ---- family-match pop-up ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(26,26,26,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal-backdrop[hidden] { display: none; }
.modal { background: #fbf6e9; border: 3px solid #1a1a1a; border-radius: 14px; padding: 22px; max-width: 420px; width: 100%; text-align: center; }
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; margin-top: 16px; }
