:root {
  --night: #0b1a2e;
  --night-2: #16305a;
  --red: #c8102e;
  --red-dark: #8e0c22;
  --green: #0f6b3a;
  --green-2: #1d8a52;
  --gold: #e8b931;
  --gold-soft: #fff1c1;
  --cream: #fbf6ec;
  --cream-2: #f3ead8;
  --ink: #2a1d14;
  --muted: #7a6a5a;
  --line: #e4d7bf;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .25);
  --display: 'Mountains of Christmas', 'Georgia', serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --nav-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: radial-gradient(ellipse at top, var(--night-2), var(--night) 70%) fixed, var(--night);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
#snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.fx-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 1000; }

#app {
  position: relative; z-index: 1;
  max-width: 560px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
  min-height: 100dvh;
}
#app.no-nav { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.15; }
.display { font-family: var(--display); font-weight: 700; letter-spacing: .5px; }
.hero-title { font-family: var(--display); color: #fff; font-size: clamp(2.3rem, 9vw, 3.2rem); text-align: center; text-shadow: 0 3px 0 var(--red-dark), 0 8px 24px rgba(0,0,0,.4); margin: 18px 0 4px; }
.hero-sub { color: #dfe7f5; text-align: center; margin: 0 0 22px; font-size: 1.05rem; }
.page-title { font-family: var(--display); color: #fff; font-size: 2.1rem; margin: 6px 0 14px; text-shadow: 0 2px 0 var(--red-dark); }

.card {
  background: var(--cream);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  position: relative;
}
.card h2 { font-size: 1.15rem; }
.card.ribbon::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: 26px; width: 10px; background: var(--red); opacity: .9; border-radius: 0;
}
.card.ribbon { padding-left: 50px; }
.card.tap { cursor: pointer; transition: transform .15s; }
.card.tap:active { transform: scale(.98); }
.card.glow { animation: glow 1.6s ease-in-out infinite alternate; background: linear-gradient(135deg, #fff6d9, var(--cream)); }
@keyframes glow { from { box-shadow: 0 0 0 0 rgba(255,214,90,.5), var(--shadow); } to { box-shadow: 0 0 0 8px rgba(255,214,90,.35), var(--shadow); } }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.big-emoji { font-size: 2.2rem; line-height: 1; }
.stack > * + * { margin-top: 10px; }
.hidden { display: none !important; }

/* forms */
label { display: block; font-weight: 700; margin: 12px 0 6px; font-size: .95rem; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
input, textarea, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px;
  outline: none; transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--gold); }
textarea { min-height: 80px; resize: vertical; }
input[inputmode="numeric"] { letter-spacing: .4em; font-weight: 800; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 800; font-size: 1rem;
  border: 0; border-radius: 999px; padding: 13px 22px; cursor: pointer;
  background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-dark);
  transition: transform .08s, box-shadow .08s, opacity .2s; text-decoration: none;
  min-height: 48px;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--red-dark); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.block { width: 100%; }
.btn.green { background: var(--green); box-shadow: 0 4px 0 #084526; }
.btn.gold { background: var(--gold); color: var(--ink); box-shadow: 0 4px 0 #a88310; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn.light { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.3); }
.btn.small { padding: 8px 14px; min-height: 36px; font-size: .88rem; }
.btn.danger { background: #fff; color: var(--red); box-shadow: inset 0 0 0 2px var(--red); }
.link { background: none; border: 0; color: #fff; font: inherit; text-decoration: underline; cursor: pointer; padding: 10px; }

/* language picker */
.lang-grid { display: grid; gap: 14px; }
.lang-btn {
  display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: var(--radius);
  background: var(--cream); border: 0; font: inherit; font-size: 1.25rem; font-weight: 800; cursor: pointer; box-shadow: var(--shadow); color: var(--ink);
}
.lang-btn .flag { font-size: 2.2rem; }
.lang-btn small { display: block; font-weight: 600; color: var(--muted); font-size: .85rem; }

/* avatar chooser */
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatars button {
  font-size: 1.7rem; padding: 6px 0; border-radius: 14px; border: 2px solid transparent; background: #fff; cursor: pointer;
}
.avatars button.on { border-color: var(--gold); background: var(--gold-soft); transform: scale(1.08); }

/* bottom nav */
nav.bottom {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center;
  background: rgba(11, 26, 46, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255,255,255,.1);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.bottom .inner { display: flex; width: 100%; max-width: 560px; }
nav.bottom a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--nav-h); color: #9fb0cc; text-decoration: none; font-size: .72rem; font-weight: 700; position: relative;
}
nav.bottom a .ic { font-size: 1.4rem; filter: grayscale(.6); transition: transform .15s; }
nav.bottom a.on { color: #fff; }
nav.bottom a.on .ic { filter: none; transform: translateY(-2px) scale(1.12); }
nav.bottom a.live-on .ic { animation: pulse 1s infinite; filter: none; }
.badge { position: absolute; top: 8px; right: calc(50% - 22px); background: var(--red); color: #fff; border-radius: 999px; font-size: .66rem; padding: 1px 6px; min-width: 18px; text-align: center; }
@keyframes pulse { 50% { transform: scale(1.25); } }

/* countdown */
.countdown { display: flex; gap: 10px; justify-content: center; margin: 4px 0 2px; }
.countdown div { background: var(--night); color: #fff; border-radius: 14px; padding: 8px 10px; min-width: 66px; text-align: center; }
.countdown b { display: block; font-size: 1.6rem; font-family: var(--display); }
.countdown span { font-size: .72rem; color: #c3cfe5; }

/* wishes */
.wish { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.wish:last-child { border-bottom: 0; }
.wish .prio { font-size: 1.4rem; }
.wish h3 { font-size: 1.02rem; margin: 0 0 2px; }
.wish p { margin: 0; font-size: .9rem; color: var(--muted); word-break: break-word; }
.wish a { color: var(--green); font-weight: 700; font-size: .88rem; }
.chip { display: inline-block; background: var(--cream-2); border-radius: 999px; padding: 3px 10px; font-size: .8rem; font-weight: 700; margin: 4px 6px 0 0; }
.prio-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.prio-pick button { border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 10px 4px; font: inherit; font-size: .82rem; font-weight: 700; cursor: pointer; color: var(--ink); }
.prio-pick button.on { border-color: var(--gold); background: var(--gold-soft); }

/* chat */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 52vh; overflow-y: auto; padding: 4px 2px 10px; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 18px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.bubble.elf { background: #fff; border: 2px solid var(--line); align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble.me { background: var(--green); color: #fff; align-self: flex-end; border-bottom-right-radius: 6px; }
.bubble.typing { color: var(--muted); font-style: italic; }
.sugg { background: var(--gold-soft); border-radius: 14px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; }
.sugg b { display: block; }
.sugg div.small { color: var(--muted); }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }

/* wichtel */
.receiver-hero { text-align: center; padding: 22px 18px; background: linear-gradient(160deg, #fff8e1, var(--cream)); }
.receiver-hero .avatar { font-size: 4.2rem; }
.receiver-hero .rname { font-family: var(--display); font-size: 2.4rem; color: var(--red); margin: 0; }
.stars { color: var(--gold); letter-spacing: 2px; font-size: 1.15rem; }
.status-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.status-pick button { border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 10px 2px; font: inherit; font-size: .74rem; font-weight: 800; cursor: pointer; color: var(--ink); }
.status-pick button .e { display: block; font-size: 1.3rem; }
.status-pick button.on { background: var(--green); border-color: var(--green); color: #fff; }
.option { border: 2px solid var(--line); background: #fff; border-radius: 16px; padding: 12px 14px; margin-top: 10px; }
.option h3 { font-size: 1rem; margin: 0 0 4px; }
.option .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.price { font-weight: 800; color: var(--green); }
.tip { background: var(--cream-2); border-radius: 14px; padding: 10px 12px; margin-top: 10px; font-size: .92rem; }

.gift-box { font-size: 7rem; text-align: center; cursor: pointer; animation: wobble 1.2s ease-in-out infinite; user-select: none; }
@keyframes wobble { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) scale(1.05); } }

/* live */
.live-wrap { text-align: center; }
.wheel-box { position: relative; display: flex; justify-content: center; margin: 8px auto 12px; max-width: 380px; }
.wheel-box canvas { display: block; filter: drop-shadow(0 12px 30px rgba(0,0,0,.45)); }
.pointer { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); font-size: 2.4rem; z-index: 2; filter: drop-shadow(0 3px 2px rgba(0,0,0,.4)); }
.turn-banner { font-family: var(--display); font-size: 1.9rem; color: #fff; text-shadow: 0 2px 0 var(--red-dark); margin: 6px 0; }
.spin-btn { font-size: 1.5rem; padding: 18px 40px; animation: pulse 1.2s infinite; }
.people { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0; }
.person { background: rgba(255,255,255,.1); color: #fff; border-radius: 999px; padding: 6px 12px 6px 8px; font-weight: 700; font-size: .9rem; display: flex; gap: 6px; align-items: center; opacity: .55; }
.person.online { opacity: 1; box-shadow: inset 0 0 0 2px var(--green-2); }
.person.current { background: var(--gold); color: var(--ink); opacity: 1; transform: scale(1.08); }
.person.done::after { content: '✓'; color: var(--gold); }
.result-card { background: var(--cream); border-radius: var(--radius); padding: 14px 16px; margin: 10px 0; text-align: left; box-shadow: var(--shadow); animation: pop .4s ease-out; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.result-card .hint { color: var(--ink); font-size: 1.05rem; font-weight: 700; margin-top: 2px; }
.results-list .result-card { animation: none; padding: 10px 14px; }

/* modal */
.modal-bg { position: fixed; inset: 0; z-index: 900; background: rgba(5, 12, 24, .82); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .25s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--cream); border-radius: 26px; padding: 26px 20px; width: 100%; max-width: 420px; text-align: center; box-shadow: var(--shadow); animation: pop .35s ease-out; max-height: 90dvh; overflow-y: auto; }
.modal.sheet { text-align: left; }
.reveal-name { font-family: var(--display); font-size: 3rem; color: var(--red); margin: 6px 0; }

/* toast */
#toast { position: fixed; z-index: 1001; left: 50%; top: calc(env(safe-area-inset-top) + 12px); transform: translateX(-50%); width: min(92vw, 480px); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 16px; box-shadow: var(--shadow); margin-bottom: 8px; animation: pop .25s; font-weight: 600; }
.toast b { display: block; }

/* admin */
.user-row { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--green); }
.user-row .house { padding: 8px 12px; font-size: 16px; min-width: 0; }
.user-row input[type=checkbox] { flex: none; }
.status-pill { display: inline-block; border-radius: 999px; padding: 4px 12px; font-weight: 800; font-size: .82rem; background: var(--cream-2); }
.status-pill.live { background: var(--red); color: #fff; animation: pulse 1.2s infinite; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.notif { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.notif.unread b::before { content: '● '; color: var(--red); }

.msg-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }

.spinner { display: inline-block; width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

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