/* Wichtelhut – mobile first */

:root {
  --bg: #0c1830;
  --card: rgba(22, 43, 77, 0.92);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f7f2e8;
  --muted: #a8b5cc;
  --red: #d8443f;
  --gold: #f3c552;
  --green: #4cc27e;
  --paper: #fbf5e6;
  --ink: #3b2b1c;
  --radius: 18px;
  --tap: 54px;
  --gutter: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(130% 70% at 50% 0%, #1d3763 0%, var(--bg) 65%) fixed, var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

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

#app {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 10px) max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
}

.loading, .noscript { text-align: center; color: var(--muted); padding: 40px 16px; }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Kopfzeile */
.topbar { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: inherit; text-decoration: none; font-weight: 800; font-size: 18px;
}
.brand svg { width: 30px; height: 30px; }
.event-title { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 850; overflow-wrap: anywhere; }

/* Karten */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.card h2 { margin: 0 0 6px; font-size: 20px; line-height: 1.25; }
.card p { margin: 0 0 12px; }
.card p:last-child { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.count { color: var(--muted); font-weight: 600; }

.notice {
  border-radius: 14px; padding: 12px 14px; font-size: 15px;
  background: rgba(243, 197, 82, 0.12); border: 1px solid rgba(243, 197, 82, 0.35); color: #fbe3a6;
}
.banner {
  text-align: center; font-weight: 800; font-size: 20px; padding: 16px;
  border-radius: var(--radius); background: linear-gradient(135deg, #1f6b45, #2c8a5a);
}

/* Buttons & Eingaben */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: var(--tap); padding: 14px 18px;
  border: 0; border-radius: 14px;
  font: inherit; font-weight: 750; font-size: 17px; line-height: 1.2;
  cursor: pointer; touch-action: manipulation; text-decoration: none;
  transition: transform 0.1s, background 0.2s, opacity 0.2s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { cursor: default; }
.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #e5534d, #b62e2e);
  box-shadow: 0 8px 20px rgba(216, 68, 63, 0.35);
}
.btn-primary:disabled { background: #33435f; color: #b6c1d4; box-shadow: none; }
.btn-secondary { color: var(--text); background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line); }
.btn-link {
  min-height: 44px; padding: 8px; background: none; color: var(--muted);
  font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.btn-small { width: auto; min-height: 40px; padding: 8px 14px; font-size: 15px; }
.danger { color: #ff9e98; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: 10px; }
.field label { font-weight: 700; }
.input {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  font: inherit; font-size: 18px; /* >= 16px verhindert Zoom auf iOS */
  color: var(--text); background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 14px;
}
.input::placeholder { color: #7c8aa3; }
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(243, 197, 82, 0.25); }

/* Untere Aktionsleiste – immer im Daumenbereich */
.actionbar {
  position: sticky; bottom: 0; z-index: 5;
  margin: auto calc(var(--gutter) * -1) 0;
  padding: 18px var(--gutter) calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: linear-gradient(to top, var(--bg) 72%, rgba(12, 24, 48, 0));
}
.spacer { flex: 1; min-height: 8px; }

/* Teilnehmerliste */
.people { list-style: none; margin: 4px 0 0; padding: 0; }
.person {
  display: flex; align-items: center; gap: 12px;
  min-height: 58px; padding: 8px 0; border-top: 1px solid var(--line);
}
.person:first-child { border-top: 0; }
.avatar {
  position: relative; flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
  background: hsl(var(--hue, 210), 50%, 40%);
}
.avatar .num { font-size: 16px; }
.dot {
  position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #162b4d; background: #6b7891;
}
.dot.on { background: var(--green); }
.person-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.you { color: var(--muted); font-weight: 500; }
.person-status { font-size: 14px; color: var(--muted); }
.badge {
  flex: none; font-size: 13px; font-weight: 750; padding: 6px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08); color: var(--muted); white-space: nowrap;
}
.badge.ok { background: rgba(76, 194, 126, 0.18); color: #93e6b6; }
.badge.now { background: rgba(243, 197, 82, 0.2); color: var(--gold); }
.person .btn-small { flex: none; }

.hint { margin-top: 12px !important; font-size: 15px; color: var(--muted); }
.hint.good { color: #93e6b6; font-weight: 700; }

/* Link teilen */
.linkbox {
  font: 14px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
  padding: 12px; margin: 10px 0 12px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.28); word-break: break-all;
  -webkit-user-select: all; user-select: all;
}

/* Auswahl Vorjahr */
.choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.choice {
  display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: rgba(0, 0, 0, 0.18);
  cursor: pointer; font-weight: 650;
}
.choice input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--red); }
.choice.is-checked { border-color: var(--gold); background: rgba(243, 197, 82, 0.1); }
.choice.none { font-weight: 500; color: var(--muted); }

/* Start-Seite */
.hero { text-align: center; padding: 14px 0 0; }
.hero .hat { width: 150px; height: 150px; margin: 0 auto; display: block; animation: bob 3s ease-in-out infinite; }
.hero h1 { margin: 4px 0 2px; font-size: 42px; font-weight: 900; letter-spacing: -0.5px; }
.hero p { margin: 0; color: var(--muted); }
.steps { margin: 0; padding-left: 22px; }
.steps li { margin: 6px 0; }
.event-links { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.event-links a {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: var(--tap); padding: 12px 14px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.07); color: var(--text); text-decoration: none; font-weight: 700;
}
.event-links a::after { content: "›"; font-size: 24px; color: var(--muted); }
.footer { text-align: center; font-size: 14px; color: var(--muted); padding: 18px 0 calc(18px + env(safe-area-inset-bottom)); }

/* Zieh-Bühne */
.stage { text-align: center; }
.stage h2 { font-size: 24px; }
.hat-area { position: relative; height: 260px; margin: 4px 0 8px; }
.hat-btn {
  position: absolute; left: 50%; bottom: 0; width: 210px; height: 210px; margin-left: -105px;
  padding: 0; border: 0; background: none; cursor: pointer; touch-action: manipulation;
  transition: transform 0.6s cubic-bezier(.3, 1.3, .5, 1), opacity 0.5s;
}
.hat-btn svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.4)); }
.hat-btn:disabled { cursor: default; opacity: 0.55; }
.hat-area.myturn .hat-btn { animation: bob 2.2s ease-in-out infinite; }
.hat-area.shaking .hat-btn { animation: shake 0.28s ease-in-out infinite; opacity: 1; }
.hat-area.revealed .hat-btn { transform: translateY(40px) scale(0.5); opacity: 0.3; }

