:root {
  --grund: #f4f1ec;
  --karte: #ffffff;
  --text: #1c1917;
  --leise: #78716c;
  --linie: #e7e2da;
  --akzent: #c2410c;
  --akzent-hell: #ffedd5;
  --sieg: #15803d;
  --sieg-hell: #dcfce7;
  --nieder: #b91c1c;
  --nieder-hell: #fee2e2;
  --remis: #a16207;
  --remis-hell: #fef3c7;
  --eingabe: #faf8f5;
  --schatten: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 4%);
  --oben: env(safe-area-inset-top, 0px);
  --unten: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --grund: #141210;
    --karte: #1f1c19;
    --text: #f5f5f4;
    --leise: #a8a29e;
    --linie: #34302b;
    --akzent: #fb923c;
    --akzent-hell: #3b2414;
    --sieg: #4ade80;
    --sieg-hell: #14301d;
    --nieder: #f87171;
    --nieder-hell: #3a1717;
    --remis: #fbbf24;
    --remis-hell: #382a0c;
    --eingabe: #171512;
    --schatten: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--grund);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* Kopf und Leiste */
.kopf {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--oben) + 10px) 16px 10px;
  background: var(--akzent); color: #fff;
}

.marke { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; letter-spacing: .3px; }
.kopf-rechts { display: flex; gap: 6px; align-items: center; }
.icon-knopf, .text-knopf {
  background: rgb(255 255 255 / 16%); border: 0; color: #fff; border-radius: 999px;
  height: 34px; min-width: 34px; padding: 0 12px; font-size: .9rem;
}
.icon-knopf { font-size: 1.2rem; padding: 0; }
.icon-knopf.dreht { animation: drehen 1s linear infinite; }
@keyframes drehen { to { transform: rotate(360deg); } }

.inhalt { max-width: 640px; margin: 0 auto; padding: 12px 12px calc(84px + var(--unten)); }

.leiste {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; background: var(--karte); border-top: 1px solid var(--linie);
  padding-bottom: var(--unten);
}
.leiste button {
  flex: 1; border: 0; background: none; padding: 8px 0 10px; color: var(--leise);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .8rem; position: relative;
}
.leiste button.aktiv { color: var(--akzent); font-weight: 600; }
.leiste-icon { font-size: 1.35rem; line-height: 1; }
.zaehler {
  position: absolute; top: 4px; left: calc(50% + 8px);
  background: var(--akzent); color: #fff; border-radius: 999px; font-size: .7rem; font-weight: 700;
  min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px;
}

