:root {
  --grund: #f4f1ec;
  --papier: #ffffff;
  --text: #1d1b19;
  --gedaempft: #6a645d;
  --linie: #d9d3ca;
  --rot: #b3261e;
  --rot-text: #ffffff;
  --gut: #1f7a3d;
  --gut-flaeche: #e6f3ea;
  --schlecht: #b3261e;
  --schlecht-flaeche: #fbe9e7;
  --warn-flaeche: #fff4d6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #171513;
    --papier: #221f1c;
    --text: #f0ebe4;
    --gedaempft: #a79f95;
    --linie: #3a3530;
    --rot: #e0584f;
    --rot-text: #1a0605;
    --gut: #6fcf8e;
    --gut-flaeche: #1c3324;
    --schlecht: #f0857d;
    --schlecht-flaeche: #3a1f1c;
    --warn-flaeche: #3a3118;
  }
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#app, .seitenkopf-innen {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}

#app { flex: 1; padding-top: 16px; padding-bottom: 32px; }

/* Kopf- und Fußzeile bleiben beim Scrollen stehen. */
.seitenkopf, .seitenfuss {
  position: sticky;
  z-index: 2;
  background: var(--grund);
}
.seitenkopf { top: 0; border-bottom: 1px solid var(--linie); }
.seitenfuss { bottom: 0; border-top: 1px solid var(--linie); text-align: center; }

