:root {
  --bg: #fbf7f1;
  --surface: #ffffff;
  --text: #2b2320;
  --muted: #74675f;
  --border: #eadfd3;
  --red: #b3261e;
  --red-dark: #8c1d17;
  --green: #1f6b45;
  --green-soft: #e3f1e8;
  --red-soft: #fbe7e5;
  --gold: #d9a43b;
  --shadow: 0 1px 2px rgba(60, 30, 20, 0.06), 0 6px 20px rgba(60, 30, 20, 0.06);
  --radius: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120f;
    --surface: #221b17;
    --text: #f3ebe4;
    --muted: #b3a69c;
    --border: #3a2f29;
    --red: #e0574d;
    --red-dark: #c4443b;
    --green: #5cc08b;
    --green-soft: #1d3428;
    --red-soft: #3d201d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

.hero {
  text-align: center;
  padding: 36px 16px 20px;
}
.hero h1 {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: -0.01em;
}
.hero p { margin: 6px 0 0; color: var(--muted); }

.badge {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--green-soft);
  color: var(--green);
}
.badge.drawn { background: var(--red-soft); color: var(--red); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 1.25rem; }
.card h3 { margin: 20px 0 8px; font-size: 1.05rem; }
.card .lead { margin: 0 0 16px; color: var(--muted); font-size: 0.95rem; }

label { display: block; font-weight: 600; font-size: 0.95rem; margin: 14px 0 6px; }
label .hint { font-weight: 400; color: var(--muted); }

input, textarea, select {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 48px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent);
}
input.pin { letter-spacing: 0.4em; font-variant-numeric: tabular-nums; max-width: 10ch; }

