:root {
  --bg: #f3eee4;
  --surface: #fffdf8;
  --surface-2: #ebe4d6;
  --text: #1d2430;
  --muted: #6a6658;
  --line: #ddd4c3;
  --accent: #1f5a6b;
  --accent-ink: #ffffff;
  --accent-soft: #d8e9ec;
  --messing: #b8862b;
  --messing-soft: #f6e8c8;
  --gruen: #2e7d4f;
  --gruen-soft: #dcefe2;
  --red: #b8352a;
  --red-soft: #f8e3df;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 16px rgb(60 40 10 / .08);
  --radius: 16px;
  --papier: #fbf5e6;
  --tinte: #2b3346;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1d2128;
    --surface-2: #272c35;
    --text: #ebe7de;
    --muted: #a19c8f;
    --line: #333944;
    --accent: #6cb6c7;
    --accent-ink: #0b1d22;
    --accent-soft: #1b343b;
    --messing: #e2b45a;
    --messing-soft: #3a3020;
    --gruen: #63c088;
    --gruen-soft: #1c3627;
    --red: #ef7a6c;
    --red-soft: #3b221f;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .3);
    --papier: #2a2822;
    --tinte: #efe6d2;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.klein { font-size: .85rem; }
[hidden] { display: none !important; }

/* ---------- Kopf ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px 14px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand img { border-radius: 7px; flex: none; }
.brand h1 { font-size: 1.2rem; margin: 0; white-space: nowrap; }
.sync { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync[data-state="live"] .dot { background: #2fb36d; }
.sync[data-state="off"] .dot { background: var(--red); }
.sync[data-state="demo"] .dot { background: #e0a423; }
body.im-spiel .sync #syncText { display: none; }
body.im-spiel #appsBtn { display: none; }
.uhr { font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--muted); padding: 0 4px; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 12px; background: transparent; color: var(--text);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.klein { width: 32px; height: 32px; }
#tippBtn { color: var(--messing); }
#tippBtn.hat-tipp { background: var(--messing-soft); }

.banner { margin: 0 14px 10px; padding: 8px 12px; border-radius: 12px; font-size: .9rem; }
.banner.demo { background: var(--messing-soft); }

/* ---------- Grundbausteine ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600;
}
.btn.primaer { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.messing { background: var(--messing); color: #fff; border-color: transparent; }
.btn.gefahr { color: var(--red); }
.btn.klein { min-height: 34px; padding: 0 12px; font-size: .9rem; }
.btn.breit { width: 100%; }
.knoepfe { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.karte { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
input[type="text"], input[type="email"], input[type="password"] {
  width: 100%; min-height: 46px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); font-size: 1.05rem;
}
.fehler { color: var(--red); }

/* ---------- Anmeldung ---------- */
.login { display: grid; place-items: center; padding: 40px 16px; }
.login form { width: min(380px, 100%); display: grid; gap: 12px; text-align: center; }
.login label { display: grid; gap: 4px; text-align: left; font-size: .9rem; color: var(--muted); }
.login img { margin: 0 auto; border-radius: 14px; }
.login h2 { margin: 4px 0 0; }

/* ---------- Reiseroute ---------- */
#v-route { padding: 4px 14px calc(30px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.kompass-karte {
  display: grid; grid-template-columns: 112px 1fr; gap: 14px; align-items: center;
  background: linear-gradient(135deg, #1f3c4f, #23505e); color: #f6efe0;
  border-radius: 20px; padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.kompass-karte h2 { margin: 0 0 4px; font-size: 1.1rem; }
.kompass-karte p { margin: 0; font-size: .9rem; opacity: .9; }
.kompass-karte .wort { font: 700 1.25rem/1 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .3em; margin-top: 8px; color: #f3c867; }
.route { list-style: none; margin: 0; padding: 0; position: relative; }
.route::before { content: ""; position: absolute; left: 25px; top: 20px; bottom: 20px; border-left: 3px dotted var(--line); }
.station { position: relative; display: grid; grid-template-columns: 52px 1fr; gap: 12px; margin-bottom: 12px; }
.station .punkt {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; z-index: 1;
  background: var(--surface); border: 3px solid var(--line); font-size: 1.4rem;
}
.station.fertig .punkt { border-color: var(--gruen); background: var(--gruen-soft); }
.station.laeuft .punkt { border-color: var(--messing); background: var(--messing-soft); }
.station.zu .punkt, .station.geplant .punkt { opacity: .55; }
.station .karte { padding: 12px 14px; text-align: left; border: 0; width: 100%; color: inherit; display: block; }
.station button.karte:active { transform: scale(.99); }
.station.zu .karte, .station.geplant .karte { box-shadow: none; background: transparent; border: 1px dashed var(--line); }
.station .nr { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.station h3 { margin: 2px 0 2px; font-size: 1.05rem; }
.station .ort { font-size: .9rem; color: var(--muted); }
.station .zeile { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); }
.chip.gruen { background: var(--gruen-soft); color: var(--gruen); }
.chip.messing { background: var(--messing-soft); color: color-mix(in srgb, var(--messing) 70%, var(--text)); }
.balken { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.balken i { display: block; height: 100%; background: var(--messing); border-radius: 3px; }
.hinweis-fiktion { font-size: .8rem; color: var(--muted); margin: 18px 4px 0; }

/* ---------- Spiel ---------- */
body.im-spiel { overscroll-behavior: none; }
#v-spiel { max-width: 720px; margin: 0 auto; padding: 0 0 calc(10px + env(safe-area-inset-bottom)); }
.szene-rahmen { position: relative; }
.szene { position: relative; background: #0f1418; line-height: 0; overflow: hidden; }
@media (min-width: 720px) { .szene { border-radius: 16px; } }
.szene svg { display: block; width: 100%; height: auto; max-height: 62vh; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.szene [data-obj] { cursor: pointer; }
.szene [data-obj].blitz { animation: blitz 1.4s ease-out; }
@keyframes blitz { 0%, 60% { filter: drop-shadow(0 0 4px #ffe08a) drop-shadow(0 0 10px #ffd35a) brightness(1.25); } 100% { filter: none; } }
.szene .welle { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%;
  border: 2px solid rgb(255 236 180 / .9); pointer-events: none; animation: welle .55s ease-out forwards; }
@keyframes welle { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
.umsehen {
  position: absolute; right: 8px; top: 8px; width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: rgb(0 0 0 / .45); color: #fff; font-size: 1.05rem;
}
.orte { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px 0; scrollbar-width: none; }
.orte:empty { display: none; }
.orte button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 5px 12px; font-size: .85rem; }
.orte button[aria-current="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.meldung {
  margin: 10px 12px 0; padding: 12px 14px; border-radius: 14px; background: var(--papier);
  color: var(--tinte); min-height: 62px; font-size: .97rem; box-shadow: var(--shadow); white-space: pre-line;
}
.meldung:empty::before { content: "Sieh dich um – tippe auf alles, was dir auffällt."; color: var(--muted); }
.meldung .neu-item { display: inline-block; margin-top: 4px; font-weight: 600; color: var(--gruen); }
.auswahl-leiste {
  display: flex; align-items: center; gap: 8px; margin: 10px 12px 0; padding: 6px 6px 6px 12px;
  background: var(--messing-soft); border-radius: 12px; font-size: .88rem;
}
.auswahl-leiste span { flex: 1; }
.inventar { display: flex; gap: 8px; overflow-x: auto; padding: 10px 12px 4px; min-height: 86px; }
.inventar:empty::before { content: "Noch nichts eingesteckt."; color: var(--muted); font-size: .9rem; padding: 18px 4px; }
.item {
  flex: none; width: 76px; display: grid; justify-items: center; gap: 2px; padding: 6px 4px;
  border-radius: 14px; border: 2px solid transparent; background: var(--surface); box-shadow: var(--shadow);
}
.item .bild { width: 40px; height: 40px; display: grid; place-items: center; font-size: 1.7rem; line-height: 1; }
.item .bild svg { width: 40px; height: 40px; }
.item .name { font-size: .7rem; line-height: 1.15; text-align: center; color: var(--muted); max-width: 72px; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item[aria-pressed="true"] { border-color: var(--messing); background: var(--messing-soft); }
.item.neu { animation: neu 1s ease-out; }
@keyframes neu { 0% { transform: scale(.4); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* ---------- Sheets ---------- */
dialog.sheet {
  border: 0; padding: 0 16px calc(18px + env(safe-area-inset-bottom)); margin: auto auto 0;
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; background: var(--surface); color: var(--text);
  box-shadow: 0 -8px 30px rgb(0 0 0 / .2);
}
dialog.sheet::backdrop { background: rgb(0 0 0 / .45); }
.sheet-kopf { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 0 8px; background: var(--surface); }
.sheet-kopf h2 { margin: 0; font-size: 1.12rem; }
.block { padding: 12px 0; border-top: 1px solid var(--line); }
.block h3 { margin: 0 0 6px; font-size: 1rem; }
.wahl { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; }
.wahl input { margin-top: 4px; width: 20px; height: 20px; accent-color: var(--accent); }
.infos { margin: 0; padding-left: 18px; font-size: .9rem; display: grid; gap: 6px; }
.status { font-weight: 600; margin: 0; }

/* Rätsel */
.frage { margin: 0 0 12px; }
.frage p { margin: 0 0 8px; }
.r-bild { margin: 0 0 12px; border-radius: 12px; overflow: hidden; background: var(--papier); line-height: 0; }
.r-bild svg { width: 100%; height: auto; display: block; }
.r-bild.text { line-height: 1.45; padding: 12px 14px; color: var(--tinte); }
.raeder { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 14px; }
.rad-spalte { display: grid; justify-items: center; gap: 4px; }
.rad-label { font-size: 1.4rem; line-height: 1; min-height: 1.4rem; }
.rad-label svg { width: 34px; height: 24px; display: block; }
.rad .wert svg { width: 40px; height: 28px; }
.rad { display: grid; grid-template-rows: 38px 64px 38px; width: 56px; border-radius: 14px; background: #2f2a22; color: #f5e7c4; overflow: hidden; box-shadow: inset 0 2px 8px rgb(0 0 0 / .5); }
.rad button { border: 0; background: rgb(255 255 255 / .06); color: #e8cf96; font-size: 1.1rem; }
.rad button:active { background: rgb(255 255 255 / .18); }
.rad .wert { display: grid; place-items: center; font: 700 1.9rem/1 ui-monospace, Consolas, monospace; background: linear-gradient(#1c1813, #3a3328 50%, #1c1813); }
.rad .wert.sym { font-size: 1.6rem; }
.r-text { display: flex; gap: 8px; margin-bottom: 12px; }
.r-text input { flex: 1; text-transform: uppercase; letter-spacing: .05em; }
.teile { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.teil { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 8px 12px; min-height: 44px; text-align: left; }
.teil[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.teil .n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--messing); color: #fff; font-size: .8rem; margin-right: 6px; }
.slots { display: grid; gap: 6px; margin-bottom: 12px; }
.slot { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px; border-radius: 12px; border: 1px dashed var(--line); text-align: left; background: transparent; width: 100%; }
.slot.voll { border-style: solid; background: var(--surface-2); }
.slot .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--messing); color: #fff; font-size: .8rem; flex: none; }
.punkte-bild { position: relative; line-height: 0; border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
.punkte-bild svg { width: 100%; height: auto; }
.punkte-bild [data-wahl] { cursor: pointer; }
.punkte-bild [data-wahl].gewaehlt { filter: drop-shadow(0 0 3px #ffcf4a) drop-shadow(0 0 6px #ffcf4a); }
.punkte-bild .marke { font: 700 16px system-ui; fill: #fff; paint-order: stroke; stroke: #000; stroke-width: 3px; pointer-events: none; }
.morse-anzeige { font: 700 1.5rem/1.2 ui-monospace, Consolas, monospace; min-height: 44px; padding: 8px 12px; border-radius: 12px; background: #1c1a16; color: #ffd36b; word-break: break-all; margin-bottom: 10px; letter-spacing: .08em; }
.morse-tasten { display: grid; grid-template-columns: 1fr 1fr 1fr 56px; gap: 8px; margin-bottom: 12px; }
.morse-tasten .btn { min-height: 56px; font-size: 1.3rem; }
.r-rueck { min-height: 24px; margin: 4px 0 10px; font-weight: 600; }
.r-rueck.falsch { color: var(--red); }
.wackeln { animation: wackeln .4s; }
@keyframes wackeln { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.r-fuss { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 4px; }

/* Tipps */
.tipp-karte { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.tipp-karte h3 { margin: 0 0 6px; font-size: 1rem; }
.tipp-karte ol { margin: 0 0 8px; padding-left: 20px; display: grid; gap: 6px; }
.tipp-karte li.loesung { color: var(--accent); font-weight: 600; }
.tipp-leer { text-align: center; padding: 20px 0; color: var(--muted); }

/* Nahansicht */
.nah-bild { border-radius: 14px; overflow: hidden; background: var(--papier); line-height: 0; margin-bottom: 12px; }
.nah-bild svg { width: 100%; height: auto; }
.nah-text { white-space: pre-line; }
.dokument { background: var(--papier); color: var(--tinte); border-radius: 12px; padding: 14px 16px; font-family: Georgia, "Times New Roman", serif; line-height: 1.55; white-space: pre-line; box-shadow: inset 0 0 0 1px rgb(120 90 40 / .15); }
.dokument.maschine { font-family: ui-monospace, "Courier New", Consolas, monospace; font-size: .95rem; }
.dokument.code { font-family: ui-monospace, Consolas, monospace; letter-spacing: .12em; font-size: 1.05rem; }
.tafel { background: #20333b; color: #e9f1ef; border-radius: 12px; padding: 14px 16px; line-height: 1.5; }
.tafel h4 { margin: 0 0 6px; color: #f0c86a; font-size: 1rem; }
.tafel p { margin: 0 0 6px; }
.dokument table, .tafel table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.dokument td, .tafel td, .dokument th, .tafel th { padding: 3px 6px; border-bottom: 1px solid rgb(127 127 127 / .25); text-align: left; }

/* Geschichte */
dialog.story { background: var(--papier); color: var(--tinte); }
.story-inhalt { padding: 22px 4px 4px; font-family: Georgia, "Times New Roman", serif; font-size: 1.04rem; line-height: 1.6; }
.story-inhalt .kapitel { font-family: system-ui, sans-serif; font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.story-inhalt h2 { margin: 2px 0 12px; font-size: 1.45rem; }
.story-inhalt p { margin: 0 0 12px; }
.story-inhalt .brief { border-left: 3px solid var(--messing); padding-left: 12px; font-style: italic; }
.story-inhalt .fiktion { font-family: system-ui, sans-serif; font-size: .8rem; color: var(--muted); }
.statistik { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; font-family: system-ui, sans-serif; }
.statistik div { background: var(--surface); border-radius: 12px; padding: 10px; text-align: center; color: var(--text); }
.statistik b { display: block; font-size: 1.2rem; }
.statistik span { font-size: .75rem; color: var(--muted); }
.fakten { font-family: system-ui, sans-serif; font-size: .9rem; margin: 10px 0; padding-left: 18px; display: grid; gap: 8px; }
.fakten a { font-size: .8rem; word-break: break-word; }
.segment-gross { display: grid; place-items: center; margin: 8px 0 14px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 50; display: flex; align-items: center; gap: 12px; max-width: calc(100% - 24px);
  padding: 12px 16px; border-radius: 14px; background: #23272e; color: #fff; box-shadow: var(--shadow); font-size: .93rem;
}
.toast button { border: 0; background: none; color: #ffd36b; font-weight: 700; }
