/*
 * Pastell-Theme „Das Geheimnis der zehn Freundinnen".
 * Heller Verlauf aus Rosa, Flieder und Mint, schwebende Blüten, rosa Akzente.
 * Bewusst ohne externe Schriften, damit die App offline funktioniert.
 */
:root {
  --bg-top: #ffe4ef;
  --bg-mid: #efe2ff;
  --bg-bot: #e0f7ef;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --rose: #ff7eb6;
  --rose-deep: #e0559a;
  --rose-soft: #ffd3e6;
  --lilac: #b48cff;
  --lilac-deep: #8a5ce6;
  --mint: #2fa982;
  --mint-soft: #c9f1e3;
  --error: #d83a6e;
  --text: #4a2340;
  --muted: #8a5f7d;
  --border: rgba(255, 126, 182, 0.4);
  --radius: 22px;
  --fairy: "Georgia", "Palatino Linotype", "Book Antiqua", serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(255, 255, 255, 0.9), transparent 60%),
    radial-gradient(700px 500px at 100% 30%, rgba(180, 140, 255, 0.18), transparent 60%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 50%, var(--bg-bot) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ---------- Schwebende Blüten ---------- */
.starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.star {
  position: absolute;
  color: var(--rose);
  font-size: var(--size, 14px);
  opacity: 0;
  animation: float var(--dur, 10s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes float {
  0% { opacity: 0; transform: translateY(30px) rotate(0deg); }
  20% { opacity: 0.55; }
  80% { opacity: 0.55; }
  100% { opacity: 0; transform: translateY(-80px) rotate(40deg); }
}

/* Herzen- und Blütenregen beim Abschluss */
.star.burst {
  animation-name: burst;
  animation-iteration-count: 1;
  animation-fill-mode: both;
}

@keyframes burst {
  0% { opacity: 0; transform: translateY(0) scale(0.4); }
  30% { opacity: 1; transform: translateY(-20px) scale(1.1); }
  100% { opacity: 0; transform: translateY(120px) scale(0.9) rotate(30deg); }
}

/* ---------- Kopfzeile ---------- */
.app-header {
  padding: 22px 16px 10px;
  padding-top: calc(22px + env(safe-area-inset-top));
  text-align: center;
}

.app-header h1 {
  margin: 0;
  font-family: var(--fairy);
  font-weight: 700;
  font-size: clamp(1.7rem, 7vw, 2.6rem);
  letter-spacing: 0.01em;
  line-height: 1.1;
  background: linear-gradient(90deg, var(--rose-deep) 0%, var(--rose) 45%, var(--lilac-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.app-header .subtitle {
  margin: 6px 0 0;
  font-family: var(--fairy);
  font-style: italic;
  color: var(--muted);
  font-size: 1rem;
}

/* ---------- Weg zum Schatz (Fortschritt) ---------- */
.magic-map {
  position: relative;
  max-width: 560px;
  margin: 14px auto 0;
  padding: 10px 18px 6px;
}

.magic-map .map-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

/* gestrichelter Weg hinter den Stationen */
.magic-map .map-track::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 0;
  border-top: 3px dashed rgba(255, 126, 182, 0.55);
  transform: translateY(-50%);
  z-index: 0;
}

.map-node {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1rem;
  background: var(--surface-solid);
  border: 2px solid var(--border);
  color: var(--muted);
  box-shadow: 0 2px 8px rgba(224, 85, 154, 0.15);
  transition: transform 0.3s ease;
}

.map-node.done {
  background: radial-gradient(circle at 30% 30%, #fff, var(--rose-soft));
  border-color: var(--rose);
  box-shadow: 0 0 10px rgba(255, 126, 182, 0.55);
}

.map-node.current {
  border-color: var(--lilac);
  color: var(--lilac-deep);
  box-shadow: 0 0 12px rgba(180, 140, 255, 0.6);
  animation: pulse 1.8s ease-in-out infinite;
}

.map-node.treasure {
  width: 40px;
  height: 40px;
  font-size: 1.3rem;
  border-color: var(--mint);
}

.map-node.treasure.done {
  background: radial-gradient(circle at 30% 30%, #fff, var(--mint-soft));
  box-shadow: 0 0 14px rgba(47, 169, 130, 0.6);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

/* ---------- Gesammelte Lösungsbuchstaben ---------- */
.magic-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px auto 0;
  font-size: 1.1rem;
  color: var(--muted);
}

.letter-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
}

.letter-tile {
  width: 30px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 2px dashed var(--border);
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  font-family: var(--fairy);
  font-weight: 700;
  font-size: 1.05rem;
}

.letter-tile.filled {
  border: 2px solid var(--rose);
  background: linear-gradient(180deg, #fff, var(--rose-soft));
  color: var(--rose-deep);
  animation: star-pop 0.6s ease;
}

.card .letter-row { margin: 0 0 20px; }

.card .letter-tile { width: 40px; height: 46px; font-size: 1.4rem; }

@keyframes star-pop {
  0% { transform: scale(0.2) rotate(-40deg); }
  60% { transform: scale(1.35) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.magic-stars .count {
  margin-left: 6px;
  font-family: var(--fairy);
  font-size: 0.95rem;
  color: var(--rose-deep);
}

/* ---------- Hauptbereich & Karten ---------- */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--surface);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 22px;
  box-shadow: 0 12px 36px rgba(224, 85, 154, 0.14), 0 2px 6px rgba(138, 92, 230, 0.08);
  animation: card-in 0.5s ease both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.card-title {
  margin: 0 0 16px;
  font-family: var(--fairy);
  font-size: 1.5rem;
  color: var(--rose-deep);
  text-align: center;
}

/* „Station 1 von 10 · Ort" über dem Titel */
.station-meta {
  margin: 0 0 6px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lilac-deep);
}

.task-label {
  margin: 20px 0 6px;
  text-align: center;
  font-family: var(--fairy);
  font-weight: 700;
  color: var(--rose-deep);
}

/* Großer Lösungsbuchstabe auf der Zwischenseite */
.card-reward { text-align: center; }

.card-reward .card-hint { margin-bottom: 12px; }

.letter-big {
  display: inline-grid;
  place-items: center;
  width: 96px;
  height: 110px;
  margin: 4px 0 16px;
  border-radius: 18px;
  border: 3px solid var(--rose);
  background: linear-gradient(180deg, #fff, var(--rose-soft));
  color: var(--rose-deep);
  font-family: var(--fairy);
  font-size: 4rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(224, 85, 154, 0.3);
  animation: star-pop 0.7s ease;
}

.card-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  background: #fff;
}

.card-hint {
  margin: 0 0 20px;
  color: var(--text);
  text-align: center;
  white-space: pre-line; /* Zeilenumbrüche (\n) aus stations.json, z. B. Rätselverse */
}

/* Sprachnachricht und Karten-Link einer Station */
.card-audio {
  display: block;
  width: 100%;
  margin: 0 0 20px;
}

.btn-map {
  display: block;
  margin: 0 0 20px;
  text-align: center;
  text-decoration: none;
}

/* Abschluss: Frage unter den gesammelten Buchstaben */
.finish-question { margin: 16px 0 12px; font-weight: 600; }

/* Abschlussbrief nach dem Lösungswort */
.finish-letter { text-align: center; color: var(--text); }

.finish-letter p { margin: 0 0 12px; }

.finish-letter .finish-word {
  margin: 4px 0 16px;
  font-family: var(--fairy);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--rose-deep);
}

/* Merkspiel: Bilder anschauen, dann auswählen */
.memory { flex: 1 1 100%; }

.btn-memory { display: block; width: 100%; margin-bottom: 12px; }

.memory-info {
  margin: 0 0 10px;
  font-weight: 600;
  text-align: center;
  color: var(--text);
}

.memory-info:empty { display: none; }

.memory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
}

.memory-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  text-align: center;
}

button.memory-tile { cursor: pointer; }

.memory-tile[aria-pressed="true"] {
  border: 2px solid var(--lilac-deep);
  background: rgba(180, 140, 255, 0.18);
}

.memory-emoji { font-size: 2rem; line-height: 1.1; }

/* Foto-Aufgabe: Auswahlknopf und Vorschau */
.btn-photo {
  flex: 1 1 100%;
  text-align: center;
  cursor: pointer;
}

.photo-preview { flex: 1 1 100%; margin: 0; }

/* Knopf für den geheimen Satz (Flüsterpost) */
.btn-secret {
  display: block;
  width: 100%;
  margin: 0 0 12px;
}

.secret-box { margin: 0 0 20px; font-weight: 600; }

/* ---------- Animiertes Schloss ---------- */
.lock {
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  display: block;
  color: var(--rose);
  filter: drop-shadow(0 4px 10px rgba(255, 126, 182, 0.45));
  transition: transform 0.3s ease;
}

.lock .shackle {
  transform-origin: 50% 60%;
  transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.lock.shake { animation: shake 0.45s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px) rotate(-3deg); }
  40% { transform: translateX(7px) rotate(3deg); }
  60% { transform: translateX(-5px) rotate(-2deg); }
  80% { transform: translateX(5px) rotate(2deg); }
}

.lock.open .shackle {
  transform: rotate(32deg) translate(-7px, -3px);
}

.lock.open {
  color: var(--mint);
  filter: drop-shadow(0 4px 14px rgba(47, 169, 130, 0.55));
  animation: lock-jump 0.6s ease;
}

@keyframes lock-jump {
  0% { transform: scale(1); }
  50% { transform: scale(1.25) translateY(-6px); }
  100% { transform: scale(1); }
}

/* ---------- Formular ---------- */
.answer-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.answer-input {
  flex: 1 1 100%;
  min-width: 0;
  padding: 13px 16px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
}

.answer-input.input-wrong { border: 2px solid var(--error); }

/* Sichtbare Frage über dem Antwortfeld (Fragen-Station) */
.question-label {
  flex: 1 1 100%;
  margin: 6px 0 -4px;
  font-weight: 600;
  color: var(--text);
}

.answer-input::placeholder { color: var(--muted); opacity: 0.8; }

/* Quizfrage mit Auswahlknöpfen */
.choice-group {
  flex: 1 1 100%;
  margin: 0;
  padding: 0 0 4px;
  border: 0;
  border-radius: 14px;
}

.choice-group .question-label { padding: 0; margin-bottom: 6px; }

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.choice input { accent-color: var(--rose-deep); width: 18px; height: 18px; margin: 0; }

.choice:has(input:checked) { border-color: var(--lilac-deep); background: rgba(180, 140, 255, 0.12); }

.choice-group.input-wrong .choice { border-color: var(--error); }

.answer-input:focus {
  outline: 2px solid var(--lilac);
  outline-offset: 1px;
}

.btn {
  font-size: 1rem;
  font-weight: 600;
  padding: 13px 22px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--fairy);
}

.btn-primary {
  background: linear-gradient(180deg, var(--rose) 0%, var(--rose-deep) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(224, 85, 154, 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(224, 85, 154, 0.5);
}

.btn-primary:disabled { opacity: 0.7; cursor: default; transform: none; }

.btn-ghost {
  background: rgba(255, 255, 255, 0.7);
  color: var(--lilac-deep);
  border: 1px solid var(--lilac);
}

.btn-ghost:hover { color: var(--rose-deep); border-color: var(--rose); }

/* Lösung prüfen und Tipp stehen nebeneinander unter dem Eingabefeld. */
.answer-form .btn-primary,
.answer-form .btn-tip { flex: 1 1 0; }

/* Eingeblendeter Tipp-Hinweis */
.tip-box {
  margin: 14px 0 0;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px dashed var(--lilac);
  background: rgba(180, 140, 255, 0.1);
  color: var(--text);
  font-style: italic;
  text-align: center;
  animation: card-in 0.35s ease both;
}

.feedback {
  margin: 14px 0 0;
  min-height: 1.3em;
  font-weight: 600;
  text-align: center;
  font-family: var(--fairy);
}

.feedback-error { color: var(--error); }
.feedback-ok { color: var(--mint); }

/* ---------- Geschichte (Startseite) ---------- */
.card-story { text-align: center; }

.card-story .card-hint { text-align: left; margin-bottom: 14px; }

.card-story .story-greeting {
  font-family: var(--fairy);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--rose-deep);
}

.story-task {
  margin: 20px 0 18px;
  padding: 16px 18px;
  border-radius: 16px;
  border: 2px dashed var(--rose);
  background: linear-gradient(135deg, rgba(255, 211, 230, 0.6), rgba(201, 241, 227, 0.6));
  text-align: left;
}

.story-task p { margin: 0; }

.story-task-title {
  font-family: var(--fairy);
  font-weight: 700;
  color: var(--rose-deep);
  margin-bottom: 4px !important;
}

.btn-start {
  display: block;
  width: 100%;
  margin-top: 8px;
}

.big-castle {
  font-size: 3.2rem;
  display: block;
  margin: 0 0 12px;
  line-height: 1;
}

/* ---------- Abschluss ---------- */
.card-finish { text-align: center; }

.card-finish .big-castle {
  font-size: 4rem;
  margin: 6px 0 10px;
  filter: drop-shadow(0 4px 16px rgba(180, 140, 255, 0.6));
  animation: lock-jump 1.4s ease infinite;
}

.error { color: var(--error); text-align: center; }

/* ---------- Fußzeile ---------- */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.offline-badge {
  font-size: 0.8rem;
  color: #fff;
  background: var(--mint);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 600;
}

/* hidden-Attribut gilt auch für Elemente mit eigener display-Regel (.btn, .card-img) */
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Rücksicht auf Nutzer:innen, die Bewegung reduzieren möchten. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .star { opacity: 0.4; }
}
