/* RENNPAPPE – Oberfläche. Mobil zuerst (Eingabe an den Stationen per Handy). */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --papier: #f4efe4;
  --karte: #fffdf8;
  --tinte: #1c2220;
  --grau: #676d68;
  --linie: #e2d9c6;
  --linie-hell: #eee7d9;
  --feld-rand: #cdc3ae;

  --gruen: #1e5a3c;
  --gruen-h: #164630;
  --gruen-soft: #e6f0e9;

  --rot: #b42318;
  --rot-h: #912018;
  --rot-soft: #fef2f2;
  --rot-rand: #fecaca;

  --bernstein: #d99a1e;
  --blau-soft: #eff6ff;
  --blau-rand: #bfdbfe;
  --blau-text: #1e3a8a;

  --gold-soft: #fff4cc;
  --gold-rand: #ecd27a;

  --r: .75rem;
  --r-klein: .6rem;
  --kopf-h: 64px;
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papier);
  color: var(--tinte);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
[hidden] { display: none !important; }
h1 { font-size: 1.35rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .9rem; }
a { color: var(--gruen); }
code { background: #efe8da; padding: .05rem .35rem; border-radius: .3rem; font-size: .9em; }
.leise { color: var(--grau); }
.zahlen { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ Kopf */
.kopf {
  position: sticky; top: 0; z-index: 30;
  background: var(--tinte); color: #fff;
  padding-top: env(safe-area-inset-top);
}
.kopf-innen {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  min-height: 56px; padding: .5rem 1rem;
}
.marke { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.marke-wort { font-weight: 900; font-style: italic; letter-spacing: .16em; font-size: 1.15rem; }
.marke-event { font-size: .8rem; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf-rechts { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.zielflagge {
  height: 8px;
  background: conic-gradient(#fff 25%, var(--tinte) 0 50%, #fff 0 75%, var(--tinte) 0) 0 0 / 16px 16px;
}

.verbindung {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .78rem; padding: .3rem .6rem; border-radius: .5rem;
  background: rgba(255, 255, 255, .1); white-space: nowrap;
}
.punkt { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; animation: puls 2s infinite; }
.verbindung.offline { background: rgba(248, 113, 113, .22); }
.verbindung.offline .punkt { background: #f87171; animation: none; }
@keyframes puls { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.knopf-kopf {
  min-height: 44px; padding: 0 .8rem; border-radius: var(--r-klein);
  background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .3);
  font: inherit; font-size: .85rem; cursor: pointer;
}

/* ------------------------------------------------------------ Navigation */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--karte); border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 16px rgba(28, 34, 32, .06);
}
.tabs a {
  position: relative;
  min-height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--grau); text-decoration: none; font-size: .75rem; font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}
.tabs svg { width: 24px; height: 24px; }
.tabs a.aktiv { color: var(--gruen); }
.tabs a.aktiv::before {
  content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px;
  background: var(--gruen); border-radius: 0 0 3px 3px;
}

.inhalt { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem calc(90px + env(safe-area-inset-bottom)); }

@media (min-width: 760px) {
  .tabs {
    position: static; box-shadow: none; border: 0; background: transparent;
    display: flex; gap: .4rem; max-width: 1100px; margin: 0 auto; padding: 1rem 1rem 0;
  }
  .tabs a { flex-direction: row; min-height: 48px; padding: 0 1.1rem; border-radius: var(--r-klein); font-size: .95rem; gap: .5rem; }
  .tabs svg { width: 20px; height: 20px; }
  .tabs a:hover { background: #ebe4d5; }
  .tabs a.aktiv { background: var(--gruen); color: #fff; }
  .tabs a.aktiv::before { display: none; }
  .inhalt { padding-bottom: 3rem; }
}

/* ------------------------------------------------------------ Bausteine */
.ansicht-kopf {
  display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  margin: .25rem 0 1rem;
}
.stand { color: var(--grau); font-size: .85rem; }

.karte {
  background: var(--karte); border: 1px solid var(--linie); border-radius: var(--r);
  padding: 1rem; margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(28, 34, 32, .04);
  scroll-margin-top: calc(var(--kopf-h) + 1rem);
}

.feld { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; min-width: 0; }
.feld > span { font-size: .85rem; font-weight: 600; color: var(--grau); }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--tinte);
  min-height: 48px; padding: .6rem .8rem;
  background: #fff; border: 1px solid var(--feld-rand); border-radius: var(--r-klein);
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gruen); outline-offset: 0; border-color: var(--gruen); }

.raster { display: grid; grid-template-columns: 1fr; gap: 0 .75rem; }
@media (min-width: 560px) { .raster { grid-template-columns: 9rem 1fr; } }
@media (min-width: 900px) { .raster { grid-template-columns: 8rem 1fr 1fr 1fr; } }

.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 52px; padding: 0 1.25rem; border-radius: var(--r-klein);
  font: inherit; font-weight: 700; border: 1px solid transparent; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.knopf:disabled { opacity: .55; cursor: default; }
.knopf-primaer { background: var(--gruen); color: #fff; }
.knopf-primaer:hover { background: var(--gruen-h); }
.knopf-sekundaer { background: #fff; color: var(--tinte); border-color: var(--feld-rand); }
.knopf-sekundaer:hover { background: #f7f2e8; }
.knopf-gefahr { background: var(--rot); color: #fff; }
.knopf-gefahr:hover { background: var(--rot-h); }
.knopf-breit { width: 100%; min-height: 56px; }
.knopf-reihe { display: flex; gap: .6rem; flex-wrap: wrap; }
.knopf-reihe-rechts { justify-content: flex-end; }

.icon-knopf {
  width: 44px; height: 44px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; color: var(--tinte); border: 1px solid var(--linie); border-radius: var(--r-klein);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.icon-knopf svg { width: 20px; height: 20px; }
.icon-knopf:hover { background: #f7f2e8; }
.icon-knopf:disabled { opacity: .3; cursor: default; }
.icon-knopf.gefahr { color: var(--rot); }

.hinweis { border-radius: var(--r); padding: .75rem 1rem; margin-bottom: 1rem; font-size: .95rem; }
.hinweis-blau { background: var(--blau-soft); border: 1px solid var(--blau-rand); color: var(--blau-text); }
.fehler {
  background: var(--rot-soft); border: 1px solid var(--rot-rand); color: var(--rot);
  border-radius: var(--r); padding: .65rem .9rem; margin: 0 0 .85rem; font-size: .92rem; white-space: pre-line;
}
.leer {
  text-align: center; color: var(--grau); padding: 2rem 1rem;
  background: var(--karte); border: 1px dashed var(--feld-rand); border-radius: var(--r);
}

.suche { margin-bottom: .75rem; }
.suche input { background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23676d68' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") no-repeat .8rem center / 18px; padding-left: 2.5rem; }

.startnr {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.1em; padding: .05rem .4rem;
  background: #fff; color: var(--tinte); border: 2px solid var(--tinte); border-radius: .45rem;
  font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.3;
}
.startnr-gross { min-width: 2.9rem; height: 2.9rem; font-size: 1.05rem; border-radius: 50%; padding: 0 .2rem; }

.abzeichen {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  padding: .1rem .45rem; border-radius: .35rem; background: var(--gruen-soft); color: var(--gruen);
  vertical-align: middle;
}

/* Aufklapper (≥56px Tapfläche, eigener Pfeil) */
.aufklapper { padding: 0; }
.aufklapper > summary {
  list-style: none; cursor: pointer; min-height: 56px; display: flex; align-items: center; gap: .6rem;
  padding: 0 1rem; font-weight: 700;
}
.aufklapper > summary::-webkit-details-marker { display: none; }
.aufklapper > summary::before {
  content: "›"; color: var(--gruen); font-size: 1.5rem; line-height: 1; transition: transform .15s;
}
.aufklapper[open] > summary::before { transform: rotate(90deg); }
.aufklapper > form { padding: 0 1rem 1rem; }
.aufklapper textarea { margin-bottom: .85rem; }

/* Listen (Teilnehmer, Stationen) */
.liste { list-style: none; margin: 0; padding: 0; background: var(--karte); border: 1px solid var(--linie); border-radius: var(--r); overflow: hidden; }
.liste:empty { display: none; }
.zeile { display: flex; align-items: center; gap: .75rem; padding: .7rem .8rem; min-height: 64px; border-bottom: 1px solid var(--linie-hell); }
.zeile:last-child { border-bottom: 0; }
.zeile.in-bearbeitung { background: var(--gruen-soft); }
.zeile-text { flex: 1; min-width: 0; }
.zeile-text .leise { font-size: .88rem; overflow-wrap: anywhere; }
.zeile-knoepfe { display: flex; gap: .4rem; flex-shrink: 0; }
.liste .leer { border: 0; border-radius: 0; }
@media (max-width: 559px) {
  .zeile-2reihig { flex-wrap: wrap; }
  .zeile-2reihig .zeile-knoepfe { width: 100%; justify-content: flex-end; }
}

/* ------------------------------------------------------------ Rangliste */
.nur-schmal { }
@media (max-width: 759px) { .nur-breit { display: none !important; } }
@media (min-width: 760px) { .nur-schmal { display: none !important; } }

.tabelle-rahmen { overflow-x: auto; background: var(--karte); border: 1px solid var(--linie); border-radius: var(--r); margin-bottom: 1rem; }
.rang-tabelle { width: 100%; border-collapse: collapse; }
.rang-tabelle th {
  text-align: left; font-size: .78rem; color: var(--grau); font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: .75rem .7rem; border-bottom: 1px solid var(--linie); white-space: nowrap;
}
.rang-tabelle td { padding: .65rem .7rem; border-bottom: 1px solid var(--linie-hell); vertical-align: middle; }
.rang-tabelle tr:last-child td { border-bottom: 0; }
.rang-tabelle .c { text-align: center; width: 3.5rem; }
.rang-tabelle .r { text-align: right; }
.rang-tabelle .st-kopf { max-width: 8.5rem; overflow: hidden; text-overflow: ellipsis; }
.rang-tabelle .gesamt { font-weight: 900; font-size: 1.15rem; }
.rang-tabelle tr.ist-fuehrend td { background: var(--gold-soft); }
.rang-tabelle td.leise { font-size: .9rem; }
.medaille { font-size: 1.5rem; line-height: 1; }
.platz-nr { font-weight: 800; color: var(--grau); }
.kein-wert { color: #b4ab98; }

.rang-karten { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; }
.rang-karte {
  display: grid; grid-template-columns: 2.6rem minmax(0, 1fr) auto; gap: .6rem; align-items: center;
  background: var(--karte); border: 1px solid var(--linie); border-radius: var(--r); padding: .7rem .8rem;
}
.rang-karte.ist-fuehrend { background: var(--gold-soft); border-color: var(--gold-rand); box-shadow: 0 2px 10px rgba(201, 154, 6, .15); }
.rk-platz { text-align: center; }
.rk-platz .medaille { font-size: 1.8rem; }
.rk-platz .platz-nr { font-size: 1.15rem; }
.rk-name { display: flex; align-items: center; gap: .45rem; min-width: 0; }
.rk-name strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-name .startnr { font-size: .85rem; flex-shrink: 0; }
.rk-unter { color: var(--grau); font-size: .85rem; margin-top: .1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-stationen {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(3.2rem, 1fr)); gap: .3rem;
}
.chip {
  display: flex; align-items: baseline; justify-content: center; gap: .35rem;
  background: #efe8da; border-radius: .4rem; padding: .2rem .35rem; font-size: .85rem;
}
.rang-karte.ist-fuehrend .chip { background: rgba(255, 255, 255, .7); }
.chip i { font-style: normal; font-size: .72rem; font-weight: 700; color: var(--grau); }
.chip b { font-variant-numeric: tabular-nums; }
.rk-legende {
  display: flex; flex-wrap: wrap; gap: .25rem .9rem; margin: 0 0 .75rem;
  font-size: .8rem; color: var(--grau);
}
.rk-legende b {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.25rem; height: 1.25rem; border-radius: .3rem; background: #e6dfcf; color: var(--tinte); font-size: .72rem;
}
.rk-gesamt { text-align: right; line-height: 1.05; }
.rk-gesamt b { display: block; font-size: 1.7rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.rk-gesamt span { font-size: .7rem; color: var(--grau); text-transform: uppercase; letter-spacing: .05em; }

.oeffentlich { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.oeffentlich-text { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.oeffentlich-text a { overflow-wrap: anywhere; }

/* ------------------------------------------------------------ Ergebnisse eintragen */
.stationswahl { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.st-wahl {
  min-height: 60px; padding: .45rem .8rem; text-align: left;
  display: flex; flex-direction: column; justify-content: center; gap: .1rem;
  background: #fff; color: var(--tinte); border: 1px solid var(--feld-rand); border-radius: var(--r-klein);
  font: inherit; font-weight: 700; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.st-wahl span { line-height: 1.2; overflow-wrap: anywhere; }
.st-wahl small { font-weight: 500; font-size: .76rem; color: var(--grau); }
.st-wahl.aktiv { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.st-wahl.aktiv small { color: rgba(255, 255, 255, .8); }

.erg-liste { list-style: none; margin: 0; padding: 0; background: var(--karte); border: 1px solid var(--linie); border-radius: var(--r); overflow: hidden; }
.erg-zeile {
  display: grid; grid-template-columns: 2.9rem minmax(0, 1fr) 5.2rem 3rem; gap: .5rem; align-items: center;
  padding: .6rem .7rem; border-bottom: 1px solid var(--linie-hell); min-height: 68px;
}
.erg-zeile:last-child { border-bottom: 0; }
.erg-name { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.erg-name strong, .erg-name .leise { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.erg-name .leise { font-size: .82rem; }
.erg-eingabe { position: relative; }
.erg-wert {
  min-height: 52px; text-align: right; font-size: 1.2rem; font-weight: 800;
  padding: .4rem 1.7rem .4rem .6rem; font-variant-numeric: tabular-nums;
}
.erg-status {
  position: absolute; right: .55rem; top: 50%; transform: translateY(-50%);
  font-size: .95rem; font-weight: 900; pointer-events: none;
}
.erg-punkte { text-align: center; line-height: 1.1; }
.erg-punkte b { display: block; font-size: 1.25rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.erg-punkte small { font-size: .68rem; color: var(--grau); white-space: nowrap; }
.erg-meldung { grid-column: 1 / -1; color: var(--rot); font-size: .85rem; margin-top: -.2rem; }
.erg-zeile.ist-dirty .erg-wert { border-color: var(--bernstein); }
.erg-zeile.ist-speichert .erg-status::after { content: "…"; color: var(--grau); }
.erg-zeile.ist-ok .erg-status::after { content: "✓"; color: var(--gruen); }
.erg-zeile.ist-ok .erg-wert { border-color: var(--gruen); }
.erg-zeile.ist-fehler .erg-wert { border-color: var(--rot); background: var(--rot-soft); }
.erg-zeile.ist-fehler .erg-status::after { content: "!"; color: var(--rot); }
.erg-zeile:not(.hat-wert) .erg-punkte b { color: #b4ab98; }

/* ------------------------------------------------------------ Anmeldung, Toast, Dialog */
.login { padding: 10vh 1rem 2rem; }
.login-karte { max-width: 24rem; margin: 0 auto; padding: 1.5rem; }
.login-karte h1 { margin-bottom: .3rem; }
.login-logo { display: block; width: 11rem; height: auto; margin: -.25rem auto 1rem; }
.live-titel { display: flex; align-items: center; gap: .6rem; }
.live-logo { width: 3.5rem; height: 3.5rem; flex-shrink: 0; }
.login-karte > .leise { margin: 0 0 1.25rem; }
.link-live { display: block; text-align: center; margin-top: 1.1rem; font-weight: 600; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(80px + env(safe-area-inset-bottom));
  max-width: calc(100% - 2rem); width: max-content;
  background: var(--tinte); color: #fff; padding: .75rem 1.1rem; border-radius: var(--r-klein);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25); font-weight: 600;
}
.toast.fehler-toast { background: var(--rot); }
@media (min-width: 760px) { .toast { bottom: 2rem; } }

.frage {
  border: 0; border-radius: 1rem; padding: 1.25rem; width: calc(100% - 2rem); max-width: 24rem;
  background: var(--karte); color: var(--tinte); box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}
.frage::backdrop { background: rgba(20, 24, 22, .5); }
.frage p { margin: 0 0 1.25rem; font-size: 1.02rem; }

/* ------------------------------------------------------------ Öffentliche Live-Seite */
.live-marke { display: inline-flex; align-items: center; gap: .45rem; font-weight: 900; letter-spacing: .1em; font-size: .85rem; padding: .35rem .7rem; border-radius: .5rem; background: var(--rot); }
.live-marke .punkt { background: #fff; }
.live-marke.offline { background: #6b716d; }
.live-marke.offline .punkt { animation: none; }
.inhalt-live { padding-bottom: 2.5rem; }
.fuss { text-align: center; color: var(--grau); font-size: .8rem; padding: 0 1rem 2rem; }
@media (min-width: 1200px) {
  .live-seite .rang-tabelle td { font-size: 1.1rem; padding: .8rem .8rem; }
  .live-seite .inhalt { max-width: 1400px; }
}
