/* ---------------------------------------------------------------------------
   24h Challenge - Mobile First, Dark Mode.
   Alles ist fuer den Daumen gebaut: grosse Trefferflaechen, feste Leisten oben
   und unten, dazwischen scrollt der Inhalt.
   --------------------------------------------------------------------------- */

:root {
  --bg: #0b0d12;
  --bg-elevated: #141822;
  --bg-input: #1b2130;
  --line: #232a39;
  --text: #eef2f8;
  --text-dim: #9aa5b8;
  --accent: #3ddc97;
  --accent-dim: #1f7f5b;
  --warn: #ffb347;
  --danger: #ff5c7a;
  --radius: 16px;
  --radius-sm: 10px;
  --topbar-h: 108px;
  --tabbar-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { padding-top: calc(var(--topbar-h) + var(--safe-top)); }

h1, h2, h3 { margin: 0 0 .25rem; line-height: 1.2; }
.muted { color: var(--text-dim); font-size: .875rem; margin: 0; }

/* --- Onboarding ---------------------------------------------------------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: radial-gradient(120% 80% at 50% 0%, #17203a 0%, var(--bg) 60%);
}
.gate[hidden] { display: none; }

.gate__card {
  width: min(420px, 100%);
  display: grid;
  gap: .75rem;
  padding: 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.gate__logo {
  justify-self: start;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: .08em;
  color: var(--bg);
  background: var(--accent);
  padding: .25rem .55rem;
  border-radius: 8px;
}
.gate__error { color: var(--danger); font-size: .875rem; margin: 0; min-height: 1.2em; }

/* --- Kopfzeile ----------------------------------------------------------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: calc(.6rem + var(--safe-top)) 1rem .5rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__row { display: flex; align-items: center; justify-content: space-between; }
.topbar__title { font-weight: 700; letter-spacing: .01em; }

.pill {
  font-size: .75rem;
  color: var(--text-dim);
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .15rem .6rem;
}

.countdown { display: flex; align-items: baseline; gap: .5rem; margin: .35rem 0 .45rem; }
.countdown__value { font-size: 1.75rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.countdown__label { font-size: .8rem; color: var(--text-dim); }

/* --- Inhalt -------------------------------------------------------------- */
.screen {
  padding: 1rem 1rem calc(var(--tabbar-h) + var(--safe-bottom) + 1.5rem);
  display: grid;
  gap: .9rem;
}
.view { display: grid; gap: .9rem; }
.view[hidden] { display: none; }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  display: grid;
  gap: .7rem;
}
.card--done { border-color: var(--accent-dim); }
.card--locked { background: linear-gradient(160deg, #1a1430, var(--bg-elevated)); }

.card__head { display: flex; gap: .7rem; align-items: flex-start; }
.card__icon { font-size: 1.6rem; line-height: 1; }
.card__title { font-size: 1.05rem; font-weight: 700; }
.card__sub { font-size: .82rem; color: var(--text-dim); }

.stat { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.stat__value { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat__target { font-size: .85rem; color: var(--text-dim); }

/* --- Fortschritt --------------------------------------------------------- */
.progress {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-input);
  overflow: hidden;
}
.progress--slim { height: 4px; border-radius: 0; background: transparent; }
.progress__bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width .45s cubic-bezier(.22, 1, .36, 1);
}
.progress__bar--full { background: linear-gradient(90deg, var(--accent), #b6ff9c); }

/* --- Beitraege ----------------------------------------------------------- */
.contributors { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--line);
}
.chip__dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--text-dim); }
.chip__amount { font-variant-numeric: tabular-nums; color: var(--text-dim); }

/* --- Eingaben ------------------------------------------------------------ */
.row { display: flex; gap: .5rem; }
.row > .input { flex: 1; min-width: 0; }

.input {
  width: 100%;
  padding: .8rem .9rem;
  font-size: 1rem;               /* >= 16px: verhindert Auto-Zoom in iOS Safari */
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
}
.input:focus { border-color: var(--accent-dim); }
.input[hidden] { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 48px;              /* Daumenfreundlich */
  padding: 0 1rem;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #05261a; }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; }
.btn--quick { min-height: 40px; padding: 0 .75rem; font-size: .85rem; }

.quick { display: flex; gap: .4rem; flex-wrap: wrap; }

/* --- Feed ---------------------------------------------------------------- */
.event {
  display: grid;
  gap: .5rem;
  padding: .8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.event__head { display: flex; align-items: center; gap: .5rem; font-size: .88rem; }
.event__who { font-weight: 700; }
.event__time { margin-left: auto; font-size: .75rem; color: var(--text-dim); }
.event__text { font-size: .92rem; }
.event__photo {
  width: 100%;
  border-radius: var(--radius-sm);
  display: block;
  background: var(--bg-input);
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.badge {
  font-size: .7rem;
  padding: .1rem .45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.badge--ok { color: var(--accent); border-color: var(--accent-dim); }
.badge--far { color: var(--warn); border-color: var(--warn); }

.avatar {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .72rem;
  font-weight: 800;
  color: #06121a;
}

/* --- Mystery ------------------------------------------------------------- */
.mystery-box {
  display: grid;
  place-items: center;
  gap: .5rem;
  padding: 1.5rem 1rem;
  text-align: center;
  border: 1px dashed #4b3f7a;
  border-radius: var(--radius-sm);
}
.mystery-box__icon { font-size: 2.5rem; }

.items { display: grid; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .7rem;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: .9rem;
}
.item--found { color: var(--text-dim); text-decoration: line-through; border-color: var(--accent-dim); }
.item__action { margin-left: auto; }

/* --- Rangliste ----------------------------------------------------------- */
.rank { display: flex; align-items: center; gap: .7rem; padding: .7rem .2rem; border-bottom: 1px solid var(--line); }
.rank:last-child { border-bottom: 0; }
.rank__pos { width: 1.6rem; font-weight: 800; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.rank__name { font-weight: 600; }
.rank__meta { font-size: .75rem; color: var(--text-dim); }
.rank__points { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }

/* --- Tableiste ----------------------------------------------------------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  position: relative;
  display: grid;
  gap: .1rem;
  place-items: center;
  min-height: var(--tabbar-h);
  padding: .4rem;
  font-size: .7rem;
  color: var(--text-dim);
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tab.is-active { color: var(--accent); }
.tab__icon { font-size: 1.25rem; }
.tab__badge {
  position: absolute;
  top: .5rem;
  right: 50%;
  transform: translateX(1.4rem);
  min-width: 1.1rem;
  padding: 0 .25rem;
  font-size: .65rem;
  font-weight: 700;
  line-height: 1.1rem;
  text-align: center;
  color: #05261a;
  background: var(--accent);
  border-radius: 999px;
}

/* --- Toasts -------------------------------------------------------------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 1rem);
  transform: translateX(-50%);
  z-index: 40;
  display: grid;
  gap: .4rem;
  width: min(420px, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  padding: .7rem .9rem;
  font-size: .88rem;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  animation: rise .25s ease-out;
}
.toast--error { border-color: var(--danger); color: #ffd9e0; }
.toast--ok { border-color: var(--accent-dim); }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.empty { text-align: center; color: var(--text-dim); padding: 2rem 1rem; font-size: .9rem; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------------------
   Lobby - der Startbildschirm, bis die Spielleitung den Countdown ausloest.
   Fuellt die ganze Hoehe, scrollt selbst (das Admin-Panel wird lang).
   --------------------------------------------------------------------------- */

.lobby {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}
.lobby[hidden] { display: none; }

/* Langsam pulsierender Schein im Hintergrund - macht das Warten weniger tot. */
.lobby__glow {
  position: fixed;
  top: -30vh;
  left: 50%;
  width: 130vw;
  height: 90vh;
  transform: translateX(-50%);
  pointer-events: none;
  background: radial-gradient(50% 50% at 50% 50%, rgba(61, 220, 151, .20), transparent 70%);
  animation: breathe 6s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: .55; transform: translateX(-50%) scale(1); }
  50%      { opacity: 1;   transform: translateX(-50%) scale(1.12); }
}

.lobby__inner {
  position: relative;
  display: grid;
  gap: 1rem;
  justify-items: center;
  text-align: center;
  padding: calc(2.5rem + var(--safe-top)) 1.25rem calc(2.5rem + var(--safe-bottom));
  max-width: 560px;
  margin: 0 auto;
}

.lobby__badge {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .28em;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 999px;
  padding: .3rem .9rem;
}
.lobby__title { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.lobby__sub { color: var(--text-dim); font-size: .95rem; margin: 0; }

.lobby__ring {
  display: grid;
  place-content: center;
  width: 132px;
  height: 132px;
  margin: .5rem 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  box-shadow: inset 0 0 40px rgba(61, 220, 151, .12);
}
.lobby__count { font-size: 2.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.lobby__count-label { font-size: .72rem; letter-spacing: .18em; color: var(--text-dim); text-transform: uppercase; }

.lobby__people { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; }

/* --- Admin-Panel in der Lobby ------------------------------------------- */
.admin {
  width: 100%;
  display: grid;
  gap: .8rem;
  margin-top: 1rem;
  padding: 1.1rem;
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.admin[hidden] { display: none; }
.admin__title { font-size: 1.05rem; }
.admin__form { display: grid; gap: .55rem; }
.admin__list { display: grid; gap: .4rem; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; }
.seg__btn {
  min-height: 44px;
  padding: .3rem .2rem;
  font-size: .74rem;
  color: var(--text-dim);
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.seg__btn.is-active { color: #05261a; background: var(--accent); border-color: var(--accent); font-weight: 700; }

.input--short { max-width: 7.5rem; flex: 0 0 auto; }

.check { display: flex; align-items: center; gap: .5rem; font-size: .88rem; color: var(--text-dim); }
.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }

.admin__row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .7rem;
  font-size: .88rem;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.admin__row-meta { margin-left: auto; font-size: .75rem; color: var(--text-dim); }
.admin__del {
  min-height: 34px;
  padding: 0 .5rem;
  color: var(--danger);
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.btn--start {
  flex-direction: column;
  gap: .1rem;
  min-height: 68px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: .04em;
  color: #05261a;
  background: linear-gradient(135deg, var(--accent), #b6ff9c);
  border: 0;
}
.btn--start small { font-size: .68rem; font-weight: 500; opacity: .75; letter-spacing: normal; }

.banner {
  padding: .8rem 1rem;
  font-size: .9rem;
  text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--warn);
  border-radius: var(--radius-sm);
}
.banner[hidden] { display: none; }

/* --- Aufschlüsselung in der Rangliste ------------------------------------ */
.rank { cursor: pointer; }
.rank__detail {
  display: grid;
  gap: .25rem;
  padding: .1rem 0 .6rem 2.3rem;
  font-size: .8rem;
  color: var(--text-dim);
}
.rank__detail-row { display: flex; gap: .5rem; }
.rank__detail-row span:last-child { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text); }

/* Lobby und Onboarding haben keine feste Kopfzeile - dann auch kein Platz dafuer. */
body.no-topbar { padding-top: 0; }

/* ---------------------------------------------------------------------------
   Easter Eggs. Bestimmte Namen loesen beim Beitritt einen Vollbild-Effekt aus -
   bei allen gleichzeitig. Danach haengt der Spitzname ueberall am Namen.
   --------------------------------------------------------------------------- */

.egg {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;          /* darf nichts blockieren, es laeuft ja weiter */
  animation: eggFade 4.2s ease-out forwards;
}

.egg__flash {
  position: absolute;
  inset: 0;
  opacity: .22;
  animation: eggFlash 4.2s ease-out forwards;
}

.egg__name {
  position: relative;
  font-size: clamp(1.6rem, 9vw, 3rem);
  font-weight: 900;
  letter-spacing: -.02em;
  text-align: center;
  text-shadow: 0 6px 30px rgba(0, 0, 0, .8);
  animation: eggPop .7s cubic-bezier(.2, 1.6, .4, 1) both;
}

.egg__label {
  position: relative;
  margin-top: .3rem;
  font-size: clamp(2rem, 13vw, 4.5rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow: 0 8px 40px rgba(0, 0, 0, .9);
  animation: eggPop .7s .12s cubic-bezier(.2, 1.6, .4, 1) both;
}

/* Ein einzelner fallender Emoji. Position, Tempo und Groesse kommen aus dem JS. */
.egg__drop {
  position: absolute;
  top: -15vh;
  animation-name: eggFall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes eggFall {
  to { transform: translateY(125vh) rotate(540deg); }
}

@keyframes eggPop {
  0%   { opacity: 0; transform: scale(.3) rotate(-8deg); }
  70%  { opacity: 1; transform: scale(1.12) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes eggFade {
  0%, 72%  { opacity: 1; }
  100%     { opacity: 0; }
}

@keyframes eggFlash {
  0%   { opacity: .38; }
  100% { opacity: 0; }
}

/* Kurzes Ruetteln der ganzen Seite - der Effekt soll auffallen. */
body.egg-shake { animation: shake .55s cubic-bezier(.36, .07, .19, .97) both; }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* Der Spitzname hinter dem Namen, ueberall wo er auftaucht. */
.egg-tag { margin-left: .2rem; }

@media (prefers-reduced-motion: reduce) {
  .egg { animation: eggFade 3s linear forwards; }
  .egg__drop { display: none; }
  body.egg-shake { animation: none; }
}
