:root {
  --grund: #0b0f14;
  --flaeche: #141b24;
  --flaeche2: #1c2530;
  --linie: #2a3542;
  --text: #eef3f8;
  --leise: #8a98a8;
  --akzent: #b8f53c;
  --akzent-dunkel: #0f1a02;
  --geist: #a78bfa;
  --route: #38bdf8;
  --gut: #4ade80;
  --schlecht: #f87171;
  --warn: #fbbf24;
  --rund: 16px;
  --leiste: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--grund); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1 { font-size: 26px; line-height: 1.15; margin: 4px 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--leise); margin: 26px 0 10px; font-weight: 600; }
.unter { color: var(--leise); margin: 0 0 14px; }
.zahl { font-variant-numeric: tabular-nums; }

#app { display: flex; flex-direction: column; height: 100dvh; max-width: 680px; margin: 0 auto; position: relative; }

/* ------------------------------------------------ Kopf und Leiste */
#kopf { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
.marke { font-weight: 800; letter-spacing: -0.02em; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.marke-punkt { width: 12px; height: 12px; border-radius: 50%; background: var(--akzent); box-shadow: 0 0 12px var(--akzent); }
.sync { margin-left: auto; font-size: 12px; color: var(--leise); }
.sync.wartet { color: var(--warn); }
.konto-knopf { width: 34px; height: 34px; border-radius: 50%; background: var(--flaeche2); display: grid; place-items: center; font-weight: 700; border: 1px solid var(--linie); }

#ansicht { flex: 1; overflow-y: auto; overflow-x: hidden; }
body[data-ansicht="laufen"] #ansicht, body[data-ansicht="zeichnen"] #ansicht { overflow: hidden; position: relative; }

#leiste { display: grid; grid-template-columns: repeat(4, 1fr); height: calc(var(--leiste) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--flaeche); border-top: 1px solid var(--linie); }
#leiste a { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; color: var(--leise); gap: 2px; }
#leiste a span { font-size: 20px; line-height: 1; }
#leiste a.aktiv { color: var(--akzent); }

#lauf-banner { display: flex; align-items: center; gap: 8px; margin: 0 16px 8px; padding: 10px 14px; border-radius: 12px;
  background: var(--akzent); color: var(--akzent-dunkel); font-weight: 700; }
#lauf-banner::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #e11d48; animation: puls 1.2s infinite; }
@keyframes puls { 50% { opacity: 0.3; } }

/* ------------------------------------------------ Seiten */
.seite { padding: 6px 16px 32px; }
.laden { padding: 40px; text-align: center; color: var(--leise); }
.zurueck { display: inline-block; color: var(--leise); margin: 4px 0 6px; padding: 4px 0; }

.kacheln { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kacheln.vier { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 520px) { .kacheln.vier { grid-template-columns: repeat(4, 1fr); } }
.kachel { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--rund); padding: 12px; min-width: 0; }
.kachel b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kachel small { color: var(--leise); font-size: 12px; }

.gross-knopf { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 58px; border: 0; border-radius: var(--rund);
  background: var(--akzent); color: var(--akzent-dunkel); font-weight: 800; font-size: 18px; cursor: pointer; margin: 16px 0 10px; }
.gross-knopf:active { transform: scale(0.98); }
.gross-knopf:disabled { opacity: 0.5; }
.knopf { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 14px; border-radius: 12px;
  background: var(--flaeche2); border: 1px solid var(--linie); cursor: pointer; font-weight: 600; text-align: center; }
