/* EcoSim – Styles (Light/Dark über data-theme, mobile-first). */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --text: #14202b;
  --muted: #5c6b7a;
  --border: #dbe1e8;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  /* Auf --surface-2 (#eef1f4) lagen --pos und --warn bei 4,42 bzw. 4,43 – knapp unter
     den 4,5, die WCAG AA für Fliesstext verlangt. Ein Kind liest Beträge in genau diesen
     Farben, und zwar auf beiden Flächen. Etwas dunkler kostet nichts und stimmt überall. */
  --pos: #136f2c;
  --neg: #b91c1c;
  --warn: #a04b07;
  --accent: #7c3aed;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  /* Himmel der begehbaren Stadt (welt.js): Zenit und Horizont. Der Horizont ist zugleich
     die Nebelfarbe – so verschwimmt die Ferne nahtlos im Himmel. */
  --welt-himmel: #5ea8e4;
  --welt-horizont: #d3eaf6;
}
:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #131c2e;
  --surface-2: #1b263b;
  --text: #e6edf5;
  --muted: #9fb0c3;
  --border: #263449;
  --primary: #2dd4bf;
  --primary-ink: #05201d;
  --pos: #4ade80;
  --neg: #f87171;
  --warn: #fbbf24;
  --accent: #a78bfa;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  /* Im dunklen Thema ist in der Stadt Nacht: Sterne, Mond, leuchtende Fenster. */
  --welt-himmel: #08122a;
  --welt-horizont: #1d2c49;
}

* { box-sizing: border-box; }
/* [hidden] muss immer verstecken – sonst überschreiben Klassenregeln wie
   `.form { display: grid }` das Attribut und zeigen versteckte Elemente doch an. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.app { max-width: 1080px; margin: 0 auto; padding: 12px 14px 96px; }

h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
a { color: var(--primary); }
button { font: inherit; cursor: pointer; }

/* --- Topbar --- */
.topbar {
  /* Umbrechen statt überlaufen: Ohne `flex-wrap` ragte die Kopfleiste bei 320 px um
     36 px über den Rand (Deutsch) und um 54 px im Französischen – „Abmelden" war zu
     38 % unsichtbar. Dasselbe gilt für die untere Navigation. */
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 20;
  background: var(--bg); padding: 8px 2px; margin-bottom: 8px;
}
.topbar .brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; }
.topbar .spacer { flex: 1; }
/* Abmelden: breit mit Text, schmal nur das Symbol (siehe topbar() in app.js). */
.logout-icon { display: none; }
@media (max-width: 480px) {
  /* Gemessen in allen sechs Sprachen: So passt die Kopfleiste ab 320 px in EINE Zeile. */
  .topbar { gap: 6px; }
  .topbar .brand { font-size: 1rem; }
  .topbar .icon-btn, .topbar .lang-select { padding: 6px 8px; }
  .logout-icon { display: inline; }
  .logout-text { display: none; }
}
.icon-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 7px 10px; font-size: 0.9rem;
}
.icon-btn:hover { border-color: var(--primary); }
/* Sprachwahl in der Kopfleiste: sieht aus wie die Icon-Knöpfe daneben, ist aber ein
   <select> – bei drei Sprachen sieht man so die aktuelle Wahl und alle Alternativen. */
.lang-select {
  width: auto; padding: 7px 8px; font-size: 0.9rem;
  background: var(--surface); border-radius: 10px;
}
/* Auf der Anmeldeseite steht sie unten in der Karte, dezent und rechtsbündig. */
.auth-lang { display: flex; justify-content: flex-end; margin-top: 14px; }
.auth-lang .lang-select { font-size: 0.85rem; }

.brand-mark {
  display: inline-grid; place-items: center;
  width: 1.5em; height: 1.5em; border-radius: 8px;
  background: var(--primary); color: var(--primary-ink); font-weight: 800;
}

