/* Dorf-Rallye – ruhig, gut lesbar draußen in der Sonne, große Touch-Flächen. Für Handys gedacht
   (hoch), funktioniert auch auf Tablet und PC. Alle Größen in rem: die Schriftgröße (Stil der Rallye
   oder Einstellung) vergrößert alles mit. */

:root {
  --bg: #f5f7f2;
  --panel: #ffffff;
  --text: #17231a;
  --muted: #56645a;
  --line: #d6ded3;
  --accent: #2e7d4f;
  --accent-dunkel: #22603c;
  --accent-hell: #e3f1e7;
  --gelb: #f4c542;
  --gelb-hell: #fff6d8;
  --shadow: 0 8px 24px rgba(23, 35, 26, 0.08);
  --radius: 1.25rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  min-height: 100svh;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 3px;
}

h2,
h3 {
  margin: 0;
  line-height: 1.25;
}

/* ---- Kopfzeile ---- */

.kopf {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 60px;
  padding: 6px max(16px, env(safe-area-inset-right)) 6px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.kopf h1 {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 19px;
  line-height: 1.3;
}

/* Kopfzeile wächst nicht mit der Schriftgröße mit – sonst bleibt auf dem Handy kein Platz für den Titel */
.kopf .knopf-rund {
  width: 46px;
  height: 46px;
  min-height: 46px;
  font-size: 21px;
}

#zurueck {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  padding-bottom: 0.2rem;
}

#tonSchalter[aria-pressed="false"] {
  background: #eef1ec;
}

#tonSchalter:disabled {
  opacity: 0.4;
}

/* ---- Bühne ---- */

#buehne {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem max(1rem, env(safe-area-inset-right)) 2.5rem max(1rem, env(safe-area-inset-left));
}

