/* Startpasskontrolle – mobile first. Main use: phone at the venue, often outdoors. */
:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --text: #14171a;
  --muted: #5a636d;
  --line: #d9dde2;
  --accent: #0b5cad;
  --accent-soft: #e2edf9;
  --ok: #17733a;
  --ok-soft: #dcf2e3;
  --bad: #b42318;
  --bad-soft: #fde6e3;
  --warn: #7f5300;
  --warn-soft: #fff1cc;
  --podium: #6b3fa0;
  --podium-soft: #efe6fa;
  --radius: 12px;
  --tap: 48px;
  --nav-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101317; --card: #1a1e23; --text: #e9ebee; --muted: #9ba4ae; --line: #2d333a;
    --accent: #6aa8ec; --accent-soft: #1a2b3f; --ok: #5cc97b; --ok-soft: #163222;
    --bad: #f2867c; --bad-soft: #3c1b18; --warn: #e8b84a; --warn-soft: #382c10;
    --podium: #b995e8; --podium-soft: #2b2040;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 130px; }
body {
  margin: 0; background: var(--bg); color: var(--text); overflow-wrap: break-word;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}
body.mit-nav { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px); }
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: .1rem 0 .3rem; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 .5rem; }
h3 { font-size: 1rem; margin: 0; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.row { display: flex; gap: 6px 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.spread > * { min-width: 0; }
.stack > * + * { margin-top: 10px; }
main, .card { min-width: 0; max-width: 100%; }

/* ---------------------------------------------------------------- top bar / bottom nav */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.topbar .wrap { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); margin-right: auto; }
.topnav { display: none; gap: 2px; align-items: center; }
.topnav a, .linkbtn {
  padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--text); background: none;
  border: 0; font: inherit; cursor: pointer;
}
.topnav a[aria-current] { background: var(--accent-soft); color: var(--accent); }
.topnav a:hover, .linkbtn:hover { background: var(--accent-soft); }

