/* ============================
   CSS Custom Properties – Theme
   ============================ */
:root {
  --bg:          #f4f6f9;
  --bg-card:     #ffffff;
  --bg-nav:      #1a5c2e;
  --bg-nav-hover:#236b38;
  --text:        #1a1a2e;
  --text-muted:  #6b7280;
  --text-nav:    #ffffff;
  --border:      #e5e7eb;
  --primary:     #1a5c2e;
  --primary-h:   #145224;
  --accent:      #f59e0b;
  --accent-h:    #d97706;
  --danger:      #dc2626;
  --success:     #16a34a;
  --joker:       #7c3aed;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --radius:      10px;
  --radius-sm:   6px;
}

[data-theme="dark"] {
  --bg:          #0f172a;
  --bg-card:     #1e293b;
  --bg-nav:      #0f2419;
  --bg-nav-hover:#1a3d26;
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --text-nav:    #e2e8f0;
  --border:      #334155;
  --primary:     #22c55e;
  --primary-h:   #16a34a;
  --accent:      #f59e0b;
  --shadow:      0 1px 3px rgba(0,0,0,.4);
}

/* ============================
   Reset & Base
   ============================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background .2s, color .2s;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: 1rem; }

/* ============================
   Layout
   ============================ */
#app { display: flex; flex-direction: column; min-height: 100vh; }

nav {
  background: var(--bg-nav);
  color: var(--text-nav);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.nav-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; gap: .5rem;
  padding: .75rem 1rem; flex-wrap: wrap;
}
.nav-brand { font-size: 1.2rem; font-weight: 700; color: var(--text-nav); margin-right: auto; }
.nav-brand span { color: var(--accent); }

.nav-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-nav); padding: .4rem .7rem; border-radius: var(--radius-sm);
  font-size: .9rem; transition: background .15s;
  display: flex; align-items: center; gap: .3rem;
}
.nav-btn:hover, .nav-btn.active { background: var(--bg-nav-hover); }
.nav-btn.accent { background: var(--accent); color: #000; font-weight: 600; }
.nav-btn.accent:hover { background: var(--accent-h); }

#theme-toggle { font-size: 1.2rem; }
#pending-badge {
  background: var(--danger); color: #fff;
  font-size: .7rem; font-weight: 700; border-radius: 50%;
  padding: .1rem .35rem; margin-left: .2rem;
  display: none;
}

main { flex: 1; max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem; width: 100%; }

section { display: none; }
section.active { display: block; }

/* ============================
   Cards & Grids
   ============================ */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  box-shadow: var(--shadow); margin-bottom: 1rem;
}
.card-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; color: var(--primary); }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ============================
   Page header
   ============================ */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; }
.page-header p { color: var(--text-muted); margin-top: .25rem; }

/* ============================
   Buttons
   ============================ */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem; border-radius: var(--radius-sm);
  border: none; cursor: pointer; font-size: .95rem; font-weight: 600;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-accent { background: var(--accent); color: #000; }
.btn-accent:hover { background: var(--accent-h); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: .3rem .7rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================
   Forms
   ============================ */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .9rem; }
.form-control {
  width: 100%; padding: .6rem .85rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text);
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }

/* ============================
   Match Cards
   ============================ */
