:root {
  --bg: #1b0f3d;
  --bg-2: #2a1660;
  --ink: #1b0f3d;
  --paper: #fff8ec;
  --pink: #ff4f9a;
  --teal: #1fd1c1;
  --yellow: #ffd23f;
  --orange: #ff8a3d;
  --green: #5ee26a;
  --purple: #9b5cff;
  --blue: #3fa9ff;
  --red: #ff4a4a;
  --muted: #6b5a8e;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: 'Fredoka', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Bunte Farbkleckse im Hintergrund */
.blobs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.blobs i {
  position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55;
  animation: drift 18s ease-in-out infinite alternate;
}
.blobs i:nth-child(1) { width: 420px; height: 420px; background: var(--pink); top: -120px; left: -100px; }
.blobs i:nth-child(2) { width: 380px; height: 380px; background: var(--teal); top: 30%; right: -140px; animation-delay: -6s; }
.blobs i:nth-child(3) { width: 360px; height: 360px; background: var(--yellow); bottom: -140px; left: 10%; animation-delay: -12s; opacity: .35; }
.blobs i:nth-child(4) { width: 300px; height: 300px; background: var(--purple); top: 55%; left: -120px; animation-delay: -3s; }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.15); } }

#sprinkles { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

.wrap { position: relative; z-index: 1; max-width: 860px; margin: 0 auto; padding: 22px 16px 80px; }