.bottomnav {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); box-shadow: 0 -2px 10px rgb(0 0 0 / .06);
}
.bottomnav > a, .bottomnav summary {
  flex: 1; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: .72rem; font-weight: 600; color: var(--muted); text-decoration: none; list-style: none; cursor: pointer;
}
.bottomnav summary::-webkit-details-marker { display: none; }
.bottomnav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bottomnav > a[aria-current] { color: var(--accent); }
.bottomnav .mehr { flex: 1; display: flex; position: relative; }
.mehr[open] summary { color: var(--accent); }
.mehr-menu {
  position: absolute; right: 8px; bottom: calc(100% + 8px); min-width: 230px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; box-shadow: 0 6px 24px rgb(0 0 0 / .18);
}
.mehr-menu > * { display: block; width: 100%; text-align: left; padding: 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.mehr-menu .small { padding: 6px 12px; }
.mehr-menu form { padding: 0; }
.mehr-menu .linkbtn { width: 100%; text-align: left; padding: 12px; color: var(--bad); }

@media (min-width: 760px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  body.mit-nav { padding-bottom: 48px; }
  .wrap { padding: 0 20px; }
}

/* ---------------------------------------------------------------- generic */
.crumbs { font-size: .9rem; margin: 12px 0 2px; }
.crumbs a { color: var(--muted); text-decoration: none; display: inline-block; padding: 4px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.karte-link { display: block; text-decoration: none; color: inherit; }
.karte-link:active { background: var(--accent-soft); }
.karte-link.vorbei { opacity: .7; }
.naechster { display: block; text-decoration: none; color: inherit; border: 2px solid var(--accent); }
.naechster h2 { margin: 4px 0 2px; font-size: 1.25rem; }
.naechster .btn { margin-top: 12px; width: 100%; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap);
  padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; touch-action: manipulation;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: .9rem; }
.btn.aktiv { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 16px+ font on inputs: iOS would otherwise zoom in on focus */
input[type=text], input[type=email], input[type=url], input[type=date], input[type=number], input[type=password], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-size: 16px;
}
input[type=file] { font-size: 15px; max-width: 100%; }
textarea { min-height: 70px; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .help, .errorlist { font-size: .85rem; }
.errorlist { color: var(--bad); padding-left: 18px; margin: 4px 0; }
.checks label { font-weight: 400; display: flex; align-items: center; gap: 10px; min-height: 44px; }
.checks input { width: 22px; height: 22px; }
.checks ul { list-style: none; padding: 0; margin: 0; }

.messages { list-style: none; padding: 0; margin: 12px 0; }
.messages li { padding: 12px; border-radius: 10px; margin-bottom: 6px; background: var(--accent-soft); }
.messages .success { background: var(--ok-soft); }
.messages .warning { background: var(--warn-soft); }
.messages .error { background: var(--bad-soft); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap; line-height: 1.5;
}
.badge.zufall { background: var(--accent-soft); color: var(--accent); }
.badge.podium { background: var(--podium-soft); color: var(--podium); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.info .badge, .badge.lang { white-space: normal; }

.progress { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress.done { color: var(--ok); }

/* ---------------------------------------------------------------- competition page */
.seitenkopf { padding-bottom: 6px; }
.toolbar {
  position: sticky; top: 0; z-index: 20; margin: 0 -12px; padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top)); background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.suche { display: flex; gap: 8px; }
.suche input { flex: 1; font-size: 18px; font-weight: 700; letter-spacing: .02em; }
#nr-ergebnis { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; max-height: 45vh; overflow-y: auto; }
.treffer-zeile {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text);
  font: inherit; text-align: left; cursor: pointer; touch-action: manipulation;
}
.treffer-zeile:active { background: var(--accent-soft); }
.treffer-zeile strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; min-width: 1.8em; }
.treffer-zeile .treffer-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.treffer-zeile .treffer-name span { font-weight: 600; }
.treffer-zeile .treffer-name small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.treffer-zeile > .badge, .treffer-zeile > .small { flex: none; }
.treffer-zeile.ohne { cursor: default; opacity: .75; background: transparent; border-style: dashed; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-size: .88rem; font-weight: 600; text-decoration: none; cursor: pointer; touch-action: manipulation;
}
.chip.aktiv { background: var(--bad); border-color: var(--bad); color: #fff; }
.chip-n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip-n.done { color: var(--ok); }

.liga { scroll-margin-top: 130px; }
.liga-head { margin-top: 18px; }
.liga-head h2 { margin: 0; }
.liga-links { margin: 4px 0 6px; }
.liga-links a { display: inline-block; padding: 6px 0; }

.team { padding: 0; overflow: hidden; }
.team-head { padding: 12px 14px; cursor: pointer; list-style: none; }
.team-head::-webkit-details-marker { display: none; }
.team-head h3 { font-size: 1.05rem; }
.team-head h3::before { content: "▸ "; color: var(--muted); }
.team[open] > .team-head h3::before { content: "▾ "; }
.team[open] > .team-head { border-bottom: 1px solid var(--line); }
.team-head.fertig { background: var(--ok-soft); }
.team-meta { margin-top: 4px; }

.athlet {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--line); transition: background-color .2s; position: relative;
}
.athlet:last-child { border-bottom: 0; }
.athlet.leer { display: block; }
.athlet.ok { background: color-mix(in srgb, var(--ok-soft) 60%, transparent); }
.athlet.beanstandet { background: color-mix(in srgb, var(--bad-soft) 75%, transparent); }
.athlet.speichert .aktionen { opacity: .45; }
.athlet.fehler { box-shadow: inset 4px 0 0 var(--bad); }
.athlet.treffer { outline: 3px solid var(--accent); outline-offset: -3px; animation: blink 1s ease-out 2; }
@keyframes blink { 50% { background: var(--accent-soft); } }
.athlet-name { display: flex; gap: 10px; align-items: baseline; }
.athlet .nr {
  flex: none; min-width: 2.1em; font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1;
}
.athlet .name { font-weight: 650; font-size: 1.02rem; }
.athlet .info { display: flex; flex-direction: column; gap: 2px; font-size: .85rem; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.athlet .startpass { font-size: .95rem; color: var(--text); font-weight: 600; letter-spacing: .01em; }
.athlet .aktionen { display: flex; gap: 8px; align-items: flex-start; }
.athlet .geprueft { grid-column: 1 / -1; font-size: .78rem; color: var(--muted); }

.tbtn {
  width: 60px; height: 56px; border-radius: 12px; border: 2px solid var(--line); background: var(--card);
  font-size: 1.6rem; font-weight: 800; cursor: pointer; color: var(--muted); touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}
.tbtn:active { transform: scale(.94); }
.tbtn.ok:not(.aktiv) { color: var(--ok); }
.tbtn.bad:not(.aktiv) { color: var(--bad); }
.tbtn.ok.aktiv { background: var(--ok); border-color: var(--ok); color: #fff; }
.tbtn.bad.aktiv { background: var(--bad); border-color: var(--bad); color: #fff; }
@media (max-width: 359px) { .tbtn { width: 52px; } .athlet { padding: 12px 10px; } }

.kommentar { grid-column: 1 / -1; }
.vorlagen { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.kommentar-frei { display: flex; gap: 8px; }
.kommentar-frei input { flex: 1; min-width: 0; }

#toast {
  position: fixed; z-index: 50; left: 12px; right: 12px; bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  max-width: 520px; margin: 0 auto; padding: 14px 16px; border-radius: 12px; font-weight: 600;
  background: var(--text); color: var(--bg); box-shadow: 0 6px 24px rgb(0 0 0 / .25);
}
#toast.fehler { background: var(--bad); color: #fff; }
@media (min-width: 760px) { #toast { bottom: 24px; } }

/* ---------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.summe td { font-weight: 700; border-top: 2px solid var(--text); }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fix { position: sticky; left: 0; background: var(--card); z-index: 1; min-width: 130px; box-shadow: 1px 0 0 var(--line); }
.diff-neu { color: var(--ok); }
.diff-weg { color: var(--bad); }
.diff-aend { color: var(--warn); }
.warnbox { background: var(--bad-soft); border: 2px solid var(--bad); border-radius: var(--radius); padding: 14px; }
details > summary { cursor: pointer; font-weight: 600; min-height: 40px; }
details.card > summary:not(.team-head) { display: flex; align-items: center; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.login { max-width: 420px; margin: 8vh auto 0; }
@media (min-width: 760px) { .toolbar { margin: 0 -20px; padding-left: 20px; padding-right: 20px; } }
