/* === KICKSIM - Bundesliga Dark Theme === */

:root {
  --red: #e8001c;
  --red-dark: #b0001a;
  --red-glow: rgba(232, 0, 28, 0.3);
  --gold: #f5c842;
  --bg-deep: #0a0a0f;
  --bg-dark: #111118;
  --bg-card: #18181f;
  --bg-card2: #1e1e28;
  --bg-hover: #22222e;
  --border: rgba(255,255,255,0.07);
  --border-bright: rgba(255,255,255,0.14);
  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #55556a;
  --green: #00c853;
  --blue: #2979ff;
  --orange: #ff6d00;
  --sim-color: #7c3aed;
  --sim-light: rgba(124, 58, 237, 0.15);
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'Barlow', sans-serif;
  font-size: 14px;
  overflow-x: hidden;
}

/* === SCREENS === */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* === AUTH === */
#auth-screen {
  justify-content: center;
  align-items: center;
  position: relative;
  background: var(--bg-deep);
}

.auth-bg {
  position: fixed; inset: 0; z-index: 0;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(232,0,28,0.18) 0%, transparent 70%);
}

.auth-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
}

.auth-container {
  position: relative; z-index: 1;
  width: 100%; max-width: 440px;
  padding: 2rem;
  display: flex; flex-direction: column; align-items: center; gap: 2rem;
}

.brand { text-align: center; }

.brand-logo {
  font-size: 3.5rem;
  filter: drop-shadow(0 0 20px rgba(232,0,28,0.5));
  animation: pulse-ball 3s ease-in-out infinite;
}

@keyframes pulse-ball {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(232,0,28,0.5)); }
  50% { filter: drop-shadow(0 0 35px rgba(232,0,28,0.8)); }
}

.brand-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg, #fff 0%, #e8001c 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.brand-sub {
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.auth-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow), 0 0 60px rgba(232,0,28,0.08);
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.75rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.auth-tab.active {
  color: var(--red);
  border-bottom-color: var(--red);
}

.auth-form { display: none; flex-direction: column; gap: 1rem; }
.auth-form.active { display: flex; }

.field-group { display: flex; flex-direction: column; gap: 0.4rem; }

.field-group label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.hint { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-muted); }

.field-group input {
  background: var(--bg-dark);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: 'Barlow', sans-serif;
  font-size: 0.95rem;
  padding: 0.7rem 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.field-group input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
}

.btn-primary {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.8rem 1.5rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  margin-top: 0.5rem;
}

.btn-primary:hover {
  background: var(--red-dark);
  box-shadow: 0 4px 20px var(--red-glow);
}

.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  font-family: 'Barlow', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.7rem 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover { border-color: var(--text-secondary); color: var(--text-primary); }

.error-msg {
  background: rgba(232,0,28,0.12);
  border: 1px solid rgba(232,0,28,0.3);
  border-radius: 6px;
  color: #ff6b6b;
  font-size: 0.85rem;
  padding: 0.6rem 0.9rem;
}

.hidden { display: none !important; }

/* === HEADER === */
.app-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(0,0,0,0.4);
}

.header-logo {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--text-primary);
  white-space: nowrap;
}

.header-logo::before { content: ''; }

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.control-group label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.control-group select {
  background: var(--bg-dark);
  border: 1px solid var(--border-bright);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: 'Barlow', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  outline: none;
}

.btn-sync {
  background: transparent;
  border: 1px solid var(--border-bright);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  align-self: flex-end;
}

.btn-sync:hover { border-color: var(--gold); color: var(--gold); }
.btn-sync.syncing #sync-icon { display: inline-block; animation: spin 1s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

.username {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* === NAV === */
.app-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1.5rem;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
}

.nav-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: 'Barlow', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-tab.active { background: var(--bg-card2); color: var(--text-primary); }

