:root {
  --blue: #0077b6;
  --blue-dark: #023e8a;
  --cyan: #00b4d8;
  --bg: #f0f8fb;
  --card: #ffffff;
  --text: #1b2a33;
  --muted: #5c7080;
  --danger: #d9534f;
  --success: #2e8b57;
  --gold: #d4a017;
  --border: #dce8ee;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

h1 { font-size: 1.3rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 10px; color: var(--blue-dark); }

.screen { min-height: 100vh; }
.muted { color: var(--muted); }

/* Login */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--cyan), var(--blue-dark));
}
#login-screen[hidden] {
  display: none;
}
.login-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 22px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 30, 60, 0.25);
}
.login-box h1 { margin-bottom: 6px; }
#login-form { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }
#login-password {
  padding: 14px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* Buttons */
.btn {
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: #e7eef2;
  color: var(--text);
  cursor: pointer;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-icon {
  background: transparent;
  font-size: 1.3rem;
  padding: 6px 10px;
}
.btn-small { padding: 8px 12px; font-size: 0.9rem; }

.error {
  color: var(--danger);
  background: #fdecea;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-top: 10px;
}
.success {
  color: var(--success);
  background: #eaf6ee;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-top: 10px;
}

/* Header + Tabs */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--blue-dark);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header h1 { color: #fff; }
.app-header .btn-icon { color: #fff; }

.tabs {
  display: flex;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 52px;
  z-index: 9;
}
.tab-btn {
  flex: 1;
  padding: 13px 6px;
  border: none;
  background: transparent;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 3px solid transparent;
}
.tab-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

main { padding: 14px; max-width: 640px; margin: 0 auto; padding-bottom: 60px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

#banner-area .banner {
  background: #fff7e0;
  border: 1px solid #f0d98c;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(0, 40, 70, 0.06);
}

.round-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.round-heading .badge {
  background: var(--blue);
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.paused-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 6px 0 14px;
  padding: 8px 10px;
  background: #f4f7f9;
  border-radius: 8px;
}

.team-chip {
  display: inline-block;
  background: #eaf6fb;
  color: var(--blue-dark);
  border: 1px solid #cbe8f4;
  border-radius: 8px;
  padding: 6px 10px;
  margin: 3px 4px 3px 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.game-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}
.game-row.game-done { background: #f7fcf9; border-color: #cfe9d8; }
.game-teams {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 0.92rem;
}
.game-teams .vs { color: var(--muted); font-weight: 400; font-size: 0.8rem; }
.team-names { flex: 1; }

.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.score-input {
  width: 100%;
  padding: 12px;
  font-size: 1.1rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.score-sep { font-weight: 700; color: var(--muted); }
.save-game-btn { white-space: nowrap; }

.game-status {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
}

/* Standings */
table.standings-table {
  width: 100%;
  border-collapse: collapse;
}
table.standings-table th,
table.standings-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.standings-table th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; }
table.standings-table tr:first-child td { font-weight: 700; }
.rank-1 { color: var(--gold); }
.eliminated-row td { opacity: 0.55; }

#final-team-box {
  background: linear-gradient(135deg, #fff8e1, #ffe9a8);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
#final-team-box h2 { color: #8a6d00; }

/* Feste-Teams-Modus: Spiel-Karten mit Saetzen */
.match-stage-label {
  display: inline-block;
  background: var(--blue-dark);
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 10px;
}
.match-teams-big {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 14px;
}
.match-teams-big .vs { color: var(--muted); font-weight: 400; font-size: 0.8rem; }
.match-teams-big .team-side { flex: 1; }
.match-teams-big .team-side.right { text-align: right; }

.set-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.set-label {
  width: 60px;
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}
.set-row .score-input { padding: 10px; font-size: 1rem; }
.set-row .save-set-btn { white-space: nowrap; }
.set-done-icon { width: 22px; text-align: center; flex-shrink: 0; }

.match-status {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}
.match-status.match-won { color: var(--success); font-weight: 600; }

.bye-card {
  background: #f4f7f9;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
}

.bracket-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px;
}
.bracket-section-title:first-child { margin-top: 0; }

.match-mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 0.88rem;
}
.match-mini-row.mini-done { background: #f7fcf9; border-color: #cfe9d8; }
.match-mini-row.mini-tbd { color: var(--muted); font-style: italic; }
.match-mini-row .mini-label { font-size: 0.72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; flex-shrink: 0; width: 90px; }
.match-mini-row .mini-teams { flex: 1; }
.match-mini-row .mini-score { font-weight: 700; white-space: nowrap; }

.placement-list { list-style: none; margin: 0; padding: 0; }
.placement-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.placement-item:last-child { border-bottom: none; }
.placement-rank {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #eaf6fb;
  color: var(--blue-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  font-size: 0.85rem;
}
.placement-item.place-1 .placement-rank { background: var(--gold); color: #fff; }
.placement-item.place-1 { font-weight: 700; }

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 30, 45, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.overlay[hidden] {
  display: none;
}
.overlay-box {
  background: #fff;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  padding: 20px;
}
.confirm-box { border-radius: var(--radius); margin-bottom: 20px; }
.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

#config-form { display: flex; flex-direction: column; gap: 12px; }
#config-form label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
#config-form textarea,
#config-form input:not([type="checkbox"]) {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  width: 100%;
  font-family: inherit;
}
.field-row { display: flex; gap: 12px; }
.field { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.field[hidden] { display: none; }

#config-form .checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.checkbox-field input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}
.hint {
  font-size: 0.82rem;
  color: var(--muted);
  background: #f4f7f9;
  border-radius: 8px;
  padding: 8px 10px;
  margin: -4px 0 0;
}

.confirm-buttons { display: flex; gap: 10px; margin-top: 16px; }
.confirm-buttons .btn { flex: 1; }

hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

@media (min-width: 700px) {
  main { padding: 24px; }
}
