:root {
  --red: #d42a3c;
  --red-dark: #9b1424;
  --green: #1f8f4e;
  --green-dark: #11633a;
  --gold: #f7c548;
  --gold-dark: #c8901a;
  --snow: #f4f8ff;
  --night: #0b1a3a;
  --ink: #2a1a1a;
  --card: #fffaf3;
  --font-fest: 'Mountains of Christmas', 'Comic Sans MS', cursive;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(ellipse at 50% 0%, #1d3a7a 0%, #0f2350 45%, var(--night) 100%) fixed;
  min-height: 100dvh;
  overflow-x: hidden;
}
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ================= Cer, stele, lună ================= */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.star {
  position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff;
  animation: twinkle var(--d, 3s) ease-in-out infinite; animation-delay: var(--delay, 0s);
}
@keyframes twinkle { 0%, 100% { opacity: .2; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.4); } }
.moon {
  position: absolute; top: calc(70px + var(--safe-top)); right: 8%; width: 70px; height: 70px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffbe8, #f4e7b4 60%, #e3d08a);
  box-shadow: 0 0 40px 12px rgba(255, 244, 190, .35), 0 0 120px 40px rgba(255, 244, 190, .12);
}
#snow, #fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#snow { z-index: 1; }
#fx { z-index: 50; }

/* ================= Instalație de lumini ================= */
.lights {
  position: fixed; top: var(--safe-top); left: 0; right: 0; margin: 0; padding: 0 0 0 10px; list-style: none;
  display: flex; justify-content: space-between; z-index: 20; pointer-events: none; height: 46px; overflow: hidden;
}
.lights::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 22px;
  border-bottom: 2px solid #1d2a1d; border-radius: 0 0 50% 50% / 0 0 100% 100%;
}
.lights li {
  position: relative; top: 16px; width: 12px; height: 22px; border-radius: 50%;
  background: var(--c); box-shadow: 0 4px 18px 3px var(--c);
  animation: flash 1.2s ease-in-out infinite alternate; animation-delay: var(--delay);
}
.lights li::before {
  content: ''; position: absolute; top: -5px; left: 2px; width: 8px; height: 7px; background: #2f3a2f; border-radius: 2px;
}
@keyframes flash { 0% { opacity: 1; filter: brightness(1.25); } 100% { opacity: .35; box-shadow: none; filter: brightness(.7); } }

/* ================= Sania ================= */
.sleigh {
  position: fixed; top: calc(130px + var(--safe-top)); left: 0; z-index: 2; pointer-events: none; white-space: nowrap;
  font-size: 30px; transform: translateX(-120vw); animation: fly 22s linear infinite 2s;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, .5));
}
.sleigh .deer { display: inline-block; transform: scaleX(-1); animation: gallop .5s ease-in-out infinite alternate; }
.sleigh .deer:nth-child(2) { animation-delay: .15s; } .sleigh .deer:nth-child(3) { animation-delay: .3s; }
.sleigh .santa { display: inline-block; transform: scaleX(-1); margin-left: 6px; }
.sleigh .trail {
  position: absolute; right: 100%; top: 50%; width: 160px; height: 3px;
  background: linear-gradient(90deg, transparent, rgba(255, 230, 150, .9)); border-radius: 3px;
  box-shadow: 0 0 10px rgba(255, 230, 150, .8);
}
@keyframes fly {
  0% { transform: translate(-60vw, 30px) rotate(-4deg); }
  45% { transform: translate(140vw, -40px) rotate(-6deg); }
  100% { transform: translate(140vw, -40px); }
}
@keyframes gallop { from { translate: 0 0; } to { translate: 0 -5px; } }