/* Filter */
.filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; scrollbar-width: none; }
.filter::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--linie); background: var(--karte); border-radius: 999px;
  padding: 6px 12px; white-space: nowrap; font-size: .9rem;
}
.chip.aktiv { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.reiter { display: grid; grid-template-columns: 1fr 1fr; background: var(--linie); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.reiter button { border: 0; background: none; padding: 7px; border-radius: 8px; font-size: .95rem; color: var(--leise); }
.reiter button.aktiv { background: var(--karte); color: var(--text); font-weight: 600; box-shadow: var(--schatten); }

.tag { margin: 18px 4px 6px; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--leise); }
.tag:first-of-type { margin-top: 4px; }

/* Spielkarte */
.karte {
  background: var(--karte); border-radius: 14px; box-shadow: var(--schatten);
  padding: 12px 14px; margin-bottom: 10px; border: 1px solid var(--linie);
}
.karte-kopf { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; color: var(--leise); margin-bottom: 8px; }
.liga { font-weight: 700; color: var(--akzent); margin-right: 6px; }
.paarung { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.team { font-weight: 600; font-size: .98rem; overflow-wrap: anywhere; }
.team.gast { text-align: right; }
.team.unser { color: var(--akzent); }
.mitte { text-align: center; }
.endstand { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vs { color: var(--leise); font-size: .85rem; }
.hinweis { font-size: .75rem; color: var(--leise); }
.hinweis.warn { color: var(--remis); }

.tipp-zeile { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 12px 0 6px; }
.tipp-zeile input {
  width: 72px; height: 52px; text-align: center; font-size: 1.5rem; font-weight: 700;
  border: 2px solid var(--linie); border-radius: 12px; background: var(--eingabe);
  font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
.tipp-zeile input::-webkit-outer-spin-button, .tipp-zeile input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tipp-zeile input:focus { outline: none; border-color: var(--akzent); }
.tipp-zeile .doppelpunkt { font-size: 1.5rem; font-weight: 700; color: var(--leise); }
.knoepfe { display: flex; gap: 8px; margin-top: 8px; }
.knopf {
  flex: 1; border: 1px solid var(--linie); background: var(--karte); border-radius: 10px;
  padding: 10px; font-weight: 600; font-size: .95rem;
}
.knopf.haupt { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.knopf:disabled { opacity: .5; }
.knopf.klein { flex: 0 0 auto; padding: 10px 12px; color: var(--leise); }

.fest {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 10px 0 4px; padding: 8px; border-radius: 10px; background: var(--akzent-hell); font-weight: 600;
}
.fest .zahl { font-size: 1.25rem; font-variant-numeric: tabular-nums; }

.status-liste { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: .85rem; color: var(--leise); }
.status-liste .ok { color: var(--sieg); }

/* Auswertung im Spiel */
.auswertung { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .92rem; }
.auswertung td { padding: 6px 4px; border-top: 1px solid var(--linie); }
.auswertung td.zahl { text-align: right; font-variant-numeric: tabular-nums; }
.auswertung tr.ich td:first-child { font-weight: 700; }
.marke-erg { display: inline-block; min-width: 26px; text-align: center; border-radius: 6px; padding: 1px 6px; font-weight: 700; font-size: .8rem; }
.erg-S { background: var(--sieg-hell); color: var(--sieg); }
.erg-N { background: var(--nieder-hell); color: var(--nieder); }
.erg-U { background: var(--remis-hell); color: var(--remis); }

/* Stand */
.duell { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; text-align: center; padding: 18px 10px; }
.duell .name { font-weight: 700; font-size: 1.05rem; }
.duell .siege { font-size: 3rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.duell .fuehrt .siege { color: var(--akzent); }
.duell .trenner { font-size: 2rem; color: var(--leise); padding: 0 8px; }
.duell .klein { font-size: .8rem; color: var(--leise); margin-top: 4px; }
.tabelle { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabelle th { text-align: right; font-weight: 600; font-size: .75rem; color: var(--leise); padding: 4px; }
.tabelle th:first-child, .tabelle td:first-child { text-align: left; }
.tabelle td { text-align: right; padding: 7px 4px; border-top: 1px solid var(--linie); font-variant-numeric: tabular-nums; }
.tabelle tr.ich td { font-weight: 700; }
h2 { font-size: 1rem; margin: 18px 4px 8px; }
.erklaerung { font-size: .82rem; color: var(--leise); margin: 14px 4px; }
.erklaerung p { margin: 4px 0; }

/* Login */
.login { max-width: 360px; margin: 8vh auto 0; text-align: center; }
.login h1 { font-size: 1.4rem; margin: 12px 0 4px; }
.login p { color: var(--leise); margin: 0 0 20px; }
.login .wahl { display: grid; gap: 10px; }
.login .wahl button { padding: 16px; font-size: 1.1rem; font-weight: 600; border-radius: 14px; border: 1px solid var(--linie); background: var(--karte); box-shadow: var(--schatten); }
.login input {
  width: 100%; text-align: center; font-size: 1.6rem; letter-spacing: 8px; padding: 12px;
  border-radius: 12px; border: 2px solid var(--linie); background: var(--eingabe); margin: 8px 0 12px;
}
.login input:focus { outline: none; border-color: var(--akzent); }
.login input::placeholder { letter-spacing: normal; font-size: 1rem; }
.login .knopf { width: 100%; padding: 14px; }
.link { background: none; border: 0; color: var(--leise); text-decoration: underline; margin-top: 14px; }

.leer { text-align: center; color: var(--leise); padding: 40px 16px; }
.fuss { text-align: center; font-size: .75rem; color: var(--leise); margin: 18px 0 0; }

.meldung {
  position: fixed; left: 50%; bottom: calc(76px + var(--unten)); transform: translateX(-50%); z-index: 10;
  background: #292524; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem;
  max-width: calc(100% - 32px); box-shadow: 0 4px 16px rgb(0 0 0 / 25%);
}
.meldung.fehler { background: #991b1b; }

/* Dunkelmodus: Kopf dunkler, dunkle Schrift auf hellem Orange (Kontrast) */
@media (prefers-color-scheme: dark) {
  .kopf { background: #7c2d12; }
  .knopf.haupt, .chip.aktiv, .zaehler { color: #1c1917; }
}

/* ---------- Tabelle und Tipp-Hilfe ---------- */
.form-zeile { margin-top: 10px; border-top: 1px solid var(--linie); padding-top: 6px; text-align: center; }
.link-knopf { background: none; border: 0; color: var(--akzent); font-size: .88rem; font-weight: 600; padding: 6px 8px; }
.karte-tabelle { padding: 4px 6px; }
.liga-tabelle { font-size: .84rem; }
.liga-tabelle th, .liga-tabelle td { padding: 7px 3px; }
.liga-tabelle th:nth-child(2), .liga-tabelle td.team-name { text-align: left; }
.liga-tabelle td.team-name { max-width: 0; width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liga-tabelle td.koerbe { color: var(--leise); font-size: .78rem; }
.liga-tabelle tr.unser td { color: var(--akzent); font-weight: 700; }
tr.klickbar { cursor: pointer; }
tr.klickbar:active td { background: var(--akzent-hell); }

body.blatt-offen { overflow: hidden; }
.blatt { position: fixed; inset: 0; z-index: 20; background: var(--grund); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.blatt-kopf {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 10px;
  padding: calc(var(--oben) + 10px) 12px 10px; background: var(--akzent); color: #fff;
}
.blatt-kopf h2 { margin: 0; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blatt-inhalt { max-width: 640px; margin: 0 auto; padding: 12px 12px calc(24px + var(--unten)); }
.team-block h3 { margin: 0 0 2px; font-size: 1rem; }
.serie { display: inline-flex; gap: 3px; vertical-align: middle; }
.serie .marke-erg { min-width: 20px; padding: 1px 4px; font-size: .72rem; }
.serie-zeile { margin: 8px 0 2px; font-size: .85rem; color: var(--leise); display: flex; align-items: center; gap: 8px; }
.vergleich { width: 100%; border-collapse: collapse; font-size: .9rem; }
.vergleich th { font-weight: 500; font-size: .75rem; color: var(--leise); padding: 7px 4px; white-space: nowrap; }
.vergleich td { padding: 7px 4px; border-top: 1px solid var(--linie); font-variant-numeric: tabular-nums; width: 40%; }
.vergleich thead td { border-top: 0; font-size: .85rem; }
.vergleich .links { text-align: left; }
.vergleich .rechts { text-align: right; }
.vergleich tbody tr td.rechts .serie { justify-content: flex-end; }
.spiel-liste { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .88rem; }
.spiel-liste td { padding: 6px 3px; border-top: 1px solid var(--linie); }
.spiel-liste td.datum { color: var(--leise); width: 3.4em; font-variant-numeric: tabular-nums; }
.spiel-liste td.ort { color: var(--leise); width: 1.4em; text-align: center; font-size: .78rem; }
.spiel-liste td.gegner.unser { color: var(--akzent); font-weight: 600; }
.spiel-liste td.zahl { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (prefers-color-scheme: dark) { .blatt-kopf { background: #7c2d12; } }

/* ---------- Vereinslogos (v1.3) ---------- */
.logo {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; position: relative;
  width: 22px; height: 22px; border-radius: 6px; background: #fff; overflow: hidden; vertical-align: middle;
  border: 1px solid var(--linie);
}
.logo img { width: 100%; height: 100%; object-fit: contain; padding: 1px; }
.logo.ohne img { display: none; }
.logo.ohne { background: var(--akzent-hell); }
.logo.ohne::before {
  content: attr(data-k); font-size: .5rem; font-weight: 800; letter-spacing: -.2px; color: var(--akzent); line-height: 1;
}
.logo.gross { width: 40px; height: 40px; border-radius: 10px; }
.logo.gross.ohne::before { font-size: .72rem; }
.logo.klein { width: 20px; height: 20px; margin-right: 6px; }
.paarung .team { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.paarung .team.gast { align-items: flex-end; }
.vergleich thead .logo { display: flex; margin-bottom: 6px; }
.vergleich thead .rechts .logo { margin-left: auto; }
.team-titel { display: flex; align-items: center; gap: 10px; }

/* ---------- Tipp-Statistik (v1.3) ---------- */
.spieler-wahl .chip { font-weight: 600; }
.kacheln { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 10px; }
.kachel {
  background: var(--karte); border: 1px solid var(--linie); border-radius: 12px; box-shadow: var(--schatten);
  padding: 10px 6px; text-align: center;
}
.kachel .wert { font-size: 1.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kachel .klein { font-size: .72rem; color: var(--leise); margin-top: 2px; }
.blatt-inhalt h3 { font-size: .95rem; margin: 16px 4px 6px; }
.tipp-liste { list-style: none; margin: 0; padding: 0; }
.tipp-eintrag {
  background: var(--karte); border: 1px solid var(--linie); border-radius: 12px; padding: 8px 12px; margin-bottom: 6px;
}
.te-kopf { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; color: var(--leise); }
.te-rechts { display: inline-flex; gap: 6px; align-items: center; }
.te-rechts .abw { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.te-spiel { font-weight: 600; font-size: .92rem; margin: 3px 0; }
.te-spiel .unser { color: var(--akzent); }
.te-zahlen { display: flex; gap: 16px; font-size: .85rem; color: var(--leise); font-variant-numeric: tabular-nums; }
.te-zahlen b { color: var(--text); }

/* ---------- Spielregeln (v1.3) ---------- */
.regeln .karte h3 { margin: 0 0 6px; font-size: 1rem; }
.regeln ul { margin: 0; padding-left: 18px; }
.regeln li { margin: 4px 0; font-size: .92rem; line-height: 1.4; }
.regeln p { margin: 4px 0; font-size: .92rem; line-height: 1.4; }
.regeln .beispiel {
  background: var(--akzent-hell); border-radius: 8px; padding: 6px 10px; margin: 8px 0;
  font-variant-numeric: tabular-nums;
}
