:root {
  --bg: #f2f5f4;
  --flaeche: #ffffff;
  --flaeche-2: #e8eeec;
  --rand: #d3dcd9;
  --text: #15201d;
  --text-2: #5a6a66;
  --akzent: #1f6f5c;          /* Hallenboden-Grün */
  --akzent-text: #ffffff;
  --akzent-hell: #dcefe9;
  --markiert: #fff4c2;        /* hervorgehobene Spieler */
  --markiert-text: #5c4300;
  --sieg: #1f7a45;
  --live: #d4332a;
  --warn: #9a5b00;
  --gefahr: #b3261e;
  --schatten: 0 1px 2px rgba(15, 40, 35, .06), 0 3px 12px rgba(15, 40, 35, .06);
  --radius: 12px;
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tabbar: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513; --flaeche: #18201e; --flaeche-2: #212b28; --rand: #2f3b38;
    --text: #e4ece9; --text-2: #97a8a3; --akzent: #5cc4a6; --akzent-text: #062019; --akzent-hell: #183a31;
    --markiert: #3d3414; --markiert-text: #f5dc85;
    --sieg: #6cd396; --live: #ff6b61; --warn: #e6a74a; --gefahr: #f08a80;
    --schatten: 0 1px 2px rgba(0, 0, 0, .3), 0 3px 12px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--schrift); -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
a { color: var(--akzent); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
.klein { font-size: .85em; color: var(--text-2); }
.leer { color: var(--text-2); padding: 2rem 0; text-align: center; }
.fehler { color: var(--gefahr); }
.zahl { font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
.zeile { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ---------- Kopf und Tab-Leiste ---------- */
.kopf {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--flaeche); border-bottom: 1px solid var(--rand);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; }
.logo img { border-radius: 8px; flex: none; }
.logo span { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.logo small { color: var(--text-2); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 2px; margin-left: auto; }
.tabs a {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px;
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
.tabs a svg { width: 20px; height: 20px; }
.tabs a.aktiv { color: var(--akzent); background: var(--akzent-hell); }
.tabs a.aus { opacity: .4; pointer-events: none; }

@media (max-width: 760px) {
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0;
    height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--flaeche); border-top: 1px solid var(--rand); justify-content: space-around;
  }
  .tabs a { flex-direction: column; gap: 2px; font-size: .72rem; padding: 8px 4px; flex: 1; justify-content: center; border-radius: 0; }
  .tabs a.aktiv { background: none; }
  .inhalt { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px) !important; }
}

.inhalt { max-width: 860px; margin: 0 auto; padding: 16px; }

/* ---------- Bedienelemente ---------- */
button, .knopf {
  font: inherit; border: 1px solid var(--rand); background: var(--flaeche); color: var(--text);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover { border-color: var(--text-2); }
button.primaer { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); font-weight: 600; }
button.gefahr { color: var(--gefahr); }
button.flach { border-color: transparent; background: none; }
button:disabled { opacity: .5; cursor: default; }
button svg { width: 18px; height: 18px; }
input, select {
  font: inherit; color: var(--text); background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--akzent); outline-offset: -1px; }
label { display: block; font-size: .85rem; color: var(--text-2); margin-bottom: .75rem; }
label input, label select { margin-top: 4px; }

.karte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); box-shadow: var(--schatten); padding: 14px 16px; margin-bottom: 12px; }

/* Segment-Umschalter */
.segment { display: inline-flex; background: var(--flaeche-2); border-radius: 9px; padding: 3px; gap: 2px; }
.segment button { border: 0; background: none; padding: 5px 11px; border-radius: 7px; color: var(--text-2); font-size: .9rem; }
.segment button.aktiv { background: var(--flaeche); color: var(--text); box-shadow: var(--schatten); font-weight: 600; }

/* Chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; border-radius: 99px;
  padding: 4px 11px; font-size: .85rem; border: 1px solid var(--rand); background: var(--flaeche); color: var(--text); cursor: pointer;
}
.chip.an { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.chip.gespeichert { border-style: dashed; }
.chip .x { opacity: .7; font-size: 1.05em; line-height: 1; }
.chip svg { width: 14px; height: 14px; }

/* ---------- Turnierliste ---------- */
.turnier { display: block; text-decoration: none; color: var(--text); }
.turnier:hover { border-color: var(--akzent); }
.turnier h3 { margin-bottom: 2px; }
.turnier .fortschritt { height: 4px; background: var(--flaeche-2); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.turnier .fortschritt i { display: block; height: 100%; background: var(--akzent); }
.live-badge { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 700; color: var(--live); text-transform: uppercase; letter-spacing: .03em; }
.live-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: puls 1.6s infinite; }
@keyframes puls { 50% { opacity: .3; } }