.counter { text-align: right; font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: var(--red);
  color: #fff;
  transition: background 0.15s, transform 0.05s;
}
button:hover { background: var(--red-dark); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.secondary {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
}
button.secondary:hover { background: var(--bg); }
button.green { background: var(--green); }
button.green:hover { background: color-mix(in srgb, var(--green) 85%, #000); }
button.small { min-height: 36px; padding: 4px 12px; font-size: 0.9rem; }
button.block { width: 100%; margin-top: 18px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; }
.row > button.small { flex: 0 0 auto; }
.row > h2 { margin: 0; }

.msg { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; font-size: 0.95rem; }
.msg:empty { display: none; }
.msg.error { background: var(--red-soft); color: var(--red); }
.msg.ok { background: var(--green-soft); color: var(--green); }

.chips { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.95rem;
}
.empty { color: var(--muted); font-style: italic; margin: 8px 0 0; }

.list { list-style: none; padding: 0; margin: 8px 0 0; }
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: none; }
.list .name { overflow-wrap: anywhere; }
.status-ok { color: var(--green); font-weight: 600; white-space: nowrap; }
.status-open { color: var(--muted); white-space: nowrap; }
.status-locked { color: var(--red); font-size: 0.9rem; white-space: nowrap; }
.actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.warning {
  background: var(--red-soft);
  color: var(--red);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.95rem;
  margin-top: 12px;
}

footer { text-align: center; margin-top: 24px; font-size: 0.9rem; }
footer a { color: var(--muted); }

[hidden] { display: none !important; }

/* ---------- Geschenk-Animation ---------- */

.reveal-stage {
  position: relative;
  text-align: center;
  padding: 12px 0 4px;
}

.gift {
  position: relative;
  width: 150px;
  height: 150px;
  min-height: 0;
  margin: 20px auto 8px;
  cursor: pointer;
  background: none;
  padding: 0;
  border-radius: 0;
}
.gift:hover { background: none; }

.gift-box {
  position: absolute;
  left: 10px; right: 10px; bottom: 0;
  height: 100px;
  background: var(--red);
  border-radius: 6px;
  transition: opacity 0.6s 0.5s, transform 0.6s 0.5s;
}
.gift-box::before {           /* senkrechtes Band */
  content: "";
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 18px;
  transform: translateX(-50%);
  background: var(--gold);
}

.gift-lid {
  position: absolute;
  left: 0; right: 0; top: 30px;
  height: 30px;
  background: var(--red-dark);
  border-radius: 6px;
  z-index: 2;
  transition: transform 0.7s cubic-bezier(.3,1.6,.5,1), opacity 0.5s 0.4s;
}
.gift-lid::before {
  content: "";
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 18px;
  transform: translateX(-50%);
  background: var(--gold);
}
.bow {
  position: absolute;
  left: 50%; top: -26px;
  width: 56px; height: 28px;
  transform: translateX(-50%);
}
.bow::before, .bow::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 26px; height: 26px;
  border: 6px solid var(--gold);
  border-radius: 50% 50% 0 50%;
}
.bow::before { left: 0; transform: rotate(-20deg); }
.bow::after { right: 0; transform: scaleX(-1) rotate(-20deg); }

.gift:not(.open) { animation: wiggle 2.4s ease-in-out infinite; }
.gift.open { cursor: default; }
.gift:disabled { opacity: 1; }
.gift.open .gift-lid { transform: translateY(-70px) rotate(-18deg); opacity: 0; }
.gift.open .gift-box { transform: scale(0.85); opacity: 0; }

@keyframes wiggle {
  0%, 80%, 100% { transform: rotate(0); }
  84% { transform: rotate(-4deg); }
  88% { transform: rotate(4deg); }
  92% { transform: rotate(-3deg); }
  96% { transform: rotate(2deg); }
}

.gift-hint { color: var(--muted); font-size: 0.95rem; margin: 4px 0 0; }

.gift.open { animation: collapse 0.5s 0.8s ease-in forwards; }
@keyframes collapse {
  to { height: 0; margin-top: 0; margin-bottom: 0; }
}

.reveal { display: none; }
.reveal.show { display: block; animation: rise 0.6s 1s ease-out both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
.reveal .you-gift { margin: 0; color: var(--muted); }
.reveal .receiver {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--red);
  margin: 2px 0 14px;
  overflow-wrap: anywhere;
}
.wish {
  text-align: left;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.wish-title { font-weight: 600; margin: 0 0 6px; text-align: left; }

/* Schneeflocken – dezent, nur CSS */
.snow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
  opacity: 0;
  transition: opacity 1s;
}
.snow.on { opacity: 1; }
.snow span {
  position: absolute;
  top: -10%;
  color: #cfe3f2;
  font-size: 14px;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.15);
  animation: fall linear infinite;
  animation-play-state: paused;
}
.snow.on span { animation-play-state: running; }
.snow span:nth-child(1)  { left: 5%;  animation-duration: 9s;  animation-delay: 0s;   font-size: 12px; }
.snow span:nth-child(2)  { left: 15%; animation-duration: 12s; animation-delay: 1.5s; }
.snow span:nth-child(3)  { left: 25%; animation-duration: 10s; animation-delay: 3s;   font-size: 18px; }
.snow span:nth-child(4)  { left: 35%; animation-duration: 13s; animation-delay: 0.7s; }
.snow span:nth-child(5)  { left: 45%; animation-duration: 8s;  animation-delay: 2.2s; font-size: 11px; }
.snow span:nth-child(6)  { left: 55%; animation-duration: 11s; animation-delay: 4s;   font-size: 16px; }
.snow span:nth-child(7)  { left: 65%; animation-duration: 9.5s; animation-delay: 1s; }
.snow span:nth-child(8)  { left: 75%; animation-duration: 12.5s; animation-delay: 3.5s; font-size: 20px; }
.snow span:nth-child(9)  { left: 85%; animation-duration: 10.5s; animation-delay: 0.3s; font-size: 12px; }
.snow span:nth-child(10) { left: 93%; animation-duration: 14s; animation-delay: 2.8s; }
.snow span:nth-child(11) { left: 10%; animation-duration: 15s; animation-delay: 5s;   font-size: 10px; }
.snow span:nth-child(12) { left: 60%; animation-duration: 13.5s; animation-delay: 6s; font-size: 13px; }

@keyframes fall {
  0%   { transform: translate(0, 0) rotate(0); }
  50%  { transform: translate(20px, 55vh) rotate(180deg); }
  100% { transform: translate(-10px, 115vh) rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .gift:not(.open) { animation: none; }
  .gift-lid, .gift-box { transition-duration: 0.01s; transition-delay: 0s; }
  .gift.open, .reveal.show { animation-duration: 0.01s; animation-delay: 0s; }
  .snow { display: none; }
}

/* ---------- Dialog ---------- */

dialog {
  border: none;
  border-radius: var(--radius);
  padding: 22px;
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(20, 10, 5, 0.5); }
dialog h3 { margin: 0 0 8px; }
dialog p { margin: 0 0 12px; }
dialog .row { margin-top: 16px; }