/* --- Cards & layout --- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px;
}
.card h2 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.grid { display: grid; gap: 12px; }
@media (min-width: 760px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } }

/* --- KPI tiles --- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 860px) { .kpis { grid-template-columns: repeat(6, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); }
.kpi .label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.kpi .value { font-size: 1.2rem; font-weight: 700; margin-top: 2px; }
.kpi .value.pos { color: var(--pos); }
.kpi .value.neg { color: var(--neg); }

/* --- Balance / rows --- */
/* `flex-wrap` und `min-width: 0`: Flex-Kinder haben von Haus aus `min-width: auto` und
   schrumpfen deshalb nicht unter ihren Inhalt. Ein langer Spielstandsname schob die
   Knopfleiste damit aus dem Bild – gemessen bei 360 px Fensterbreite: 20 Zeichen im
   Namen liessen „Weiterspielen" bei x=374 enden, 30 Zeichen bei x=455, 60 Zeichen (die
   Feldgrenze) noch weiter. Die Knöpfe waren dort weder sichtbar noch antippbar. */
.row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.row > :first-child { min-width: 0; flex: 1 1 auto; }
.row .name { overflow-wrap: anywhere; }
.row:last-child { border-bottom: 0; }
.row .name { color: var(--text); }
.row .sub { color: var(--muted); font-size: 0.82rem; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.amount.pos { color: var(--pos); }
.amount.neg { color: var(--neg); }
.total { font-weight: 800; border-top: 2px solid var(--border); margin-top: 4px; padding-top: 8px; }

.pill { display: inline-block; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.cash_equiv { color: var(--muted); }
.pill.cashflow { color: var(--pos); }
.pill.growth { color: var(--accent); }
.pill.consumptive { color: var(--warn); }
.badge { font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); }
.badge.boom { color: var(--pos); } .badge.recession { color: var(--neg); } .badge.normal { color: var(--muted); }

/* --- Meters --- */
.meter { height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.meter > span { display: block; height: 100%; background: var(--primary); }
.meter.accent > span { background: var(--accent); }

/* --- Forms & buttons --- */
.form { display: grid; gap: 10px; }
label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); }
input, select {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-weight: 600;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
/* Zerstörende Aktion (z. B. Spielstand löschen). Nutzt nur Variablen aus :root,
   damit die Farbe in hell UND dunkel automatisch stimmt. */
.btn.danger { color: var(--neg); border-color: var(--neg); }
.btn.danger:hover { background: var(--neg); color: var(--surface); border-color: var(--neg); }
/* Nebensächliche Aktion, die wie ein Link aussieht („Passwort vergessen?"). Bewusst ein
   <button> und kein <a>: Es führt nirgendwohin, es öffnet ein Formular. Nur Variablen
   aus :root, damit die Farbe in hell UND dunkel stimmt. */
.btn.link {
  border-color: transparent; background: none; color: var(--primary);
  font-weight: 500; text-decoration: underline; padding: 4px 2px;
}
.btn.link:hover { border-color: transparent; background: none; box-shadow: none; }
.btn.wide { width: 100%; }
.btn.lg { padding: 12px 14px; font-size: 1.02rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.action-grid { display: grid; gap: 10px; }
.action { border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: var(--surface-2); }
.action h3 { font-size: 0.9rem; margin-bottom: 8px; }
.action .line { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.action .line > * { flex: 1 1 120px; }
.action .line > button { flex: 0 0 auto; }
/* Im Dialog (höchstens 460 px breit) bekommt eine Auswahl ihre eigene Zeile. Sonst teilte
   sie sich die Zeile mit Betrag und Knopf und war 155 px breit – von „Konsumkredit
   (8,9 % p. a., bis 50’000 CHF)" blieb „Konsumkre" übrig, im Französischen noch weniger.
   Gerade in der Kreditauswahl stehen Zins und Höchstbetrag, die das Kind lesen soll. */
.modal .action .line > select { flex-basis: 100%; }
/* Die volle Beschriftung einer Auswahl, wenn sie nicht hineinpasst (`vollTexte` misst es
   im Browser – eine feste Bildschirmbreite lag zweimal daneben). */
.auswahl-voll { margin: 6px 0 0; }
/* Auf dem Handy bekommt jede Auswahl ihre eigene Zeile, wie im Dialog: Bei 320 px
   blieben für den Lebensstil 112 px und für „Welt-ETF (5’971 CHF)" 102 px. */
@media (max-width: 480px) { .action .line > select { flex-basis: 100%; } }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input[type="checkbox"] { width: auto; margin: 0; }
/* Platzhalter tragen Information („Betrag (leer = alles)") – mit der Vorgabe des Browsers
   (rgb 117,117,117) lagen sie im dunklen Thema bei 3,29:1, im hellen bei 4,06:1. */
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }

/* --- Tabs / auth --- */
.auth-wrap { min-height: 78vh; display: grid; place-items: center; }
.auth-card { width: min(420px, 94vw); }
.brand { font-size: 1.6rem; font-weight: 800; margin-bottom: 4px; }
.tagline { color: var(--muted); margin: 0 0 14px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.tab.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.auth-msg { color: var(--muted); font-size: 0.88rem; margin-top: 10px; min-height: 1.2em; }
.auth-msg.error { color: var(--neg); }
.auth-msg.ok { color: var(--pos); }

/* --- Events / feed / concept cards --- */
.feed { display: grid; gap: 8px; }
.feed .item { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 0.9rem; }
.feed .item .t { color: var(--muted); font-size: 0.75rem; }
.concept { border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.concept h4 { margin: 0 0 3px; font-size: 0.9rem; color: var(--accent); }
.concept p { margin: 0; font-size: 0.86rem; color: var(--text); }

.status-banner { padding: 12px 14px; border-radius: 12px; font-weight: 700; text-align: center; margin-bottom: 12px; }
.status-banner.won { background: rgba(21,128,61,0.15); color: var(--pos); }
.status-banner.retired { background: rgba(124,58,237,0.15); color: var(--accent); }
.status-banner.bankrupt { background: rgba(185,28,28,0.15); color: var(--neg); }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.center { text-align: center; }
.mt { margin-top: 10px; }

/* --- Toast --- */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 70; max-width: 90vw; font-size: 0.9rem;
}
/* z-index ÜBER dem Dialog (60): Darunter lag jede Fehlermeldung einer Aktion IM Dialog
   abgedunkelt und verschwommen hinter der Verdunkelung – „zu wenig Bargeld", ein
   falsches Passwort im 2FA-Dialog –, und der Dialog blieb ohne erkennbare Antwort. */

/* --- Bottom nav --- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; flex-wrap: wrap; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav button {
  background: none; border: 0; color: var(--muted); font-size: 0.78rem;
  display: grid; justify-items: center; gap: 2px; padding: 4px 6px; border-radius: 8px;
  min-width: 0;
}
.bottom-nav button.active { color: var(--primary); }
.glossary dt { font-weight: 700; margin-top: 10px; }
.glossary dd { margin: 2px 0 0; color: var(--muted); }

/* --- Stadtkarte --- */
.town {
  position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 62vh;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow), inset 0 0 60px rgba(255,255,255,.15);
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAxMjAgMTIwJyBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSd4TWlkWU1pZCBzbGljZSc+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSdza3knIHgxPScwJyB5MT0nMCcgeDI9JzAnIHkyPScxJz48c3RvcCBvZmZzZXQ9JzAnIHN0b3AtY29sb3I9JyNhOWU0ZmYnLz48c3RvcCBvZmZzZXQ9JzEnIHN0b3AtY29sb3I9JyNlN2Y3ZWYnLz48L2xpbmVhckdyYWRpZW50PjxsaW5lYXJHcmFkaWVudCBpZD0nZ3Jhc3MnIHgxPScwJyB5MT0nMCcgeDI9JzAnIHkyPScxJz48c3RvcCBvZmZzZXQ9JzAnIHN0b3AtY29sb3I9JyM5YWRmYWUnLz48c3RvcCBvZmZzZXQ9JzEnIHN0b3AtY29sb3I9JyM3MWM5OGQnLz48L2xpbmVhckdyYWRpZW50PjxyYWRpYWxHcmFkaWVudCBpZD0nc3VuJyBjeD0nMC41JyBjeT0nMC41JyByPScwLjUnPjxzdG9wIG9mZnNldD0nMCcgc3RvcC1jb2xvcj0nI2ZmZjNjMCcvPjxzdG9wIG9mZnNldD0nMC42JyBzdG9wLWNvbG9yPScjZmZlMDgzJy8+PHN0b3Agb2Zmc2V0PScxJyBzdG9wLWNvbG9yPScjZmZkNDVlJy8+PC9yYWRpYWxHcmFkaWVudD48L2RlZnM+PHJlY3Qgd2lkdGg9JzEyMCcgaGVpZ2h0PScxMjAnIGZpbGw9J3VybCglMjNza3kpJy8+PGNpcmNsZSBjeD0nOTknIGN5PScyMCcgcj0nMTMnIGZpbGw9J3VybCglMjNzdW4pJy8+PGcgZmlsbD0nI2ZmZmZmZic+PGcgb3BhY2l0eT0nMC45NSc+PGVsbGlwc2UgY3g9JzI4JyBjeT0nMjInIHJ4PScxMycgcnk9JzcnLz48ZWxsaXBzZSBjeD0nNDAnIGN5PScxOScgcng9JzknIHJ5PSc2Jy8+PGVsbGlwc2UgY3g9JzE4JyBjeT0nMjUnIHJ4PSc4JyByeT0nNScvPjwvZz48ZyBvcGFjaXR5PScwLjg1Jz48ZWxsaXBzZSBjeD0nNzMnIGN5PSc0MCcgcng9JzEwJyByeT0nNicvPjxlbGxpcHNlIGN4PSc4MicgY3k9JzM3JyByeD0nNycgcnk9JzUnLz48L2c+PC9nPjxwYXRoIGQ9J00wIDcwIFEzMCA1NiA2MiA2NiBUMTIwIDYyIFYxMjAgSDAgWicgZmlsbD0nIzgzZDE5YScvPjxwYXRoIGQ9J00wIDg0IFEzNCA3MiA3NCA4MiBUMTIwIDc4IFYxMjAgSDAgWicgZmlsbD0ndXJsKCUyM2dyYXNzKScvPjxwYXRoIGQ9J00wIDEwMSBRNDAgOTIgNzggMTAwIFQxMjAgOTcgVjEyMCBIMCBaJyBmaWxsPScjNWNiZDdjJyBvcGFjaXR5PScwLjU1Jy8+PC9zdmc+");
  background-size: cover; background-position: center;
  border: 1px solid var(--border);
}
:root[data-theme="dark"] .town {
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAxMjAgMTIwJyBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSd4TWlkWU1pZCBzbGljZSc+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSduc2t5JyB4MT0nMCcgeTE9JzAnIHgyPScwJyB5Mj0nMSc+PHN0b3Agb2Zmc2V0PScwJyBzdG9wLWNvbG9yPScjMTgyYTRhJy8+PHN0b3Agb2Zmc2V0PScxJyBzdG9wLWNvbG9yPScjMTIyMDM2Jy8+PC9saW5lYXJHcmFkaWVudD48bGluZWFyR3JhZGllbnQgaWQ9J25ncmFzcycgeDE9JzAnIHkxPScwJyB4Mj0nMCcgeTI9JzEnPjxzdG9wIG9mZnNldD0nMCcgc3RvcC1jb2xvcj0nIzFkNDAzMCcvPjxzdG9wIG9mZnNldD0nMScgc3RvcC1jb2xvcj0nIzEyMjgxZicvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHdpZHRoPScxMjAnIGhlaWdodD0nMTIwJyBmaWxsPSd1cmwoJTIzbnNreSknLz48Y2lyY2xlIGN4PSc5OScgY3k9JzIwJyByPScxMScgZmlsbD0nI2VlZjJmZicvPjxjaXJjbGUgY3g9Jzk1JyBjeT0nMTcnIHI9JzExJyBmaWxsPScjMTgyYTRhJy8+PGcgZmlsbD0nI2ZmZmZmZicgb3BhY2l0eT0nMC44NSc+PGNpcmNsZSBjeD0nMjAnIGN5PScxNicgcj0nMC44Jy8+PGNpcmNsZSBjeD0nMzQnIGN5PScyNicgcj0nMC43Jy8+PGNpcmNsZSBjeD0nNTInIGN5PScxNCcgcj0nMC45Jy8+PGNpcmNsZSBjeD0nNjYnIGN5PSczMCcgcj0nMC43Jy8+PGNpcmNsZSBjeD0nNzgnIGN5PScxOCcgcj0nMC44Jy8+PGNpcmNsZSBjeD0nNDQnIGN5PSczNCcgcj0nMC42Jy8+PGNpcmNsZSBjeD0nMTInIGN5PSczMCcgcj0nMC43Jy8+PC9nPjxwYXRoIGQ9J00wIDcwIFEzMCA1NiA2MiA2NiBUMTIwIDYyIFYxMjAgSDAgWicgZmlsbD0nIzFhM2EyYycvPjxwYXRoIGQ9J00wIDg0IFEzNCA3MiA3NCA4MiBUMTIwIDc4IFYxMjAgSDAgWicgZmlsbD0ndXJsKCUyM25ncmFzcyknLz48cGF0aCBkPSdNMCAxMDEgUTQwIDkyIDc4IDEwMCBUMTIwIDk3IFYxMjAgSDAgWicgZmlsbD0nIzBlMjAxOCcgb3BhY2l0eT0nMC42Jy8+PC9zdmc+");
}
.town .plaza {
  position: absolute; left: 50%; top: 58%; width: 30%; height: 20%;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at center, rgba(233,214,168,.85), rgba(214,193,146,.5));
  border-radius: 50%; box-shadow: 0 6px 16px rgba(120,90,40,.18);
}
:root[data-theme="dark"] .town .plaza {
  background: radial-gradient(ellipse at center, rgba(120,104,74,.55), rgba(70,60,42,.3));
  box-shadow: 0 6px 16px rgba(0,0,0,.3);
}
/* Die Gebäude sind <button>, damit sie mit der Tastatur erreichbar sind. Die
   Browser-Vorgaben werden abgeräumt, damit sie weiter wie Kacheln aussehen – der
   Fokusring bleibt bewusst stehen. */
.building {
  position: absolute; transform: translate(-50%, -50%);
  display: grid; justify-items: center; gap: 3px; cursor: pointer; width: 80px; z-index: 2;
  transition: transform .15s ease;
  appearance: none; -webkit-appearance: none;
  background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit;
}
.building:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 18px; }
.building .b-emoji {
  font-size: 2rem; line-height: 1;
  width: 3rem; height: 3rem; display: grid; place-items: center;
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(255,255,255,.78));
  border-radius: 16px; border: 1px solid rgba(255,255,255,.9);
  box-shadow: 0 4px 10px rgba(16,24,40,.22), inset 0 1px 0 rgba(255,255,255,.8);
}
:root[data-theme="dark"] .building .b-emoji {
  background: linear-gradient(180deg, rgba(38,52,73,.95), rgba(27,38,59,.85));
  border-color: rgba(120,140,170,.35);
}
.building .b-label {
  font-size: .68rem; background: rgba(255,255,255,.92); color: #14202b;
  padding: 1px 8px; border-radius: 999px; white-space: nowrap; font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
:root[data-theme="dark"] .building .b-label { background: rgba(15,23,36,.85); color: #e6edf5; }
/* Bei 320 px liegen die Gebäude der unteren Reihe nur rund 63 px auseinander. Auf
   Spanisch überdeckte „Ayuntamiento" (90 px) „Dormir" um 13 px – kleiner gesetzt und
   mit weniger Rand passen alle Sprachen nebeneinander. */
@media (max-width: 360px) { .building .b-label { font-size: .62rem; padding: 1px 4px; } }
/* Das Ziel aus Filos Tipp: Ring und ein wippender Pfeil darüber (wie in der 3D-Stadt). */
.building.ziel .b-emoji { box-shadow: 0 0 0 3px var(--accent), 0 4px 10px rgba(16,24,40,.22); }
.building.ziel::before {
  content: "▼"; position: absolute; left: 50%; top: -1.35rem; transform: translateX(-50%);
  color: var(--accent); font-size: 1rem; line-height: 1; animation: bob 1.2s ease-in-out infinite;
}
.building:hover { transform: translate(-50%, -50%) translateY(-3px); }
.building:active { transform: translate(-50%, -50%) scale(.94); }
.player {
  position: absolute; transform: translate(-50%, -50%); font-size: 2rem; z-index: 5;
  pointer-events: none; transition: left .5s ease, top .5s ease;
  filter: drop-shadow(0 6px 4px rgba(0,0,0,.3)); animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob { 0%,100% { margin-top: 0; } 50% { margin-top: -4px; } }
.map-hint { text-align: center; color: var(--muted); font-size: .82rem; margin: 8px 0 4px; }

/* --- Begehbare Stadt (Ich-Perspektive, welt.js) ---
   Die Leinwand füllt welt.js; alles darüber (Knöpfe, Tür-Hinweis) baut app.js. Farben nur
   über Variablen, damit Tag und Nacht dem Farbschema folgen. */
.welt {
  position: relative; display: flex; flex-direction: column;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
  box-shadow: var(--shadow); background: var(--surface);
}
.welt-slot { position: relative; flex: 1 1 auto; min-height: 0; }
.welt-buehne {
  position: relative; width: 100%; height: clamp(300px, 58vh, 620px);
  background: var(--welt-horizont);
}
.welt-leinwand {
  display: block; width: 100%; height: 100%; cursor: grab; outline: none;
  /* Wischen bewegt den Blick, nicht die Seite. */
  touch-action: none; -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.welt-leinwand:active { cursor: grabbing; }
.welt-leinwand:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.welt-karte {
  position: absolute; left: 8px; top: 8px; width: 96px; height: 96px;
  border-radius: 50%; box-shadow: var(--shadow); cursor: pointer; touch-action: none;
}
.welt-stick {
  position: absolute; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--surface) 70%, transparent);
  background: color-mix(in srgb, var(--surface) 25%, transparent); pointer-events: none;
}
.welt-stick-knopf {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 80%, transparent); box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}
.welt-oben {
  position: absolute; top: 8px; left: 8px; right: 8px;
  display: flex; align-items: flex-start; justify-content: flex-end; gap: 6px; pointer-events: none;
}
.welt-oben > * { pointer-events: auto; }
.welt-chips { display: none; flex-wrap: wrap; gap: 6px; margin-right: auto; }
.welt-chip, .welt-knopf {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: var(--shadow); font-weight: 700;
}
.welt-chip { border-radius: 999px; padding: 4px 10px; font-size: .85rem; white-space: nowrap; }
.welt-knopf { border-radius: 10px; padding: 6px 10px; line-height: 1.15; }
.welt-tuer {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; width: max-content; max-width: calc(100% - 24px);
}
.welt-tuer .btn { box-shadow: var(--shadow); }
.welt-tuer kbd {
  font: inherit; font-size: .8rem; font-weight: 700; padding: 2px 8px; border-radius: 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
}
@media (pointer: coarse) { .welt-tuer kbd { display: none; } }
/* Filos Sprechblase: unten, wo sonst der Tür-Hinweis steht – Filo steht nie an einer Tür. */
.welt-filo {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  width: max-content; max-width: min(520px, calc(100% - 24px));
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); font-size: .9rem;
}
.welt-filo p { margin: 0; }
.welt-filo-gesicht { font-size: 1.8rem; line-height: 1; }
.welt-hilfe {
  margin: 0; padding: 6px 10px; font-size: .8rem; color: var(--muted); text-align: center;
  border-top: 1px solid var(--border); background: var(--surface);
}
/* Grosse Ansicht: die Stadt füllt den Bildschirm. Bewusst KEIN Fullscreen-API – Dialoge
   hängen an `document.body` und lägen sonst unsichtbar hinter der Stadt; auf dem iPhone
   gibt es die Schnittstelle für Elemente ausserdem gar nicht. */
