@font-face { font-family: Nunito; font-weight: 400; font-display: swap; src: url(fonts/nunito-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: Nunito; font-weight: 600; font-display: swap; src: url(fonts/nunito-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: Nunito; font-weight: 700; font-display: swap; src: url(fonts/nunito-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: Nunito; font-weight: 800; font-display: swap; src: url(fonts/nunito-latin-800-normal.woff2) format('woff2'); }
@font-face { font-family: 'Mountains of Christmas'; font-weight: 700; font-display: swap; src: url(fonts/mountains-of-christmas-latin-700-normal.woff2) format('woff2'); }

/* Winternacht: glass over the 3D village, warm paper for lists */
:root {
  --ink: #1d2b44; --muted: #5d6b82; --paper: #fffdf8; --card: #ffffff; --line: #ece6d9; --sand: #f1ebdf; --sand-d: #e4dccb;
  --red: #b8322a; --red-d: #8f241d; --gold: #f6c94c; --gold-ink: #7a4f00; --green: #1e7a46; --green-d: #17603a;
  --violet: #4b2fa0; --violet-bg: #efe9ff; --night: #0a1830;
  --glass: rgba(8, 20, 40, .62); --glass-line: rgba(255, 255, 255, .12);
  --radius: 18px; --shadow: 0 24px 70px rgba(3, 8, 20, .45);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --panel-w: 456px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); font-family: Nunito, system-ui, sans-serif; color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
#scene { position: fixed; inset: 0; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.ava { width: 32px; height: 32px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 14px; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.ava.lg { width: 44px; height: 44px; font-size: 18px; font-family: Nunito, sans-serif; }

/* ---------- HUD (top glass bar) ---------- */
#hud { position: fixed; top: calc(12px + var(--safe-t)); left: 16px; right: 16px; z-index: 5; display: flex; align-items: center; gap: 14px;
  padding: 8px 8px 8px 20px; background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-line); border-radius: 20px; box-shadow: 0 12px 40px rgba(3, 8, 20, .35); transition: right .45s cubic-bezier(.2,.8,.2,1); }
.brand { font-family: 'Mountains of Christmas', cursive; font-size: 32px; font-weight: 700; color: #fff; line-height: 1; white-space: nowrap; }
.countdown { display: inline-flex; align-items: center; gap: 6px; color: #ffe3a3; font-weight: 700; font-size: 14px; white-space: nowrap;
  background: rgba(255, 215, 120, .14); padding: 6px 12px; border-radius: 99px; }
.countdown .star { width: 14px; height: 14px; fill: var(--gold); stroke: none; }
.cd-short { display: none; }
.nav { margin-left: auto; display: flex; gap: 4px; align-items: center; padding: 4px; border-radius: 16px; background: rgba(255,255,255,.08); }
.pill { height: 44px; border: 0; background: transparent; color: #fff; padding: 0 16px; border-radius: 12px; font-weight: 700; font-size: 15px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; transition: background .2s; }
.pill:hover { background: rgba(255,255,255,.12); }
.pill.primary { background: var(--paper); color: var(--ink); }
.pill.primary:hover { background: #fff; }
.pill .ico { display: none; }
.pill.icon { width: 44px; padding: 0; justify-content: center; }
.pill.icon .ico { display: block; }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--gold); color: var(--ink); font-size: 12px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 52px; background: var(--paper); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; min-width: 200px; }
.menu button { display: block; width: 100%; min-height: 44px; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 700; color: var(--ink); }
.menu button:hover { background: var(--sand); }

/* ---------- dock (family chips) ---------- */
.dock { position: fixed; left: 16px; right: 16px; bottom: calc(18px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 10px;
  z-index: 4; pointer-events: none; transition: right .45s cubic-bezier(.2,.8,.2,1); }
.dock > * { pointer-events: auto; }
.hint { margin: 0; color: #fff; background: var(--glass); padding: 8px 16px; border-radius: 99px; font-weight: 600; font-size: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); text-align: center; }
.family { display: flex; gap: 8px; padding: 6px; border-radius: 999px; background: rgba(8, 20, 40, .5); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.family::-webkit-scrollbar { display: none; }
.family button { flex: none; height: 44px; border: 0; background: rgba(255,255,255,.92); border-radius: 999px; padding: 0 16px 0 6px; font-weight: 800; font-size: 15px;
  cursor: pointer; display: inline-flex; gap: 8px; align-items: center; color: var(--ink); transition: transform .15s; }
.family button:hover { transform: translateY(-1px); }
.family button.active { background: var(--paper); box-shadow: 0 0 0 3px var(--gold); }
.panel-open #hud, .panel-open .dock { right: calc(var(--panel-w) + 32px); }

/* ---------- side panel (desktop: floating card, phone: bottom sheet) ---------- */
.panel { --mc: var(--red); position: fixed; top: 16px; right: 16px; bottom: 16px; width: var(--panel-w); background: var(--paper); z-index: 6;
  border-radius: 26px; box-shadow: var(--shadow); transform: translateX(calc(100% + 40px)); transition: transform .45s cubic-bezier(.2,.8,.2,1);
  overflow-y: auto; overscroll-behavior: contain; padding: 0 24px calc(32px + var(--safe-b)); border-top: 6px solid var(--mc); }
.panel.open { transform: none; }
.sheet-handle { display: none; }
.panel-close { position: sticky; top: 16px; float: right; margin: 16px -6px 0 8px; border: 0; background: var(--sand); width: 44px; height: 44px; border-radius: 50%;
  cursor: pointer; z-index: 2; display: flex; align-items: center; justify-content: center; color: var(--ink); }
.panel-close:hover { background: var(--sand-d); }
.p-title { font-family: 'Mountains of Christmas', cursive; font-size: 32px; line-height: 1.05; margin: 20px 0 4px; display: flex; align-items: center; gap: 12px; }
.p-sub { color: var(--muted); margin: 0 0 16px; font-size: 15px; }
.secret-note { background: #fff6dc; border: 1px solid #f0d58a; border-radius: 14px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.progress { height: 8px; background: #ece6d8; border-radius: 99px; overflow: hidden; margin: 6px 0 18px; }
.progress > i { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width .5s; }

form.card-form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
form.card-form label { font-weight: 800; font-size: 15px; display: block; margin-bottom: 8px; }
.field { width: 100%; min-height: 48px; border: 1.5px solid #ddd5c5; border-radius: 12px; padding: 10px 14px; background: var(--paper); color: var(--ink); font-size: 16px; }
.field:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 4px rgba(184,50,42,.14); }
textarea.field { resize: vertical; min-height: 72px; }
select.field { appearance: auto; }
.row { display: flex; gap: 8px; } .row > * { flex: 1; min-width: 0; }
details.more { margin: 10px 0; } details.more summary { cursor: pointer; color: var(--muted); font-weight: 700; font-size: 14px; min-height: 32px; display: flex; align-items: center; }
details.more .row, details.more textarea { margin-top: 8px; }
.btn { min-height: 44px; border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 800; cursor: pointer; background: var(--red); color: #fff;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); transition: transform .1s, background .2s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { background: var(--red-d); } .btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; margin-top: 10px; min-height: 52px; font-size: 16px; }
.btn.ghost { background: var(--sand); color: var(--ink); box-shadow: none; } .btn.ghost:hover { background: var(--sand-d); }
.btn.green { background: var(--green); } .btn.green:hover { background: var(--green-d); }
.btn.danger { background: var(--red); }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.linkbtn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 8px 4px; font-size: 14px; min-height: 36px; }

.wish { display: flex; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px;
  position: relative; animation: pop .35s ease both; }
.wish.taken { background: #f7f4ee; }
.wish.taken .wtitle { color: var(--muted); }
.wish .thumb { width: 76px; height: 76px; flex: none; border-radius: 16px; border: 0; padding: 6px; cursor: pointer;
  background: radial-gradient(circle at 50% 40%, #fff, var(--c2, #fbeee0)); box-shadow: inset 0 0 0 3px var(--c0, #c0392b); transition: transform .2s; }
.wish .thumb:hover { transform: rotate(-4deg) scale(1.05); }
.wish .thumb img { width: 100%; height: 100%; object-fit: contain; }
.wbody { flex: 1; min-width: 0; }
.wtitle { font-weight: 800; font-size: 17px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; overflow-wrap: anywhere; }
.prio { color: #c98a00; font-size: 13px; letter-spacing: 1px; }
.tagline { color: var(--muted); font-size: 14px; margin: 2px 0 4px; font-style: italic; }
.meta { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.meta a { color: var(--red); font-weight: 700; word-break: break-all; }
.note { font-size: 14px; margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.chip { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 99px; background: #e9f4ed; color: var(--green-d); }
.chip.mine { background: #fff1d1; color: var(--gold-ink); } .chip.other { background: #eeeae2; color: #4d5566; }
.chip.secret { background: var(--violet-bg); color: var(--violet); }
.group-h { font-weight: 800; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.empty .big { font-size: 46px; }
.total { background: var(--card); border-radius: 14px; padding: 14px; border: 1px solid var(--line); display: flex; justify-content: space-between; font-weight: 800; margin-top: 14px; }
.member-row { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-bottom: 10px; }
.member-row .row { align-items: center; }
.member-row input[type=color] { flex: none; width: 44px; height: 44px; border: 0; padding: 0; background: none; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

/* ---------- overlay (login / setup) ---------- */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(ellipse at center, rgba(10,24,48,.3), rgba(10,24,48,.8)); overflow-y: auto; }
.overlay-card { background: rgba(255,253,248,.97); border-radius: 28px; padding: 32px; width: min(520px, 100%); box-shadow: var(--shadow); text-align: center; animation: pop .5s ease both; }
.overlay .title { font-family: 'Mountains of Christmas', cursive; font-size: 56px; color: var(--red); line-height: 1; }
.overlay .sub { color: var(--muted); margin: 8px 0 20px; }
.who { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.who button { min-height: 92px; border: 0; background: var(--card); border-radius: 18px; padding: 14px 10px; cursor: pointer; font-weight: 800; font-size: 17px; color: var(--ink);
  box-shadow: inset 0 0 0 2px #e6dfd1, 0 6px 16px rgba(29,43,68,.08); transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.who button:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 2px var(--c, #ccc), 0 10px 22px rgba(29,43,68,.12); }
.who .house-ico { width: 44px; height: 40px; }
.overlay form { text-align: left; }
.overlay form .field { margin-bottom: 10px; }
.err { color: var(--red); font-weight: 700; min-height: 1.2em; font-size: 14px; margin: 4px 0; }
.setup-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.setup-row input[type=color] { width: 44px; height: 44px; border: 0; background: none; padding: 0; flex: none; }

/* ---------- unwrap animation ---------- */
.unwrap { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(6,14,30,.8); backdrop-filter: blur(4px); padding: 16px 16px calc(16px + var(--safe-b)); overflow-y: auto; }
.uw-inner { width: min(460px, 100%); text-align: center; color: #fff; }
.uw-stage { position: relative; width: 300px; height: 300px; margin: 0 auto; }
.uw-rays { position: absolute; inset: -60px; border-radius: 50%; opacity: 0;
  background: repeating-conic-gradient(from 0deg, rgba(255,226,140,.35) 0deg 10deg, transparent 10deg 24deg);
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 68%); mask: radial-gradient(circle, #000 20%, transparent 68%); }
.uw-gift { position: absolute; left: 50%; bottom: 40px; width: 170px; height: 170px; transform: translateX(-50%); }
.uw-box { position: absolute; bottom: 0; left: 10px; width: 150px; height: 118px; border-radius: 10px;
  background: linear-gradient(90deg, transparent 43%, var(--c1) 43% 57%, transparent 57%), var(--c0);
  box-shadow: inset 0 -12px 0 rgba(0,0,0,.15), 0 18px 30px rgba(0,0,0,.35); }
.uw-lid { position: absolute; bottom: 108px; left: 0; width: 170px; height: 38px; border-radius: 8px;
  background: linear-gradient(90deg, transparent 43%, var(--c1) 43% 57%, transparent 57%), var(--c0);
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.18); filter: brightness(1.08); transform-origin: 20% 100%; }
.uw-bow { position: absolute; left: 50%; top: -30px; width: 0; height: 0; }
.uw-bow i { position: absolute; top: 0; width: 46px; height: 34px; border: 9px solid var(--c1); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; }
.uw-bow i:first-child { right: 0; transform: rotate(-20deg); } .uw-bow i:last-child { left: 0; transform: rotate(20deg); }
.uw-img { position: absolute; left: 50%; top: 50%; width: 200px; height: 200px; transform: translate(-50%, -30%) scale(.1); opacity: 0;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,.35)); }
.uw-confetti { position: absolute; inset: -150px; width: 600px; height: 600px; pointer-events: none; }
.uw-status { min-height: 26px; font-weight: 700; color: #ffe3a3; margin-top: 6px; }
.uw-text { opacity: 0; transform: translateY(10px); transition: all .6s .2s; }
.uw-title { font-family: 'Mountains of Christmas', cursive; font-size: 40px; margin: 4px 0; line-height: 1.1; overflow-wrap: anywhere; }
.uw-title[contenteditable=true] { outline: 2px dashed rgba(255,255,255,.35); border-radius: 8px; padding: 0 8px; cursor: text; }
.uw-tagline { margin: 0 0 8px; color: #dfe7f5; font-size: 17px; }
.uw-extra { font-size: 14px; color: #b9c6dc; }
.uw-extra a { color: #ffd98a; }
.uw-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; opacity: 0; transition: opacity .4s .5s; }
.unwrap.open .uw-text, .unwrap.open .uw-actions { opacity: 1; transform: none; }
.unwrap.wrapping .uw-gift { animation: wobble 1s ease-in-out infinite; }
.unwrap.open .uw-lid { animation: lidOff .9s cubic-bezier(.3,.7,.4,1) forwards; }
.unwrap.open .uw-box { animation: boxAway .8s .35s ease forwards; }
.unwrap.open .uw-rays { animation: rays 1s .3s ease forwards, spin 18s linear infinite; }
.unwrap.open .uw-img { animation: rise .9s .45s cubic-bezier(.2,1.5,.4,1) forwards; }
.unwrap.open .uw-img.float { animation: floaty 3s ease-in-out infinite; opacity: 1; transform: translate(-50%, -55%) scale(1); }
@keyframes wobble { 0%,100% { transform: translateX(-50%) rotate(0) } 20% { transform: translateX(-50%) rotate(-6deg) translateY(-6px) }
  40% { transform: translateX(-50%) rotate(5deg) } 60% { transform: translateX(-50%) rotate(-3deg) translateY(-3px) } 80% { transform: translateX(-50%) rotate(2deg) } }
@keyframes lidOff { 30% { transform: translate(-10px, -40px) rotate(-12deg) } 100% { transform: translate(-150px, -260px) rotate(-70deg); opacity: 0 } }
@keyframes boxAway { to { transform: translateY(60px) scale(.85); opacity: 0 } }
@keyframes rays { to { opacity: 1 } }
@keyframes spin { to { transform: rotate(360deg) } }
@keyframes rise { to { transform: translate(-50%, -55%) scale(1); opacity: 1 } }
@keyframes floaty { 0%,100% { transform: translate(-50%, -55%) } 50% { transform: translate(-50%, -60%) rotate(2deg) } }
.uw-title-input { width: 100%; }

/* ---------- dialog & toast ---------- */
.dialog { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(6,14,30,.55); padding: 20px; }
.dialog-card { background: var(--paper); border-radius: 20px; padding: 22px; width: min(380px, 100%); box-shadow: var(--shadow); }
.dialog-card p { margin: 0 0 16px; font-weight: 600; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.toast { position: fixed; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px;
  border-radius: 14px; font-weight: 700; z-index: 40; box-shadow: var(--shadow); max-width: calc(100vw - 32px); text-align: center; animation: pop .3s; }

/* ---------- tablet: narrower panel ---------- */
@media (max-width: 1100px) and (min-width: 761px) {
  :root { --panel-w: 400px; }
  .panel-open .countdown { display: none; }
  .panel-open .pill .lbl { display: none; }
  .panel-open .pill .ico { display: block; }
  .panel-open .pill { padding: 0 12px; }
  .panel-open #btnMine .dot { display: none; }
}

/* ---------- phone ---------- */
@media (max-width: 760px) {
  #hud { left: 10px; right: 10px; padding: 6px 6px 6px 14px; gap: 8px; border-radius: 18px; }
  .panel-open #hud, .panel-open .dock { right: 10px; }
  .brand { font-size: 26px; }
  .countdown { background: none; padding: 0; font-size: 12px; position: absolute; left: 14px; bottom: 3px; }
  .countdown .star { display: none; }
  .cd-long { display: none; } .cd-short { display: inline; }
  #hud { padding-bottom: 18px; }
  .nav { background: none; padding: 0; gap: 6px; }
  .pill { width: 44px; padding: 0; justify-content: center; background: rgba(255,255,255,.12); border-radius: 14px; position: relative; }
  .pill.primary { background: var(--paper); }
  .pill .lbl, #btnMine .dot { display: none; }
  .pill .ico { display: block; }
  .pill .badge { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px; }
  .dock { left: 10px; right: 10px; bottom: calc(12px + var(--safe-b)); }
  .family { border-radius: 22px; justify-content: flex-start; }
  .family button { height: 48px; border-radius: 16px; padding: 0 14px 0 6px; }
  .family button .ava { width: 34px; height: 34px; }
  .panel-open .dock { display: none !important; }

  .panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: min(78dvh, calc(100dvh - 120px)); border-radius: 28px 28px 0 0;
    border-top: 0; padding: 0 16px calc(24px + var(--safe-b)); transform: translateY(105%); box-shadow: 0 -18px 50px rgba(3,8,20,.45); }
  .panel::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--mc); border-radius: 28px 28px 0 0; opacity: .9; }
  .sheet-handle { display: flex; justify-content: center; position: sticky; top: 0; z-index: 3; height: 26px; margin: 0 -16px; padding-top: 10px;
    background: var(--paper); cursor: grab; touch-action: none; }
  .sheet-handle i { width: 44px; height: 5px; border-radius: 99px; background: #ddd5c5; }
  .panel-close { top: 30px; margin-top: 0; }
  .p-title { font-size: 28px; margin-top: 4px; }
  .wish { gap: 12px; padding: 12px; flex-wrap: wrap; }
  .wish .thumb { width: 64px; height: 64px; border-radius: 14px; }
  .actions { gap: 8px; }
  .btn.small { min-height: 44px; font-size: 15px; }
  .btn.small.claim, .actions .btn.green { flex: 1 1 auto; }
  .row { flex-wrap: wrap; }

  .overlay { place-items: end stretch; padding: 0; }
  .overlay-card { width: 100%; border-radius: 28px 28px 0 0; padding: 24px 20px calc(28px + var(--safe-b)); max-height: 92dvh; overflow-y: auto; }
  .overlay .title { font-size: 48px; }
  .who { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .uw-stage { width: 260px; height: 260px; }
  .uw-actions .btn { flex: 1 1 40%; }
  .dialog { place-items: end stretch; padding: 0; }
  .dialog-card { width: 100%; border-radius: 22px 22px 0 0; padding: 22px 20px calc(22px + var(--safe-b)); }
  .dialog-actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
