:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --line: #2b303b;
  --text: #eef0f4;
  --muted: #8d94a3;
  --accent: #e8483b;      /* Becher-Rot */
  --accent-2: #f4b13e;    /* Bier-Gold */
  --ok: #3ccf86;
  --radius: 14px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
}
button, input, select { font: inherit; color: inherit; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 10;
  padding: 14px 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.top h1 { font-size: 1.15rem; margin: 0; flex: 1; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { width: 28px; height: 28px; flex: none; }
.live-dot { font-size: .75rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live-dot.on::before { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }

main { max-width: 760px; margin: 0 auto; padding: 16px; }
section[hidden] { display: none; }
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 4px 10px; font-weight: 600; }
h2:first-child { margin-top: 4px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card + .card { margin-top: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.card-head b { font-size: 1rem; }
.pill { font-size: .72rem; padding: 3px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.live { background: color-mix(in srgb, var(--accent) 22%, transparent); color: #ff8a7f; }
.pill.done { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--accent-2) 20%, transparent); color: var(--accent-2); }

/* Tabelle */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 6px; text-align: center; }
th { white-space: nowrap; font-size: .72rem; color: var(--muted); font-weight: 600; }
td { border-top: 1px solid var(--line); }
th:nth-child(2), td:nth-child(2) { text-align: left; width: 100%; }
td:first-child, th:first-child { padding-left: 14px; width: 28px; color: var(--muted); }
td:last-child, th:last-child { padding-right: 14px; }
tr.qual td:first-child { color: var(--accent-2); font-weight: 700; }
tr.qual td:nth-child(2) { font-weight: 600; }
tr.qual td:nth-child(2)::after { content: " HF"; font-size: .65rem; color: var(--accent-2); vertical-align: 2px; }
.hide-s { display: none; }
@media (min-width: 480px) { .hide-s { display: table-cell; } }

/* Spiele */
.match { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.card > .match:first-child, .card-head + .match { border-top: 0; }
.match .meta { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; font-size: .75rem; color: var(--muted); margin-bottom: -2px; }
.team { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team.home { text-align: right; }
.team.tbd { color: var(--muted); font-style: italic; font-size: .9rem; }
.team.win { font-weight: 700; }
.team.lose { color: var(--muted); }
.score { min-width: 64px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--surface-2); border-radius: 8px; padding: 4px 8px; }
.score.empty { color: var(--muted); font-weight: 500; }
.match.is-live { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%); }

.filter { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.filter button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 7px 14px; font-size: .88rem; }
.filter button.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* K.o. */
.champion { text-align: center; padding: 22px 16px; background: radial-gradient(circle at 50% 0, color-mix(in srgb, var(--accent-2) 30%, transparent), transparent 70%), var(--surface); border-color: color-mix(in srgb, var(--accent-2) 45%, var(--line)); }
.champion .trophy { font-size: 2.4rem; }
.champion small { color: var(--accent-2); text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; }
.champion div:last-child { font-size: 1.5rem; font-weight: 800; margin-top: 4px; }

/* Tabbar */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .72rem; color: var(--muted); cursor: pointer; }
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button[aria-selected="true"] { color: var(--accent-2); }
@media (min-width: 760px) {
  .tabbar { position: sticky; top: 57px; height: auto; padding: 0; max-width: 760px; margin: 0 auto; background: none; border: 0; backdrop-filter: none; display: flex; gap: 8px; padding: 12px 16px 0; }
  .tabbar button { flex-direction: row; font-size: .9rem; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); }
  .tabbar button[aria-selected="true"] { background: var(--surface); }
  body { padding-bottom: 32px; }
}

.empty-note { color: var(--muted); text-align: center; padding: 24px 12px; font-size: .9rem; }
.foot { text-align: center; color: var(--muted); font-size: .75rem; margin-top: 24px; }
.foot a { color: var(--muted); }

/* ---------- Admin ---------- */
.btn { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 600; background: var(--surface-2); cursor: pointer; min-height: 44px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.gold { background: var(--accent-2); color: #1b1300; }
.btn.ghost { background: none; border: 1px solid var(--line); }
.btn.danger { background: none; border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent); color: #ff8a7f; }
.btn.small { padding: 6px 10px; min-height: 36px; font-size: .85rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.field { display: block; padding: 12px 14px; border-top: 1px solid var(--line); }
.field:first-child { border-top: 0; }
.field span { display: block; font-size: .75rem; color: var(--muted); margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input:focus, select:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; border-color: transparent; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { min-width: 0; }
.team-row { display: grid; grid-template-columns: 1fr 72px; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--line); }
.actions { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }

.edit-match { padding: 12px 14px; border-top: 1px solid var(--line); }
.edit-match .meta { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-bottom: 8px; }
.edit-match .vs { display: grid; grid-template-columns: 1fr 64px 12px 64px 1fr; align-items: center; gap: 6px; }
.edit-match .vs input { text-align: center; padding: 8px 4px; font-weight: 700; font-size: 1.1rem; }
.edit-match .vs .team { font-size: .92rem; }
.edit-match .btns { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.edit-match .btns .btn { flex: 1; }
.edit-match.locked { opacity: .55; }

.login { max-width: 380px; margin: 12vh auto 0; }
.login .card { padding: 4px 0; }
.err { color: #ff8a7f; font-size: .88rem; padding: 0 14px 12px; min-height: 1em; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: .9rem;
  opacity: 0; transition: .2s; pointer-events: none; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.error { background: var(--accent); color: #fff; }