.match-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr auto 1fr; gap: .5rem; align-items: center;
  position: relative; overflow: hidden;
}
.match-card.deadline-passed { opacity: .8; }
.match-card.deadline-passed::after {
  content: 'Abgabe geschlossen';
  position: absolute; top: 0; right: 0;
  background: var(--text-muted); color: #fff;
  font-size: .7rem; font-weight: 700; padding: .15rem .5rem;
  border-bottom-left-radius: var(--radius-sm);
}
.match-card.finished::after {
  content: 'Beendet';
  background: var(--success);
}
.team-name { font-weight: 700; font-size: 1rem; }
.team-home { text-align: right; }
.match-center { text-align: center; }
.vs { font-size: .8rem; color: var(--text-muted); font-weight: 600; }
.score-display { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.match-meta { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
.countdown { font-size: .85rem; font-weight: 600; color: var(--accent); }
.countdown.urgent { color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.5; } }

/* Tipp-Eingabe im Match-Card */
.tip-form { margin-top: .75rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.tip-score-input { display: flex; align-items: center; gap: .4rem; }
.tip-score-input input[type=number] {
  width: 48px; text-align: center; padding: .4rem .2rem;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--text); font-size: 1.1rem; font-weight: 700;
}
.tip-score-input input:focus { border-color: var(--primary); outline: none; }
.tip-colon { font-size: 1.2rem; font-weight: 800; }

.joker-btn {
  background: transparent; border: 2px solid var(--joker); color: var(--joker);
  border-radius: var(--radius-sm); padding: .3rem .7rem; cursor: pointer;
  font-size: .85rem; font-weight: 700; transition: all .15s;
  display: flex; align-items: center; gap: .25rem;
}
.joker-btn.active { background: var(--joker); color: #fff; }
.joker-btn:disabled { opacity: .4; cursor: not-allowed; }

.tip-points {
  font-size: .9rem; font-weight: 700; padding: .25rem .5rem;
  border-radius: var(--radius-sm);
}
.tip-points.p5, .tip-points.p10 { background: #dcfce7; color: #15803d; }
.tip-points.p3, .tip-points.p6 { background: #dbeafe; color: #1d4ed8; }
.tip-points.p2, .tip-points.p4 { background: #fef9c3; color: #854d0e; }
.tip-points.p0 { background: #fee2e2; color: #b91c1c; }
[data-theme="dark"] .tip-points.p5, [data-theme="dark"] .tip-points.p10 { background: #14532d; color: #86efac; }
[data-theme="dark"] .tip-points.p3, [data-theme="dark"] .tip-points.p6 { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .tip-points.p2, [data-theme="dark"] .tip-points.p4 { background: #3f2d00; color: #fde68a; }
[data-theme="dark"] .tip-points.p0 { background: #450a0a; color: #fca5a5; }

/* ============================
   Standings Table
   ============================ */
.standings-table { width: 100%; border-collapse: collapse; }
.standings-table th, .standings-table td {
  padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border);
}
.standings-table th { background: var(--bg); font-size: .85rem; font-weight: 700; color: var(--text-muted); }
.standings-table tr:hover td { background: var(--bg); }
.standings-table .rank { font-weight: 800; color: var(--text-muted); width: 36px; }
.standings-table .rank-1 { color: #d97706; }
.standings-table .rank-2 { color: #9ca3af; }
.standings-table .rank-3 { color: #b45309; }
.standings-table .pts { font-weight: 800; font-size: 1.05rem; color: var(--primary); }
.standings-table .winner-badge {
  background: var(--accent); color: #000; font-size: .7rem; font-weight: 700;
  padding: .1rem .4rem; border-radius: 20px; margin-left: .4rem;
}
.avatar-sm {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
  background: var(--border); flex-shrink: 0;
}
.user-cell { display: flex; align-items: center; gap: .5rem; }

/* ============================
   Badges & Tags
   ============================ */
.badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 20px;
  font-size: .75rem; font-weight: 700;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-muted   { background: var(--border); color: var(--text-muted); }
.badge-joker   { background: #ede9fe; color: #6d28d9; }
[data-theme="dark"] .badge-success { background: #14532d; color: #86efac; }
[data-theme="dark"] .badge-warning { background: #3f2d00; color: #fde68a; }
[data-theme="dark"] .badge-danger  { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .badge-joker   { background: #2e1065; color: #c4b5fd; }

/* ============================
   Stats Cards
   ============================ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* Streak highlight */
.streak-display { display: flex; gap: 1rem; flex-wrap: wrap; }
.streak-card { flex: 1; min-width: 140px; }
.streak-fire { font-size: 1.5rem; }

/* ============================
   Observer Panel
   ============================ */
.result-row {
  display: flex; align-items: center; gap: .75rem; padding: .75rem 0;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.result-row:last-child { border-bottom: none; }
.result-teams { flex: 1; font-weight: 600; }
.result-score-inputs { display: flex; align-items: center; gap: .4rem; }
.result-score-inputs input {
  width: 48px; text-align: center; padding: .4rem;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--text); font-size: 1.1rem; font-weight: 700;
}

/* ============================
   Admin Tables
   ============================ */
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td {
  padding: .55rem .75rem; text-align: left; border-bottom: 1px solid var(--border);
}
.admin-table th { font-weight: 700; color: var(--text-muted); font-size: .8rem; }
.admin-table tr:hover td { background: var(--bg); }
.action-btns { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ============================
   Profile
   ============================ */
.profile-avatar-wrap { text-align: center; margin-bottom: 1.5rem; }
.profile-avatar {
  width: 100px; height: 100px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--primary); margin-bottom: .75rem;
}
.avatar-placeholder {
  width: 100px; height: 100px; border-radius: 50%;
  background: var(--border); display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; margin: 0 auto .75rem;
}

/* Joker counter */
.joker-counter {
  display: flex; gap: .4rem; align-items: center; flex-wrap: wrap;
  margin: .5rem 0;
}
.joker-pip {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--joker); display: inline-block;
}
.joker-pip.used { background: var(--border); }

/* ============================
   Chart Container
   ============================ */
.chart-wrap { position: relative; height: 280px; margin-top: 1rem; }

/* ============================
   Matchday Selector
   ============================ */
.matchday-nav {
  display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.matchday-tab {
  padding: .35rem .75rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  cursor: pointer; font-size: .9rem; font-weight: 600; transition: all .15s;
}
.matchday-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.matchday-tab:hover:not(.active) { background: var(--border); }

/* ============================
   Auth Pages
   ============================ */
.auth-wrap {
  max-width: 420px; margin: 3rem auto;
}
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo h1 { font-size: 2rem; font-weight: 800; }
.auth-logo h1 span { color: var(--primary); }

/* ============================
   Toast Notifications
   ============================ */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
  display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  background: var(--bg-card); border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm); padding: .75rem 1rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  font-size: .9rem; min-width: 240px; max-width: 360px;
  animation: slideIn .3s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes slideIn { from { transform: translateX(110%); } to { transform: translateX(0); } }

/* ============================
   Tages-Sieger Banner
   ============================ */
.winner-banner {
  background: linear-gradient(135deg, var(--accent), #f97316);
  color: #000; border-radius: var(--radius); padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem;
  font-weight: 700;
}
.winner-banner .trophy { font-size: 1.8rem; }

/* ============================
   Head-to-Head
   ============================ */
.h2h-bar {
  display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: .5rem 0;
}
.h2h-bar .seg1 { background: var(--primary); }
.h2h-bar .seg-draw { background: var(--border); }
.h2h-bar .seg2 { background: var(--accent); }
.h2h-labels { display: flex; justify-content: space-between; font-size: .85rem; font-weight: 700; }

/* ============================
   Responsive
   ============================ */
@media (max-width: 640px) {
  .match-card { grid-template-columns: 1fr; }
  .team-home { text-align: left; }
  .match-center { display: flex; justify-content: space-between; align-items: center; }
  .standings-table .hide-mobile { display: none; }
  nav .nav-btn span { display: none; }
  main { padding: 1rem .75rem; }
}
