/* ============================================================
   Flip entdeckt Miami — "Miami Sunset Postcard"
   Animierte Abendhimmel-Szene (Sonne, Wellen, Palmen) hinter
   Milchglas-Karten. Fredoka (Display) + Nunito (Text), selbst
   gehostet für Offline-Garantie. Große Touch-Ziele fürs Auto.
   ============================================================ */

@font-face {
  font-family: 'Fredoka';
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/fredoka.woff2') format('woff2');
}
@font-face {
  font-family: 'Nunito';
  font-weight: 200 1000;
  font-display: swap;
  src: url('fonts/nunito.woff2') format('woff2');
}

:root {
  /* Sunset-Himmel */
  --dusk: #5B3A8C;
  --magenta: #E4569B;
  --coral: #FF8A6B;
  --gold: #FFCf85;
  /* Ozean */
  --ocean: #1B9AAA;
  --ocean-deep: #12707C;
  --teal: #2EC4B6;
  /* UI */
  --pink: #FF5E9C;
  --pink-dark: #E8407F;
  --maps: #1a73e8;
  --ok: #1fab5e;
  --ink: #35284B;
  --muted: #7A6F8F;
  --card: rgba(255, 255, 255, 0.90);
  --radius: 22px;
  --shadow: 0 10px 30px rgba(70, 30, 90, 0.18), 0 2px 8px rgba(70, 30, 90, 0.10);
  --font-display: 'Fredoka', 'Avenir Next Rounded', -apple-system, sans-serif;
  --font-body: 'Nunito', -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
}
/* Fallback-Farbe NUR auf html: sie malt die Canvas und liegt damit garantiert
   HINTER der .scene (ein body-Hintergrund würde die z-index:-1-Szene verdecken). */
html { background: var(--ocean-deep); }
body { background: transparent; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.92em; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 0.8em; }

/* ============================================================
   Die Szene: fixierter Sunset mit Sonne, Wellen, Palmen
   ============================================================ */
.scene {
  position: fixed; inset: 0; z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.sky {
  position: absolute; inset: 0;
  background: linear-gradient(180deg,
    #8A5BBF 0%,
    #C25AA8 7%,
    var(--magenta) 16%,
    var(--coral) 28%,
    var(--gold) 41%,
    #58C9BE 49%,
    var(--ocean) 62%,
    var(--ocean-deep) 100%);
}
/* Feine Abend-Sterne im oberen Himmel */
.sky::after {
  content: '';
  position: absolute; inset: 0 0 60% 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(255,255,255,0.9) 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 8%,  rgba(255,255,255,0.7) 50%, transparent 51%),
    radial-gradient(2px 2px at 44% 22%, rgba(255,255,255,0.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 62% 12%, rgba(255,255,255,0.75) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 78% 26%, rgba(255,255,255,0.85) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 6%,  rgba(255,255,255,0.7) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 6% 40%, rgba(255,255,255,0.6) 50%, transparent 51%),
    radial-gradient(1px 1px at 52% 38%, rgba(255,255,255,0.55) 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 94% 44%, rgba(255,255,255,0.6) 50%, transparent 51%);
  mask-image: linear-gradient(180deg, #000 0%, #000 20%, transparent 60%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 20%, transparent 60%);
  animation: star-twinkle 4s ease-in-out infinite alternate;
}
@keyframes star-twinkle {
  from { opacity: 0.55; }
  to   { opacity: 1; }
}

.sun {
  position: absolute;
  left: 50%; top: 26%;
  width: min(52vw, 320px); height: min(52vw, 320px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, #FFF3C9 0%, #FFD98E 45%, rgba(255, 170, 120, 0.65) 70%, rgba(255, 150, 130, 0) 72%);
  animation: sun-breathe 9s ease-in-out infinite;
}
@keyframes sun-breathe {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.95; }
  50%      { transform: translate(-50%, -52%) scale(1.05); opacity: 1; }
}

.waves {
  position: absolute; left: -20%; bottom: 0;
  width: 160%; height: 42vh; min-height: 220px;
}
.waves-back path { fill: rgba(23, 130, 140, 0.6); }
.waves-front path { fill: rgba(13, 95, 106, 0.8); }
.waves-back  { animation: wave-drift 16s linear infinite alternate; bottom: 7vh; }
.waves-front { animation: wave-drift 11s linear infinite alternate-reverse; }
@keyframes wave-drift {
  from { transform: translateX(0); }
  to   { transform: translateX(-6%); }
}

.palm {
  position: absolute; bottom: 6vh;
  width: clamp(130px, 30vw, 210px); height: auto;
  fill: #123540;
  opacity: 0.95;
  transform-origin: 50% 100%;
}
.palm-left  { left: -38px;  animation: palm-sway 7s ease-in-out infinite; }
.palm-right { right: -38px; transform: scaleX(-1); animation: palm-sway 8.5s ease-in-out infinite reverse; }
@keyframes palm-sway {
  0%, 100% { rotate: -1.6deg; }
  50%      { rotate: 1.6deg; }
}

.flamingo-float {
  position: absolute;
  right: 10%; top: 20%;
  font-size: 36px;
  filter: drop-shadow(0 4px 6px rgba(60, 20, 60, 0.35));
  animation: flamingo-bob 6s ease-in-out infinite;
}
@keyframes flamingo-bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-14px) rotate(4deg); }
}