.slip {
  position: absolute; left: 50%; top: 6px; z-index: 2;
  width: min(290px, 86%); min-height: 160px; padding: 20px 16px;
  display: grid; place-items: center;
  border: 0; border-radius: 6px; cursor: pointer; font: inherit; color: var(--ink);
  background:
    linear-gradient(180deg, transparent 49.5%, rgba(59, 43, 28, 0.12) 50%, transparent 51%),
    repeating-linear-gradient(transparent 0 27px, rgba(59, 43, 28, 0.07) 27px 28px),
    var(--paper);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.4);
  opacity: 0; pointer-events: none;
  transform: translate(-50%, 110px) scale(0.15) rotate(-10deg);
  transition: transform 0.8s cubic-bezier(.2, 1.35, .4, 1), opacity 0.3s;
}
.hat-area.revealed .slip { opacity: 1; pointer-events: auto; transform: translate(-50%, 0) rotate(-2deg); }
.slip.open { background: repeating-linear-gradient(transparent 0 27px, rgba(59, 43, 28, 0.07) 27px 28px), var(--paper); }
.slip-front, .slip-back { grid-area: 1 / 1; transition: opacity 0.35s, transform 0.35s; }
.slip-front { font-weight: 700; color: #7b6146; }
.slip-front::before { content: "✉️"; display: block; font-size: 34px; margin-bottom: 6px; }
.slip-back { opacity: 0; transform: scale(0.9); }
.slip.open .slip-front { opacity: 0; transform: scale(0.9); }
.slip.open .slip-back { opacity: 1; transform: none; }
.slip-label { display: block; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: #8a6d4c; font-weight: 700; }
.slip-name {
  display: block; margin-top: 4px; overflow-wrap: anywhere;
  font-family: "Bradley Hand", "Segoe Print", "Chalkboard SE", "Comic Sans MS", cursive;
  font-size: 38px; line-height: 1.15; font-weight: 700; color: #a42a28;
}
.slip-hint { display: block; margin-top: 10px; font-size: 13px; color: #8a6d4c; }

.spark {
  position: absolute; left: 50%; top: 40%; z-index: 3; width: 10px; height: 10px; pointer-events: none;
  background: var(--gold); clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: spark 0.9s ease-out forwards;
}

/* Toast */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 10px); z-index: 50;
  width: max-content; max-width: calc(100% - 32px);
  padding: 12px 16px; border-radius: 14px; font-weight: 650; font-size: 15px;
  background: #f7f2e8; color: #1b2333; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -160%); transition: transform 0.3s; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: #ffe0de; color: #7a1414; }

.netwarn {
  text-align: center; font-size: 14px; padding: 8px 12px; border-radius: 12px;
  background: rgba(255, 158, 152, 0.15); color: #ffc7c3;
}

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes shake { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg) translateY(-4px); } }
@keyframes spark {
  from { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.4) rotate(120deg); opacity: 0; }
}

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

@media (min-width: 600px) {
  #app { padding-top: 28px; }
  .event-title { font-size: 32px; }
}