.btn-reset-small {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-reset-small:hover { border-color: var(--orange); color: var(--orange); }

/* === VIEWS === */
.app-main { flex: 1; padding: 1.5rem; max-width: 1200px; margin: 0 auto; width: 100%; }
.view { display: none; }
.view.active { display: block; }

.view-header {
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.view-header h2 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.view-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 400;
  font-family: 'Barlow', sans-serif;
}

.view-hint { font-size: 0.8rem; color: var(--text-muted); margin-left: auto; }
.sim-indicator { color: var(--sim-color); font-weight: 600; }

/* === STANDINGS TABLE === */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.standings-table {
  width: 100%;
  border-collapse: collapse;
}

.standings-table thead th {
  background: var(--bg-card2);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.7rem 0.8rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.standings-table thead th.col-team { text-align: left; }

.standings-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.standings-table tbody tr:last-child { border-bottom: none; }
.standings-table tbody tr:hover { background: var(--bg-hover); }
.standings-table tbody tr.simulated-row { background: var(--sim-light); }

.standings-table td {
  padding: 0.7rem 0.8rem;
  text-align: center;
  font-size: 0.9rem;
}

.standings-table td.col-team { text-align: left; }

.col-pos { width: 40px; }
.col-team { min-width: 160px; }
.col-stat { width: 40px; }
.col-pts { width: 50px; font-weight: 700; color: var(--text-primary); }

.pos-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
}

.pos-cl { background: rgba(41,121,255,0.2); color: var(--blue); }
.pos-ecl { background: rgba(0,200,83,0.15); color: var(--green); }
.pos-rel { background: rgba(255,109,0,0.15); color: var(--orange); }
.pos-rel2 { background: rgba(232,0,28,0.2); color: var(--red); }
.pos-normal { background: var(--bg-dark); color: var(--text-secondary); }

.team-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.team-abbr {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
}

.team-full {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.sim-dot {
  width: 6px; height: 6px;
  background: var(--sim-color);
  border-radius: 50%;
  flex-shrink: 0;
}

/* Zone indicators */
.zone-bar {
  width: 3px;
  position: absolute;
  left: 0; top: 0; bottom: 0;
}

.standings-table tbody tr { position: relative; }

/* === MATCHES GRID === */
.matchday-filter {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.05em;
}

.btn-icon {
  background: var(--bg-card2);
  border: 1px solid var(--border-bright);
  color: var(--text-primary);
  border-radius: 6px;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}

.btn-icon:hover { background: var(--bg-hover); border-color: var(--red); color: var(--red); }

.matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.75rem;
}

.match-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.match-card:hover { border-color: var(--border-bright); background: var(--bg-hover); }
.match-card.is-finished { cursor: default; opacity: 0.85; }
.match-card.is-simulated { border-color: rgba(124,58,237,0.4); background: var(--sim-light); }
.match-card.is-finished:hover { background: var(--bg-card); border-color: var(--border); }

.match-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.match-teams {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.match-team {
  flex: 1;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.2;
}

.match-team.away { text-align: right; }

.match-score {
  background: var(--bg-dark);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  padding: 0.4rem 0.9rem;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  min-width: 70px;
  text-align: center;
  white-space: nowrap;
}

.match-score.has-score { color: var(--text-primary); }
.match-score.no-score { color: var(--text-muted); font-size: 1rem; }
.match-score.sim-score { color: var(--sim-color); border-color: rgba(124,58,237,0.3); }

.match-status {
  position: absolute;
  top: 0.5rem; right: 0.6rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.match-status.finished { color: var(--green); }
.match-status.simulated { color: var(--sim-color); }

/* === MIN/MAX TABLE === */
.minmax-table .col-minmax { width: 70px; }
.minmax-table .col-bar { min-width: 140px; }

.minmax-bar-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.25rem;
}

.minmax-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-dark);
  border-radius: 4px;
  position: relative;
  overflow: visible;
}

.minmax-bar-fill {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--red));
  transition: all 0.4s;
}

.pos-best { color: var(--green); font-weight: 700; }
.pos-worst { color: #ff6b6b; font-weight: 700; }

/* === LOADING === */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(10,10,15,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 1000;
}

.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border-bright);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* === MODAL === */
.modal {
  position: fixed; inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  padding: 1.5rem;
  box-shadow: var(--shadow), 0 0 40px rgba(232,0,28,0.1);
  animation: modal-in 0.2s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-header h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: color 0.2s;
}

.modal-close:hover { color: var(--text-primary); }

.score-input-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.team-score {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.team-name-modal {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  line-height: 1.2;
  color: var(--text-primary);
}

.score-input {
  background: var(--bg-dark);
  border: 2px solid var(--border-bright);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 2.5rem;
  font-weight: 900;
  text-align: center;
  width: 90px; height: 70px;
  outline: none;
  transition: border-color 0.2s;
}

.score-input:focus { border-color: var(--red); }
.score-input::-webkit-inner-spin-button { opacity: 0; }

.score-sep {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 2rem;
  font-weight: 900;
  color: var(--text-muted);
  align-self: flex-end;
  padding-bottom: 10px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* === ZONE LEGEND === */
.zone-legend {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.zone-item { display: flex; align-items: center; gap: 0.4rem; }
.zone-dot { width: 10px; height: 10px; border-radius: 2px; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .app-header { flex-wrap: wrap; gap: 0.75rem; }
  .header-controls { order: 3; width: 100%; }
  .app-main { padding: 1rem; }
  .matches-grid { grid-template-columns: 1fr; }
  .standings-table .team-full { display: none; }
  .col-stat { display: none; }
}

/* === FIXES === */

/* Header layout fix */
.app-header {
  flex-wrap: nowrap;
}

.header-left {
  flex-shrink: 0;
}

/* Nav fix - kein overflow */
.app-nav {
  overflow-x: auto;
  flex-wrap: nowrap;
  white-space: nowrap;
}

/* Match card fix - kein pointer auf finished */
.match-card.is-finished {
  cursor: default !important;
}

/* Score input fix */
.score-input-row {
  justify-content: center;
}

.team-score {
  align-items: center;
  text-align: center;
}

/* Modal fix - team names gleich groß */
.team-name-modal {
  max-width: 120px;
  word-break: break-word;
  text-align: center;
  min-height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Tabelle - leere Nachricht */
#standings-body td[colspan] {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

/* Spin animation für sync */
@keyframes spin {
  to { transform: rotate(360deg); }
}