h1, h2, .title-font { font-family: 'Lilita One', 'Fredoka', sans-serif; font-weight: 400; letter-spacing: .5px; }
h1 {
  font-size: clamp(2.6rem, 9vw, 4.4rem); line-height: 1.02; margin: .15em 0 .2em; color: #fff;
  text-shadow: 4px 4px 0 var(--ink);
}
h1 .ch { display: inline-block; transition: transform .2s; }
h1 .ch:hover { transform: translateY(-4px) rotate(-6deg); }
h2 { font-size: 2rem; margin: 0 0 .35em; line-height: 1.1; }
h3 { margin: 0 0 .5em; font-size: 1.15rem; font-weight: 700; }
p { line-height: 1.5; }
.center { text-align: center; }
.small { font-size: .9rem; }
.muted { color: var(--muted); }
.light { color: #efe7ff; }
.hand { font-family: 'Caveat', cursive; font-size: 1.45rem; line-height: 1.2; }

.kicker {
  display: inline-block; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; font-size: .8rem;
  background: var(--yellow); border: 3px solid var(--ink); border-radius: 999px; padding: 5px 14px;
  box-shadow: 3px 3px 0 var(--ink); transform: rotate(-2deg);
}

/* Lichterkette */
.lights { display: flex; justify-content: center; gap: 18px; margin: 0 auto 8px; height: 34px; position: relative; }
.lights::before { content: ''; position: absolute; left: 0; right: 0; top: 4px; height: 14px; border-bottom: 3px solid #0d0726; border-radius: 0 0 50% 50%; }
.lights span {
  width: 14px; height: 22px; border-radius: 50% 50% 45% 45%; margin-top: 10px; border: 2px solid var(--ink);
  animation: blink 1.6s infinite alternate;
}
.lights span:nth-child(5n+1) { background: var(--pink); }
.lights span:nth-child(5n+2) { background: var(--yellow); animation-delay: .3s; }
.lights span:nth-child(5n+3) { background: var(--teal); animation-delay: .6s; }
.lights span:nth-child(5n+4) { background: var(--orange); animation-delay: .9s; }
.lights span:nth-child(5n+5) { background: var(--green); animation-delay: 1.2s; }
@keyframes blink { from { filter: brightness(.6); } to { filter: brightness(1.25) drop-shadow(0 0 8px rgba(255,255,255,.7)); } }

/* Karten im Sticker-Look */
.card {
  position: relative; background: var(--paper); border: 3px solid var(--ink); border-radius: 26px;
  padding: 22px; margin: 22px 0; box-shadow: 8px 8px 0 var(--shadow, var(--pink));
}
.card.c-teal { --shadow: var(--teal); }
.card.c-yellow { --shadow: var(--yellow); }
.card.c-orange { --shadow: var(--orange); }
.card.c-green { --shadow: var(--green); }
.card.c-purple { --shadow: var(--purple); }
.card.c-blue { --shadow: var(--blue); }
.tilt-l { transform: rotate(-.7deg); }
.tilt-r { transform: rotate(.7deg); }

.sticker {
  position: absolute; top: -18px; right: 18px; font-size: 1.9rem; transform: rotate(12deg);
  filter: drop-shadow(2px 2px 0 var(--ink));
}

/* Spruch-Zettel */
.note {
  display: inline-block; max-width: 520px; margin: 14px auto 0; padding: 10px 18px;
  background: var(--yellow); border: 3px solid var(--ink); border-radius: 6px 18px 6px 18px;
  box-shadow: 5px 5px 0 var(--ink); transform: rotate(-1.5deg); transition: opacity .4s;
}
.note.fade { opacity: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 12px 0 0; }
.chip {
  font-weight: 700; padding: 6px 14px; border-radius: 999px; border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink); background: #fff;
}
.chip:nth-child(3n+1) { background: var(--teal); transform: rotate(-2deg); }
.chip:nth-child(3n+2) { background: var(--pink); color: #fff; transform: rotate(1.5deg); }
.chip:nth-child(3n+3) { background: var(--orange); transform: rotate(-1deg); }

/* Formulare */
label { display: block; font-weight: 700; font-size: .92rem; margin: 12px 0 6px; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 3px solid var(--ink); border-radius: 14px; padding: 10px 13px; outline: none;
}
input:focus, textarea:focus, select:focus { box-shadow: 0 0 0 4px var(--yellow); }
textarea { min-height: 90px; resize: vertical; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 150px; }
.row > .shrink { flex: 0 0 auto; }

/* Knöpfe */
.btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 700; font-size: 1rem;
  padding: 11px 18px; border-radius: 14px; border: 3px solid var(--ink); color: var(--ink);
  background: var(--yellow); box-shadow: 5px 5px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
@media (hover: hover) { .btn:hover { transform: translate(-1px, -1px) rotate(-1deg); box-shadow: 6px 6px 0 var(--ink); } }
.btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 5px 5px 0 var(--ink); }
.btn.pink { background: var(--pink); color: #fff; }
.btn.teal { background: var(--teal); }
.btn.green { background: var(--green); }
.btn.orange { background: var(--orange); }
.btn.purple { background: var(--purple); color: #fff; }
.btn.white { background: #fff; }
.btn.small { padding: 6px 12px; font-size: .88rem; border-radius: 11px; box-shadow: 3px 3px 0 var(--ink); }
.btn.big { padding: 16px 28px; font-size: 1.3rem; border-radius: 18px; }
.btn.danger { background: #fff; color: #c4163f; }

/* Namen wählen */
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; margin-top: 18px; }
.name-btn {
  cursor: pointer; font: inherit; font-weight: 700; font-size: 1.15rem; color: var(--ink);
  padding: 18px 10px 14px; border-radius: 20px; border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink); transition: transform .12s;
}
.name-btn .em { display: block; font-size: 2rem; margin-bottom: 4px; }
.name-btn:nth-child(6n+1) { background: var(--pink); color: #fff; transform: rotate(-2deg); }
.name-btn:nth-child(6n+2) { background: var(--teal); transform: rotate(1.5deg); }
.name-btn:nth-child(6n+3) { background: var(--yellow); transform: rotate(-1deg); }
.name-btn:nth-child(6n+4) { background: var(--orange); transform: rotate(2deg); }
.name-btn:nth-child(6n+5) { background: var(--green); transform: rotate(-1.5deg); }
.name-btn:nth-child(6n+6) { background: var(--purple); color: #fff; transform: rotate(1deg); }
@media (hover: hover) { .name-btn:hover:not(:disabled) { transform: scale(1.06) rotate(-3deg); } }
.name-btn:disabled { background: #d9d2e6 !important; color: #7a6d93 !important; cursor: not-allowed; box-shadow: 2px 2px 0 var(--ink); }
.name-btn .tag { display: block; font-size: .78rem; font-weight: 600; margin-top: 3px; }

/* Wichtel-Maschine */
.machine { text-align: center; }
.machine-box {
  position: relative; margin: 26px auto 10px; max-width: 420px; padding: 22px 22px 26px; border-radius: 30px;
  border: 4px solid var(--ink); box-shadow: 8px 8px 0 var(--ink);
  background: repeating-linear-gradient(-45deg, var(--pink) 0 22px, #fff 22px 44px);
}
.machine-box .label {
  font-family: 'Lilita One', sans-serif; font-size: 1.5rem; background: var(--yellow); display: inline-block;
  padding: 4px 16px; border: 3px solid var(--ink); border-radius: 12px; box-shadow: 3px 3px 0 var(--ink); margin-bottom: 14px;
}
.bulbs { display: flex; justify-content: space-between; margin: 0 6px 12px; }
.bulbs b { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink); background: var(--yellow); }
.machine.spinning .bulbs b { animation: chase .5s infinite; }
.bulbs b:nth-child(2n) { animation-delay: .25s !important; background: var(--teal); }
@keyframes chase { 50% { background: #fff; box-shadow: 0 0 12px #fff; } }
.window {
  position: relative; height: 110px; overflow: hidden; background: #fff; border: 4px solid var(--ink); border-radius: 20px;
}
.window::before, .window::after {
  content: ''; position: absolute; left: 0; right: 0; height: 30px; z-index: 2; pointer-events: none;
}
.window::before { top: 0; background: linear-gradient(#fff, transparent); }
.window::after { bottom: 0; background: linear-gradient(transparent, #fff); }
.pointer { position: absolute; top: 50%; z-index: 3; font-size: 1.6rem; transform: translateY(-50%); }
.pointer.l { left: 6px; } .pointer.r { right: 6px; }
.reel { will-change: transform; }
.reel div {
  height: 110px; line-height: 110px; font-family: 'Lilita One', sans-serif; font-size: 2.6rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 40px;
}
.reel div:nth-child(5n+1) { color: var(--pink); }
.reel div:nth-child(5n+2) { color: #0fa597; }
.reel div:nth-child(5n+3) { color: var(--orange); }
.reel div:nth-child(5n+4) { color: var(--purple); }
.reel div:nth-child(5n+5) { color: #2a9d36; }
.status { min-height: 2.2em; margin-top: 12px; }
.machine.done .machine-box { animation: jump .6s cubic-bezier(.2,1.8,.4,1); }
@keyframes jump { 40% { transform: scale(1.08) rotate(-2deg); } }

/* Ergebnis */
.big-name {
  font-family: 'Lilita One', sans-serif; font-size: clamp(3rem, 13vw, 5.4rem); line-height: 1; margin: 10px 0;
  text-shadow: 4px 4px 0 var(--ink); color: #fff; animation: pop .8s cubic-bezier(.2,1.7,.4,1);
}
.big-name .ch { display: inline-block; }
@keyframes pop { from { transform: scale(.2) rotate(-20deg); opacity: 0; } }
.card-img {
  display: block; width: 100%; max-width: 420px; margin: 16px auto; border-radius: 22px; border: 4px solid var(--ink);
  box-shadow: 8px 8px 0 var(--teal); transform: rotate(-1deg);
}
.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }


/* Listen */
.list { list-style: none; margin: 12px 0 0; padding: 0; }
.list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: 14px; background: #fff; border: 2.5px solid var(--ink); margin-bottom: 8px;
}
.list li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.x { background: none; border: none; color: #c4163f; cursor: pointer; font-size: 1.3rem; font-weight: 700; padding: 0 6px; }

.badge { font-size: .8rem; font-weight: 700; padding: 4px 11px; border-radius: 999px; border: 2.5px solid var(--ink); white-space: nowrap; }
.badge.on { background: var(--green); }
.badge.off { background: var(--yellow); }
.badge.pause { background: #fff; }

.event-card { cursor: pointer; transition: transform .12s; }
@media (hover: hover) { .event-card:hover { transform: rotate(-1deg) scale(1.01); } }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.back { color: #fff; text-decoration: none; font-weight: 700; }
.linkbox { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.linkbox input { flex: 1 1 240px; font-family: ui-monospace, Menlo, monospace; font-size: .88rem; }
.feas { margin-top: 12px; padding: 10px 12px; border-radius: 14px; border: 2.5px solid var(--ink); font-weight: 600; }
.feas.ok { background: #d8f8dc; } .feas.bad { background: #ffd9e2; } .feas.na { background: #f1ecfa; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } .card { padding: 18px; } }

/* Toast & Modal */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(140px); z-index: 100;
  background: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--teal); transition: transform .35s cubic-bezier(.2,1.5,.4,1); max-width: calc(100% - 30px); text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { box-shadow: 5px 5px 0 var(--pink); }
.modal-bg {
  position: fixed; inset: 0; background: rgba(20, 8, 50, .75); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal { max-width: 420px; width: 100%; text-align: center; animation: pop .4s cubic-bezier(.2,1.5,.4,1); }

.confetti { position: fixed; top: -30px; z-index: 90; pointer-events: none; animation: fall linear forwards; }
.confetti.piece { width: 10px; height: 16px; border-radius: 3px; border: 1.5px solid var(--ink); }
@keyframes fall { to { transform: translateY(115vh) rotate(900deg); } }

.hidden { display: none !important; }
.footer { text-align: center; color: #cbb9f2; font-size: .9rem; margin-top: 30px; }
#edit > .topbar { margin-top: 22px; }

/* ---------- iPhone / Mobile-Feinschliff ---------- */
.wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-bottom: max(80px, env(safe-area-inset-bottom)); }
.btn, .name-btn, .x { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
input, textarea, select { font-size: 16px; -webkit-appearance: none; appearance: none; min-height: 48px; }
textarea { min-height: 96px; }
input[type="date"] { display: block; text-align: left; line-height: 1.2; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input[type="date"]:invalid, input[type="date"][value=""] { color: #8a7aa8; }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px;
}
.btn.full { width: 100%; }
.ex-form { display: grid; gap: 8px; margin-top: 6px; }
.ex-mid { text-align: center; font-weight: 700; font-size: .9rem; color: var(--muted); }
#inviteLink { font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.linkbtns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.linkbtns .btn { padding-left: 6px; padding-right: 6px; }
.list li .sub { display: block; margin-top: 2px; }
.list li .btn { flex: 0 0 auto; }
#addPForm input { flex: 1 1 auto; }

@media (max-width: 640px) {
  .tilt-l, .tilt-r { transform: none; }
  .card { margin: 18px 0; box-shadow: 6px 6px 0 var(--shadow, var(--pink)); }
  .sticker { font-size: 1.6rem; top: -16px; }
  h2 { font-size: 1.65rem; }
  .row > * { flex: 1 1 130px; }
  .actions .btn { flex: 1 1 140px; }
  /* Werkstatt: kompakter Kopf */
  .admin header .note { font-size: 1.2rem; padding: 8px 14px; margin-top: 10px; }
  .admin h1 { font-size: 2.5rem; }
  .admin .lights { height: 28px; }
  .admin .topbar { margin-top: 16px; }
}
#addPForm { flex-wrap: nowrap; }
#addPForm input { flex: 1 1 auto; min-width: 0; }
#addPForm .btn { flex: 0 0 auto; min-height: 48px; padding: 0 16px; font-size: 1.2rem; }
.linkbtns .btn { white-space: nowrap; font-size: .85rem; }
@media (max-width: 640px) { #result .actions .btn { white-space: nowrap; font-size: .95rem; padding-left: 10px; padding-right: 10px; } }
