:root {
  --cranberry: #a3142a;
  --pine: #0e4a38;
  --snow: #f3f8f6;
  --bulb: #ffc53d;
  --berry: #3b0611;
  --ice: #bfeaf2;
  --display: Grandstander, "Trebuchet MS", sans-serif;
  --body: "Nunito Sans", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--cranberry); }
body {
  margin: 0; min-height: 100vh; overflow-x: hidden;
  font: 400 1.0625rem/1.5 var(--body); color: var(--berry); background-color: var(--cranberry);
}
h1, h2, p, dl, dd { margin: 0; }
h2 { font: 800 1.625rem/1.15 var(--display); text-wrap: balance; }
canvas { display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.loading { color: #fff; text-align: center; font-weight: 700; }

/* ---------- jumper front ---------- */
.front { position: relative; min-height: 190px; overflow: hidden; }
.front canvas { position: absolute; top: 0; left: 0; }
.sewn {
  position: absolute; left: var(--mid, 50%); translate: -50% 0; white-space: nowrap;
  font: 800 1.5rem/1 var(--display); color: var(--cranberry);
  padding: .5em .95em .38em; border-radius: 3px; box-shadow: 0 2px 0 rgba(59, 6, 17, .5);
  /* a woven label, with the stitches holding it on at each end */
  background:
    repeating-linear-gradient(var(--cranberry) 0 4px, transparent 4px 8px) 6px 5px / 2px calc(100% - 8px) no-repeat,
    repeating-linear-gradient(var(--cranberry) 0 4px, transparent 4px 8px) calc(100% - 6px) 5px / 2px calc(100% - 8px) no-repeat,
    var(--snow);
}
.tree { position: absolute; inset: 0; }
.tree > * { position: absolute; translate: -50% -50%; }
.star { width: calc(var(--w) * 7); color: #7d3a3a; }
.star svg { display: block; width: 100%; }
.star.on { color: var(--bulb); filter: drop-shadow(0 0 10px #ffd870) drop-shadow(0 0 26px #ffb52e); }

.bulb {
  width: calc(var(--w) * 1.15); height: calc(var(--w) * 1.5);
  border-radius: 50% 50% 50% 50% / 38% 38% 62% 62%;
  background: #07291f; border: 1px solid #3c7561; pointer-events: none;
}
.bulb::after { content: ""; position: absolute; left: 25%; right: 25%; top: -28%; height: 34%; background: #04180f; border-radius: 2px; }
.bulb.on {
  background: radial-gradient(circle at 38% 40%, #fff 0 12%, var(--c) 46%); border-color: transparent;
  box-shadow: 0 0 6px 1px var(--c), 0 0 20px 5px color-mix(in srgb, var(--c) 55%, transparent);
  animation: twinkle 5s ease-in-out var(--delay) infinite;
}
.bulb.mine { scale: 1.3; z-index: 1; }
.bulb.mine.on { outline: 2px solid #fff; outline-offset: 1px; }
@keyframes twinkle { 0%, 84%, 100% { opacity: 1; } 92% { opacity: .5; } }
.bulb.ping, .party .star { animation: ping .7s ease-out; }
.party .star { animation-iteration-count: 4; }
@keyframes ping { 30% { transform: scale(1.9); } }
.party .bulb.on { animation: chase .5s steps(2) var(--delay) infinite; }
@keyframes chase { 50% { opacity: .15; } }

.tree .hook {
  width: max(44px, calc(var(--w) * 5.6)); aspect-ratio: 1; min-height: 0; padding: 0;
  background: none; box-shadow: none; translate: -50% -2px; transform-origin: 50% 4px;
}
.hook svg { display: block; width: 100%; height: 100%; }
.tree .hook:not(.has) { background: rgba(59, 6, 17, .82); border: 2px dashed #f3f8f6; border-radius: 50%; padding: 5px; }
.hook:not(.has) svg { filter: brightness(0) invert(1); opacity: .6; }
.hook:not(.has):hover svg { opacity: 1; }
.hook.has svg { filter: drop-shadow(0 3px 2px rgba(40, 0, 12, .5)); }
.swing { animation: swing 1.2s ease-out; }
@keyframes swing { 15% { transform: rotate(18deg); } 40% { transform: rotate(-13deg); } 65% { transform: rotate(7deg); } 85% { transform: rotate(-3deg); } }
.hook.drop { animation: drop 1.1s cubic-bezier(.3, 1.6, .5, 1); z-index: 3; }
@keyframes drop { 0% { transform: translateY(-160px) scale(1.7); opacity: 0; } 45% { transform: none; opacity: 1; } 65% { transform: rotate(14deg); } 82% { transform: rotate(-8deg); } }

.pom {
  position: absolute; z-index: 5; width: var(--s); height: var(--s); border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 35%, #fff8, transparent 60%), var(--c);
  animation: pom 1.6s cubic-bezier(.1, .8, .3, 1) forwards;
}
@keyframes pom { 0% { transform: scale(.2); } 60% { opacity: 1; } 100% { transform: translate(var(--x), calc(var(--y) + 70px)); opacity: 0; } }

/* ---------- felt patches, cut with pinking shears ---------- */
main { position: relative; max-width: 1020px; margin: 0 auto; padding: 20px 16px 56px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
.cols, .col { display: grid; grid-template-columns: minmax(0, 1fr); gap: 36px; align-content: start; }
@media (min-width: 820px) { .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.narrow, #progress, main > .whisper { width: 100%; max-width: 560px; justify-self: center; }

.patch, .card {
  --felt: var(--snow); --btn: var(--cranberry); --btn-ink: #fff; --quiet: #d3e5de; --quiet-ink: var(--berry);
  position: relative; isolation: isolate; padding: 30px 22px 32px;
}
.patch::before, .patch::after, .card::before, .card::after {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--felt);
  --zig:
    conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / 14px 51% repeat-x,
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 14px 51% repeat-x;
  -webkit-mask: var(--zig); mask: var(--zig);
}
.patch::after, .card::after { z-index: -2; background: #4a0715; translate: 0 5px; }
.pine { --felt: var(--pine); --btn: var(--bulb); --btn-ink: var(--berry); --quiet: #1f6a51; --quiet-ink: #fff; color: #fff; text-align: center; }
.berry { --felt: var(--berry); --btn: var(--bulb); --btn-ink: var(--berry); --quiet: #6b1a2c; --quiet-ink: #fff; color: #fff; text-align: center; }
.ice { --felt: var(--ice); text-align: center; }
.card-day { --felt: var(--bulb); }
.patch h2, .card h2 { margin-bottom: 10px; }
.nudge { animation: nudge .6s ease-out .45s; }
@keyframes nudge { 30% { transform: rotate(-1.2deg) scale(1.02); } 65% { transform: rotate(1deg) scale(1.02); } }

.sewn-strip { background: var(--berry); color: #fff; font-weight: 700; text-align: center; padding: 10px 16px; border-radius: 3px; overflow-wrap: anywhere; }
#progress .sewn-strip { margin-top: 18px; }
.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(.94); } 60% { transform: scale(1.03); } }

/* ---------- controls ---------- */
button {
  font: 800 1.0625rem/1.1 var(--display); color: var(--btn-ink, #fff); background: var(--btn, var(--pine));
  border: 0; border-radius: 12px; padding: 15px 20px 12px; min-height: 48px; cursor: pointer; touch-action: manipulation;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--btn, var(--pine)) 70%, #220000);
}
button:active { transform: translateY(3px); }
button.secondary { background: var(--quiet, #6d0a20); color: var(--quiet-ink, #fff); box-shadow: none; font-weight: 600; }
button.danger { background: #8a0f22; color: #fff; box-shadow: none; }
button.small { padding: 10px 12px 8px; min-height: 40px; font-size: .95rem; }
button.gap { margin-top: 16px; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 7px var(--berry); }
input, textarea { font: inherit; color: inherit; width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 10px; border: 2px solid #6f9486; background: #fff; }
input:focus, textarea:focus { outline: 3px solid var(--pine); outline-offset: 0; box-shadow: none; }
textarea { min-height: 160px; }
label { display: block; font-weight: 700; margin: 16px 0 6px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
form > .row { margin-top: 16px; gap: 10px; }
#do-song .row button { padding-inline: 15px; }
.spread { justify-content: space-between; }
.foot { justify-content: center; }
.note { margin-top: 10px; }
.error { color: var(--cranberry); font-weight: 700; margin-top: 10px; }
.ok { color: #0e5a41; font-weight: 700; margin-top: 10px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

.search { margin-top: 16px; }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 10px; margin-top: 16px; }
.names .none { grid-column: 1 / -1; }
.names button {
  display: flex; align-items: center; gap: 10px; text-align: left; min-width: 0; padding: 12px; overflow-wrap: anywhere;
  font: 700 1rem/1.2 var(--body); background: #fff; color: var(--berry); box-shadow: inset 0 0 0 2px #b9d0c7;
}
.names button:hover { box-shadow: inset 0 0 0 2px var(--pine); }
.names button:focus-visible { box-shadow: none; outline-color: var(--pine); }
.dot { flex: none; width: 13px; height: 17px; border-radius: 50% 50% 50% 50% / 38% 38% 62% 62%; background: #c4d2cc; }
.claimed .dot { background: var(--bulb); box-shadow: 0 0 0 1px #c98a0c, 0 0 8px 2px #ffc53daa; }
.pin { letter-spacing: 14px; font-size: 1.6rem; text-align: center; }

/* ---------- Secret Santa ---------- */
.box, .cracker, .bell { background: none; box-shadow: none; padding: 0; }
.box { display: block; width: min(240px, 80%); margin: 18px auto 10px; border-radius: 14px; }
.box:disabled, .cracker:disabled { opacity: 1; }
.box svg { display: block; width: 100%; overflow: visible; }
.box-lid, .box-bow { transform-box: fill-box; transform-origin: 50% 100%; transition: transform .6s cubic-bezier(.3, 1.4, .5, 1), opacity .4s; }
.box:hover:not(.open) .box-lid { transform: translateY(-5px) rotate(-1.5deg); }
.box.open .box-bow { transform: scale(1.25, .3); opacity: 0; }
.box.open .box-lid { transform: translate(34px, -30px) rotate(20deg); transition-delay: .3s; }
.shake { animation: shake .5s linear; }
@keyframes shake { 20% { transform: rotate(-7deg) translateX(-8px); } 40% { transform: rotate(6deg) translateX(8px); } 60% { transform: rotate(-5deg) translateX(-5px); } 80% { transform: rotate(3deg); } }
.who { min-height: 52px; }
.who .tag {
  display: inline-block; max-width: 100%; margin: 10px 0 18px; padding: 16px 26px 11px 46px; overflow-wrap: anywhere; rotate: -2deg;
  font: 800 2rem/1.1 var(--display); color: var(--cranberry); border-radius: 26px 8px 8px 26px;
  background: radial-gradient(circle at 23px 50%, var(--pine) 0 7px, var(--snow) 7.5px);
  animation: tag .6s cubic-bezier(.3, 1.6, .5, 1);
}
@keyframes tag { 0% { transform: translateY(-90px) scale(.3); opacity: 0; } }
.facts { display: grid; grid-template-columns: auto auto; justify-content: center; gap: 2px 14px; margin-top: 18px; text-align: left; }
.facts dd { font-weight: 700; overflow-wrap: anywhere; }
.partners { font: 800 2rem/1.1 var(--display); color: var(--cranberry); overflow-wrap: anywhere; }

/* ---------- the day ---------- */
.when { font: 800 1.25rem/1.25 var(--display); }
.when + .pre { margin-top: 14px; }
.unfold { animation: unfold .6s cubic-bezier(.3, 1.3, .5, 1); transform-origin: top; }
@keyframes unfold { 0% { transform: perspective(900px) rotateX(-70deg); } }

/* ---------- cracker ---------- */
.cracker { position: relative; display: block; width: min(320px, 100%); margin: 14px auto 24px; border-radius: 14px; }
.cracker svg { display: block; width: 100%; overflow: visible; }
.half { transform-origin: 160px 55px; transition: transform .25s cubic-bezier(.3, 1.8, .5, 1); }
.half.left { transform: translateX(calc(var(--tug, 0) * -4px)) rotate(calc(var(--tug, 0) * -1deg)); }
.half.right { transform: translateX(calc(var(--tug, 0) * 4px)) rotate(calc(var(--tug, 0) * 1deg)); }
.bang .half.left { transform: translate(-24px, 8px) rotate(-14deg) scale(.8); }
.bang .half.right { transform: translate(24px, 8px) rotate(14deg) scale(.8); }
.strain { animation: shake .3s linear; }
.joke { min-height: 52px; }
.joke .q { font: 800 1.25rem/1.25 var(--display); margin-bottom: 6px; }

/* ---------- bells ---------- */
.bells { display: flex; justify-content: center; align-items: flex-start; gap: 4px; margin: 14px 0 8px; }
.bell { flex: 1; max-width: calc(78px - var(--i) * 5px); min-width: 0; transform-origin: 50% 8%; border-radius: 14px; padding: 6px 2px; }
.bell svg { display: block; width: 100%; overflow: visible; }
.bell svg rect, .bell svg circle { fill: #c98a6a; }
.bell.next { background: rgba(255, 255, 255, .2); }
.bell.next svg { filter: drop-shadow(0 0 9px #fff3cf); }
.bell.swing { animation-duration: .7s; }
.dots { display: flex; justify-content: center; gap: 7px; margin: 14px 0; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: #6b1a2c; }
.dots i.on { background: var(--bulb); box-shadow: 0 0 8px var(--bulb); }

/* ---------- robin, peeking over the top of a patch ---------- */
.robin { position: absolute; top: -34px; z-index: -3; width: 52px; height: 52px; min-height: 0; padding: 0; background: none; box-shadow: none; }
.robin svg { width: 100%; height: 100%; display: block; }
.robin.fly { z-index: 3; opacity: 1; animation: fly .8s ease-in forwards; }
@keyframes fly { 25% { transform: translateY(-22px) rotate(-10deg); } 100% { transform: translate(-90px, -340px) rotate(-18deg) scale(.7); opacity: 0; } }

/* ---------- golden ticket ---------- */
.ticket {
  --r: 12px; padding: 32px 34px 28px; text-align: center;
  --punch:
    radial-gradient(circle at 0 50%, #0000 var(--r), #000 calc(var(--r) + .5px)) 0 0 / 51% 30px repeat-y,
    radial-gradient(circle at 100% 50%, #0000 var(--r), #000 calc(var(--r) + .5px)) 100% 0 / 51% 30px repeat-y;
  background: linear-gradient(115deg, #f6b21f, #ffe38f 38%, #ffc53d 55%, #ffedb0 74%, #f3ab17);
  -webkit-mask: var(--punch); mask: var(--punch);
}
.ticket h2 { font-size: 2.4rem; }
.ticket-name { font: 800 1.5rem/1.2 var(--display); color: #8a0f22; margin: 4px 0 8px; overflow-wrap: anywhere; }
.ticket-no { font-weight: 700; margin-top: 8px; }

/* ---------- toast ---------- */
#toast { position: fixed; inset: auto 0 0; z-index: 10; padding: 12px; pointer-events: none; display: grid; justify-items: center; }
.toast {
  --btn: var(--bulb); --btn-ink: var(--berry); pointer-events: auto;
  display: flex; align-items: center; gap: 12px; max-width: 560px; padding: 12px 14px; border-radius: 16px;
  background: var(--berry); color: #fff; box-shadow: 0 0 0 3px var(--bulb), 0 8px 22px rgba(40, 0, 12, .6);
  animation: rise .4s cubic-bezier(.3, 1.4, .5, 1);
}
.toast svg { flex: none; width: 46px; }
.toast p { font-weight: 700; line-height: 1.3; }
.toast button { flex: none; max-width: 136px; padding: 10px 14px 8px; box-shadow: none; font-size: 1rem; }
@keyframes rise { 0% { transform: translateY(120%); } }

footer { overflow: hidden; }

/* ---------- organiser ---------- */
.muted { color: #52473f; }
.admin main { max-width: 760px; }
td { text-align: left; padding: 10px 8px 10px 0; border-bottom: 1px solid #c3d6ce; vertical-align: middle; overflow-wrap: anywhere; }
table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.card > p + button, .card > p + form, .card > .row + button { margin-top: 14px; }
.card input[type="checkbox"] { min-height: 0; width: 22px; height: 22px; accent-color: var(--pine); }
@media (max-width: 640px) {
  .people tr { display: grid; grid-template-columns: 1fr auto; align-items: center; border-bottom: 1px solid #c3d6ce; padding: 8px 0; }
  .people td { border: 0; padding: 4px 0; font-weight: 700; }
  .people td.row { grid-column: 1 / -1; gap: 8px; }
}
.badge { display: inline-block; white-space: nowrap; font-size: .9rem; font-weight: 700; padding: 2px 10px; border-radius: 99px; background: #d3e5de; }
.badge.yes { background: var(--pine); color: #fff; }
.badge.gold { background: var(--bulb); }

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