/* ---------- Filterleiste ---------- */
.filterleiste {
  position: sticky; top: 57px; z-index: 10; background: var(--bg); padding: 8px 0 10px; margin: -8px 0 4px;
  display: flex; flex-direction: column; gap: 8px;
}
.suchzeile { display: flex; gap: 8px; }
.suchzeile input { flex: 1; }
.filter-knopf { position: relative; }
.filter-knopf .zaehler {
  background: var(--akzent); color: var(--akzent-text); border-radius: 99px; font-size: .72rem; font-weight: 700;
  min-width: 18px; height: 18px; display: inline-grid; place-items: center; padding: 0 5px;
}
.stand { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--text-2); }

/* ---------- Spielerübersicht über der Liste ---------- */
.uebersicht { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-bottom: 12px; }
.ue-spieler { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); padding: 10px 12px; }
.ue-spieler b { display: block; }
.ue-spieler .bilanz { font-variant-numeric: tabular-nums; }
.ue-spieler .naechstes { margin-top: 4px; font-size: .85rem; color: var(--akzent); font-weight: 600; }

/* ---------- Spielliste ---------- */
.tag-kopf { font-weight: 700; margin: 18px 0 6px; font-size: 1.05rem; }
.zeit-kopf {
  display: flex; align-items: center; gap: 8px; margin: 14px 0 6px; font-size: .85rem; font-weight: 700; color: var(--text-2);
}
.zeit-kopf::after { content: ""; flex: 1; height: 1px; background: var(--rand); }
.spiel {
  background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); margin-bottom: 8px;
  box-shadow: var(--schatten); overflow: hidden;
}
.spiel.live { border-color: var(--live); box-shadow: 0 0 0 1px var(--live), var(--schatten); }
.spiel-kopf { display: flex; gap: 8px; align-items: center; padding: 7px 12px 0; font-size: .8rem; color: var(--text-2); flex-wrap: wrap; }
.spiel-kopf .bewerb { font-weight: 700; color: var(--text); }
.spiel-kopf .status { margin-left: auto; font-weight: 600; }
.spiel-kopf a.extern { color: inherit; text-decoration: none; display: inline-flex; gap: 8px; align-items: center; }
.spiel-kopf a.extern:hover .bewerb, .spiel-kopf a.h2h:hover { text-decoration: underline; }
.spiel-kopf .pfeil { color: var(--akzent); font-size: .9em; margin-left: -4px; }
.spiel-kopf a.h2h { color: var(--akzent); font-weight: 600; }
.spiel-kopf .rechts { margin-left: auto; display: inline-flex; gap: 10px; align-items: center; }
.spiel-kopf .rechts .status { margin-left: 0; }
a.chip { text-decoration: none; }
.status.wo, .status.abgesagt { color: var(--warn); }
.status.geplant { color: var(--text-2); }
.spiel-koerper { padding: 4px 12px 8px; }
.team { display: flex; align-items: center; gap: 6px; padding: 4px 0; min-width: 0; }
.team + .team { border-top: 1px dashed var(--rand); }
.team .namen { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.team .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: inherit; text-decoration: none; align-self: flex-start; max-width: 100%; }
a.name:hover { text-decoration: underline; }
.punkte { display: flex; gap: 2px; font-variant-numeric: tabular-nums; flex: none; }
.punkte span { min-width: 28px; text-align: center; color: var(--text-2); font-size: 1.02rem; }
.punkte span.gew { color: var(--text); font-weight: 700; }
.team .verein { font-size: .75rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team.sieger .name { font-weight: 700; }
.team.verlierer { color: var(--text-2); }
.team .haken { color: var(--sieg); width: 16px; flex: none; font-weight: 700; }
.team .platzhalter { color: var(--text-2); font-style: italic; }
.name.markiert { background: var(--markiert); color: var(--markiert-text); border-radius: 4px; padding: 0 4px; margin: 0 -4px; }
.name .setz { font-size: .75em; color: var(--text-2); margin-left: 3px; }
.spiel-fuss { padding: 0 12px 8px; font-size: .78rem; color: var(--text-2); display: flex; gap: 10px; }

.jetzt-knopf { position: fixed; right: 16px; bottom: 20px; z-index: 25; box-shadow: var(--schatten); border-radius: 99px; }
@media (max-width: 760px) { .jetzt-knopf { bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 14px); } }

