/* Animationen und die Bausteine, die erst durch sie Sinn ergeben
   (Karte zum Umdrehen, Timer, Ergebnis mit Spannungspause, Konfetti).
   Wer "Bewegung reduzieren" eingestellt hat, bekommt alles sofort. */

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes pop-in { 0% { opacity: 0; transform: scale(.85); } 60% { opacity: 1; transform: scale(1.04); } 100% { transform: none; } }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-8px); } 40%, 60% { transform: translateX(8px); } }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
@keyframes tick { 0% { transform: scale(.4); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes dots { 0%, 20% { content: ""; } 40% { content: "."; } 60% { content: ".."; } 80%, 100% { content: "..."; } }

/* Neuer Bildschirm: Elemente kommen gestaffelt von unten. */
.app.enter > * { animation: rise .45s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 55ms); }

.hero .logo { animation: bob 3.2s ease-in-out infinite; }
.btn { transition: transform .12s ease, opacity .15s ease, box-shadow .15s ease, background .15s ease; }
.btn:not(:disabled):hover { box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.chip, .vote-option, .player, .tab { transition: background .2s ease, color .2s ease, transform .15s ease, border-color .2s ease; }
.chip:not(:disabled):active, .vote-option:active { transform: scale(.97); }
.vote-option.picked { animation: pop-in .3s ease; }
.player.pop { animation: pop-in .4s ease both; }
.player.tick .avatar { animation: tick .45s ease both; }
.waiting-dots::after { content: ""; animation: dots 1.6s steps(1) infinite; }
.progress > i { transition: width .4s cubic-bezier(.2, .8, .2, 1); }

/* Raumcode: Buchstaben fallen nacheinander ein. */
.code-box .code span { display: inline-block; }
.code-box .code.intro span { animation: pop-in .45s ease both; animation-delay: calc(200ms + var(--i) * 90ms); }

/* Sprecherwechsel */
.speaker.pop { animation: pop-in .45s cubic-bezier(.2, .8, .2, 1) both; }
.speaker.me.pop { animation: pop-in .45s cubic-bezier(.2, .8, .2, 1) both, pulse 1.6s ease-in-out .45s infinite; }

/* ---------- Karte zum Umdrehen ---------- */
.flip { perspective: 1200px; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; outline: none; }
.flip-inner {
  position: relative; min-height: 300px;
  transition: transform .6s cubic-bezier(.3, 1.4, .5, 1);
  transform-style: preserve-3d;
}
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0;
  border-radius: var(--r-xl);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--md);
  padding: var(--xxl); text-align: center;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.face.front {
  transform: rotateY(0deg);
  background: var(--surface-strong); border: 2px dashed var(--surface-border);
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 12px, transparent 12px 24px);
}
.face.front .tap { animation: bob 2.4s ease-in-out infinite; }
.face.back { transform: rotateY(180deg); box-shadow: 0 10px 30px rgba(0,0,0,.15); }
.face.crew { background: rgba(207, 229, 253, 1); color: #327334; }
.face.impostor { background: rgba(255, 240, 240, 1); color: #a52e26; }
.face .big { font-size: 38px; font-weight: 800; line-height: 1.1; word-break: break-word; }
.face .tap { font-size: 18px; font-weight: 700; }
.face .small { font-size: 13px; opacity: .8; }

/* ---------- Eigenes Wort ansehen ---------- */
.peek {
  border-radius: var(--r-md); padding: var(--md) var(--lg);
  background: var(--surface); text-align: center; font-weight: 700;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: pointer; touch-action: manipulation;
  display: grid; transition: background .2s, color .2s;
}
.peek > span { grid-area: 1 / 1; transition: opacity .2s, transform .2s; }
.peek .peek-shown { opacity: 0; transform: translateY(6px); }
.peek.open { background: #fff; color: var(--primary); }
.peek.open .peek-hidden { opacity: 0; transform: translateY(-6px); }
.peek.open .peek-shown { opacity: 1; transform: none; }

/* ---------- Timer ---------- */
.timer { display: flex; align-items: center; gap: var(--sm); flex-shrink: 0; }
.ring { position: relative; width: 60px; height: 60px; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring circle { fill: none; stroke-width: 6; stroke-linecap: round; }
.ring .track { stroke: var(--surface-strong); }
.ring .bar {
  stroke: #fff; stroke-dasharray: 157.08;
  animation: ring var(--dur) linear both; animation-delay: var(--delay);
}
@keyframes ring { from { stroke-dashoffset: 0; } to { stroke-dashoffset: 157.08; } }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.timer.urgent .ring { animation: pulse-ring .8s ease-in-out infinite; }
.timer.urgent .ring .bar, .timer.urgent .num { stroke: #FFE0E0; color: #FFE0E0; }
@keyframes pulse-ring { 50% { transform: scale(1.1); } }

/* ---------- Ergebnis ---------- */
.result { display: flex; flex-direction: column; gap: var(--xl); }
.stage { position: relative; min-height: 190px; display: grid; }
.stage > * { grid-area: 1 / 1; }
.suspense {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--lg);
  animation: suspense 2.2s ease both; pointer-events: none;
}
@keyframes suspense { 0% { opacity: 0; } 12%, 85% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
.drum { display: flex; gap: 10px; }
.drum i { width: 14px; height: 14px; border-radius: 50%; background: #fff; animation: drum .6s ease-in-out infinite alternate; }
.drum i:nth-child(2) { animation-delay: .15s; }
.drum i:nth-child(3) { animation-delay: .3s; }
@keyframes drum { from { transform: translateY(6px); opacity: .5; } to { transform: translateY(-10px); opacity: 1; } }

.verdict { text-align: center; padding: var(--xxl) var(--lg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sm); }
.verdict .who { font-size: 34px; font-weight: 800; word-break: break-word; }
.verdict.hit { background: var(--success-deep); border: none; }
.verdict.miss { background: var(--danger-deep); border: none; }
.verdict.none { background: var(--surface-strong); }
.result .verdict { animation: verdict-in .6s cubic-bezier(.2, 1.4, .4, 1) 2.2s both; }
.result .verdict.miss { animation: verdict-in .6s cubic-bezier(.2, 1.4, .4, 1) 2.2s both, shake .5s ease 2.9s; }
@keyframes verdict-in { from { opacity: 0; transform: scale(.6) rotate(-4deg); } to { opacity: 1; transform: none; } }
.stamp {
  margin-top: var(--xs);
  padding: var(--xs) var(--lg);
  border: 3px solid #fff; border-radius: var(--r-sm);
  font-weight: 900; font-size: 20px; letter-spacing: 1px; text-transform: uppercase;
  transform: rotate(-6deg);
}
.result .stamp { animation: stamp .45s cubic-bezier(.2, 1.6, .4, 1) 2.75s both; }
@keyframes stamp { from { opacity: 0; transform: scale(3) rotate(-20deg); } to { opacity: 1; transform: rotate(-6deg); } }
.goes-on { font-weight: 700; }
.goes-on .arrow { display: inline-block; animation: nudge 1s ease-in-out 2.8s infinite; }
@keyframes nudge { 50% { transform: translateX(6px); } }
.result .tally { animation: rise .5s ease var(--t) both; }
.result .after { animation: rise .4s ease 3.3s both; }
.result.instant, .result.instant * { animation-delay: 0s !important; animation-duration: .01s !important; }
.result.instant .suspense { display: none; }

.tally-row { display: flex; flex-direction: column; gap: 6px; padding: var(--sm) 0; font-size: 15px; }
.tally-row + .tally-row { border-top: 1px solid var(--surface-border); }
.tally-row .voters { opacity: .8; font-size: 13px; }
.tally-row .bar { height: 8px; border-radius: 999px; background: var(--surface-strong); overflow: hidden; }
.tally-row .bar i { display: block; height: 100%; background: #fff; border-radius: 999px; transform-origin: left; animation: grow .7s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes grow { from { transform: scaleX(0); } }

/* ---------- Ende ---------- */
.winner { text-align: center; padding: var(--xxxl) var(--lg); }
.winner .emoji { font-size: 60px; display: inline-block; }
.winner.crew { background: var(--success-deep); border: none; }
.winner.impostors { background: var(--danger-deep); border: none; }
.winner.won .emoji { animation: pop-in .6s ease .2s both, bob 2s ease-in-out 1s infinite; }
.winner.lost { animation: wobble .6s ease .4s; }
.solution .dim { color: var(--text-on-light-muted); }
.returning { animation: pop-in .4s ease both; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

/* ---------- Start ---------- */
.mode-card {
  appearance: none; cursor: pointer; width: 100%; text-align: left; color: #fff; font: inherit;
  display: flex; align-items: center; gap: var(--md);
  padding: var(--lg); border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--surface-border);
  transition: background .2s, transform .15s;
}
.mode-card:hover { background: var(--surface-strong); }
.mode-card:active { transform: scale(.98); }
.mode-card .mode-icon { font-size: 30px; }
.mode-card .arrow { margin-left: auto; font-size: 22px; transition: transform .2s; }
.mode-card:hover .arrow { transform: translateX(4px); }
.store-badge {
  display: flex; flex-direction: column; align-items: center; gap: var(--sm);
  color: #fff; text-decoration: none; -webkit-touch-callout: default;
}
.store-badge img { display: block; height: 50px; width: auto; }
.store-badge:active img { transform: scale(.97); }
.footer.links { display: flex; justify-content: center; align-items: center; gap: var(--xs); opacity: .9; }

/* ---------- Hilfe ---------- */
.help-fab {
  position: fixed; right: max(16px, calc(50% - 260px + 16px)); bottom: calc(16px + env(safe-area-inset-bottom));
  width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.9); color: var(--primary); font-weight: 900; font-size: 18px;
  box-shadow: 0 4px 14px rgba(0,0,0,.15); z-index: 5;
}
.icon-btn.big { width: 40px; height: 40px; font-size: 22px; }
.tabs { display: flex; gap: var(--xs); background: var(--surface); padding: var(--xs); border-radius: 999px; }
.tab {
  appearance: none; border: none; cursor: pointer; flex: 1;
  padding: 10px; border-radius: 999px; background: transparent; color: #fff; font-weight: 700; font-size: 14px;
}
.tab.on { background: #fff; color: var(--primary); }
.step { display: flex; gap: var(--md); align-items: flex-start; animation: rise .45s ease both; animation-delay: calc(var(--i) * 80ms); }
.step-icon { font-size: 28px; line-height: 1; }
.card p { margin: 0; line-height: 1.5; }
.tips { margin: 0; padding-left: 20px; line-height: 1.5; }
.faq summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: var(--md); }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 20px; line-height: 1; transition: transform .2s; }
.faq[open] summary::after { transform: rotate(45deg); }
.faq[open] p { margin-top: var(--sm); animation: rise .25s ease both; }
.logo.small { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto; }
.card a { color: #fff; font-weight: 700; }

/* ---------- Snackbar ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom));
  max-width: min(480px, calc(100% - 32px)); width: max-content;
  background: rgba(20, 20, 20, .92); color: #fff;
  padding: var(--md) var(--lg); border-radius: var(--r-md); font-size: 15px; z-index: 40;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  transform: translate(-50%, 20px); opacity: 0;
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), opacity .25s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast[data-kind="error"] { background: var(--danger-deep); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
  .suspense { display: none; }
}

/* ---------- Gedrueckt halten ---------- */
.btn.hold { position: relative; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.hold-fill { position: absolute; inset: 0; background: rgba(255, 106, 0, .22); transform: scaleX(0); transform-origin: left; transition: transform .2s ease; }
.btn.hold.holding .hold-fill { transform: scaleX(1); transition: transform .9s linear; }
.btn.hold.holding { transform: scale(.98); }
.hold-label { position: relative; }

/* Aufloesung im Einzelspieler */
.verdict.unmasked { background: var(--danger-deep); border: none; }
.result .later { animation: rise .5s ease var(--t, 3s) both; }