.welt.gross { position: fixed; inset: 0; z-index: 45; border: 0; border-radius: 0; }
.welt.gross .welt-buehne { position: absolute; inset: 0; height: auto; }
.welt.gross .welt-chips { display: flex; }
/* Randbereiche (Notch, runde Ecken) im Querformat: Die Seite nutzt viewport-fit=cover. */
.welt.gross .welt-oben {
  top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
}
.welt.gross .welt-hilfe { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
.welt-knopf.nur-gross { display: none; }
.welt.gross .welt-knopf.nur-gross { display: inline-block; }
/* Unter der Kopfzeile der grossen Ansicht; ihre Höhe misst app.js (weltObenMessen). */
.welt.gross .welt-karte {
  top: calc(max(8px, env(safe-area-inset-top)) + var(--welt-oben, 36px) + 8px);
  left: max(8px, env(safe-area-inset-left));
}
body.welt-vollbild { overflow: hidden; }

/* --- Modal (Gebäude-Panel) --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: grid; place-items: center; z-index: 60; padding: 14px;
}
.modal { width: min(460px, 96vw); max-height: 86vh; overflow: auto; margin: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h2 { margin: 0; text-transform: none; letter-spacing: 0; color: var(--text); font-size: 1.1rem; }
.modal .close { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 4px 10px; }
.stat-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

/* --- Steuerzeile, Avatar, Maskottchen --- */
.controls-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.controls-row .btn { padding: 6px 10px; }
.avatar-pick { display: flex; gap: 4px; margin-left: auto; }
.avatar-pick button { font-size: 1.15rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px 6px; line-height: 1.2; }
.avatar-pick button.active { border-color: var(--primary); background: var(--surface-2); }
.mascot { display: flex; gap: 8px; align-items: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; margin: 8px 0; }
.mascot .face { font-size: 1.8rem; line-height: 1; }
.mascot .bubble { font-size: .86rem; }

/* --- Verlaufs-Chart --- */
.chart { display: block; width: 100%; height: auto; }
/* Der Platzhaltertext stand als hartes „#8aa" im JavaScript: im hellen Thema
   2,51:1 – das Erste, was ein neuer Spieler sieht, und praktisch unlesbar. */
.chart .hinweis { fill: var(--muted); font-size: .8rem; }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--primary); }
.chart .zero { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 3; }