/* ================= Sol ================= */
.ground { position: fixed; left: 0; right: 0; bottom: 0; height: 160px; z-index: 1; pointer-events: none; }
.hills { position: absolute; inset: 0; width: 100%; height: 100%; }
.trees { position: absolute; left: 0; right: 0; bottom: calc(28px + var(--safe-bottom)); display: flex; justify-content: space-around; align-items: flex-end; }
.trees span { display: inline-block; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .25)); }
.tree { font-size: 54px; animation: sway 4s ease-in-out infinite alternate; transform-origin: bottom center; }
.t2 { font-size: 40px; animation-delay: -1s; } .t3 { font-size: 46px; animation-delay: -2s; } .t4 { font-size: 60px; animation-delay: -3s; }
.house { font-size: 44px; } .snowman { font-size: 42px; animation: bob 2.4s ease-in-out infinite; }
@keyframes sway { from { transform: rotate(-2deg); } to { transform: rotate(2deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* ================= Butoane colț ================= */
.corner-btn {
  position: fixed; z-index: 30; top: calc(52px + var(--safe-top)); border: 0; border-radius: 999px;
  background: rgba(255, 255, 255, .16); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .3); padding: 8px 14px; font-weight: 700; font-size: 15px;
  transition: transform .15s, background .2s;
}
.corner-btn:active { transform: scale(.94); }
.corner-btn:hover { background: rgba(255, 255, 255, .28); }
.admin-btn { right: 12px; }
.music-btn { left: 12px; width: 44px; height: 40px; padding: 0; font-size: 20px; }
.music-btn.on { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(247, 197, 72, .6); } 50% { box-shadow: 0 0 0 8px rgba(247, 197, 72, 0); } }

/* ================= Layout principal ================= */
.stage {
  position: relative; z-index: 10; min-height: 100dvh; display: flex; flex-direction: column; align-items: center;
  padding: calc(100px + var(--safe-top)) 16px calc(150px + var(--safe-bottom));
}
.hero { text-align: center; color: #fff; margin-bottom: 18px; }
.hat { font-size: 54px; animation: wobble 2.5s ease-in-out infinite; display: inline-block; }
@keyframes wobble { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg) translateY(-4px); } }
.title {
  font-family: var(--font-fest); font-size: clamp(42px, 11vw, 76px); line-height: 1; margin: 4px 0 8px;
  background: linear-gradient(180deg, #fff 0%, #ffe9a8 40%, var(--gold) 70%, #e8a22b 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 var(--red-dark)) drop-shadow(0 0 18px rgba(255, 210, 110, .55));
  animation: glow 3s ease-in-out infinite alternate;
}
@keyframes glow { to { filter: drop-shadow(0 3px 0 var(--red-dark)) drop-shadow(0 0 30px rgba(255, 210, 110, .9)); } }
.subtitle { margin: 0 auto; max-width: 440px; font-size: 16px; opacity: .92; text-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.chip {
  background: rgba(255, 255, 255, .15); border: 1px solid rgba(255, 255, 255, .35); padding: 6px 12px; border-radius: 999px;
  font-size: 14px; font-weight: 700; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}

/* card cu margine de acadea */
.card {
  position: relative; width: 100%; max-width: 440px; padding: 26px 22px 24px; border-radius: 26px; background: var(--card);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45), inset 0 0 0 2px rgba(255, 255, 255, .6);
}
.card::before {
  content: ''; position: absolute; inset: -7px; border-radius: 32px; z-index: -1;
  background: repeating-linear-gradient(45deg, var(--red) 0 14px, #fff 14px 28px);
  animation: candy 3s linear infinite; background-size: 200% 200%;
}
@keyframes candy { to { background-position: 39.6px 0; } }
.card::after {
  content: '❄'; position: absolute; top: -26px; left: 50%; transform: translateX(-50%); font-size: 34px; color: #fff;
  text-shadow: 0 0 12px #9cd3ff; animation: spin 8s linear infinite;
}
@keyframes spin { to { transform: translateX(-50%) rotate(360deg); } }

.screen { display: none; animation: fadeUp .5s ease both; }
.screen.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.label { display: block; font-family: var(--font-fest); font-size: 30px; color: var(--red-dark); text-align: center; margin-bottom: 12px; }
.input {
  width: 100%; padding: 14px 16px; font: inherit; font-size: 17px; /* >=16px: fără zoom pe iOS */
  border: 2px solid #e6d3c2; border-radius: 14px; background: #fffdf8; color: var(--ink); outline: none; transition: border-color .2s, box-shadow .2s;
}
.input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(31, 143, 78, .18); }

/* ================= Etichete cu nume ================= */
.people { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.person {
  border: 2px solid #ead8c4; background: #fff; color: var(--ink); border-radius: 999px; padding: 10px 14px;
  font-weight: 800; font-size: 16px; line-height: 1.1; transition: transform .15s, background .2s, border-color .2s, box-shadow .2s;
  box-shadow: 0 3px 0 #ead8c4;
}
.person:active { transform: scale(.95); }
.person[aria-checked="true"] {
  background: linear-gradient(180deg, #2fb36a, var(--green)); border-color: var(--green-dark); color: #fff;
  box-shadow: 0 3px 0 var(--green-dark), 0 0 0 4px rgba(31, 143, 78, .2); transform: scale(1.06);
}
.person[aria-checked="true"]::before { content: '🎅 '; }
.person.done { background: #f3ede6; color: #a8978a; border-style: dashed; box-shadow: none; }
.person.done::after { content: ' ✓'; color: var(--green); }
.person.mine { border-color: var(--gold-dark); background: #fff6d8; color: #6b4a00; }
.person:disabled { cursor: not-allowed; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 14px;
  padding: 12px 18px; font-weight: 900; font-size: 16px; color: #fff; transition: transform .12s, filter .2s; position: relative;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .25);
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.btn:disabled { filter: grayscale(.6) opacity(.7); }
.btn-red { background: linear-gradient(180deg, #ef4256, var(--red) 55%, var(--red-dark)); }
.btn-green { background: linear-gradient(180deg, #2fb36a, var(--green) 55%, var(--green-dark)); }
.btn-gold { background: linear-gradient(180deg, #ffe08a, var(--gold) 55%, var(--gold-dark)); color: #5a3a00; }
.btn-ghost { background: #efe6dc; color: var(--ink); }
.btn.big {
  width: 100%; margin-top: 14px; padding: 16px; font-size: 22px; overflow: hidden;
  background: repeating-linear-gradient(-45deg, var(--red) 0 18px, #e23b4d 18px 36px);
  box-shadow: 0 6px 0 var(--red-dark), 0 10px 24px rgba(212, 42, 60, .45);
}
.btn.big::after {
  content: ''; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent); transform: skewX(-20deg);
  animation: shine 2.6s ease-in-out infinite;
}
@keyframes shine { 0%, 60% { left: -60%; } 100% { left: 130%; } }
.link-btn { background: none; border: 0; color: #7a5c5c; text-decoration: underline; padding: 8px; display: block; margin: 8px auto 0; }

.hint { font-size: 13.5px; text-align: center; color: #6d5555; margin: 14px 0 0; }
.error { color: var(--red); font-weight: 700; text-align: center; min-height: 1.2em; margin: 10px 0 0; }
.error.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.progress { margin-top: 14px; }
.progress .bar { height: 12px; border-radius: 999px; background: #eee3d6; overflow: hidden; }
.progress .fill {
  height: 100%; border-radius: 999px; transition: width .8s;
  background: repeating-linear-gradient(-45deg, var(--green) 0 8px, #34b56b 8px 16px);
}
.progress p { font-size: 13px; text-align: center; margin: 6px 0 0; color: #6d5555; }
.welcome-back { text-align: center; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 2px dashed #ecd9c6; }
.welcome-back p { font-size: 18px; margin: 0 0 10px; }
.welcome-back .btn { width: 100%; }

/* ================= Cadoul ================= */
.gift-wrap { position: relative; height: 220px; display: grid; place-items: center; }
.rays {
  position: absolute; width: 320px; height: 320px; border-radius: 50%; opacity: 0;
  background: repeating-conic-gradient(rgba(255, 215, 90, .55) 0 10deg, transparent 10deg 20deg);
  mask: radial-gradient(circle, #000 25%, transparent 70%); -webkit-mask: radial-gradient(circle, #000 25%, transparent 70%);
  animation: rot 6s linear infinite; transition: opacity .6s;
}
.opened .rays { opacity: 1; }
@keyframes rot { to { transform: rotate(360deg); } }
.gift { position: relative; width: 140px; height: 140px; margin-top: 30px; }
.gift .box, .gift .lid { position: absolute; left: 50%; transform: translateX(-50%); }
.gift .box {
  bottom: 0; width: 130px; height: 100px; border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 43%, var(--gold) 43% 57%, transparent 57%),
    linear-gradient(180deg, #e3384b, var(--red-dark));
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, .15), 0 12px 20px rgba(0, 0, 0, .3);
}
.gift .lid {
  bottom: 96px; width: 146px; height: 30px; border-radius: 6px; z-index: 2;
  background:
    linear-gradient(90deg, transparent 43%, #ffd76a 43% 57%, transparent 57%),
    linear-gradient(180deg, #f24a5c, #c11d30);
  box-shadow: 0 4px 6px rgba(0, 0, 0, .25); transition: transform .9s cubic-bezier(.2, 1.6, .4, 1);
}
.gift .bow { position: absolute; left: 50%; top: -34px; transform: translateX(-50%); font-size: 44px; }
.shaking .gift { animation: giftShake .5s ease-in-out infinite; }
@keyframes giftShake {
  0%, 100% { transform: rotate(0); } 20% { transform: rotate(-8deg) translateY(-4px); }
  40% { transform: rotate(7deg); } 60% { transform: rotate(-5deg) translateY(-6px); } 80% { transform: rotate(4deg); }
}
.opened .gift .lid { transform: translate(-30%, -140px) rotate(35deg); }
.opened .gift { animation: pop .5s ease-out; }
@keyframes pop { 50% { transform: scale(1.12); } }

.roulette {
  font-family: var(--font-fest); font-size: 34px; text-align: center; margin: 8px 0 0; color: var(--green-dark); min-height: 1.3em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.draw-text { text-align: center; color: #6d5555; margin: 4px 0 0; }
.draw-text::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ================= Rezultat ================= */
.res-intro { text-align: center; font-size: 17px; margin: 0 0 10px; }
.res-name-wrap { position: relative; margin: 0 auto 14px; border-radius: 18px; overflow: hidden; cursor: pointer; }
.res-name {
  font-family: var(--font-fest); font-size: clamp(42px, 12vw, 60px); text-align: center; padding: 18px 10px; line-height: 1.05;
  color: var(--red); word-break: break-word;
  background: radial-gradient(circle at 50% 50%, #fff9e3, #ffefc2); border: 3px dashed var(--gold-dark); border-radius: 18px;
  text-shadow: 0 2px 0 #ffd76a, 0 0 18px rgba(255, 200, 80, .8);
  animation: reveal 1s cubic-bezier(.2, 1.5, .4, 1) both;
}
@keyframes reveal { from { transform: scale(.2) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
.res-cover {
  position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; font-size: 18px; color: #fff; border-radius: 18px;
  background: repeating-linear-gradient(45deg, var(--green) 0 16px, var(--green-dark) 16px 32px);
  opacity: 0; pointer-events: none; transition: opacity .35s;
}
.res-name-wrap.covered .res-cover { opacity: 1; pointer-events: auto; }
.res-details { display: flex; flex-direction: column; gap: 6px; font-size: 15px; margin-bottom: 6px; }
.res-details div { background: #fbf2e6; border-radius: 12px; padding: 8px 12px; }
.secret-note { text-align: center; font-size: 14px; color: #6d5555; }
.row { display: flex; gap: 10px; } .row .btn { flex: 1; }

.foot { color: rgba(255, 255, 255, .65); font-size: 13px; margin-top: 18px; text-align: center; }

/* ================= Modale ================= */
.modal {
  position: fixed; inset: 0; z-index: 60; background: rgba(5, 12, 30, .7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center; padding: calc(30px + var(--safe-top)) 12px calc(30px + var(--safe-bottom));
  overflow-y: auto; animation: fade .25s;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  position: relative; width: 100%; max-width: 560px; background: #fffaf3; border-radius: 22px; padding: 22px 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5); border-top: 8px solid var(--red); animation: fadeUp .35s;
}
.modal-card.small { max-width: 360px; margin-top: 12vh; display: flex; flex-direction: column; gap: 10px; }
.modal-card h2 { font-family: var(--font-fest); font-size: 34px; margin: 0 0 6px; color: var(--red-dark); }
.close { position: absolute; top: 10px; right: 12px; border: 0; background: #f0e4d6; width: 34px; height: 34px; border-radius: 50%; font-size: 16px; }
.muted { color: #7a6464; margin: 0; } .small { font-size: 13px; }

.panel { background: #fff; border: 1px solid #f0e1d0; border-radius: 16px; padding: 12px 14px; margin: 12px 0; }
.panel summary { font-weight: 900; font-size: 17px; cursor: pointer; list-style: none; padding: 2px 0; }
.panel summary::-webkit-details-marker { display: none; }
.panel summary::after { content: '▾'; float: right; transition: transform .2s; }
.panel[open] summary::after { transform: rotate(180deg); }
.panel[open] summary { margin-bottom: 10px; }
.panel > .btn, .settings .btn { width: 100%; margin-top: 8px; }
.danger { border-color: #f3c3c3; background: #fff6f6; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: #fbf2e6; border-radius: 12px; text-align: center; padding: 8px 4px; }
.stat b { display: block; font-size: 26px; color: var(--green-dark); }
.stat span { font-size: 12px; color: #7a6464; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.slider { position: relative; width: 54px; height: 30px; background: #d9c9b8; border-radius: 999px; transition: background .25s; flex: none; }
.slider::after {
  content: '🎄'; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  display: grid; place-items: center; font-size: 14px; transition: transform .25s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::after { transform: translateX(24px); }

.plist, .pairs { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.plist li, .pairs li { display: flex; align-items: center; gap: 8px; background: #fbf6ef; border-radius: 12px; padding: 8px 10px; }
.plist .pname { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11.5px; font-weight: 800; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: #d8f3e2; color: var(--green-dark); }
.badge.wait { background: #f3ead9; color: #8a6a2a; }
.icon-btn { border: 0; background: #efe3d4; border-radius: 10px; width: 34px; height: 34px; flex: none; }
.pairs li { justify-content: space-between; font-weight: 700; }
.pairs li span:nth-child(2) { color: var(--red); }
.settings { display: flex; flex-direction: column; gap: 10px; }
.settings label { font-weight: 700; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translate(-50%, 140%); z-index: 70;
  background: #1c2b1c; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; transition: transform .35s; max-width: 90vw; text-align: center;
}
.toast.show { transform: translate(-50%, 0); }

@media (min-width: 700px) {
  .moon { width: 100px; height: 100px; }
  .sleigh { font-size: 40px; }
  .ground { height: 200px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; }
  .sleigh { display: none; }
}