.knopf:active { transform: scale(0.98); }
.knopf.gefahr { color: var(--schlecht); }
.knopf.akzent { background: var(--akzent); color: var(--akzent-dunkel); border-color: transparent; }
.knopf.geist { border-color: var(--geist); color: var(--geist); }
.zwei { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.knopfreihe .knopf { flex: 1 1 140px; }

.leer { background: var(--flaeche); border: 1px dashed var(--linie); border-radius: var(--rund); padding: 22px; text-align: center; color: var(--leise); }
.fehlerbox { margin: 16px; padding: 16px; border-radius: var(--rund); background: #3b1111; color: #fecaca; }

/* ------------------------------------------------ Listen */
.liste { display: flex; flex-direction: column; gap: 8px; }
.zeile { display: flex; align-items: center; gap: 12px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.zeile-links { flex: 1; min-width: 0; }
.zeile-links b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zeile small { color: var(--leise); font-size: 12px; }
.zeile-rechts { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.zeile-rechts small { display: block; }
.marke-klein { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 11px; font-weight: 700; background: var(--flaeche2); }
.marke-klein.sieg { background: rgba(74, 222, 128, 0.15); color: var(--gut); }
.marke-klein.niederlage { background: rgba(248, 113, 113, 0.15); color: var(--schlecht); }
.monat { font-size: 12px; color: var(--leise); margin: 16px 2px 6px; }
.rang { width: 30px; text-align: center; font-size: 18px; font-weight: 800; color: var(--leise); }

.rekorde { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.rekord { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 14px; padding: 12px; }
.rekord small { color: var(--leise); display: block; font-size: 12px; }
.rekord b { font-size: 20px; font-variant-numeric: tabular-nums; }

.diagramm { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--rund); padding: 12px 10px 6px; }
.diagramm svg { display: block; width: 100%; height: auto; }

.splits { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.splits td { padding: 7px 4px; border-bottom: 1px solid var(--linie); }
.splits td:first-child { color: var(--leise); width: 56px; }
.splits .balken { height: 8px; border-radius: 4px; background: var(--akzent); opacity: 0.85; }
.splits .balken.schnell { background: var(--gut); }

.duell-karte { border-radius: var(--rund); padding: 14px; margin-top: 14px; border: 1px solid var(--geist); background: rgba(167, 139, 250, 0.08); }
.duell-karte b { font-size: 20px; }
.duell-karte.sieg { border-color: var(--gut); background: rgba(74, 222, 128, 0.08); }
.duell-karte.niederlage { border-color: var(--schlecht); background: rgba(248, 113, 113, 0.08); }

/* ------------------------------------------------ Formulare */
form label, .feld { display: block; margin: 12px 0; }
form label > span, .feld > span { display: block; color: var(--leise); font-size: 13px; margin-bottom: 5px; }
input, select, textarea { width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--linie);
  background: var(--flaeche); font-size: 16px; outline: none; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--akzent); }
.reihe { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.reihe3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.reihe label, .reihe3 label { margin: 0; }
.formfehler { color: var(--schlecht); min-height: 20px; margin: 6px 0; }
.vorschau { background: var(--flaeche2); border-radius: 12px; padding: 10px 12px; color: var(--leise); }
.vorschau b { color: var(--text); }
.haken { display: flex !important; align-items: center; gap: 10px; }
.haken input { width: 22px; min-height: 22px; accent-color: var(--akzent); }

.gefuehl { display: flex; gap: 8px; }
.gefuehl label { flex: 1; margin: 0; }
.gefuehl input { position: absolute; opacity: 0; pointer-events: none; }
.gefuehl span { display: grid !important; place-items: center; height: 48px; border-radius: 12px; background: var(--flaeche); border: 1px solid var(--linie);
  font-size: 24px !important; margin: 0 !important; cursor: pointer; }
.gefuehl input:checked + span { border-color: var(--akzent); background: var(--flaeche2); }

.umschalter { display: flex; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: 4px; gap: 4px; }
.umschalter button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: none; color: var(--leise); font-weight: 700; cursor: pointer; }
.umschalter button.aktiv { background: var(--flaeche2); color: var(--text); }

/* ------------------------------------------------ Anmeldung */
.anmelden { padding: calc(40px + env(safe-area-inset-top)) 22px 40px; max-width: 420px; margin: 0 auto; }
.anmelden .logo { font-size: 34px; font-weight: 900; letter-spacing: -0.03em; display: flex; align-items: center; gap: 12px; }
.anmelden .logo .marke-punkt { width: 20px; height: 20px; }
.anmelden p { color: var(--leise); margin: 6px 0 24px; }

/* ------------------------------------------------ Karten */
.karte-klein { height: 240px; border-radius: var(--rund); overflow: hidden; border: 1px solid var(--linie); margin: 10px 0; background: var(--flaeche); }
.karte-fehlt { display: grid; place-items: center; height: 100%; color: var(--leise); padding: 20px; text-align: center; }
.leaflet-container { background: #1b222b; font: inherit; }
.leaflet-control-attribution { background: rgba(11, 15, 20, 0.7) !important; color: var(--leise) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--leise) !important; }
.punkt-ich { width: 20px; height: 20px; border-radius: 50%; background: var(--akzent); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(184, 245, 60, 0.3); }
.punkt-geist { width: 22px; height: 22px; border-radius: 50%; background: var(--geist); border: 3px solid #fff; opacity: 0.9;
  box-shadow: 0 0 0 6px rgba(167, 139, 250, 0.3); display: grid; place-items: center; font-size: 11px; }

/* ------------------------------------------------ Laufen */
.laufen { position: absolute; inset: 0; }
.laufen #karte { position: absolute; inset: 0; }
.lauf-oben { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 500; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.lauf-oben > * { pointer-events: auto; }
.werte { display: grid; grid-template-columns: repeat(3, 1fr); background: rgba(11, 15, 20, 0.88); backdrop-filter: blur(8px); border-radius: var(--rund); padding: 10px 6px; border: 1px solid var(--linie); }
.wert { text-align: center; min-width: 0; }
.wert span { display: block; font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; line-height: 1.1; }
.wert small { color: var(--leise); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.wert.gross { grid-column: 1 / -1; margin-bottom: 4px; }
.wert.gross span { font-size: 52px; }
.gps { align-self: flex-start; font-size: 12px; padding: 4px 10px; border-radius: 99px; background: rgba(11, 15, 20, 0.88); color: var(--leise); }
.gps.gut { color: var(--gut); } .gps.mittel { color: var(--warn); } .gps.schlecht { color: var(--schlecht); }

.duell { background: rgba(11, 15, 20, 0.9); backdrop-filter: blur(8px); border: 1px solid var(--geist); border-radius: var(--rund); padding: 10px 12px; }
.duell-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.duell-kopf small { color: var(--leise); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vorsprung { font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vorsprung.vorne { color: var(--gut); } .vorsprung.hinten { color: var(--schlecht); }
.bahn { position: relative; height: 10px; border-radius: 5px; background: var(--flaeche2); margin: 12px 4px 6px; }
.bahn i { position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%; transform: translate(-50%, -50%); border: 2px solid #fff; }
.bahn i.ich { background: var(--akzent); z-index: 2; }
.bahn i.geist { background: var(--geist); }
.bahn::after { content: "🏁"; position: absolute; right: -6px; top: -14px; font-size: 14px; }
.duell-text { font-size: 13px; color: var(--leise); }

.lauf-unten { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 500; background: rgba(11, 15, 20, 0.92); backdrop-filter: blur(8px);
  border-radius: 20px; border: 1px solid var(--linie); padding: 12px; }
.lauf-unten .gross-knopf { margin: 10px 0 0; }
.lauf-unten select { margin-top: 10px; }
.steuer { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.steuer .gross-knopf { margin: 0; }
.gross-knopf.pause { background: var(--flaeche2); color: var(--text); border: 1px solid var(--linie); }
.gross-knopf.stopp { background: var(--schlecht); color: #fff; }
.hinweis { color: var(--leise); font-size: 13px; margin-top: 8px; }
.folgen { position: absolute; right: 12px; z-index: 600; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--linie);
  background: rgba(11, 15, 20, 0.92); font-size: 20px; cursor: pointer; }
.zoomknoepfe { position: absolute; right: 12px; z-index: 600; display: flex; flex-direction: column; gap: 6px; }

/* ------------------------------------------------ Zeichnen */
.zeichnen-kopf { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 500; background: rgba(11, 15, 20, 0.92); border-radius: var(--rund); padding: 10px 14px; border: 1px solid var(--linie); }
.zeichnen-kopf b { font-size: 24px; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------ Dialoge */
.dialog-grund { position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, 0.6); display: flex; align-items: flex-end; justify-content: center; }
.dialog { width: 100%; max-width: 680px; max-height: 92dvh; overflow-y: auto; background: var(--flaeche); border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); border-top: 1px solid var(--linie); animation: hoch 0.2s ease-out; }
@media (min-width: 700px) { .dialog-grund { align-items: center; } .dialog { border-radius: 22px; border: 1px solid var(--linie); } }
@keyframes hoch { from { transform: translateY(40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .dialog { animation: none; } #lauf-banner::before { animation: none; } }
.dialog h1 { font-size: 22px; }

/* ------------------------------------------------ Benutzermenü */
.konto-knopf { position: relative; cursor: pointer; color: var(--akzent-dunkel); font-weight: 900; font-size: 13px; padding: 0;
  background: linear-gradient(135deg, var(--akzent), #4ade80); border: 0; }
.konto-knopf[data-anfragen]::after { content: attr(data-anfragen); position: absolute; top: -5px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: #f43f5e; color: #fff; font-size: 11px; line-height: 18px; border: 2px solid var(--grund); box-sizing: content-box; }
.benutzermenue { position: absolute; top: calc(56px + env(safe-area-inset-top)); right: 12px; z-index: 1500; width: min(300px, calc(100% - 24px));
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55); padding: 8px; animation: hoch 0.15s ease-out; }
.bm-kopf { display: flex; gap: 12px; align-items: center; padding: 10px 10px 12px; border-bottom: 1px solid var(--linie); margin-bottom: 6px; min-width: 0; }
.bm-kopf > div { min-width: 0; }
.bm-kopf b, .bm-kopf small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-kopf small { color: var(--leise); font-size: 12px; }
.bm-liste a, .bm-liste button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 10px; border-radius: 10px;
  background: none; border: 0; text-align: left; cursor: pointer; font-size: 15px; }
.bm-liste a:hover, .bm-liste button:hover, .bm-liste a:focus-visible, .bm-liste button:focus-visible { background: var(--flaeche2); outline: none; }
.bm-liste a.aktiv { color: var(--akzent); }
.bm-liste .bm-abmelden { color: var(--schlecht); border-top: 1px solid var(--linie); border-radius: 0 0 10px 10px; margin-top: 6px; }
.bm-symbol { width: 22px; text-align: center; }
.zaehler { margin-left: auto; font-style: normal; background: #f43f5e; color: #fff; font-size: 12px; font-weight: 800; min-width: 22px; height: 22px;
  border-radius: 11px; display: grid; place-items: center; padding: 0 6px; }
.avatar { display: grid; place-items: center; flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%; font-weight: 900;
  background: linear-gradient(135deg, var(--akzent), #4ade80); color: var(--akzent-dunkel); }
.avatar.riesig { width: 64px; height: 64px; font-size: 24px; }
.avatar.freund { background: linear-gradient(135deg, var(--geist), #60a5fa); color: #10081f; }

/* ------------------------------------------------ Konto */
.profilkarte { display: flex; gap: 14px; align-items: center; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--rund); padding: 16px; margin: 8px 0 12px; min-width: 0; }
.profilkarte > div { min-width: 0; }
.profilkarte b { display: block; font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profilkarte small { color: var(--leise); display: block; }
.menuegruppe { margin-top: 20px; }
.menuegruppe > p { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--leise); margin: 0 0 8px 2px; font-weight: 600; }
.menuezeile { display: flex; align-items: center; gap: 12px; background: var(--flaeche); border: 1px solid var(--linie); padding: 12px 14px; min-width: 0; }
.menuezeile + .menuezeile { border-top: 0; }
.menuegruppe .menuezeile:first-of-type { border-radius: 14px 14px 0 0; }
.menuegruppe .menuezeile:last-of-type { border-radius: 0 0 14px 14px; }
.menuegruppe .menuezeile:only-of-type { border-radius: 14px; }
.menuezeile::after { content: "›"; color: var(--leise); font-size: 22px; line-height: 1; }
.menuezeile .bm-symbol { font-size: 18px; }
.menuezeile small { display: block; color: var(--leise); font-size: 12px; }
.hinweiskarte { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--geist); background: rgba(167, 139, 250, 0.1); margin: 12px 0; }
.hinweiskarte > div { flex: 1; min-width: 0; }
.reihe-knopf { display: flex; gap: 8px; }
.reihe-knopf input { flex: 1; min-width: 0; }
.reihe-knopf .knopf { flex-shrink: 0; }
.knopf.klein { min-height: 34px; padding: 0 10px; font-size: 13px; }
.textlink { background: none; border: 0; color: var(--akzent); cursor: pointer; padding: 8px 0; font-weight: 600; font-size: 14px; }
details.frage { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
details.frage summary { font-weight: 700; cursor: pointer; }
details.frage p { color: var(--leise); margin: 8px 0 0; }
.rechtstext h3 { font-size: 15px; margin: 18px 0 4px; }
.rechtstext p, .rechtstext li { color: var(--leise); }
.rechtstext ul { padding-left: 20px; margin: 4px 0; }
.rechtstext a, .haken a { color: var(--akzent); }
.gefahrzone { margin-top: 26px; border: 1px solid rgba(248, 113, 113, 0.5); border-radius: var(--rund); padding: 14px; }
.gefahrzone b { color: var(--schlecht); }
.drei { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.drei .knopf { flex-direction: column; min-height: 66px; gap: 2px; font-size: 13px; padding: 0 6px; }
.drei .knopf span { font-size: 20px; }
.geraet .zeile-links small { display: block; }
.marke-klein.dieses { background: rgba(184, 245, 60, 0.15); color: var(--akzent); }
.zeichnen-kopf .schalter { display: flex !important; align-items: center; gap: 8px; margin-top: 6px; font-weight: 600; cursor: pointer; }
.zeichnen-kopf .schalter input { width: 20px; min-height: 20px; accent-color: var(--akzent); }

#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 3000; background: var(--text); color: var(--grund);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; max-width: calc(100% - 32px); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
#toast.sichtbar { opacity: 1; }
