:root {
  --ink: #1a1a2e;
  --red: #E63946;
  --green: #1F7A4D;
  --gold: #FFC93C;
  --cream: #FFF4E0;
  --night: #141430;
  --shadow: 5px 5px 0 var(--ink);
  --comic: "Bangers", Impact, "Arial Black", sans-serif;
  --body: "Fredoka", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--body);
  color: var(--ink);
  background-color: var(--cream);
  background-image:
    radial-gradient(rgba(230, 57, 70, .16) 1.6px, transparent 1.8px),
    radial-gradient(rgba(31, 122, 77, .10) 1.6px, transparent 1.8px);
  background-size: 14px 14px, 14px 14px;
  background-position: 0 0, 7px 7px;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#snow, #fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#snow { z-index: 1; }
#fx { z-index: 60; }

/* ---------- Lichterkette ---------- */
#garland { position: fixed; top: 0; left: 0; right: 0; height: 46px; z-index: 30; pointer-events: none; }
#garland svg { width: 100%; height: 100%; display: block; }
.bulb { animation: twinkle 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

#app {
  position: relative; z-index: 5;
  max-width: 480px; margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 52px) 18px calc(env(safe-area-inset-bottom) + 14px);
}
.screen { display: none; flex-direction: column; align-items: center; min-height: calc(100dvh - 70px); }
.screen.active { display: flex; animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.icon-btn {
  position: relative; border: 3px solid var(--ink); background: #fff; border-radius: 50%;
  width: 42px; height: 42px; font-size: 20px; line-height: 1; box-shadow: 3px 3px 0 var(--ink);
}
.icon-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
#mute { position: fixed; z-index: 40; bottom: calc(env(safe-area-inset-bottom) + 14px); right: 14px; width: 38px; height: 38px; font-size: 17px; }

/* ---------- Logo ---------- */
.logo { text-align: center; margin: 14px 0 4px; position: relative; width: 100%; padding-right: 0; }
.logo .ribbon {
  display: inline-block; font-family: var(--comic); font-size: 24px; letter-spacing: 3px;
  background: var(--red); color: #fff; padding: 2px 18px; border: 3px solid var(--ink);
  transform: rotate(-3deg); box-shadow: 3px 3px 0 var(--ink);
}
.logo h1 {
  margin: 0; font-family: var(--comic); font-weight: 400; font-size: clamp(50px, 15.5vw, 76px);
  line-height: .95; letter-spacing: 2px; color: var(--gold);
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 4px 4px 0 var(--red), 7px 7px 0 var(--ink);
  transform: rotate(-4deg);
}
.logo .year {
  position: absolute; right: 2px; top: -14px; font-family: var(--comic); font-size: 20px;
  background: var(--green); color: #fff; border: 3px solid var(--ink); border-radius: 50%;
  width: 54px; height: 54px; display: grid; place-items: center; transform: rotate(12deg);
  box-shadow: 3px 3px 0 var(--ink);
}
.hint { font-weight: 700; font-size: 18px; margin: 18px 0 10px; }

/* ---------- Personen-Raster ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; }
.person {
  position: relative; border: 4px solid var(--ink); border-radius: 18px; padding: 6px 6px 0;
  background: var(--c); box-shadow: var(--shadow); overflow: hidden; transition: transform .12s;
  background-image: radial-gradient(rgba(255,255,255,.28) 2px, transparent 2.3px); background-size: 10px 10px;
}
.person:nth-child(odd) { transform: rotate(-1.5deg); }
.person:nth-child(even) { transform: rotate(1.5deg); }
.person:active { transform: scale(.95); }
.person .char { display: block; width: 100%; height: auto; }
.person .tag {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%) rotate(-2deg);
  font-family: var(--comic); font-size: 24px; letter-spacing: 1px; background: #fff;
  border: 3px solid var(--ink); border-radius: 10px; padding: 0 12px; white-space: nowrap;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--comic); font-size: 28px; letter-spacing: 2px;
  background: var(--gold); border: 4px solid var(--ink); border-radius: 16px;
  padding: 10px 28px; box-shadow: var(--shadow); transition: transform .1s;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.btn-red { background: var(--red); color: #fff; font-size: 22px; }
.btn-small { font-size: 20px; padding: 6px 18px; background: #fff; }
.btn-big { font-size: 46px; padding: 8px 46px; background: var(--red); color: #fff;
  -webkit-text-stroke: 1.5px var(--ink); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.07) rotate(-2deg); } }
.link { background: none; border: 0; font-weight: 700; font-size: 15px; text-decoration: underline; opacity: .7; }
.foot { margin-top: auto; padding-top: 22px; display: flex; gap: 14px; align-items: center; justify-content: center; width: 100%; }
.gear { width: 34px; height: 34px; font-size: 17px; opacity: .55; box-shadow: 2px 2px 0 var(--ink); }

/* ---------- Bühne ---------- */
body[data-screen="stage"] { background: var(--night); }
body[data-screen="stage"] #app { max-width: none; }
.stage { position: relative; color: #fff; }
.stage::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(ellipse at 50% 120%, #2a1f5c 0%, var(--night) 60%),
              var(--night);
}
.stage .spot {
  position: fixed; top: 0; left: 50%; width: 140vw; max-width: 760px; height: 90dvh;
  transform: translateX(-50%); pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse 30% 90% at 50% 0%, rgba(255, 236, 170, .22), transparent 70%);
  clip-path: polygon(40% 0, 60% 0, 88% 100%, 12% 100%);
  animation: sway 6s ease-in-out infinite;
}
@keyframes sway { 50% { transform: translateX(-50%) rotate(2deg); } }
.stage-title { position: relative; font-family: var(--comic); font-size: 34px; letter-spacing: 2px; margin: 14px 0 0;
  color: var(--gold); -webkit-text-stroke: 1.5px var(--ink); text-shadow: 3px 3px 0 var(--red); }
#carousel { position: relative; width: 100%; max-width: 480px; height: 330px; margin-top: 10px; }
#carousel::after { /* Bodenschein */
  content: ""; position: absolute; left: 10%; right: 10%; bottom: 6px; height: 46px; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 201, 60, .35), transparent 70%); z-index: 0;
}
.item { position: absolute; left: 50%; top: 52%; width: 150px; will-change: transform, opacity; }
.item .inner { transform-origin: 50% 80%; }
.item .char { width: 100%; height: auto; display: block;
  filter: brightness(0) drop-shadow(0 0 10px rgba(140, 170, 255, .55));
  transition: filter .35s ease; }
