:root {
  --bg: #0f1418;
  --card: #182027;
  --card-2: #1f2a33;
  --line: #2a3640;
  --text: #eef4f8;
  --muted: #8fa3b0;
  --accent: #b6f24a;
  --accent-ink: #142000;
  --blue: #4cc2ff;
  --danger: #ff6b6b;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }
.muted { color: var(--muted); margin: 2px 0 0; font-size: 13px; }
.center { text-align: center; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 4px 0 0; }

/* ---------------------------------------------------------------- Login */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
}
.login-logo { font-size: 44px; }
.login-card h1 { font-size: 22px; margin: 8px 0 0; }
.login-card input { margin-top: 20px; }

/* ---------------------------------------------------------------- Chrome */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  background: rgba(15, 20, 24, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; margin: 0; }

main { padding: 16px 16px 8px; }

.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(15, 20, 24, .95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 6;
}
.tab {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 10px 4px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
.tab span { font-size: 20px; }
.tab.active { color: var(--accent); }

/* ----------------------------------------------------------------- Cards */
.round {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.round.current { border-color: var(--accent); }
.round-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--card-2);
  font-weight: 600;
  font-size: 15px;
}
.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
}
.badge.done { background: var(--line); color: var(--muted); }

.match {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
  color: inherit;
  font: inherit;
  padding: 12px 16px;
  cursor: pointer;
}
.match:active { background: var(--card-2); }
.match-court {
  font-size: 11px;
  color: var(--muted);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.match-teams { flex: 1; min-width: 0; }
.match-team {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
  font-size: 15px;
}
.match-team.winner { font-weight: 700; color: var(--accent); }
.match-team .pts { font-variant-numeric: tabular-nums; color: var(--muted); }
.match-team.winner .pts { color: var(--accent); }
.match-cta { font-size: 13px; color: var(--blue); white-space: nowrap; }

/* ------------------------------------------------------------- Rangliste */
.table {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.trow {
  display: grid;
  grid-template-columns: 34px 1fr 54px 46px 46px;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.trow:first-child { border-top: 0; }
.trow.head {
  background: var(--card-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.trow .rank { font-weight: 700; color: var(--muted); }
.trow.top .rank { color: var(--accent); }
.trow .pts { font-weight: 700; text-align: right; }
.trow .num { text-align: right; color: var(--muted); font-size: 14px; }
.trow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----------------------------------------------------------------- Setup */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.panel h2 { font-size: 15px; margin: 0 0 12px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
input[type=text], input[type=number], input[type=password] {
  width: 100%;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  padding: 13px 14px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.player-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.player-row .idx {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--card-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }

.btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  padding: 14px;
  margin-top: 14px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.icon-btn {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  font-size: 17px;
  cursor: pointer;
}

/* ------------------------------------------------------------ Score-Sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: flex-end;
  z-index: 10;
}
.sheet {
  width: 100%;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--line);
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(24px); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.score-row { display: flex; align-items: flex-start; gap: 8px; margin: 18px 0 10px; }
.score-team { flex: 1; text-align: center; }
.team-names { margin: 0 0 10px; font-size: 14px; min-height: 40px; }
.score-vs { font-size: 24px; color: var(--muted); padding-top: 46px; }
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
}
.stepper button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--line);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}
.stepper button:active { background: var(--accent); color: var(--accent-ink); }
.stepper span {
  min-width: 46px;
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  z-index: 20;
}
.toast.err { border-color: var(--danger); color: var(--danger); }
