:root {
  --red: #e0262b;
  --red-dark: #8e1b12;
  --green: #12a150;
  --green-dark: #0b5a2c;
  --gold: #ffd23f;
  --cream: #fffaf0;
  --ink: #3b2a20;
  --muted: #8a7766;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #0b1d3a, #1d3f8a, #0b1d3a);
  background-size: 100% 300%;
  animation: sky 12s ease-in-out infinite alternate;
  display: flex; flex-direction: column; align-items: center;
  padding: 90px 16px 120px;
  overflow-x: hidden;
}
body.shake { animation: sky 12s infinite alternate, shake .5s; }
@keyframes sky { to { background-position: 0 100%; } }
@keyframes shake {
  10%, 90% { transform: translate(-2px, 1px); } 20%, 80% { transform: translate(4px, -2px); }
  30%, 50%, 70% { transform: translate(-8px, 3px) rotate(-1deg); } 40%, 60% { transform: translate(8px, -3px) rotate(1deg); }
}

/* Gwiazdy */
.stars { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.star { position: absolute; width: 3px; height: 3px; background: #fff; border-radius: 50%; box-shadow: 0 0 6px 2px #fff8; animation: twinkle ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: .1; transform: scale(.5); } 50% { opacity: 1; transform: scale(1.4); } }

/* Śnieg */
.snow { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.flake { position: absolute; top: -20px; color: #fff; opacity: .9; animation: fall linear forwards; user-select: none; text-shadow: 0 0 6px #fff; }
@keyframes fall { to { transform: translate(var(--drift), 105vh) rotate(720deg); } }

/* Lampki choinkowe */
.lights {
  position: fixed; top: -6px; left: 0; right: 0; z-index: 20; margin: 0; padding: 0;
  list-style: none; display: flex; justify-content: space-between; overflow: hidden; white-space: nowrap;
  pointer-events: none;
}
.lights::before { content: ''; position: absolute; top: 12px; left: 0; right: 0; height: 3px; background: #222; border-radius: 50%; }
.lights li {
  position: relative; flex: 0 0 auto; width: 14px; height: 24px; margin: 14px 8px 0; border-radius: 50%;
  background: var(--c); box-shadow: 0 6px 22px 4px var(--c);
  animation: blink 1s infinite steps(1);
}
.lights li::before { content: ''; position: absolute; top: -6px; left: 2px; width: 10px; height: 8px; background: #444; border-radius: 3px; }
.lights li:nth-child(4n+1) { --c: #ff2d55; animation-delay: 0s; }
.lights li:nth-child(4n+2) { --c: #ffd60a; animation-delay: .25s; }
.lights li:nth-child(4n+3) { --c: #30d158; animation-delay: .5s; }
.lights li:nth-child(4n+4) { --c: #0af; animation-delay: .75s; }
@keyframes blink { 50% { background: #5553; box-shadow: none; } }

/* Sanie */
.sleigh {
  position: fixed; top: 70px; left: -360px; z-index: 3; font-size: 42px; pointer-events: none;
  display: flex; align-items: flex-end; gap: 2px; white-space: nowrap;
  animation: fly 14s linear infinite;
  filter: drop-shadow(0 0 10px #fff8);
}
.sleigh .deer { display: inline-block; transform: scaleX(-1); animation: gallop .4s ease-in-out infinite alternate; }
.sleigh .deer:nth-child(2) { animation-delay: .13s; }
.sleigh .deer:nth-child(3) { animation-delay: .26s; }
.rudolf { position: relative; }
.rudolf::after { content: ''; position: absolute; left: 4px; top: 16px; width: 9px; height: 9px; border-radius: 50%; background: #f22; box-shadow: 0 0 14px 6px #f22; animation: blink .5s infinite steps(1); }
.santa-sleigh { font-size: 54px; transform: scaleX(-1); display: inline-block; }
.santa-rider { margin-left: -48px; margin-bottom: 18px; font-size: 34px; display: inline-block; animation: gallop .3s infinite alternate; }
@keyframes fly {
  0% { transform: translate(0, 0) rotate(-3deg); }
  25% { transform: translate(35vw, 40px) rotate(4deg); }
  50% { transform: translate(70vw, -10px) rotate(-4deg); }
  75% { transform: translate(105vw, 50px) rotate(3deg); }
  100% { transform: translate(calc(100vw + 720px), 0) rotate(-3deg); }
}
@keyframes gallop { from { transform: scaleX(-1) translateY(0); } to { transform: scaleX(-1) translateY(-10px); } }
.santa-rider { animation-name: bob; }
@keyframes bob { from { transform: translateY(0) rotate(-8deg); } to { transform: translateY(-6px) rotate(8deg); } }

/* Tańczące dekoracje */
.deco { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.d { position: absolute; font-size: 54px; filter: drop-shadow(0 6px 8px #0006); animation: dance 1.2s ease-in-out infinite alternate; }
.d1 { left: 3%; bottom: 30px; font-size: 80px; }
.d2 { left: 12%; bottom: 40px; font-size: 90px; animation-delay: .3s; }
.d3 { left: 6%; top: 30%; animation-name: spin; animation-duration: 3s; animation-timing-function: linear; }
.d4 { right: 4%; bottom: 40px; font-size: 100px; animation-delay: .5s; }
.d5 { right: 14%; bottom: 30px; font-size: 70px; animation-name: hop; animation-duration: .7s; }
.d6 { right: 6%; top: 28%; animation-name: ring; animation-duration: .6s; }
.d7 { left: 4%; top: 55%; animation-name: ring; animation-duration: 1s; }
.d8 { right: 5%; top: 55%; animation-name: pulseglow; animation-duration: 1s; }
@keyframes dance { from { transform: rotate(-12deg) scale(1); } to { transform: rotate(12deg) scale(1.15) translateY(-14px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes hop { 0%, 100% { transform: translateY(0) scaleY(1); } 10% { transform: translateY(0) scaleY(.8); } 50% { transform: translateY(-60px) scaleY(1.1) rotate(-10deg); } }
@keyframes ring { 0%, 100% { transform: rotate(-25deg); } 50% { transform: rotate(25deg); } }
@keyframes pulseglow { 0%, 100% { transform: scale(1); filter: drop-shadow(0 0 4px gold); } 50% { transform: scale(1.4) rotate(20deg); filter: drop-shadow(0 0 24px gold) drop-shadow(0 0 40px orange); } }
.ground { position: fixed; left: 0; right: 0; bottom: 0; height: 40px; z-index: 1; background: #fff; border-radius: 50% 50% 0 0 / 30px 30px 0 0; box-shadow: 0 -6px 30px #fff6; }

/* Karta */
.card {
  position: relative; z-index: 10;
  width: 100%; max-width: 560px;
  background: var(--cream);
  border-radius: 24px;
  padding: 64px 28px 32px;
  border: 8px solid transparent;
  background-image: linear-gradient(var(--cream), var(--cream)),
    repeating-linear-gradient(45deg, var(--red) 0 14px, #fff 14px 28px, var(--green) 28px 42px, #fff 42px 56px);
  background-size: auto, 160px 160px;
  background-origin: border-box;
  background-clip: padding-box, border-box;
  text-align: center;
  animation: candy 2s linear infinite, wobble 4s ease-in-out infinite, glow 1.5s ease-in-out infinite alternate;
}
@keyframes candy { to { background-position: 0 0, 160px 0; } }
@keyframes wobble { 0%, 100% { transform: rotate(-.8deg) translateY(0); } 50% { transform: rotate(.8deg) translateY(-8px); } }
@keyframes glow {
  from { box-shadow: 0 20px 60px #0008, 0 0 30px 4px #ff2d5588; }
  to { box-shadow: 0 30px 70px #0008, 0 0 60px 14px #30d15888; }
}
.hat {
  position: absolute; top: -62px; left: 50%; font-size: 96px; cursor: pointer;
  animation: hatbounce .9s cubic-bezier(.3, 1.8, .6, 1) infinite alternate;
  filter: drop-shadow(0 8px 6px #0005);
}
@keyframes hatbounce { from { transform: translateX(-50%) translateY(0) rotate(-15deg) scale(1); } to { transform: translateX(-50%) translateY(-18px) rotate(15deg) scale(1.12); } }
.hat:hover { animation-duration: .2s; }

h1 { font-family: 'Mountains of Christmas', cursive; font-size: clamp(36px, 9vw, 54px); margin: 0 0 10px; line-height: 1.1; }
h1 .ch { display: inline-block; animation: jump 1.2s ease-in-out infinite, rainbow 1.6s linear infinite; text-shadow: 0 0 12px currentColor, 3px 3px 0 #0002; }
h1 .sp { display: inline-block; width: .3em; }
@keyframes jump { 0%, 60%, 100% { transform: translateY(0) rotate(0); } 30% { transform: translateY(-16px) rotate(-8deg) scale(1.2); } }
@keyframes rainbow { 0% { color: var(--red); } 33% { color: var(--green); } 66% { color: #e6a400; } 100% { color: var(--red); } }

.lead { font-size: 18px; margin: 0 0 22px; }
.lead strong { display: inline-block; color: var(--red); animation: jello 1.5s infinite; }
@keyframes jello { 0%, 100% { transform: scale(1, 1); } 30% { transform: scale(1.25, .75); } 40% { transform: scale(.75, 1.25); } 50% { transform: scale(1.15, .85); } 65% { transform: scale(.95, 1.05); } }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.alert { background: #fde2df; color: var(--red-dark); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-weight: 700; animation: shake .6s; }

/* Lista */
.people { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 10px; text-align: left; }
.people li { animation: dropin .6s cubic-bezier(.3, 1.6, .5, 1) backwards; }
.people li:nth-child(1) { animation-delay: .05s; } .people li:nth-child(2) { animation-delay: .1s; }
.people li:nth-child(3) { animation-delay: .15s; } .people li:nth-child(4) { animation-delay: .2s; }
.people li:nth-child(5) { animation-delay: .25s; } .people li:nth-child(6) { animation-delay: .3s; }
.people li:nth-child(7) { animation-delay: .35s; } .people li:nth-child(8) { animation-delay: .4s; }
.people li:nth-child(n+9) { animation-delay: .45s; }
@keyframes dropin { from { opacity: 0; transform: translateY(-60px) rotate(-10deg) scale(.5); } }
.person {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px;
  background: #fff; border: 3px solid #eadfcf; cursor: pointer;
  transition: transform .2s cubic-bezier(.3, 1.8, .5, 1), border-color .2s, box-shadow .2s;
}
.person:hover { transform: scale(1.05) rotate(-1.5deg); border-color: var(--green); box-shadow: 0 0 20px #30d15866; }
.person:hover .avatar { animation: spin .6s linear infinite; }
.person:hover .pname { animation: jello .8s; }
.person input { position: absolute; opacity: 0; pointer-events: none; }
.person:has(input:checked) {
  border-color: var(--red); background: #fff1ef; transform: scale(1.06);
  animation: selected .5s ease-in-out infinite alternate;
}
.person:has(input:checked) .avatar { animation: hop .6s infinite; }
@keyframes selected { from { box-shadow: 0 0 0 4px #ff2d5544, 0 0 20px #ff2d55aa; } to { box-shadow: 0 0 0 8px #ffd60a66, 0 0 34px #ffd60aaa; } }
.person:has(input:focus-visible) { outline: 3px solid var(--gold); }
.person.done { opacity: .5; cursor: not-allowed; filter: grayscale(.6); }
.person.done:hover { transform: none; border-color: #eadfcf; box-shadow: none; }
.person.done:hover .avatar, .person.done:hover .pname { animation: none; }
.avatar { font-size: 26px; display: inline-block; animation: wiggle-small 2s ease-in-out infinite; }
.people li:nth-child(odd) .avatar { animation-delay: .5s; }
@keyframes wiggle-small { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-20deg) scale(1.2); } 92% { transform: rotate(20deg) scale(1.2); } }
.pname { font-weight: 700; flex: 1; display: inline-block; }
.tag { font-size: 12px; color: var(--green-dark); background: #d5f5df; border-radius: 999px; padding: 2px 10px; white-space: nowrap; }

/* Przycisk */
.btn {
  display: inline-block; border: 0; cursor: pointer;
  font: 800 22px 'Nunito', sans-serif; color: #fff; text-shadow: 0 2px 0 #0004;
  background: linear-gradient(90deg, #e0262b, #ff8a00, #ffd23f, #12a150, #0af, #a34bff, #e0262b);
  background-size: 300% 100%;
  padding: 16px 40px; border-radius: 999px;
  box-shadow: 0 6px 0 var(--red-dark), 0 0 30px #ff2d5599;
  animation: rainbowbg 2s linear infinite, pulse 1s ease-in-out infinite;
}
@keyframes rainbowbg { to { background-position: 300% 0; } }
@keyframes pulse { 0%, 100% { transform: scale(1) rotate(0); } 25% { transform: scale(1.08) rotate(-2deg); } 75% { transform: scale(1.08) rotate(2deg); } }
.btn:hover { animation: rainbowbg .5s linear infinite, shake .4s infinite; }
.btn:active { transform: translateY(5px) scale(.95); box-shadow: 0 1px 0 var(--red-dark); }

/* Prezent */
.gift { position: relative; width: 240px; height: 220px; margin: 30px auto 10px; cursor: pointer; }
.gift::before { /* promienie światła */
  content: ''; position: absolute; left: 50%; top: 55%; width: 420px; height: 420px; margin: -210px 0 0 -210px;
  background: repeating-conic-gradient(#ffd23f55 0 10deg, transparent 10deg 20deg);
  border-radius: 50%; z-index: 0; animation: spin 8s linear infinite;
  mask: radial-gradient(circle, #000 30%, transparent 70%);
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%);
}
.gift-box {
  position: absolute; bottom: 0; left: 20px; width: 200px; height: 150px;
  background: var(--red); border-radius: 6px;
  background-image: linear-gradient(90deg, transparent 88px, var(--gold) 88px 112px, transparent 112px),
    radial-gradient(circle, #fff6 3px, transparent 4px);
  background-size: auto, 24px 24px;
  box-shadow: inset 0 -10px 0 #0002, 0 0 30px #ffd23f88;
  z-index: 2;
}
.gift-lid {
  position: absolute; top: 40px; left: 8px; width: 224px; height: 42px;
  background: #f0413a; border-radius: 6px; z-index: 3;
  background-image: linear-gradient(90deg, transparent 100px, var(--gold) 100px 124px, transparent 124px);
  transition: transform .8s cubic-bezier(.5, -0.4, .5, 1.4), opacity .8s;
}
.bow { position: absolute; top: -40px; left: 50%; font-size: 52px; animation: bowspin 1s ease-in-out infinite alternate; }
@keyframes bowspin { from { transform: translateX(-50%) rotate(-15deg); } to { transform: translateX(-50%) rotate(15deg) scale(1.15); } }
.gift-content {
  position: absolute; left: -40px; right: -40px; top: 90px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  opacity: 0; transform: translateY(40px) scale(.3) rotate(-30deg); z-index: 1;
  transition: transform 1s .3s cubic-bezier(.2, 1.8, .4, 1), opacity .5s .3s;
}
.gift-content .small { font-weight: 700; font-size: 15px; }
.gift-content .name {
  font-family: 'Mountains of Christmas', cursive; font-size: 42px; color: var(--green);
  background: #fff; padding: 6px 22px; border-radius: 14px; border: 4px dashed var(--gold);
  box-shadow: 0 8px 20px #0003, 0 0 30px #ffd23f;
}
.gift.opened { cursor: default; height: 170px; }
.gift.opened .gift-lid { transform: translate(180px, -160px) rotate(220deg); opacity: 0; }
.gift.opened .gift-box { transform: scale(0) rotate(90deg); opacity: 0; transition: transform .5s .2s, opacity .5s .2s; }
.gift.opened .gift-content { opacity: 1; transform: translateY(-70px) scale(1) rotate(0); z-index: 4; }
.gift.opened .gift-content .name { animation: namedance 1.2s 1.3s ease-in-out infinite alternate, glowname 1s 1.3s infinite alternate; }
@keyframes namedance { from { transform: rotate(-4deg) scale(1); } to { transform: rotate(4deg) scale(1.08); } }
@keyframes glowname { from { box-shadow: 0 8px 20px #0003, 0 0 20px #ffd23f; } to { box-shadow: 0 8px 20px #0003, 0 0 50px 10px #ff2d55aa; } }
.gift:not(.opened) { animation: giftjump 1.4s ease-in-out infinite; }
@keyframes giftjump {
  0%, 50%, 100% { transform: translateY(0) rotate(0) scale(1); }
  10% { transform: translateY(4px) scale(1.1, .9); }
  25% { transform: translateY(-40px) rotate(-6deg) scale(.95, 1.05); }
  40% { transform: translateY(0) scale(1.08, .92); }
  60% { transform: rotate(-5deg); } 70% { transform: rotate(5deg); } 80% { transform: rotate(-3deg); }
}
.hint { color: var(--red); font-weight: 800; min-height: 1.2em; font-size: 18px; animation: blinktext .8s steps(1) infinite; }
@keyframes blinktext { 50% { opacity: .2; } }
.secret { margin-top: 24px; font-size: 14px; background: #fff; border-radius: 10px; padding: 10px 14px; border: 2px dashed #d9c7ae; }

/* Efekty JS */
.spark { position: fixed; pointer-events: none; z-index: 50; font-size: 16px; animation: sparkfade .9s ease-out forwards; }
@keyframes sparkfade { to { transform: translate(var(--dx), var(--dy)) scale(0) rotate(180deg); opacity: 0; } }
.confetti { position: fixed; top: 0; left: 0; z-index: 60; pointer-events: none; animation: boom var(--t) cubic-bezier(.1, .7, .3, 1) forwards; }
@keyframes boom {
  0% { transform: translate(var(--x0), var(--y0)) scale(.3) rotate(0); opacity: 1; }
  100% { transform: translate(var(--x1), var(--y1)) scale(1.1) rotate(var(--r)); opacity: 0; }
}
.hohoho {
  position: fixed; z-index: 70; pointer-events: none; font: 700 30px 'Mountains of Christmas', cursive;
  color: var(--red); text-shadow: 0 0 10px #fff, 0 0 20px #fff, 2px 2px 0 var(--gold);
  animation: hoho 1.2s ease-out forwards; white-space: nowrap;
}
@keyframes hoho { 0% { transform: translate(-50%, 0) scale(.3) rotate(-20deg); opacity: 0; } 20% { transform: translate(-50%, -20px) scale(1.3) rotate(8deg); opacity: 1; } 100% { transform: translate(-50%, -120px) scale(1) rotate(-5deg); opacity: 0; } }

footer { position: relative; z-index: 10; color: #fff; margin-top: 30px; font: 700 28px 'Mountains of Christmas', cursive; text-shadow: 0 0 12px #ffd23f; }
footer .ch { display: inline-block; animation: wave 1.4s ease-in-out infinite; }
@keyframes wave { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px) rotate(6deg); } }

@media (max-width: 640px) {
  .d { font-size: 36px !important; opacity: .7; }
  .d3, .d6, .d7, .d8 { display: none; }
  .sleigh { font-size: 28px; top: 50px; }
  .santa-sleigh { font-size: 36px; } .santa-rider { font-size: 22px; margin-left: -32px; margin-bottom: 12px; }
}

/* Dla osób wrażliwych na ruch – wszystko się uspokaja */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .sleigh { display: none; }
}