.item .q { position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%);
  font-family: var(--comic); font-size: 44px; color: rgba(255,255,255,.18); pointer-events: none; transition: opacity .3s; }
.revealing .item:not(.target) { opacity: 0 !important; transition: opacity .4s; }
.item.target .inner { animation: zoomShake .85s cubic-bezier(.3, 1.4, .6, 1) forwards; }
.item.lit .char { filter: brightness(1) drop-shadow(0 0 18px rgba(255, 201, 60, .9)); }
.item.lit .q { opacity: 0; }
@keyframes zoomShake {
  0% { transform: scale(1); }
  45% { transform: scale(1.32) rotate(-3deg); }
  55% { transform: scale(1.32) rotate(3deg); }
  65% { transform: scale(1.34) rotate(-3deg); }
  75% { transform: scale(1.34) rotate(3deg); }
  100% { transform: scale(1.38) rotate(0); }
}
.burst { position: absolute; left: 50%; top: 52%; width: 330px; height: 330px; z-index: 1;
  transform: translate(-50%, -50%) scale(0); pointer-events: none; }
.burst.show { animation: burstIn .5s cubic-bezier(.2, 1.6, .5, 1) forwards, spinSlow 14s linear .5s infinite; }
@keyframes burstIn { to { transform: translate(-50%, -50%) scale(1) rotate(8deg); } }
@keyframes spinSlow { from { transform: translate(-50%, -50%) scale(1) rotate(8deg); } to { transform: translate(-50%, -50%) scale(1) rotate(368deg); } }
.bam { position: absolute; z-index: 300; left: 50%; top: 8%; font-family: var(--comic); font-size: 64px; color: var(--gold);
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--red);
  transform: translateX(-50%) rotate(-10deg) scale(0); animation: bamIn .45s cubic-bezier(.2, 1.8, .5, 1) forwards; }
@keyframes bamIn { to { transform: translateX(-50%) rotate(-10deg) scale(1); } }

