:root {
  --bg: #0f0e0d;
  --karte: #1a1816;
  --karte-hell: #24211e;
  --text: #f1ece6;
  --leise: #b8afa4;
  --gold: #d4a574;
  --gold-hell: #e6bf96;
  --ok: #86c797;
  --fehler: #e8867b;
  --schatten: 0 0 0 1px rgba(255, 255, 255, .06), 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --font: 'DM Sans', 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(120% 60% at 50% 0%, #1d1915 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

main {
  flex: 1;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 1rem;
}

h1, h2 { text-wrap: balance; line-height: 1.2; margin: 0 0 .75rem; font-weight: 700; }
h1 { font-size: 1.9rem; color: var(--gold); }
h2 { font-size: 1.45rem; }
h2:focus { outline: none; }
p { text-wrap: pretty; margin: 0 0 1rem; }

.karte {
  background: var(--karte);
  border-radius: 20px;
  padding: 1.25rem;
  box-shadow: var(--schatten);
  animation: rein .35s ease-out both;
}
.karte > * { animation: rein .35s ease-out both; }
.karte > :nth-child(2) { animation-delay: .06s; }
.karte > :nth-child(3) { animation-delay: .12s; }
.karte > :nth-child(4) { animation-delay: .18s; }
.karte > :nth-child(5) { animation-delay: .24s; }

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

/* Fortschritt */
.kopf { margin-bottom: 1rem; }
.kopf .zeile { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; color: var(--leise); font-size: .95rem; }
.kopf .zeile b { color: var(--gold); font-weight: 600; }
.punkte { list-style: none; display: flex; gap: .4rem; padding: 0; margin: .6rem 0 0; }
.punkte li { flex: 1; height: 6px; border-radius: 3px; background: var(--karte-hell); transition: background-color .3s ease; }
.punkte li.fertig { background: var(--gold); }
.punkte li.aktuell { background: var(--gold-hell); opacity: .55; }

/* Buttons */
.btn {
  font: inherit;
  font-weight: 600;
  min-height: 48px;
  min-width: 48px;
  padding: .6rem 1.2rem;
  border: 0;
  border-radius: 14px;
  background: var(--karte-hell);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .08);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .15s ease, background-color .2s ease, box-shadow .2s ease, opacity .2s ease;
}
.btn:hover { background: #2d2925; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primaer { background: var(--gold); color: #1a130c; box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.btn.primaer:hover { background: var(--gold-hell); }
.btn.breit { width: 100%; }
.btn.klein { min-height: 44px; padding: .4rem .9rem; font-size: .95rem; }
.btn.text { background: none; box-shadow: none; color: var(--leise); text-decoration: underline; text-underline-offset: 3px; }
.btn.text:hover { color: var(--text); background: none; }

:focus-visible { outline: 2px solid var(--gold-hell); outline-offset: 3px; }

.reihe { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: 1rem; }

/* Eingaben */
input[type=text] {
  font: inherit;
  font-size: 1.15rem; /* mind. 16px, sonst zoomt iOS */
  width: 100%;
  min-height: 52px;
  padding: .6rem .9rem;
  border-radius: 14px;
  border: 0;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .14);
  transition: box-shadow .2s ease;
}
input[type=text]:focus { outline: none; box-shadow: 0 0 0 2px var(--gold); }

/* Zahlenschloss */
.schloss { display: flex; justify-content: center; gap: .6rem; margin: 1rem 0; }
.rad { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.rad .btn { width: 56px; padding: 0; font-size: 1.1rem; line-height: 1; }
.rad output {
  display: grid; place-items: center;
  width: 56px; height: 64px;
  border-radius: 14px;
  background: var(--bg);
  box-shadow: 0 0 0 1px rgba(212, 165, 116, .4);
  color: var(--gold-hell);
  font-size: 2rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Anagramm */
.kacheln { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; margin: 1rem 0; }
.kachel {
  display: grid; place-items: center;
  width: 2.6rem; height: 3rem;
  border-radius: 10px;
  background: var(--karte-hell);
  box-shadow: 0 0 0 1px rgba(212, 165, 116, .35);
  color: var(--gold-hell);
  font-size: 1.35rem; font-weight: 700;
}

/* Reihenfolge */
.auswahl { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.auswahl .btn { width: 100%; text-align: left; display: flex; align-items: center; gap: .75rem; }
.auswahl .btn.gewaehlt { box-shadow: 0 0 0 2px var(--gold); background: #2a241d; }
.nummer {
  flex: none; display: grid; place-items: center;
  width: 1.9rem; height: 1.9rem; border-radius: 50%;
  background: var(--gold); color: #1a130c; font-weight: 700; font-size: .95rem;
  font-variant-numeric: tabular-nums;
}
.nummer.leer { background: transparent; box-shadow: 0 0 0 1px rgba(255, 255, 255, .2); color: transparent; }

/* Geheimschrift */
.geheim {
  text-align: center;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 1.9rem; font-weight: 700;
  letter-spacing: .35em;
  padding-left: .35em;
  margin: 1rem 0;
  color: var(--gold-hell);
  overflow-wrap: anywhere;
}
.regel { color: var(--leise); font-size: .95rem; }

/* Mehrzeilige Texte (Zeilenumbrüche aus dem Ersteller bleiben erhalten) */
.text { white-space: pre-line; }

/* Bilder in Rätseln */
.bilder { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin: 0 0 1rem; }
.bilder.einzeln { grid-template-columns: 1fr; }
.bild {
  display: block; width: 100%; padding: 0; border: 0; cursor: zoom-in;
  border-radius: 14px; overflow: hidden; background: var(--bg);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .1);
  touch-action: manipulation;
  transition: transform .15s ease;
}
.bild:active { transform: scale(.98); }
.bild img { display: block; width: 100%; height: auto; max-height: 20rem; object-fit: contain; outline: 1px solid rgba(255, 255, 255, .08); outline-offset: -1px; }
.finalebild { margin: 0 0 1rem; }

/* Bildauswahl */
.bildwahl { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin: 0 0 1rem; }
.wahl {
  padding: 0; border: 0; border-radius: 16px; overflow: hidden; cursor: pointer;
  background: var(--bg); aspect-ratio: 1 / 1;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .12);
  touch-action: manipulation;
  transition: transform .15s ease, box-shadow .2s ease;
}
.wahl img { display: block; width: 100%; height: 100%; object-fit: cover; }
.wahl:active { transform: scale(.97); }
.wahl.gewaehlt { box-shadow: 0 0 0 3px var(--gold); }

/* Vergrößerte Ansicht */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: 1rem; background: rgba(8, 7, 6, .92);
  animation: rein .2s ease-out both;
}
.overlay img { max-width: 100%; max-height: 100%; border-radius: 12px; object-fit: contain; }
.overlay-zu { position: absolute; top: max(.75rem, env(safe-area-inset-top)); right: max(.75rem, env(safe-area-inset-right)); }

/* Netz-Sperre */
.netzstatus { margin: 1rem 0; padding: .75rem 1rem; border-radius: 14px; background: var(--karte-hell); font-weight: 600; }
.netzstatus::before { content: '● '; }
.netzstatus.online { color: var(--fehler); }
.netzstatus.bald { color: var(--gold-hell); }
.netzstatus.offline { color: var(--ok); }

/* Meldungen */
.meldung { min-height: 1.6em; margin: .9rem 0 0; font-weight: 600; }
.meldung.ok { color: var(--ok); }
.meldung.nein { color: var(--fehler); }
.tipp {
  margin: .9rem 0 0; padding: .75rem 1rem; border-radius: 14px;
  background: var(--karte-hell); color: var(--leise); font-size: .98rem;
}

.karte.wackeln { animation: wackeln .35s ease; }
@keyframes wackeln {
  0%, 100% { transform: none; }
  20% { transform: translateX(-8px); }
  45% { transform: translateX(7px); }
  70% { transform: translateX(-4px); }
  90% { transform: translateX(2px); }
}
.karte.richtig { box-shadow: 0 0 0 2px var(--ok), var(--schatten); transition: box-shadow .3s ease; }

/* Gutschein */
.gutschein {
  margin: 1.25rem 0;
  padding: 1.25rem;
  border-radius: 16px;
  background: linear-gradient(160deg, #2b231a, #1d1915);
  box-shadow: 0 0 0 1px rgba(212, 165, 116, .55);
  text-align: center;
}
.gutschein .art { margin: 0 0 .5rem; color: var(--gold); font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; }
.gutschein .text { font-size: 1.2rem; font-weight: 600; margin-bottom: 1rem; }
.gutschein code {
  display: block;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 1.5rem; font-weight: 700;
  letter-spacing: .08em;
  padding: .8rem .5rem;
  border-radius: 12px;
  background: var(--bg);
  color: var(--gold-hell);
  box-shadow: 0 0 0 1px rgba(212, 165, 116, .4);
  overflow-wrap: anywhere;
  user-select: all;
}

.hinweis {
  margin: 1rem 0 0; padding: .75rem 1rem;
  border-radius: 14px; background: var(--karte-hell);
  color: var(--leise); font-size: .95rem;
}

/* Fußzeile */
.fuss {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .25rem .75rem;
  width: 100%; max-width: 34rem; margin: 0 auto;
  padding: .5rem 1rem calc(.75rem + env(safe-area-inset-bottom));
  color: var(--leise); font-size: .88rem;
}
.status::before { content: '● '; color: var(--leise); }
.status.bereit::before { color: var(--ok); }
.aktionen { display: flex; gap: .25rem; }
.aktionen .btn { min-height: 44px; font-size: .88rem; font-weight: 500; }

/* Konfetti */
.konfetti {
  position: fixed; top: -12px; width: 8px; height: 14px; border-radius: 2px;
  pointer-events: none; z-index: 10;
  animation: fall var(--dauer, 2.4s) cubic-bezier(.3, .1, .6, 1) forwards;
}
@keyframes fall {
  to { transform: translate(var(--x, 0), 105vh) rotate(var(--r, 540deg)); opacity: .85; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .konfetti { display: none; }
}