@media (prefers-reduced-motion: reduce) {
  .sun, .waves-back, .waves-front, .palm-left, .palm-right, .flamingo-float { animation: none; }
  .screen .card { animation: none !important; opacity: 1 !important; }
}

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  background: linear-gradient(180deg, rgba(50, 26, 80, 0.55), rgba(50, 26, 80, 0));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.topbar-title { display: flex; align-items: center; gap: 12px; }
.flamingo {
  font-size: 40px;
  filter: drop-shadow(0 3px 5px rgba(40, 10, 50, 0.4));
  animation: flamingo-hello 5s ease-in-out infinite;
}
@keyframes flamingo-hello {
  0%, 90%, 100% { transform: rotate(0); }
  93%           { transform: rotate(-10deg); }
  96%           { transform: rotate(8deg); }
}
.topbar h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: 0.4px;
  color: #FFF6EC;
  text-shadow: 0 2px 10px rgba(60, 20, 70, 0.45);
}
.topbar p { font-size: 0.8rem; color: rgba(255, 240, 235, 0.85); }

/* ============================================================
   Screens & Karten (Milchglas über der Szene)
   ============================================================ */
#main { flex: 1; padding: 16px 14px 96px; max-width: 560px; width: 100%; margin: 0 auto; }
.screen { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: blur(16px) saturate(1.35);
  backdrop-filter: blur(16px) saturate(1.35);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  opacity: 0;
  animation: card-in 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
.screen .card:nth-child(1) { animation-delay: 0.05s; }
.screen .card:nth-child(2) { animation-delay: 0.14s; }
.screen .card:nth-child(3) { animation-delay: 0.23s; }
.screen .card:nth-child(4) { animation-delay: 0.32s; }
.screen .card:nth-child(5) { animation-delay: 0.41s; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.card h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.08rem;
  margin-bottom: 8px;
  color: var(--ink);
}

.hero { text-align: center; background: rgba(255, 255, 255, 0.74); }
.hero-emoji { font-size: 46px; margin-bottom: 8px; letter-spacing: 6px; }
.hero p { margin-bottom: 14px; }

.eyebrow {
  font-family: var(--font-display);
  text-transform: uppercase; letter-spacing: 2px;
  font-size: 0.72rem; font-weight: 600; color: var(--pink-dark);
  margin-bottom: 2px;
}

/* ============================================================
   Buttons
   ============================================================ */
button { font: inherit; border: none; cursor: pointer; border-radius: 16px; }

.btn-big {
  display: block; width: 100%;
  padding: 17px 18px;
  font-family: var(--font-display);
  font-size: 1.12rem; font-weight: 600; letter-spacing: 0.3px;
  margin-top: 10px;
  min-height: 58px; /* Touch-Ziel im Auto */
  color: #fff;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn-big:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--pink) 0%, var(--coral) 100%);
  box-shadow: 0 8px 20px rgba(232, 64, 127, 0.38);
}
.btn-maps {
  background: linear-gradient(135deg, #2E86F0 0%, #1a73e8 100%);
  box-shadow: 0 8px 20px rgba(26, 115, 232, 0.35);
}
.btn-secondary {
  display: block; width: 100%;
  margin-top: 10px; padding: 14px 16px;
  background: rgba(53, 40, 75, 0.07);
  color: var(--ink); font-weight: 700;
  min-height: 50px;
  transition: transform 0.12s ease;
}
.btn-secondary:active { transform: scale(0.98); background: rgba(53, 40, 75, 0.13); }
.btn-ghost {
  background: transparent; color: var(--muted);
  padding: 10px 12px; font-size: 0.95rem; font-weight: 700;
}
.btn-round {
  width: 64px; height: 64px; border-radius: 50%;
  font-size: 26px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(70, 30, 90, 0.16);
  transition: transform 0.12s ease;
}
.btn-round:active { transform: scale(0.9); }

/* ============================================================
   Player
   ============================================================ */
.player-controls { display: flex; justify-content: center; gap: 20px; margin-top: 14px; }
.now-playing {
  font-weight: 800; color: var(--pink-dark); min-height: 1.4em;
}

/* ============================================================
   Route / Distanz
   ============================================================ */
.route-status h2, .stop-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
}
.distance-row { display: flex; align-items: baseline; gap: 8px; margin: 12px 0 4px; }
.distance-label { color: var(--muted); font-size: 0.9rem; }
.distance-value {
  font-family: var(--font-display);
  font-size: 1.7rem; font-weight: 600; color: var(--ocean-deep);
}

/* ============================================================
   Stopp-Liste
   ============================================================ */
.stop-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.stop-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.6);
  transition: opacity 0.3s ease;
}
.stop-list .num {
  flex: 0 0 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 600; font-size: 0.95rem;
  background: linear-gradient(135deg, var(--pink), var(--coral));
  color: #fff;
  box-shadow: 0 3px 8px rgba(232, 64, 127, 0.3);
}
.stop-list li.locked { opacity: 0.55; }
.stop-list li.locked .num { background: #B9B2C7; box-shadow: none; }
.stop-list li.done .num { background: linear-gradient(135deg, var(--teal), var(--ok)); box-shadow: 0 3px 8px rgba(31, 171, 94, 0.3); }
.stop-list .stop-line { display: flex; flex-direction: column; }
.stop-list .stop-line b { font-size: 1rem; }
.stop-list .stop-line span { font-size: 0.78rem; color: var(--muted); }
.stop-list .badge { margin-left: auto; font-size: 1.15rem; }

/* ============================================================
   Quiz
   ============================================================ */
.quiz-card { border: 3px solid var(--teal); }
.quiz-question { font-size: 1.1rem; font-weight: 800; margin-bottom: 12px; }
.quiz-choices { display: flex; flex-direction: column; gap: 10px; }
.quiz-choices button {
  padding: 15px 16px; font-size: 1.05rem; font-weight: 700;
  background: rgba(46, 196, 182, 0.10);
  border: 2px solid var(--teal); color: var(--ink);
  border-radius: 16px; text-align: left; min-height: 56px;
  transition: transform 0.1s ease;
}
.quiz-choices button:active { transform: scale(0.98); background: rgba(46, 196, 182, 0.22); }
.quiz-choices button.correct { background: #DCFCE7; border-color: var(--ok); animation: correct-pop 0.4s ease; }
.quiz-choices button.wrong { background: #FEE2E2; border-color: #ef4444; animation: wrong-shake 0.4s ease; }
@keyframes correct-pop { 50% { transform: scale(1.04); } }
@keyframes wrong-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.quiz-input-row { display: flex; gap: 8px; }
.quiz-input-row input {
  flex: 1; padding: 14px; font-size: 1.05rem; font-family: var(--font-body);
  border: 2px solid var(--teal); border-radius: 16px; background: #fff;
}
.quiz-input-row .btn-primary {
  padding: 0 24px; color: #fff; font-weight: 800;
  background: linear-gradient(135deg, var(--pink), var(--coral));
}
.quiz-feedback { margin-top: 10px; font-weight: 800; min-height: 1.3em; }
.quiz-feedback.ok { color: var(--ok); }
.quiz-feedback.no { color: #ef4444; }
.quiz-hint {
  margin-top: 8px; padding: 11px 13px; border-radius: 14px;
  background: #FEF6C7; color: #6d4f12; font-size: 0.95rem; font-weight: 600;
}
.quiz-actions { display: flex; gap: 10px; margin-top: 10px; }

/* ============================================================
   Suchauftrag / Weiter-Karte / Urkunde
   ============================================================ */
.search-card { background: rgba(255, 250, 224, 0.92); }
.next-card { border: 3px solid var(--ok); }

.cert {
  margin: 14px 0; padding: 16px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 214, 232, 0.7), rgba(255, 240, 213, 0.7));
  border: 2px dashed var(--pink);
  font-size: 0.97rem; text-align: left;
}

/* ============================================================
   Maps-Vorbereitung
   ============================================================ */
.prep-links { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.prep-links a {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 14px; border-radius: 14px;
  background: rgba(26, 115, 232, 0.09);
  color: var(--maps);
  text-decoration: none; font-weight: 800; min-height: 50px;
  transition: transform 0.1s ease;
}
.prep-links a:active { transform: scale(0.98); background: rgba(26, 115, 232, 0.18); }
.prep-links a::before { content: '📍'; }

/* ============================================================
   Fortschrittsbalken
   ============================================================ */
.progress-outer {
  width: 100%; height: 16px; border-radius: 8px;
  background: rgba(53, 40, 75, 0.10); overflow: hidden; margin: 10px 0 6px;
}
.progress-inner {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--pink));
  border-radius: 8px;
  transition: width 0.25s ease;
}

/* ============================================================
   Debug-Panel
   ============================================================ */
.debug {
  position: fixed; bottom: 64px; left: 10px; right: 10px; z-index: 40;
  max-width: 540px; margin: 0 auto;
  background: rgba(17, 24, 39, 0.96); color: #E5E7EB;
  border-radius: var(--radius); padding: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  max-height: 60dvh; overflow-y: auto;
}
.debug h3 { font-size: 0.95rem; margin-bottom: 8px; font-family: var(--font-display); }
.debug .muted { color: #9CA3AF; }
.debug-row { display: block; margin: 8px 0; font-size: 0.9rem; }
.debug-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.debug-grid button {
  padding: 9px 8px; font-size: 0.8rem; border-radius: 10px;
  background: #374151; color: #E5E7EB;
}
.debug .btn-secondary { background: #374151; color: #E5E7EB; }
.debug .btn-ghost { color: #F87171; }

/* ============================================================
   Bottombar (schwebende Glas-Pille)
   ============================================================ */
.bottombar {
  position: fixed; bottom: calc(10px + env(safe-area-inset-bottom)); left: 14px; right: 14px; z-index: 30;
  max-width: 532px; margin: 0 auto;
  display: flex; justify-content: space-around;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(50, 20, 70, 0.25);
  font-size: 0.8rem; color: var(--muted); font-weight: 700;
}