#reveal-label { position: relative; z-index: 400; text-align: center; opacity: 0; transform: scale(.6); transition: all .45s cubic-bezier(.2, 1.6, .5, 1); margin-top: -6px; }
#reveal-label.show { opacity: 1; transform: none; }
.kicker { display: block; font-weight: 700; font-size: 18px; letter-spacing: 1px; text-transform: uppercase; opacity: .9; }
.kicker.dark { margin: 8px 0 0; }
#reveal-name, #result-name {
  display: block; font-family: var(--comic); font-weight: 400; font-size: clamp(64px, 20vw, 92px); line-height: 1;
  color: var(--gold); letter-spacing: 3px; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 4px 4px 0 var(--red), 7px 7px 0 var(--ink);
}
#draw-btn { position: relative; z-index: 5; margin-top: 18px; }
.stage .foot .link { color: #fff; }

#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 70; }
#flash.go { animation: flash .5s ease-out; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }

/* ---------- Ergebnis ---------- */
.hero { position: relative; width: 230px; height: 230px; margin-top: 8px; }
.rays { position: absolute; inset: 0; border-radius: 50%; border: 4px solid var(--ink); box-shadow: var(--shadow); overflow: hidden;
  background: repeating-conic-gradient(var(--gold) 0 12deg, #ffdf7a 12deg 24deg); }
.rays::after { content: ""; position: absolute; inset: -20%; background: repeating-conic-gradient(var(--gold) 0 12deg, #ffe38c 12deg 24deg); animation: spin 20s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#result-char { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; }
#result-char .char { position: absolute; left: 50%; bottom: -2px; width: 92%; transform: translateX(-50%); }
#result-name { margin: 6px 0 10px; }
.rules { list-style: none; padding: 0; margin: 4px 0 18px; width: 100%; display: grid; gap: 10px; }
.rules li { display: flex; align-items: center; gap: 12px; background: #fff; border: 3px solid var(--ink); border-radius: 14px;
  padding: 9px 12px; box-shadow: 4px 4px 0 var(--ink); font-size: 17px; }
.rules li:nth-child(2) { background: #FFE9EC; }
.rules li:nth-child(3) { background: #E7F6EE; }
.badge { flex: none; width: 38px; height: 38px; display: grid; place-items: center; font-size: 21px; background: var(--gold); border: 3px solid var(--ink); border-radius: 50%; }
.enter .hero { animation: popIn .6s cubic-bezier(.2, 1.6, .5, 1) both; }
.enter #result-name { animation: popIn .6s cubic-bezier(.2, 1.6, .5, 1) .15s both; }
.enter .rules li { animation: slideIn .45s ease both; }
.enter .rules li:nth-child(1) { animation-delay: .35s; }
.enter .rules li:nth-child(2) { animation-delay: .5s; }
.enter .rules li:nth-child(3) { animation-delay: .65s; }
@keyframes popIn { from { transform: scale(.3) rotate(-10deg); opacity: 0; } }
@keyframes slideIn { from { transform: translateX(-30px); opacity: 0; } }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(20, 20, 48, .55); display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .2s; }
.panel { position: relative; width: 100%; max-width: 480px; background: var(--cream); border: 4px solid var(--ink); border-bottom: 0;
  border-radius: 26px 26px 0 0; padding: 20px 22px calc(env(safe-area-inset-bottom) + 24px); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px; animation: up .3s cubic-bezier(.2, 1.2, .5, 1); }
@keyframes up { from { transform: translateY(100%); } }
.panel h3 { margin: 0; font-family: var(--comic); font-weight: 400; font-size: 36px; letter-spacing: 2px; }
.close { position: absolute; top: 12px; right: 14px; background: none; border: 0; font-size: 22px; }
.sheet-char { width: 120px; height: 120px; border-radius: 50%; border: 4px solid var(--ink); overflow: hidden; margin-top: -70px; box-shadow: var(--shadow); position: relative; }
.sheet-char .char { position: absolute; left: 50%; bottom: -2px; width: 96%; transform: translateX(-50%); }
.panel input { width: 100%; max-width: 280px; font: 700 26px var(--body); text-align: center; letter-spacing: 6px;
  padding: 10px; border: 4px solid var(--ink); border-radius: 14px; background: #fff; outline: none; box-shadow: inset 3px 3px 0 rgba(0,0,0,.08); }
.panel input:focus { border-color: var(--red); }
.err { margin: 0; min-height: 20px; color: var(--red); font-weight: 700; }
.shake { animation: shakeX .4s; }
@keyframes shakeX { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%) translateY(140%);
  z-index: 80; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px; font-weight: 700; transition: transform .3s, opacity .3s; opacity: 0; visibility: hidden; max-width: 90vw; text-align: center; }
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }

@media (prefers-reduced-motion: reduce) { .btn-big, .rays::after, .stage .spot { animation: none; } }