/* --- Achievements / Sterne --- */
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
/* Ein noch nicht erreichter Stern soll blass wirken, aber lesbar bleiben: Bei 45 %
   Deckkraft stand sein Name bei 1,84:1 – weit unter jeder Lesbarkeitsgrenze, und in
   einem Kinderspiel ist „welche Sterne kann ich noch holen?" eine echte Information.
   Die Unterscheidung trägt jetzt das blasse Emoji, nicht der unlesbare Text. */
.ach { text-align: center; padding: 8px 6px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.ach .a-emoji { opacity: .45; }
.ach .a-title { color: var(--muted); }
.ach.on { border-color: var(--primary); }
.ach.on .a-emoji { opacity: 1; }
.ach.on .a-title { color: var(--text); }
.ach .a-emoji { font-size: 1.5rem; }
.ach .a-title { font-size: .72rem; font-weight: 600; margin-top: 2px; }
.celebrate { text-align: center; }
.celebrate .big { font-size: 2.6rem; margin-bottom: 4px; }

/* ======================================================================
   Grafik-Feinschliff: Tiefe, Verläufe, sanfte Bewegung (CSP-konform: nur CSS).
   ====================================================================== */
:root { --grad-primary: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #22d3ee)); }

body {
  background-image:
    radial-gradient(1200px 480px at 100% -10%, color-mix(in srgb, var(--primary) 12%, transparent), transparent),
    radial-gradient(900px 420px at -10% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent);
  background-attachment: fixed;
}

/* Buttons: Verlauf, Tiefe, spürbarer Druck */
.btn { transition: transform .12s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary {
  background-image: var(--grad-primary); border-color: transparent;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 35%, transparent);
}
.btn.primary:hover { box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 45%, transparent); }
.icon-btn { transition: transform .12s ease, border-color .18s ease; }
.icon-btn:active { transform: scale(.94); }

/* Karten & KPIs: Hover-Lift + Farbakzent */
.card { transition: transform .18s ease, box-shadow .18s ease; }
.kpi {
  position: relative; overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background-image: var(--grad-primary);
}
.kpi:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(16,24,40,.12); }
.kpi .value.pos { color: var(--pos); }
.kpi .value.neg { color: var(--neg); }