.seitenkopf-innen {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
  padding-bottom: 8px;
}
.kopf-status { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.heim {
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 6px;
  min-height: 44px;
  padding: 0 8px;
  margin-left: -8px;
  cursor: pointer;
  touch-action: manipulation;
}
.logo { display: block; flex: none; border-radius: 6px; }
.logo img { display: block; height: 48px; width: auto; }
.logo:focus-visible, .heim:focus-visible, .zurueck:focus-visible, .impressum-knopf:focus-visible, .lightbox a:focus-visible {
  outline: 3px solid var(--rot);
  outline-offset: 2px;
}
.impressum-knopf {
  font: inherit;
  font-size: 0.875rem;
  color: var(--gedaempft);
  background: none;
  border: 0;
  border-radius: 6px;
  min-height: 44px;
  padding: 8px 12px;
  cursor: pointer;
  touch-action: manipulation;
}
@media (hover: hover) {
  .impressum-knopf:hover { color: var(--text); text-decoration: underline; }
}

.lightbox {
  width: min(360px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--linie);
  border-radius: 12px;
  background: var(--papier);
  color: var(--text);
}
.lightbox::backdrop { background: rgb(0 0 0 / 0.6); }

@media (prefers-reduced-motion: no-preference) {
  .lightbox[open] { animation: lightbox-auf 240ms ease-in; }
  .lightbox[open]::backdrop { animation: lightbox-abdunkeln 240ms ease-in; }
  .lightbox.schliesst { animation: lightbox-zu 200ms ease-out forwards; }
  .lightbox.schliesst::backdrop { animation: lightbox-aufhellen 200ms ease-out forwards; }
}
@keyframes lightbox-auf { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
@keyframes lightbox-zu { to { opacity: 0; transform: translateY(12px) scale(0.96); } }
@keyframes lightbox-abdunkeln { from { opacity: 0; } }
@keyframes lightbox-aufhellen { to { opacity: 0; } }
.lightbox address { font-style: normal; line-height: 1.7; margin-bottom: 20px; }
.lightbox a { color: var(--rot); }
.lightbox .knopf { width: 100%; }

h1, h2, p { margin: 0; }

.kopf { padding: 0 0 20px; }
.dachzeile { color: var(--gedaempft); font-size: 0.875rem; }
.kopf h1 { font-size: 2rem; line-height: 1.15; margin: 4px 0; }
.kopf h1.gut { color: var(--gut); }
.kopf h1.schlecht { color: var(--schlecht); }
.unterzeile { color: var(--gedaempft); }
.bestanden { font-weight: 600; margin-bottom: 4px; }
.bestanden.gut { color: var(--gut); }
.bestanden.schlecht { color: var(--schlecht); }

.karte {
  background: var(--papier);
  border: 1px solid var(--linie);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}
.karte h2 { font-size: 1.1rem; margin-bottom: 12px; }

.regeln { margin: 0 0 20px; padding-left: 1.2em; }
.regeln li { margin-bottom: 6px; }

.knopf {
  font: inherit;
  font-weight: 600;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--linie);
  background: var(--papier);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}
.knopf.haupt {
  background: var(--rot);
  border-color: var(--rot);
  color: var(--rot-text);
  width: 100%;
}
.knopf:focus-visible, .antwort input:focus-visible {
  outline: 3px solid var(--rot);
  outline-offset: 2px;
}
@media (hover: hover) {
  .knopf:hover { filter: brightness(0.95); }
}

.bogenwahl { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.knopf.bogen { display: flex; align-items: center; gap: 14px; text-align: left; }
.bogen-buchstabe { font-size: 1.6rem; font-weight: 700; color: var(--rot); width: 1.2em; }
.bogen-info { font-weight: 400; font-size: 0.875rem; color: var(--gedaempft); }

.katalogwahl { display: grid; gap: 10px; }
.knopf.katalog { display: grid; gap: 2px; text-align: left; padding: 14px 18px; }
.katalog-titel { font-size: 1.1rem; }
.katalog-info { font-weight: 400; font-size: 0.875rem; color: var(--gedaempft); }
.knopf.katalog .dachzeile { font-weight: 400; color: var(--rot); }

.zurueck {
  font: inherit;
  font-size: 0.875rem;
  color: var(--gedaempft);
  background: none;
  border: 0;
  border-radius: 6px;
  min-height: 44px;
  padding: 0 8px;
  margin: -8px 0 0 -8px;
  cursor: pointer;
  touch-action: manipulation;
}
@media (hover: hover) {
  .zurueck:hover, .heim:hover { text-decoration: underline; }
}

.knopf.loeschen { margin-top: 16px; width: 100%; font-weight: 400; color: var(--schlecht); }
.knopf:disabled, .knopf:disabled .dachzeile { color: var(--gedaempft); }
.knopf:disabled { opacity: 0.6; cursor: default; filter: none; }

/* Prüfung */

.pruefstand { display: grid; min-width: 0; margin-right: auto; line-height: 1.25; }
.fortschritt { color: var(--gedaempft); font-size: 0.875rem; }
.uhr {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.uhr.knapp { color: var(--schlecht); }

.hinweis { margin: 0 0 16px; font-weight: 600; }

.frage {
  background: var(--papier);
  border: 1px solid var(--linie);
  border-radius: 10px;
  padding: 16px;
  margin: 0 0 12px;
  min-width: 0;
}
.frage legend, .fragetext { font-weight: 600; padding: 0; }
.frage legend { float: left; width: 100%; margin-bottom: 10px; }
.fragetext { margin-bottom: 10px; }
.nr { color: var(--rot); }

.frage legend, .fragetext { white-space: pre-line; }
.foto { display: block; max-width: min(100%, 360px); height: auto; margin: 0 0 10px; border-radius: 4px; clear: both; }
.katalognr { margin: -6px 0 10px; font-size: 0.8rem; color: var(--gedaempft); }
.bestwert { margin-top: 12px; font-size: 0.875rem; color: var(--gedaempft); text-align: center; }

.zeichen { display: block; width: 96px; height: 96px; margin: 0 0 10px; background: #fff; border-radius: 4px; clear: both; }

.antworten { clear: both; display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.antwort {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border-radius: 6px;
}
label.antwort { cursor: pointer; }
.antwort input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--rot); }
label.antwort:has(input:checked) { background: var(--grund); }

.bogenformular > .knopf { margin-top: 8px; }

.kartentext { margin-bottom: 16px; }

.hinweistabelle { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.hinweistabelle th, .hinweistabelle td { padding: 8px 10px; text-align: left; vertical-align: top; border-top: 1px solid var(--linie); }
.hinweistabelle thead th { border-top: 0; color: var(--gedaempft); font-weight: 600; }
.hinweistabelle tbody th { font-weight: 400; width: 40%; }
.hinweistabelle th:first-child, .hinweistabelle td:first-child { padding-left: 0; }
.hinweistabelle td:last-child { padding-right: 0; }
.hinweistabelle .abweichend td:last-child { font-weight: 600; }

/* Auf schmalen Bildschirmen jede Zeile als Block mit Spaltentitel vor dem Wert. */
@media (max-width: 600px) {
  .hinweistabelle thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .hinweistabelle tr { display: block; padding: 10px 0; border-top: 1px solid var(--linie); }
  .hinweistabelle tbody th, .hinweistabelle td { display: block; width: auto; padding: 2px 0; border: 0; }
  .hinweistabelle tbody th { font-weight: 600; margin-bottom: 4px; }
  .hinweistabelle td::before { content: attr(data-spalte) ": "; color: var(--gedaempft); font-weight: 400; }
}
.karte > .knopf { width: 100%; }
.knopf.pruefen { margin-top: 12px; min-width: 140px; }

/* Auswertung */

.aktionen { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 20px; }
.aktionen .haupt { grid-column: 1 / -1; }

.frage.fehler { border-color: var(--schlecht); }
.urteil {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  white-space: nowrap;
}
.ok .urteil { background: var(--gut-flaeche); color: var(--gut); }
.fehler .urteil { background: var(--schlecht-flaeche); color: var(--schlecht); }

.kasten {
  flex: none;
  width: 22px;
  height: 22px;
  border: 2px solid currentColor;
  border-radius: 3px;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}
.antwort.treffer { background: var(--gut-flaeche); color: var(--gut); }
.antwort.falsch { background: var(--schlecht-flaeche); color: var(--schlecht); }
.antwort.verpasst { background: var(--warn-flaeche); }
.vermerk { display: block; font-size: 0.8rem; font-style: normal; font-weight: 600; }

.pruefhinweis {
  margin-top: 10px;
  padding: 10px;
  border-left: 3px solid var(--rot);
  background: var(--grund);
  font-size: 0.875rem;
}