.hinweis {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.adresse {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---- Knöpfe ---- */

.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 3.25rem;
  padding: 0.6rem 1.1rem;
  border: 2px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  font-size: 1.1rem;
  font-weight: 600;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s, background-color 0.15s, opacity 0.15s;
}

.knopf:active {
  transform: scale(0.97);
}

.knopf-rund {
  width: 2.9rem;
  min-height: 2.9rem;
  height: 2.9rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.3rem;
  flex: none;
}

.knopf-haupt {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.knopf-breit {
  width: 100%;
  min-height: 3.75rem;
  font-size: 1.2rem;
}

.knopf-klein {
  min-height: 2.75rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.95rem;
}

.knopf-icon {
  font-size: 1.25em;
  line-height: 1;
}

/* ---- Ansage (Lautsprecher + Text) ---- */

.ansage {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 1.15rem;
}

.ansage-text {
  flex: 1;
  padding-top: 0.45rem;
}

.knopf-vorlesen {
  width: 2.75rem;
  height: 2.75rem;
  min-height: 2.75rem;
  font-size: 1.2rem;
}

.ansage.frage {
  font-size: 1.3rem;
  font-weight: 600;
}

.ansage.rueckmeldung {
  background: var(--gelb-hell);
}

.ansage.richtig {
  background: var(--accent-hell);
  font-weight: 600;
}

/* ---- Startseite: Rallyes ---- */

.rallye-liste {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rallye-liste:empty {
  display: none;
}

.rallye-karte {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
}

.rallye-karte:active {
  transform: scale(0.99);
}

.rallye-symbol {
  font-size: 2.6rem;
  line-height: 1;
  flex: none;
}

.rallye-inhalt {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.rallye-gruppe {
  color: var(--accent-dunkel);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rallye-name {
  font-size: 1.25rem;
  font-weight: 700;
}

.rallye-beschreibung {
  color: var(--muted);
  font-size: 0.95rem;
}

.rallye-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.marke {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--gelb);
  color: #3d3000;
  font-size: 0.8rem;
  font-weight: 700;
}

.entwurf-zeile {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---- Reihenfolge wählen ---- */

.rallye-titel {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rallye-titel h2 {
  font-size: 1.5rem;
}

.modus-liste {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modus-karte {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: left;
  cursor: pointer;
}

.modus-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.modus-inhalt {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.modus-name {
  font-size: 1.2rem;
  font-weight: 700;
}

.modus-text {
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---- Lösungswort ---- */

.loesungswort {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
}

.wort-feld {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.8rem;
  border: 2px dashed var(--line);
  border-radius: 0.6rem;
  background: var(--panel);
  font-size: 1.5rem;
  font-weight: 800;
}

.wort-feld.voll {
  border: 2px solid var(--accent);
  background: var(--accent-hell);
  color: var(--accent-dunkel);
}

.wort-luecke {
  width: 0.9rem;
}

.fortschritt {
  margin: -0.4rem 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.95rem;
}

/* ---- Rallye-Übersicht ---- */

.naechste-station {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-hell);
}

.naechste-station .ansage {
  width: 100%;
  box-shadow: none;
  font-weight: 600;
}

.karte {
  width: 100%;
  height: auto;
  /* lange Nord-Süd-Strecken würden am PC sonst den ganzen Bildschirm füllen; das SVG skaliert mittig hinein */
  max-height: 55svh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #eef3ea;
}

.karte-norden {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

/* Reihenfolge bei „Der Reihe nach“ */
.karte-weg-linie {
  fill: none;
  stroke: var(--accent-dunkel);
  stroke-width: 2.5;
  stroke-dasharray: 6 5;
  stroke-linecap: round;
  opacity: 0.75;
}

/* Hintergrund aus OpenStreetMap (js/karte-daten.js): ruhig, damit die Stationen vorne bleiben */
.karte-ort { fill: #e8e6df; }
.karte-gruen { fill: #e1eed8; }
.karte-wald { fill: #cfe3c2; }
.karte-wasser { fill: #bfdcef; }
.karte-haus { fill: #d6d0c4; }
.karte-bach { fill: none; stroke: #9cc8e6; stroke-width: 1.5; }
.karte-weg { fill: none; stroke: #b5a993; stroke-width: 1; stroke-dasharray: 3 2; }
.karte-strasse-rand,
.karte-hauptstrasse-rand { fill: none; stroke: #c9c1b2; stroke-linecap: round; stroke-linejoin: round; }
.karte-strasse-rand { stroke-width: 5; }
.karte-hauptstrasse-rand { stroke-width: 7; }
.karte-strasse,
.karte-hauptstrasse { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.karte-strasse { stroke: #ffffff; stroke-width: 3.5; }
.karte-hauptstrasse { stroke: #fbe3a0; stroke-width: 5; }

/* Straßennamen; die Schriftgröße setzt js/karte.js je nach Stil */
.karte-name {
  fill: #5a5246;
  font-weight: 600;
  stroke: #ffffff;
  stroke-width: 2.5px;
  stroke-linejoin: round;
  paint-order: stroke;
}

/* eigener Standort: blauer Punkt mit weißem Rand, darum die Ungenauigkeit */
.karte-position-genau {
  fill: rgba(37, 120, 230, 0.15);
  stroke: rgba(37, 120, 230, 0.45);
  stroke-width: 1;
}

.karte-position-punkt {
  fill: #2578e6;
  stroke: #ffffff;
  stroke-width: 2.5;
}

.standort {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: -0.4rem;
}

.standort .hinweis:empty {
  display: none;
}

.karte.mit-osm {
  cursor: zoom-in;
}

.karte-osm text {
  fill: var(--accent-dunkel);
  font-size: 9px;
  font-weight: 700;
  stroke: #ffffff;
  stroke-width: 2.5px;
  paint-order: stroke;
}

.karte-osm:focus-visible text {
  text-decoration: underline;
}

.karte-quelle {
  fill: var(--muted);
  font-size: 8px;
}

.karte-nadel {
  stroke: var(--text);
  stroke-width: 1.2;
}

.karte-nadel-punkt {
  fill: var(--text);
}

.karte-station circle {
  fill: var(--panel);
  stroke: var(--accent);
  stroke-width: 2.5;
}

.karte-station text {
  fill: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.karte-station.antippbar {
  cursor: pointer;
  outline: none;
}

/* die größere Tippfläche bleibt unsichtbar – stärker als die Regeln für geschafft/nächste weiter unten */
.karte .karte-station circle.karte-tippflaeche {
  fill: transparent;
  stroke: none;
}

.karte-station.antippbar:hover circle:not(.karte-tippflaeche) {
  stroke-width: 4;
}

.karte .karte-station.antippbar:focus-visible circle.karte-tippflaeche {
  stroke: var(--accent);
  stroke-width: 3;
}

.karte-station.geschafft circle {
  fill: var(--accent);
}

.karte-station.geschafft text {
  fill: #fff;
}

/* ✓-Abzeichen an geschafften Stationen – stärker als die Kreisregel für „geschafft“ */
.karte .karte-station circle.karte-haken {
  fill: var(--accent-dunkel);
  stroke: #fff;
  stroke-width: 1.5;
}

.karte .karte-station text.karte-haken-text {
  font-size: 9px;
}

.karte-station.naechste circle {
  fill: var(--gelb);
  stroke: var(--text);
  stroke-width: 3;
}

.stations-liste {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.station-zeile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  text-align: left;
}

button.station-zeile {
  cursor: pointer;
}

.station-zeile.naechste {
  border-color: var(--text);
  background: var(--gelb-hell);
}

.station-zeile .station-nr,
.station-kopf .station-nr {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.4rem;
  height: 2.4rem;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--panel);
  font-weight: 800;
}

.station-zeile.geschafft .station-nr {
  position: relative;
  background: var(--accent);
  color: #fff;
}

/* geschafft: die Nummer bleibt, dazu ein kleines ✓ oben rechts */
.station-zeile.geschafft .station-nr::after {
  content: "✓";
  position: absolute;
  top: -0.35rem;
  right: -0.4rem;
  display: grid;
  place-items: center;
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent-dunkel);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1;
}

.nur-vorlesen {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.station-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.station-name {
  font-weight: 700;
}

.station-buchstabe {
  min-width: 1.5rem;
  color: var(--accent-dunkel);
  font-size: 1.4rem;
  font-weight: 800;
  text-align: center;
}

.fuss {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.5rem;
}

/* ---- Frage ---- */

.station-kopf {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.station-kopf .station-nr {
  width: 3rem;
  height: 3rem;
  font-size: 1.3rem;
}

.station-kopf h2 {
  font-size: 1.35rem;
}

.antworten {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.antwort {
  justify-content: flex-start;
  width: 100%;
  min-height: 3.75rem;
  padding: 0.75rem 1rem;
  font-size: 1.2rem;
  text-align: left;
}

/* Schon versucht: zurückgenommen, aber nicht rot */
.antwort.versucht {
  opacity: 0.4;
  cursor: default;
}

.zahl-eingabe {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.zahl-anzeige {
  min-width: 8rem;
  padding: 0.5rem 1rem;
  border: 2px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  font-size: 2.2rem;
  font-weight: 800;
  text-align: center;
}

.zahl-tasten {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  width: min(100%, 20rem);
}

.taste {
  min-height: 3.6rem;
  font-size: 1.5rem;
}

.buchstabe-gross {
  align-self: center;
  display: grid;
  place-items: center;
  width: 6rem;
  height: 6rem;
  border: 3px solid var(--accent);
  border-radius: 1.25rem;
  background: var(--accent-hell);
  color: var(--accent-dunkel);
  font-size: 3.6rem;
  font-weight: 800;
  animation: auftauchen 0.35s ease-out;
}

.info {
  margin: 0;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--accent);
  border-radius: 0.5rem;
  background: var(--panel);
  font-size: 1.05rem;
}

.ziel-bild {
  font-size: 4rem;
  text-align: center;
  line-height: 1.1;
  animation: auftauchen 0.5s ease-out;
}

.zwischentitel {
  margin-top: 0.5rem;
  font-size: 1.05rem;
}

@keyframes auftauchen {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Falsche Antwort: nur kurz wackeln */
.wackeln {
  animation: wackeln 0.4s ease-in-out;
}

@keyframes wackeln {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

@media (prefers-reduced-motion: reduce) {
  .wackeln,
  .buchstabe-gross,
  .ziel-bild {
    animation: none;
  }
}

/* ---- QR-Scanner ---- */

.scanner {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.scanner-rahmen {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: 1rem;
  background: #1b2420;
}

.scanner-bild {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Zielrahmen in der Mitte: hier soll der Code hin */
.scanner-ziel {
  position: absolute;
  inset: 18%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 1rem;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.25);
}

.scanner-hinweis {
  margin: 0;
  font-size: 1.05rem;
}

/* ---- Dialog ---- */

.dialog-ebene {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(23, 35, 26, 0.45);
}

.dialog {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: min(100%, 30rem);
  max-height: calc(100svh - 2rem);
  overflow-y: auto;
  padding: 1.25rem;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.dialog-titel {
  font-size: 1.3rem;
}

.dialog-text {
  margin: 0;
}

.dialog-knoepfe {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.einstellungen {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.einstellungen h3 {
  margin-top: 0.5rem;
  font-size: 1rem;
}

.auswahl {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.auswahl .gewaehlt {
  border-color: var(--accent);
  background: var(--accent-hell);
}

/* Impressum · Datenschutz */
.rechtliches {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

.rechtliches a {
  color: var(--muted);
}

.version {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---- Vorschau für die Redaktion ---- */

.bericht {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bericht-zeile {
  padding: 0.75rem;
  border-left: 4px solid var(--accent);
  border-radius: 0.5rem;
  background: var(--panel);
}

.bericht-zeile.mit-fehlern {
  border-left-color: var(--gelb);
}

.bericht-zeile a {
  display: table;
  margin-top: 0.25rem;
  color: var(--accent-dunkel);
  font-weight: 600;
}

.ohne-js {
  padding: 1rem;
  text-align: center;
}

/* ---- Stile der Rallyes ---- */

/* Senioren: kräftigere Kontraste und Ränder */
body[data-stil="gross"] {
  --muted: #3a463d;
  --line: #a9b6a5;
}

body[data-stil="gross"] .knopf,
body[data-stil="gross"] .station-zeile,
body[data-stil="gross"] .rallye-karte {
  border-width: 3px;
}

/* Kinder und Familien: etwas verspielter */
body[data-stil="kind"] .rallye-karte,
body[data-stil="kind"] .antwort {
  border-radius: 1.5rem;
}
