:root {
  --color-green: #1f8a4c;
  --color-green-dark: #156638;
  --color-blue: #1565c0;
  --color-blue-light: #e8f1fb;
  --color-bg: #f5f7f8;
  --color-card: #ffffff;
  --color-text: #1a2027;
  --color-muted: #66727e;
  --color-border: #e1e6ea;
  --color-error: #c0392b;
  --color-success: #1f8a4c;
  --btn-bg: #eef0f2;
  --btn-text: #1a2027;
  --radius: 12px;
}

* { box-sizing: border-box; }

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

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

h1 { font-size: 1.4rem; margin: 8px 0 16px; color: var(--color-green-dark); }

.topbar {
  background: linear-gradient(135deg, var(--color-green) 0%, var(--color-blue) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.nav-toggle {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 6px 10px;
}
.nav-menu {
  display: none;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.15);
}
.nav-menu.open { display: flex; }
.nav-menu a {
  color: #fff;
  text-decoration: none;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

@media (min-width: 700px) {
  .nav-toggle { display: none; }
  .nav-menu {
    display: flex !important;
    flex-direction: row;
    background: none;
  }
  .nav-menu a { border-top: none; padding: 12px 14px; }
}

.topbar-right { display: flex; align-items: center; gap: 10px; }
.nav-avatar-link { display: flex; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--color-green) 0%, var(--color-blue) 100%);
  flex-shrink: 0;
}
.avatar-klein { width: 28px; height: 28px; font-size: 0.7rem; }
.avatar-gross { width: 72px; height: 72px; font-size: 1.4rem; }

.profil-card { display: flex; align-items: center; gap: 14px; }
.profil-email { color: var(--color-muted); font-size: 0.85rem; }
.profil-abschnitt { font-size: 1rem; margin: 20px 0 10px; color: var(--color-text); }

table.rangliste td:nth-child(2) { width: 36px; }

.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}
.podium-spieler {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 33%;
}
.podium-erste { order: 2; }
.podium-zweite { order: 1; }
.podium-dritte { order: 3; }