/* ---------- Bewerbe: Tabellen, Platzierungen ---------- */
details.bewerb { padding: 0; }
details.bewerb > summary { padding: 12px 16px; cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; gap: 4px; align-items: baseline; }
details.bewerb > summary::-webkit-details-marker { display: none; }
details.bewerb > summary::before { content: "▸"; color: var(--text-2); width: 14px; }
details.bewerb[open] > summary::before { content: "▾"; }
details.bewerb[open] > summary { border-bottom: 1px solid var(--rand); }
.draw { padding: 10px 16px 6px; }
.draw + .draw { border-top: 1px dashed var(--rand); }
.draw h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); margin-bottom: 6px; }
.extern-klein { text-decoration: none; font-weight: 400; color: var(--akzent); }
.gtab { width: 100%; border-collapse: collapse; font-size: .9rem; margin-bottom: 6px; }
.gtab th { font-size: .72rem; color: var(--text-2); text-align: left; font-weight: 600; padding: 2px 4px; }
.gtab td { padding: 5px 4px; border-top: 1px solid var(--rand); vertical-align: top; }
.gtab td.zahl, .gtab th:nth-child(n+3) { text-align: right; white-space: nowrap; }
.gtab .namen-zeile { display: block; }
.gtab .verein, .platz-team .verein { display: block; font-size: .75rem; color: var(--text-2); }
.markiert-zeile { background: var(--markiert); }
.markiert-zeile, .markiert-zeile .verein { color: var(--markiert-text); }
.namen-zeile a.name, .k-namen a.name, .platz-team a.name { color: inherit; text-decoration: none; }
.namen-zeile a.name.markiert, .k-namen a.name.markiert { padding: 0 3px; margin: 0; }
.plaetze { display: flex; flex-direction: column; gap: 2px; }
.platz-zeile { display: flex; gap: 10px; padding: 4px 6px; border-radius: 6px; }
.platz-nr { min-width: 58px; white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.kompakt { border: 1px solid var(--rand); border-radius: 8px; padding: 5px 8px; margin-bottom: 6px; background: var(--flaeche); }
.k-kopf { font-size: .75rem; color: var(--text-2); margin-bottom: 2px; }
.k-team { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.k-team .k-namen { flex: 1; min-width: 0; }
.k-team.sieger { font-weight: 700; }
.k-team.verlierer { color: var(--text-2); }
.klein-punkte span { min-width: 22px; font-size: .9rem; }
.platzhalter { color: var(--text-2); font-style: italic; }

/* ---------- Feldbelegung ---------- */
.felder { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.feld-karte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); padding: 8px 10px; box-shadow: var(--schatten); }
.feld-karte.belegt { border-color: var(--akzent); }
.feld-karte.markiert-karte { box-shadow: 0 0 0 2px var(--markiert-text), var(--schatten); }
.feld-kopf { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.feld-karte .zuletzt { opacity: .75; }
.feld-karte .zuletzt .kompakt { margin-bottom: 0; }

/* ---------- Spielerliste ---------- */
.liste { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); overflow: hidden; }
.liste-zeile { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--rand); }
.liste-zeile:first-child { border-top: 0; }
.liste-zeile .haupt { flex: 1; min-width: 0; cursor: pointer; }
.liste-zeile .haupt b { font-weight: 600; }
.liste-gruppe { padding: 6px 12px; font-size: .78rem; font-weight: 700; color: var(--text-2); background: var(--flaeche-2); text-transform: uppercase; letter-spacing: .03em; }
.stern { border: 0; background: none; padding: 4px; color: var(--text-2); }
.stern.an { color: #e0a800; }
.stern svg { width: 22px; height: 22px; }
.bilanz-mini { font-size: .82rem; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Dialog ---------- */
.dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px);
  background: var(--flaeche); color: var(--text); box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
.dialog::backdrop { background: rgba(10, 20, 18, .45); }
.dialog-kopf { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--rand); position: sticky; top: 0; background: var(--flaeche); z-index: 1; }
.dialog-kopf h2 { margin: 0; flex: 1; }
.dialog-inhalt { padding: 14px 16px; }
.dialog-fuss { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--rand); position: sticky; bottom: 0; background: var(--flaeche); }
.abschnitt { margin-bottom: 16px; }
.abschnitt h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin-bottom: 8px; }
.auswahl-liste { max-height: 260px; overflow-y: auto; border: 1px solid var(--rand); border-radius: 8px; margin-top: 8px; }
.auswahl-liste label { display: flex; align-items: center; gap: 10px; margin: 0; padding: 8px 10px; border-top: 1px solid var(--rand); color: var(--text); font-size: .95rem; cursor: pointer; }
.auswahl-liste label:first-child { border-top: 0; }
.auswahl-liste input { width: auto; margin: 0; accent-color: var(--akzent); }

/* ---------- Meldung ---------- */
.meldung {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--schatten); max-width: calc(100vw - 32px);
}
@media (max-width: 760px) { .meldung { bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px); } }
.meldung.fehler { background: var(--gefahr); color: #fff; }

table.tabelle { width: 100%; border-collapse: collapse; }
.tabelle td, .tabelle th { padding: 8px 6px; border-top: 1px solid var(--rand); text-align: left; vertical-align: middle; }
.tabelle th { font-size: .8rem; color: var(--text-2); border-top: 0; }
.markiert-zeile a.name.markiert { background: none; padding: 0; margin: 0; }
.schalter { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: .9rem; cursor: pointer; }
.schalter input { width: auto; margin: 0; accent-color: var(--akzent); }
