:root {
  --bg: #fff8f4;
  --card: #ffffff;
  --ink: #2b2a33;
  --muted: #7a7684;
  --red: #d2453f;
  --red-dark: #b3332e;
  --green: #2f8f5b;
  --gold: #f2b134;
  --line: #f0e4de;
  --shadow: 0 8px 30px rgba(180, 80, 60, .10);
  --radius: 22px;
  --item: 4.6rem;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.15rem;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 50% -10%, #ffe9e2 0%, transparent 70%),
    linear-gradient(#fff8f4, #f4fbf7);
  background-attachment: fixed;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

#snow, #confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
#snow { z-index: 0; }
#confetti { z-index: 50; }

.wrap {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}
body.admin .wrap { max-width: 920px; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem .25rem 1rem;
}
.logo { font-weight: 700; font-size: 1.2rem; color: var(--red); }
.logo span { color: var(--ink); }

h1 { font-size: 2rem; line-height: 1.2; margin: 0; }
h2 { font-size: 1.45rem; margin: 0 0 .5rem; }
h3 { font-size: 1.2rem; margin: 1.2rem 0 .4rem; }
p { margin: .3rem 0 .8rem; }

.muted { color: var(--muted); margin: 0 0 .5rem; }
.center { text-align: center; }
.big-emoji { font-size: 3.5rem; line-height: 1.1; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.3rem;
  margin-bottom: 1.1rem;
  position: relative;
}
.card.hello { border-top: 5px solid var(--red); background: linear-gradient(#fff, #fffaf8); }

/* Buttons & Formulare */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: 0;
  border-radius: 16px;
  padding: .85rem 1.3rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
  background: #f3ebe7;
  text-decoration: none;
  transition: transform .12s, box-shadow .12s, background .12s;
  -webkit-tap-highlight-color: transparent;
  min-height: 3.2rem;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary {
  background: linear-gradient(var(--red), var(--red-dark));
  color: #fff;
  box-shadow: 0 6px 16px rgba(210, 69, 63, .3);
}
.btn-green { background: var(--green); color: #fff; }
.btn-danger { background: #fdeceb; color: var(--red-dark); }
.btn-small { padding: .45rem .8rem; min-height: 2.6rem; font-size: 1rem; border-radius: 12px; }
.btn-xl { font-size: 1.35rem; padding: 1.1rem 1.8rem; width: 100%; max-width: 360px; }
.is-hidden { display: none; }

input[type=text], input[type=password], textarea {
  width: 100%;
  font: inherit;
  padding: .85rem 1rem;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fffdfc;
  color: var(--ink);
  margin-bottom: .8rem;
}
input:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 4px rgba(210, 69, 63, .12); }
textarea { resize: vertical; }

.saved { color: var(--green); font-weight: 600; margin: .6rem 0 0; }
.error, .saved.error { color: var(--red-dark); font-weight: 600; }

/* Ergebnis */
.result { text-align: center; border-top: 5px solid var(--green); opacity: 0; transform: translateY(18px) scale(.97); transition: opacity .7s, transform .7s; }
.result.is-visible { opacity: 1; transform: none; }
.target-name {
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--red);
  word-break: break-word;
  margin: .2rem 0 .4rem;
}
.wish-list { list-style: none; padding: 0; margin: 0 0 .5rem; text-align: left; }
.wish-list li {
  background: #f6fbf8;
  border: 1px solid #dcefe4;
  border-radius: 14px;
  padding: .7rem 1rem .7rem 2.6rem;
  margin-bottom: .5rem;
  position: relative;
  word-break: break-word;
}
.wish-list li::before { content: "⭐"; position: absolute; left: .85rem; top: .7rem; font-size: 1rem; }
.hint { color: var(--muted); font-size: 1rem; margin-top: 1rem; }
.stage-card.done { display: none; }

/* ---------- Ziehungs-Bühne ---------- */
.stage {
  position: relative;
  height: 290px;
  margin: .5rem 0 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rays {
  position: absolute;
  width: 520px;
  height: 520px;
  max-width: 140%;
  opacity: 0;
  background: repeating-conic-gradient(from 0deg, rgba(242, 177, 52, .30) 0 8deg, transparent 8deg 20deg);
  -webkit-mask-image: radial-gradient(circle, #000 10%, transparent 68%);
  mask-image: radial-gradient(circle, #000 10%, transparent 68%);
  border-radius: 50%;
  transition: opacity .6s;
  pointer-events: none;
}
.stage.glow .rays { opacity: 1; animation: spin 14s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.gift { position: relative; width: 170px; height: 190px; animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }

.gift-body, .gift-lid {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #e0574f, #b3332e);
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, .08);
}
.gift-body { bottom: 0; width: 150px; height: 120px; border-radius: 0 0 14px 14px; }
.gift-lid { top: 22px; width: 170px; height: 46px; border-radius: 12px; z-index: 2; transform-origin: 20% 100%; }
.gift-body::before, .gift-lid::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 30px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #f6c453, #f2b134 50%, #e19f1c);
}
.bow { position: absolute; left: 50%; top: -42px; transform: translateX(-50%); font-size: 3.4rem; line-height: 1; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .15)); }

.gift.shaking { animation: shake 1.9s ease-in forwards; }
@keyframes shake {
  0%   { transform: rotate(0) scale(1); }
  10%  { transform: rotate(-5deg) scale(1.02); }
  20%  { transform: rotate(5deg) scale(1.03); }
  30%  { transform: rotate(-7deg) scale(1.04); }
  40%  { transform: rotate(7deg) scale(1.05); }
  50%  { transform: rotate(-9deg) scale(1.07); }
  60%  { transform: rotate(9deg) scale(1.08); }
  70%  { transform: rotate(-11deg) scale(1.1); }
  80%  { transform: rotate(11deg) scale(1.12); }
  90%  { transform: rotate(-6deg) scale(1.15); }
  100% { transform: rotate(0) scale(1.15); }
}

.gift.opening { animation: none; transform: scale(1.15); }
.gift.opening .gift-lid { animation: lid .9s cubic-bezier(.3, .1, .3, 1) forwards; }
.gift.opening .gift-body { animation: body-out .9s .45s ease-in forwards; }
@keyframes lid {
  0%   { transform: translateX(-50%) translateY(0) rotate(0); opacity: 1; }
  40%  { transform: translateX(-50%) translateY(-90px) rotate(-12deg); opacity: 1; }
  100% { transform: translateX(-20%) translateY(-200px) rotate(35deg); opacity: 0; }
}
@keyframes body-out { to { opacity: 0; transform: translateX(-50%) scale(.8); } }

/* Slot-Maschine */
.slot { width: 100%; position: relative; z-index: 1; }
.slot-window {
  position: relative;
  height: calc(var(--item) * 3);
  overflow: hidden;
  border-radius: 20px;
  background: #fff;
  border: 3px solid var(--gold);
  box-shadow: 0 10px 30px rgba(242, 177, 52, .3), inset 0 0 24px rgba(0, 0, 0, .06);
}
.slot-window::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: var(--item);
  height: var(--item);
  background: rgba(210, 69, 63, .07);
  border-top: 2px solid rgba(210, 69, 63, .3);
  border-bottom: 2px solid rgba(210, 69, 63, .3);
  z-index: 1;
  pointer-events: none;
}
.slot-window::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(#fff 0%, rgba(255, 255, 255, 0) 32%, rgba(255, 255, 255, 0) 68%, #fff 100%);
  z-index: 2;
  pointer-events: none;
}
.slot-reel { will-change: transform; }
.slot-item {
  height: var(--item);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  padding: 0 .8rem;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.slot.spinning .slot-item { filter: blur(.6px); }
.slot-item.win { color: var(--red); font-size: 2.3rem; animation: pop .8s ease-out; }
.slot.won .slot-window { animation: win-glow 1.2s ease-in-out infinite alternate; }
@keyframes pop { 0% { transform: scale(.8); } 50% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes win-glow { to { box-shadow: 0 0 40px 8px rgba(242, 177, 52, .55); } }

/* ---------- Backoffice ---------- */
.admin-grid { display: grid; gap: 1rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row > input { flex: 1 1 200px; margin-bottom: 0; }
.spread { justify-content: space-between; }
.badge {
  display: inline-block;
  padding: .15rem .7rem;
  border-radius: 99px;
  font-size: .9rem;
  font-weight: 600;
  background: #eee9e6;
}
.badge.ok { background: #e1f4ea; color: #1f6e43; }
.badge.warn { background: #fff1d6; color: #8a5a00; }

.participants { list-style: none; padding: 0; margin: 1rem 0 0; }
.participant {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: .9rem 1rem;
  margin-bottom: .7rem;
  background: #fffdfc;
}
.participant .pname { font-weight: 700; font-size: 1.2rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.url-row { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; }
.url-row input {
  flex: 1;
  margin: 0;
  font-size: .95rem;
  padding: .6rem .8rem;
  background: #f7f3f1;
  min-width: 0;
}
.copy-btn { flex: none; width: 3rem; padding: 0; }
.copy-btn.copied { background: var(--green); color: #fff; }
.notice { background: #fff1d6; border-radius: 14px; padding: .8rem 1rem; margin-bottom: 1rem; }
.notice.good { background: #e1f4ea; }
.round-link { text-decoration: none; color: inherit; display: block; }
.round-item { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }

.progress { height: 14px; background: #f1e9e5; border-radius: 99px; overflow: hidden; margin: .4rem 0 1rem; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--green), #54c28a); border-radius: 99px; transition: width .4s; }
.overview { display: grid; gap: 1rem; }
@media (min-width: 640px) { .overview { grid-template-columns: 1fr 1fr; } }
.overview h3 { margin-top: .2rem; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { padding: .35rem .9rem; border-radius: 99px; font-weight: 600; background: #eee9e6; }
.chip.ok { background: #e1f4ea; color: #1f6e43; }
.chip.warn { background: #fff1d6; color: #8a5a00; }

@media (max-width: 420px) {
  body { font-size: 1.1rem; }
  .target-name { font-size: 2.2rem; }
  .slot-item { font-size: 1.7rem; }
  .slot-item.win { font-size: 2rem; }
}

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