/* Brand-Mark & Auth: einladender Hintergrund */
.brand-mark { background-image: var(--grad-primary); box-shadow: 0 4px 10px color-mix(in srgb, var(--primary) 35%, transparent); }
.auth-wrap {
  background-image:
    radial-gradient(700px 360px at 80% -5%, color-mix(in srgb, var(--primary) 16%, transparent), transparent),
    radial-gradient(600px 320px at 10% 100%, color-mix(in srgb, var(--accent) 16%, transparent), transparent);
  border-radius: var(--radius);
}
.auth-card { animation: pop .3s cubic-bezier(.2,.8,.2,1) both; box-shadow: 0 12px 40px rgba(16,24,40,.16); }
.tab { transition: transform .12s ease, background .18s ease, color .18s ease; }
.tab.active { background-image: var(--grad-primary); border-color: transparent; }

/* Sanfte Auftritte für Seiteninhalte */
.kpis, .town, .controls-row, .mascot, .card, .status-banner { animation: fadeUp .28s ease both; }
.modal { animation: pop .26s cubic-bezier(.2,.8,.2,1) both; }
.modal-overlay { animation: fade .2s ease both; backdrop-filter: blur(2px); }

/* Maskottchen: Sprechblase mit Zipfel, wippendes Gesicht */
.mascot { position: relative; background: none; border: 0; padding: 0; align-items: center; }
.mascot .face { animation: bob 2.2s ease-in-out infinite; font-size: 2.1rem; }
.mascot .bubble {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 8px 10px; box-shadow: var(--shadow);
}
.mascot .bubble::before {
  content: ""; position: absolute; left: -7px; top: 14px; width: 12px; height: 12px;
  background: var(--surface); border-left: 1px solid var(--border); border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
}