.podium-medaille { font-size: 1.6rem; line-height: 1; margin-bottom: 4px; }
.podium-name {
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.podium-punkte { font-size: 0.8rem; color: var(--color-muted); margin-bottom: 8px; }

.podium-stufe {
  width: 100%;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8px;
  font-weight: 800;
  font-size: 1.4rem;
  color: #fff;
}
.podium-erste .podium-stufe { height: 92px; background: linear-gradient(180deg, #f4c95d, #d9a520); }
.podium-zweite .podium-stufe { height: 68px; background: linear-gradient(180deg, #c9d0d8, #9aa4af); }
.podium-dritte .podium-stufe { height: 52px; background: linear-gradient(180deg, #e0a06e, #b97b48); }

.podium-erste .avatar-gross { width: 84px; height: 84px; font-size: 1.6rem; border: 3px solid #d9a520; }
.podium-zweite .avatar-gross { width: 68px; height: 68px; font-size: 1.3rem; border: 3px solid #9aa4af; }
.podium-dritte .avatar-gross { width: 68px; height: 68px; font-size: 1.3rem; border: 3px solid #b97b48; }

.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.spieltag-gruppe {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.spieltag-gruppe summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: var(--color-green-dark);
}
.spieltag-gruppe summary::-webkit-details-marker { display: none; }
.spieltag-gruppe summary::marker { content: ""; }
.spieltag-meta {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--color-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.spieltag-chevron {
  display: inline-block;
  transition: transform 0.15s ease;
}
.spieltag-gruppe[open] .spieltag-chevron { transform: rotate(90deg); }
.spieltag-gruppe > .spiel-card {
  margin: 0 12px 12px;
  box-shadow: none;
}
.spieltag-gruppe > .spiel-card:last-child { margin-bottom: 12px; }

.spiel-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: 8px;
}

.teams {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.team { display: flex; align-items: center; gap: 8px; }
.team-favorit { color: var(--color-green-dark); }
.team-logo { width: 28px; height: 28px; object-fit: contain; border-radius: 4px; }
.vs { color: var(--color-muted); font-weight: 400; }

.anpfiff-zeit { font-size: 0.85rem; color: var(--color-muted); margin-bottom: 10px; }

.countdown {
  display: block;
  font-size: 0.8rem;
  color: var(--color-blue);
  margin-bottom: 10px;
}

.ergebnis-stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.ergebnis-btn {
  position: relative;
  display: block;
  text-align: center;
  padding: 12px 0;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  color: var(--color-text);
}
.ergebnis-btn input { position: absolute; opacity: 0; pointer-events: none; }
.ergebnis-btn.selected,
.ergebnis-btn:has(input:checked) {
  border-color: var(--color-blue);
  background: var(--color-blue-light);
  color: var(--color-blue);
}

.joker-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.95rem;
  font-weight: 400;
}

.btn {
  display: inline-block;
  padding: 12px 18px;
  border-radius: 10px;
  border: none;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  font-size: 1rem;
}
.btn-primary { background: var(--color-green); color: #fff; }
.btn-primary:active { background: var(--color-green-dark); }
.btn-small { padding: 8px 12px; font-size: 0.85rem; }
.btn-loeschen { background: #fdecea; color: var(--color-error); }

.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.form { display: flex; flex-direction: column; gap: 14px; max-width: 420px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.form input[type=text],
.form input[type=email],
.form input[type=password],
.form input[type=number],
.form input[type=datetime-local],
.form select {
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--color-card);
  color: var(--color-text);
}

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 0.9rem; }
.alert-error { background: #fdecea; color: var(--color-error); }
.alert-success { background: #e9f7ef; color: var(--color-success); }

.gesperrt-hinweis { color: var(--color-muted); font-size: 0.9rem; }

.login-hinweis { color: var(--color-muted); font-size: 0.9rem; margin-top: -8px; margin-bottom: 20px; }
.app-footer {
  text-align: center;
  padding: 20px 16px 30px;
  font-size: 0.8rem;
  color: var(--color-muted);
}
.login-footer { margin-top: 16px; font-size: 0.9rem; }
.login-footer a { color: var(--color-blue); }

.table-wrap { overflow-x: auto; }
table.rangliste, table.historie {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-card);
  border-radius: var(--radius);
  overflow: hidden;
}
table.rangliste th, table.rangliste td,
table.historie th, table.historie td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
  white-space: nowrap;
}
table.rangliste th, table.historie th { background: var(--color-blue-light); color: var(--color-blue); }

.status { font-size: 0.75rem; padding: 2px 8px; border-radius: 6px; background: #eee; }
.status-offen { background: #e9f7ef; color: var(--color-green); }
.status-gesperrt { background: #fff4e5; color: #b9770e; }
.status-beendet { background: var(--btn-bg); color: var(--color-muted); }

.inline-form { display: flex; align-items: center; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.inline-form select { padding: 8px; border-radius: 8px; border: 1px solid var(--color-border); }

.phase-switch { font-size: 0.9rem; margin-bottom: 16px; }
.phase-switch a { color: var(--color-muted); text-decoration: none; margin-right: 4px; }
.phase-switch a.active { color: var(--color-blue); font-weight: 600; }

.deadline-hinweis { font-size: 0.85rem; color: var(--color-muted); margin: 6px 0; }

.spieltagsieger-kopf { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.spieltagsieger-kopf .spieltag { font-weight: 700; color: var(--color-green-dark); }
.spieltagsieger-punkte { font-size: 0.85rem; color: var(--color-muted); }
.spieltagsieger-gewinner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spieltagsieger-person { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.spieltagsieger-geteilt { font-size: 0.85rem; color: var(--color-muted); margin-left: auto; }

.einsatz-form { margin: 0; }
.einsatz-checkbox { display: flex; justify-content: center; }
.einsatz-checkbox input { width: 20px; height: 20px; cursor: pointer; }

.registrierungslink-box { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.registrierungslink-box input {
  flex: 1;
  min-width: 200px;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.85rem;
}

.tipp-reihenfolge { margin: 8px 0; padding-left: 20px; font-size: 0.9rem; }
.tipp-reihenfolge li.treffer { color: var(--color-green-dark); font-weight: 600; }

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #10151a;
    --color-card: #1b232b;
    --color-text: #e7edf2;
    --color-muted: #8b98a5;
    --color-border: #2a343d;
    --color-blue-light: #17273a;
    --btn-bg: #2a343d;
    --btn-text: #e7edf2;
  }
}
