/* Gwiazdkowe losowanie — witryna w Wigilię
   Jodła, szampańskie złoto, wino i opłatkowa kość słoniowa. */
:root {
  color-scheme: dark;
  --night: #061a14;
  --fir: #0a2a1f;
  --fir-2: #12402f;
  --gold: #d8b977;
  --gold-light: #f3e2b3;
  --gold-deep: #8a6420;
  --wine: #7a1830;
  --wine-deep: #4e0d1c;
  --wafer: #f7f0e1;
  --wafer-2: #efe4cc;
  --ink: #1c2621;
  --ink-soft: #4a524c;
  --hairline: #c9a96199;
  --foil: linear-gradient(100deg, #9c7428 0%, #f3e2b3 28%, #c79a45 50%, #fff2c9 70%, #a27a2c 100%);
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", P052, Georgia, serif;
  --sans: system-ui, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-family: var(--sans);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--night); }
body {
  margin: 0;
  min-height: 100svh;
  color: var(--wafer);
  background:
    radial-gradient(ellipse 55% 75% at 30% 48%, #174634 0%, transparent 70%),
    radial-gradient(ellipse 70% 50% at 85% 0%, #0f3326 0%, transparent 65%),
    radial-gradient(ellipse 120% 90% at 50% 50%, transparent 55%, #020b08 100%),
    var(--night);
}

/* ---------- Układ ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  align-items: center;
  gap: clamp(2rem, 5.5vw, 5.5rem);
  width: min(100% - 3rem, 72rem);
  min-height: 100svh;
  margin: auto;
  padding-block: 2.5rem;
}
.window { display: grid; justify-items: center; min-width: 0; }
.side { min-width: 0; max-width: 31rem; }

h1, h2, h3, .recipient { font-family: var(--serif); font-weight: 400; margin: 0; }
.cover { margin-bottom: clamp(1.4rem, 3vh, 2.2rem); }
.cover h1 {
  font-size: clamp(2.7rem, 5.6vw, 4.8rem);
  line-height: .98;
  letter-spacing: -.012em;
  background: var(--foil);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-bottom: .08em;
  text-wrap: balance;
}
.cover p {
  max-width: 34ch;
  margin: 1rem 0 0;
  color: #e6dbc2;
  font: 1.12rem/1.6 var(--serif);
}

/* ---------- Karta (opłatek) ---------- */
.card {
  position: relative;
  color: var(--ink);
  background: linear-gradient(165deg, #fbf6ea, var(--wafer) 55%, #f1e7d1);
  border-radius: .5rem;
  padding: clamp(1.5rem, 3vw, 2.4rem);
  box-shadow: 0 2rem 4rem -1rem #000000a0, 0 0 0 1px #00000030;
}
.card::before {
  content: "";
  position: absolute;
  inset: .5rem;
  border: 1px solid var(--hairline);
  border-radius: .25rem;
  pointer-events: none;
}
.seal {
  position: absolute;
  top: -1.55rem;
  right: clamp(1.4rem, 3vw, 2.2rem);
  display: grid;
  place-items: center;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 48% 52% 50% 46% / 51% 46% 54% 49%;
  background: radial-gradient(circle at 34% 30%, #c03c58 0%, var(--wine) 52%, var(--wine-deep) 100%);
  box-shadow: 0 .45rem .9rem #00000070, inset 0 -.2rem .4rem #00000055, inset 0 .15rem .3rem #ffffff30;
}
.seal span {
  display: grid;
  place-items: center;
  width: 70%;
  height: 70%;
  border-radius: 50%;
  border: 1px solid #00000035;
  box-shadow: inset 0 1px 0 #ffffff25;
  color: #57101f;
  font: 1.25rem/1 var(--serif);
  text-shadow: 0 1px 0 #d5627a88, 0 -1px 0 #2a050c;
}

h2 { font-size: clamp(1.75rem, 3vw, 2.25rem); line-height: 1.12; color: var(--fir); margin-bottom: 1.1rem; }
h3 { font-size: 1.45rem; line-height: 1.2; color: var(--fir); margin-bottom: .5rem; }
label { display: block; margin: 1rem 0 .4rem; font-size: .9rem; font-weight: 600; color: #3b443e; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  padding: .8rem .9rem;
  color: var(--ink);
  background: #fffdf7;
  border: 1px solid #cdbf9f;
  border-radius: .35rem;
  box-shadow: inset 0 1px 2px #5a4a2014;
}
input:focus, select:focus, textarea:focus { border-color: var(--fir-2); }
textarea { resize: vertical; font-family: var(--serif); font-size: 1.05rem; line-height: 1.5; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: .7rem 1.2rem;
  margin-top: 1.1rem;
  color: #fbf1dc;
  background: linear-gradient(180deg, #92213b, #6a1229);
  border: 1px solid var(--wine-deep);
  border-radius: .4rem;
  box-shadow: inset 0 0 0 1px #e2c27f50, 0 .6rem 1.2rem -.6rem #6a1229;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  transition: filter .2s, background-color .2s;
}
form > button { width: 100%; }
button:hover { filter: brightness(1.1); }
button:disabled { opacity: .6; cursor: wait; }
.secondary {
  color: var(--fir);
  background: transparent;
  border-color: #b9a474;
  box-shadow: none;
}
.secondary:hover { background: #efe4cc; filter: none; }
.quiet {
  min-height: 2.4rem;
  padding: .35rem .5rem;
  color: var(--fir);
  background: transparent;
  border: 0;
  box-shadow: none;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: #b9a474;
  text-underline-offset: .25em;
}
.quiet:hover { filter: none; text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.card :focus-visible, dialog :focus-visible { outline-color: var(--fir-2); }

.hint { font: .95rem/1.5 var(--serif); margin: .5rem 0 0; color: var(--ink-soft); }
.local-note { font: .82rem/1.4 var(--sans); padding-bottom: .7rem; margin: 0 0 1rem; border-bottom: 1px solid #dccbaa; }
#staging-tools { margin: 0 0 .5rem -.5rem; font-size: .88rem; }
#status { margin: 0 0 1rem; font: 1rem/1.5 var(--serif); }
#status:empty { display: none; }
#status[data-error] { color: var(--wine); font-weight: 700; }

/* ---------- Panel gry ---------- */
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.2rem; }
.panel-heading h2 { margin: 0; }
.panel-heading button { margin: 0 -.5rem 0 0; }
.delivery-email { margin: -.4rem 0 1rem; font-size: .9rem; overflow-wrap: anywhere; }
#unlock .hint { margin-bottom: .2rem; }
.draw { padding-top: 1.2rem; border-top: 1px solid #dccbaa; }
.draw:has(> #draw-form[hidden] + #result[hidden]) { display: none; }
#result-body h3 { font-size: 1.05rem; font-style: italic; color: var(--ink-soft); margin: 0; }
.recipient {
  margin: .15rem 0 .2rem;
  color: var(--wine);
  font-size: clamp(2.2rem, 4.6vw, 3rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}
.wish-text {
  margin: .8rem 0 0;
  padding: .1rem 0 .1rem .9rem;
  border-left: 2px solid var(--gold);
  font: italic 1.02rem/1.55 var(--serif);
  color: #39423c;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: clamp(3rem, 18svh, 9rem);
  overflow: auto;
}
#toggle-result { margin: .6rem 0 0 -.5rem; }
.game-controls .wish-open { width: 100%; margin-top: 1rem; }

/* ---------- Okna dialogowe ---------- */
dialog {
  width: min(calc(100% - 1.5rem), 32rem);
  max-height: calc(100dvh - 1.5rem);
  padding: clamp(1.1rem, 3.5vw, 2rem);
  border: 0;
  border-radius: .5rem;
  color: var(--ink);
  background: linear-gradient(165deg, #fbf6ea, var(--wafer));
  box-shadow: 0 2rem 5rem #000000b0, inset 0 0 0 .5rem var(--wafer), inset 0 0 0 calc(.5rem + 1px) var(--hairline);
}
dialog::backdrop { background: #020c08cc; backdrop-filter: blur(3px); }
.wish-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.wish-heading :is(h2, h3) { margin: 0; font-size: 1.6rem; }
.wish-heading button { margin: 0 -.5rem 0 0; }
#wish-error { color: var(--wine); margin: .5rem 0 0; font-weight: 600; }
#wish-error:empty { display: none; }
.staging-actions { display: grid; }
.staging-actions button { margin-top: .7rem; }

/* ---------- Witryna z choinką ---------- */
.tree-stage {
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  width: min(100%, calc((100svh - 5rem) * .851));
  aspect-ratio: 4 / 4.7;
  overflow: hidden;
  border-radius: 50% 50% .5rem .5rem / 42.5% 42.5% .5rem .5rem;
  border: 1px solid #d8b977aa;
  background:
    radial-gradient(ellipse at 50% 42%, #123a2c 0%, transparent 62%),
    linear-gradient(180deg, #04120d, #082219 60%, #0b2a1f);
  box-shadow:
    0 0 0 .55rem #0b2a1f,
    0 0 0 calc(.55rem + 1px) #d8b97766,
    0 2.5rem 5rem -1rem #000000b0,
    0 0 6rem -1rem #e9c77a33;
}
.tree-stage::after {
  content: "";
  position: absolute;
  inset: .45rem;
  z-index: 9;
  border: 1px solid #d8b97738;
  border-radius: inherit;
  pointer-events: none;
}
.tree-art { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.tier-base { fill: url(#tier-fill); }
.tier-needles { fill: url(#needles); opacity: .2; }
.tier-shadow { fill: #000; opacity: .55; }
.fold-l { fill: #8fd0aa; opacity: .07; }
.fold-d { fill: #000; opacity: .2; }
.tier-frost path { fill: #f4ecd8; opacity: .55; }
.trunk { fill: #3d2618; }
.ribbon { fill: none; stroke: url(#gold-foil); stroke-width: 3.4; stroke-linecap: round; }
.ribbon-shine { fill: none; stroke: #fff6d8; stroke-width: .7; opacity: .7; transform: translateY(-.8px); }
.wires path { fill: none; stroke: #3a3020; stroke-width: .6; opacity: .8; }
.bauble line { stroke: #d8b977; stroke-width: .6; opacity: .75; }
.bauble rect { fill: #d8b977; }
.bauble .band { fill: none; stroke: #f3e2b3; stroke-width: .6; opacity: .55; }
.bauble .shine { fill: #fff; opacity: .7; }
.sparkles path { fill: #fff3cf; transform-box: fill-box; transform-origin: center; animation: sparkle 3.6s ease-in-out infinite; }
.sparkles path:nth-child(2) { animation-delay: -1.1s; } .sparkles path:nth-child(3) { animation-delay: -2.3s; }
.sparkles path:nth-child(4) { animation-delay: -.6s; } .sparkles path:nth-child(5) { animation-delay: -1.8s; }
.sparkles path:nth-child(6) { animation-delay: -2.9s; }
@keyframes sparkle { 0%, 100% { opacity: 0; transform: scale(.3) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }
.box-ivory { fill: #f1e6cd; } .lid-ivory { fill: #fbf3e0; }
.box-fir { fill: #134a35; } .lid-fir { fill: #1b5b42; }
.box-wine { fill: #6e1428; }
.gift-gold { fill: url(#gold-foil); } .gift-ivory { fill: #f3e2b3; }
.bow-gold { fill: #e3c47e; stroke: #8a6420; stroke-width: .5; }
.bow-ivory { fill: #f7ecd2; stroke: #b9a474; stroke-width: .4; }
.bokeh circle { fill: url(#bokeh-fill); animation: bokeh 7s ease-in-out infinite; }
.bokeh circle:nth-child(2n) { animation-duration: 9s; animation-delay: -3s; }
.bokeh circle:nth-child(3n) { animation-duration: 11s; animation-delay: -5s; }
@keyframes bokeh { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
.snowfall circle { fill: #fff; opacity: .6; animation: snow-fall 10s linear infinite; }
.snowfall circle:nth-child(3n) { animation-duration: 13s; opacity: .4; }
.snowfall circle:nth-child(4n+1) { animation-duration: 8s; }
.snowfall circle:nth-child(2) { animation-delay: -1s; } .snowfall circle:nth-child(3) { animation-delay: -6s; }
.snowfall circle:nth-child(4) { animation-delay: -3s; } .snowfall circle:nth-child(5) { animation-delay: -8s; }
.snowfall circle:nth-child(6) { animation-delay: -4.5s; } .snowfall circle:nth-child(7) { animation-delay: -2s; }
.snowfall circle:nth-child(8) { animation-delay: -7s; } .snowfall circle:nth-child(9) { animation-delay: -5.5s; }
.snowfall circle:nth-child(10) { animation-delay: -.5s; } .snowfall circle:nth-child(11) { animation-delay: -9.5s; }
.snowfall circle:nth-child(12) { animation-delay: -2.7s; } .snowfall circle:nth-child(13) { animation-delay: -6.6s; }
.snowfall circle:nth-child(14) { animation-delay: -3.9s; } .snowfall circle:nth-child(15) { animation-delay: -10.4s; }
.snowfall circle:nth-child(16) { animation-delay: -1.6s; } .snowfall circle:nth-child(17) { animation-delay: -7.7s; }
.snowfall circle:nth-child(18) { animation-delay: -4.1s; } .snowfall circle:nth-child(19) { animation-delay: -8.8s; }
.snowfall circle:nth-child(20) { animation-delay: -11s; }
@keyframes snow-fall {
  from { transform: translate(0, 0); }
  50% { transform: translate(8px, 245px); }
  to { transform: translate(-4px, 490px); }
}

/* lampki — ciepła biel */
.light .halo { fill: url(#glow-warm); opacity: .7; }
.light .bulb { fill: #fff6df; }
.light { animation: twinkle 3.4s ease-in-out infinite; animation-delay: calc(var(--i, 0) * -.61s); }
@keyframes twinkle { 0%, 100% { opacity: 1; } 45% { opacity: .5; } 62% { opacity: .92; } }

/* gwiazda */
.facet-l { fill: url(#facet-light); }
.facet-d { fill: url(#facet-dark); }
.star-shape { filter: drop-shadow(0 0 5px #ffd98a); }
.star-rays { stroke: #ffeab3; stroke-width: 1; stroke-linecap: round; opacity: .45; transform-box: view-box; transform-origin: 200px 46px; animation: rays 24s linear infinite; }
.star-halo { transform-box: fill-box; transform-origin: center; animation: halo 4.5s ease-in-out infinite; }
@keyframes rays { to { transform: rotate(360deg); } }
@keyframes halo { 0%, 100% { opacity: .75; transform: scale(.92); } 50% { opacity: 1; transform: scale(1.06); } }
.tree-glow, .floor-glow { transition: opacity .6s; }
.tree-body { transform-box: view-box; transform-origin: 200px 410px; transition: filter .9s ease; }

/* bombka z niespodzianką */
.reveal-ornament {
  position: absolute;
  z-index: 4;
  width: 19%;
  aspect-ratio: 1;
  left: 40.5%;
  top: 52.5%;
  border-radius: 50%;
  border: 1.5px solid #e7cd92;
  background: var(--wine-deep);
  color: var(--gold-light);
  box-shadow: 0 0 1.2rem #f3d18755, 0 .5rem 1.2rem #020b08a0;
  transform-origin: 50% -12%;
  transition: transform .7s cubic-bezier(.2,1.4,.4,1), box-shadow .7s ease;
}
.reveal-ornament::before {
  content: "";
  position: absolute;
  z-index: 3;
  left: 35%;
  top: -11%;
  width: 30%;
  height: 13%;
  background: var(--foil);
  border-radius: 30% 30% 12% 12%;
  box-shadow: 0 1px 2px #0006;
}
.reveal-ornament::after {
  content: "";
  position: absolute;
  left: 45.5%;
  top: -25%;
  width: 9%;
  height: 15%;
  border: 1.5px solid #e6c47c;
  border-bottom: 0;
  border-radius: 50% 50% 0 0;
}
.ornament-portrait, .ornament-shell { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; }
.ornament-portrait { overflow: hidden; }
.ornament-portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ornament-portrait img[data-frame]:not([data-frame=""]) {
  inset: auto;
  top: var(--portrait-y, 0);
  left: var(--portrait-x, 0);
  width: 300%;
  height: 200%;
  max-width: none;
  object-fit: fill;
}
.ornament-portrait img:is([data-frame="2"], [data-frame="5"]) { --portrait-x: -100%; }
.ornament-portrait img:is([data-frame="3"], [data-frame="6"]) { --portrait-x: -200%; }
.ornament-portrait img:is([data-frame="4"], [data-frame="5"], [data-frame="6"]) { --portrait-y: -100%; }
#portrait-initial { display: grid; height: 100%; place-items: center; color: var(--gold-light); background: radial-gradient(circle at 35% 30%, #a3304b, var(--wine-deep) 78%); font: clamp(1rem, 9cqi, 3rem)/1 var(--serif); }
.ornament-shell {
  z-index: 1;
  background:
    radial-gradient(circle at 50% 50%, transparent 38%, #f3e2b322 39%, transparent 41%),
    repeating-conic-gradient(from 0deg at 50% 50%, transparent 0 14deg, #f3e2b318 14deg 16deg),
    radial-gradient(circle at 32% 26%, #f6c7cf, #b8344f 20%, #6e1428 60%, #2e0610);
  box-shadow: inset 0 0 0 1.5px #f2c98266, inset -.5rem -.6rem 1.2rem #1a030a80;
  transition: transform .9s cubic-bezier(.2,.8,.3,1), opacity .6s ease .15s;
}
.shell-left { clip-path: inset(-2px 50% -2px -2px); }
.shell-right { clip-path: inset(-2px -2px -2px 50%); }
.shell-mark {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  font: italic clamp(1rem, 10cqi, 3.1rem)/1 var(--serif);
  color: var(--gold-light);
  text-shadow: 0 0 .6rem #ffcf6b;
  transition: opacity .3s;
}
.burst, .flash, .sweep { position: absolute; pointer-events: none; z-index: 6; }
.burst { left: 50%; top: 60.6%; width: 0; height: 0; }
.burst i {
  position: absolute;
  left: -.25rem;
  top: -.25rem;
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: #f3d58c;
  box-shadow: 0 0 .4rem #ffd77a;
  opacity: 0;
}
.burst i:nth-child(4n) { background: #fff6dc; width: .35rem; height: .35rem; }
.burst i:nth-child(4n+1) { background: #fff3cf; border-radius: 0; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); width: .9rem; height: .9rem; left: -.45rem; top: -.45rem; }
.burst i:nth-child(4n+2) { background: #b8344f; box-shadow: none; }
.burst i:nth-child(1) { --a: 0deg; --d: 30cqi; } .burst i:nth-child(2) { --a: 18deg; --d: 22cqi; }
.burst i:nth-child(3) { --a: 36deg; --d: 34cqi; } .burst i:nth-child(4) { --a: 54deg; --d: 24cqi; }
.burst i:nth-child(5) { --a: 72deg; --d: 31cqi; } .burst i:nth-child(6) { --a: 90deg; --d: 21cqi; }
.burst i:nth-child(7) { --a: 108deg; --d: 33cqi; } .burst i:nth-child(8) { --a: 126deg; --d: 25cqi; }
.burst i:nth-child(9) { --a: 144deg; --d: 29cqi; } .burst i:nth-child(10) { --a: 162deg; --d: 23cqi; }
.burst i:nth-child(11) { --a: 180deg; --d: 32cqi; } .burst i:nth-child(12) { --a: 198deg; --d: 22cqi; }
.burst i:nth-child(13) { --a: 216deg; --d: 34cqi; } .burst i:nth-child(14) { --a: 234deg; --d: 24cqi; }
.burst i:nth-child(15) { --a: 252deg; --d: 30cqi; } .burst i:nth-child(16) { --a: 270deg; --d: 21cqi; }
.burst i:nth-child(17) { --a: 288deg; --d: 33cqi; } .burst i:nth-child(18) { --a: 306deg; --d: 25cqi; }
.burst i:nth-child(19) { --a: 324deg; --d: 31cqi; } .burst i:nth-child(20) { --a: 342deg; --d: 23cqi; }
.flash { inset: 0; background: radial-gradient(circle at 50% 60%, #fffaf0, #ffe6abaa 20%, transparent 58%); opacity: 0; }
.sweep { inset: -20% -60%; background: linear-gradient(105deg, transparent 40%, #fff2c933 48%, #fff6dc66 50%, #fff2c933 52%, transparent 60%); opacity: 0; transform: translateX(-60%); }
.stage-dim { position: absolute; inset: 0; z-index: 2; pointer-events: none; background: radial-gradient(ellipse at 50% 58%, transparent 16%, #01070599 55%, #010504ee 85%); opacity: 0; transition: opacity .8s ease; }
.tree-recipient {
  position: absolute;
  inset: auto 12% 5%;
  z-index: 7;
  padding: .3em .7em .38em;
  color: var(--gold-light);
  background: linear-gradient(90deg, transparent, #04120dd9 20%, #04120dd9 80%, transparent);
  font: italic clamp(.85rem, 6.6cqi, 1.9rem)/1.15 var(--serif);
  text-align: center;
  overflow-wrap: anywhere;
  opacity: 0;
  transition: opacity .4s;
}
.tree-recipient::before, .tree-recipient::after {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  height: 1px;
  background: linear-gradient(90deg, transparent, #d8b977aa, transparent);
}
.tree-recipient::before { top: 0; }
.tree-recipient::after { bottom: 0; }
.tree-recipient:empty { visibility: hidden; }

/* ---------- Losowanie: napięcie ---------- */
.tree-stage[data-state="drawing"] .stage-dim { opacity: .7; }
.tree-stage[data-state="drawing"] .light { animation: chase var(--chase, 1.5s) linear infinite; animation-delay: calc(var(--i, 0) * var(--chase, 1.5s) / -46); }
.tree-stage[data-state="drawing"] .star-rays { animation-duration: 5s; opacity: .75; }
.tree-stage[data-state="drawing"] .reveal-ornament { animation: swing var(--swing, 1.6s) ease-in-out infinite; box-shadow: 0 0 1.8rem #ffd06a99, 0 .5rem 1.2rem #020b08a0; }
.tree-stage[data-state="drawing"] .tree-recipient { opacity: 1; text-shadow: 0 0 .8rem #ffcf6b; }
.tree-stage[data-phase="2"] { --chase: .8s; --swing: 1s; }
.tree-stage[data-phase="3"] { --chase: .4s; --swing: .55s; }
.tree-stage[data-phase="3"] .reveal-ornament { box-shadow: 0 0 2.8rem #ffd06acc, 0 .5rem 1.2rem #020b08a0; }
.tree-stage[data-phase="3"] .tree-body { animation: rustle .18s linear infinite; }
.tree-stage[data-phase="3"] .sweep { animation: sweep 1.1s ease-in-out infinite; }
@keyframes chase { 0% { opacity: .12; } 8% { opacity: 1; } 30%, 100% { opacity: .12; } }
@keyframes swing { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
@keyframes rustle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(.5deg); } 75% { transform: rotate(-.5deg); } }
@keyframes sweep { from { opacity: 1; transform: translateX(-60%); } to { opacity: 1; transform: translateX(60%); } }
/* cisza przed odsłonięciem */
.tree-stage[data-phase="hush"] .stage-dim { opacity: 1; }
.gifts { transition: filter .9s ease; }
.tree-stage[data-phase="hush"] :is(.tree-body, .gifts) { filter: brightness(.35) saturate(.6); }
.tree-stage[data-phase="hush"] .light { animation: none; opacity: .06; }
.tree-stage[data-phase="hush"] :is(.tree-glow, .floor-glow) { opacity: 0; }
.tree-stage[data-phase="hush"] .bokeh circle { animation: none; opacity: .15; }
.tree-stage[data-phase="hush"] .star-halo { animation: star-charge 1.2s ease-in both; }
.tree-stage[data-phase="hush"] .reveal-ornament { animation: tremble .07s linear infinite; box-shadow: 0 0 3.6rem #fff0b3, 0 0 1rem #ffd06a; transform: scale(1.18); }
.tree-stage[data-phase="hush"] .shell-mark { animation: mark-pulse .5s ease-in-out infinite alternate; }
.tree-stage[data-phase="hush"] .tree-recipient { opacity: 0; }
@keyframes star-charge { from { transform: scale(1); opacity: .8; } to { transform: scale(2); opacity: 1; } }
@keyframes tremble {
  0% { transform: scale(1.18) translate(0, 0) rotate(0); }
  25% { transform: scale(1.18) translate(1.5px, -1px) rotate(1.5deg); }
  50% { transform: scale(1.18) translate(-1px, 1px) rotate(-1deg); }
  75% { transform: scale(1.18) translate(1px, 1.5px) rotate(1deg); }
  100% { transform: scale(1.18) translate(0, 0) rotate(0); }
}
@keyframes mark-pulse { from { transform: scale(1); } to { transform: scale(1.25); } }

/* ---------- Wynik ---------- */
.tree-stage[data-state="revealed"] .reveal-ornament { transform: scale(1.65); box-shadow: 0 0 2rem #f3d187aa, 0 .5rem 1.2rem #020b08a0; }
.tree-stage[data-state="revealed"] .shell-left { transform: translateX(-70%) rotate(-35deg); opacity: 0; }
.tree-stage[data-state="revealed"] .shell-right { transform: translateX(70%) rotate(35deg); opacity: 0; }
.tree-stage[data-state="revealed"] .shell-mark { opacity: 0; }
.tree-stage[data-state="revealed"] .tree-recipient { opacity: 1; }
.tree-stage[data-fresh] .flash { animation: flash 1.3s ease-out both; }
.tree-stage[data-fresh] .burst i { animation: burst 1.6s cubic-bezier(.15,.7,.3,1) both; }
.tree-stage[data-fresh] .burst i:nth-child(even) { animation-delay: .08s; }
.tree-stage[data-fresh] .reveal-ornament { animation: pop .9s cubic-bezier(.2,1.5,.4,1) both; }
.tree-stage[data-fresh] .tree-recipient { animation: name-in .9s cubic-bezier(.2,1.3,.4,1) .35s both; }
.tree-stage[data-fresh] .light { animation: celebrate .5s ease-in-out 3 both; }
@keyframes flash { 0% { opacity: 0; } 12% { opacity: 1; } 100% { opacity: 0; } }
@keyframes burst {
  0% { opacity: 1; transform: rotate(var(--a)) translateY(0) scale(.4); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--a)) translateY(calc(var(--d) * -1)) rotate(200deg) scale(1); }
}
@keyframes pop { 0% { transform: scale(1.18); } 45% { transform: scale(1.9); } 100% { transform: scale(1.65); } }
@keyframes name-in { from { opacity: 0; transform: translateY(1rem) scale(.85); } to { opacity: 1; transform: none; } }
@keyframes celebrate { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- W grze ---------- */
.in-game .cover p { display: none; }
.in-game .cover h1 { font-size: clamp(2rem, 3.6vw, 3rem); }
@media (max-width: 760px) { .in-game .cover { display: none; } }
.in-game #local-note { display: none; }

/* ---------- Mniejsze ekrany ---------- */
@media (max-height: 720px) and (min-width: 761px) {
  .layout { padding-block: 1.25rem; }
  .card { padding: 1.4rem 1.6rem; }
  label { margin-top: .7rem; }
  button { margin-top: .9rem; }
  .cover h1 { font-size: clamp(2.4rem, 4.8vw, 3.8rem); }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; gap: 1.6rem; width: min(100% - 2rem, 30rem); align-content: start; padding-block: 1.25rem 2rem; }
  .side { max-width: none; }
  .tree-stage { width: min(100%, 33svh, 19rem); }
  .in-game .tree-stage { width: min(100%, 36svh, 19rem); }
  .cover { text-align: center; margin-bottom: 1.8rem; }
  .cover h1 { font-size: clamp(2.3rem, 10.5vw, 3.2rem); }
  .cover p { margin-inline: auto; font-size: 1.02rem; }
  .card { padding: 1.5rem 1.25rem 1.3rem; }
  .seal { width: 2.9rem; height: 2.9rem; top: -1.35rem; }
  .in-game .layout { gap: 2rem; }
  .in-game .card { padding-top: 1.3rem; }
  .panel-heading { margin-bottom: .8rem; }
  .panel-heading h2 { font-size: 1.6rem; }
  .draw { padding-top: .9rem; }
  h3 { font-size: 1.3rem; }
  .recipient { font-size: 2.1rem; }
  .wish-text { max-height: 4.8em; }
}
@media (max-width: 760px) and (max-height: 680px) {
  .tree-stage { width: min(100%, 30svh); }
  .in-game .tree-stage { width: min(100%, 28svh); }
  .cover h1 { font-size: 2.2rem; }
  .cover p { display: none; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .layout { grid-template-columns: auto minmax(0, 1fr); gap: 1.5rem; width: min(100% - 1.5rem, 60rem); padding-block: .75rem; align-content: center; }
  .tree-stage, .in-game .tree-stage { width: calc((100svh - 2.6rem) * .851); }
  .cover { text-align: left; margin-bottom: .9rem; }
  .cover h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); }
  .cover p { display: none; }
  .card { padding: 1rem 1.2rem; }
  .seal { display: none; }
  h2 { font-size: 1.45rem; margin-bottom: .4rem; }
  label { margin-top: .5rem; }
  input, select { padding-block: .55rem; }
  button { margin-top: .7rem; min-height: 2.6rem; }
  .panel-heading { margin-bottom: .5rem; }
  .draw { padding-top: .6rem; }
  .draw .hint { display: none; }
  h3 { font-size: 1.2rem; }
  .recipient { font-size: 1.8rem; }
  .wish-text { max-height: 3.2em; margin-top: .4rem; }
  .game-controls .wish-open { margin-top: .6rem; }
}

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