/* Bottom-Nav: aktives Element als Pille */
.bottom-nav button { transition: color .15s ease, background .15s ease; }
/* 10 % statt 14 %: Mit 14 % lag die Schrift des aktiven Reiters im hellen Thema bei
   4,49:1 – knapp unter den 4,5, die `test_frontend_contract.py` verlangt. */
.bottom-nav button.active { background: color-mix(in srgb, var(--primary) 10%, transparent); }

/* Fortschrittsbalken (Meter) mit Verlauf + weichem Lauf */
.meter > span { background-image: var(--grad-primary); transition: width .5s ease; }

/* Konzept-/Angebots-Karten: farbiger Rand je Kontext bleibt, jetzt mit Verlauf-Akzent */
.concept { transition: transform .15s ease; }
.concept:hover { transform: translateX(2px); }

/* Erfolgs-Feier: Stern-Pop + kleines Konfetti */
.celebrate .big { animation: star-pop .6s cubic-bezier(.2,1.4,.4,1) both; }
.status-banner.won { position: relative; overflow: hidden; }
.status-banner.won::after {
  content: "🎉✨🎊✨"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 1.2rem; letter-spacing: 1.2rem; opacity: .25; animation: drift 3s linear infinite;
}

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
@keyframes star-pop { 0% { transform: scale(0) rotate(-30deg); } 70% { transform: scale(1.25) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes drift { from { background-position: 0 0; transform: translateX(-6px); } to { transform: translateX(6px); } }

/* Barrierefreiheit: Bewegung reduzieren, wenn gewünscht */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Konto / zweiter Faktor ---------------------------------------------------------
   Nur Variablen aus :root verwenden, dann stimmt der Dunkelmodus automatisch mit. */
.code-block {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  margin: 8px 0;
  /* Ersatzcodes sind lang: lieber scrollen als aus der Karte laufen. */
  overflow-x: auto;
  white-space: nowrap;
}
.code-block > div { line-height: 1.6; }
.warnline { color: var(--warn); }
