:root {
  --tsv-green: #1a7f37;
  --tsv-green-dark: #135c28;
  --tsv-black: #111111;
  --tsv-black-soft: #2a2a2a;
  --bg: #f5f6f7;
  --text: #1b1b1b;
}

* {
  box-sizing: border-box;
}

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

.app-header {
  background: var(--tsv-black);
  color: #fff;
  padding: 1rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

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

.crest {
  height: 44px;
  width: auto;
  display: block;
  /* Wappen ist schwarz/weiß – auf dunklem Header weißen Hintergrund geben. */
  background: #fff;
  border-radius: 6px;
  padding: 3px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.4rem;
}

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

.controls select {
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: none;
  font-size: 0.95rem;
}

.badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.export-link {
  font-size: 0.85rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.export-link:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Farb-Legende der Termine */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin-bottom: 1rem;
  padding: 0.6rem 0.9rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  font-size: 0.85rem;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}
.legend-swatch.status-scheduled { background: var(--tsv-green); }
.legend-swatch.status-finished { background: #4b5563; }
.legend-swatch.status-postponed { background: #b45309; }
.legend-swatch.status-cancelled { background: #b91c1c; }

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

#calendar {
  background: #fff;
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Termine (Status-Farben kommen aus den Event-Farben, s. app.ts). */
.fc-event {
  cursor: pointer;
}
/* Gefüllte Balken (Monat/Woche): weiße, fette Schrift für gute Lesbarkeit. */
.fc-daygrid-event,
.fc-daygrid-event .fc-event-title,
.fc-daygrid-event .fc-event-time,
.fc-timegrid-event,
.fc-timegrid-event .fc-event-title,
.fc-timegrid-event .fc-event-time {
  color: #fff !important;
}
.fc-daygrid-event .fc-event-title {
  font-weight: 600;
}
/* Abgesagte Spiele durchgestrichen (Balken + Liste). */
.status-cancelled .fc-event-title,
.fc-list-event.status-cancelled .fc-list-event-title {
  text-decoration: line-through;
}

/* Detail-Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}
.modal-overlay[hidden] {
  display: none;
}

.modal {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 1.75rem 1.5rem 1.5rem;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
}
.modal-close:hover {
  color: var(--text);
}

.modal-competition {
  margin: 0 0 0.75rem;
  text-align: center;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

.modal-teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.modal-team {
  font-size: 1.05rem;
  font-weight: 600;
}
.modal-teams .modal-team:first-child {
  text-align: right;
}
.modal-team.is-tsv {
  color: var(--tsv-green);
}
.modal-score {
  font-size: 1.4rem;
  font-weight: 700;
  padding: 0 0.4rem;
  white-space: nowrap;
}

.modal-meta {
  margin: 0 0 1.25rem;
  display: grid;
  gap: 0.5rem;
}
.modal-meta > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid #eef0f2;
  padding-bottom: 0.5rem;
}
.modal-meta dt {
  margin: 0;
  color: #6b7280;
  font-size: 0.9rem;
}
.modal-meta dd {
  margin: 0;
  text-align: right;
  font-size: 0.9rem;
}

.modal-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  color: #fff;
  background: var(--tsv-green);
}
.modal-badge.status-finished { background: #4b5563; }
.modal-badge.status-postponed { background: #b45309; }
.modal-badge.status-cancelled { background: #b91c1c; }
.modal-badge.status-live { background: #dc2626; }

.modal-link {
  display: block;
  text-align: center;
  padding: 0.6rem 1rem;
  background: var(--tsv-green);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}
.modal-link:hover {
  background: var(--tsv-green-dark);
}
.modal-link[hidden] {
  display: none;
}

/* ---------- Mobile / kleine Bildschirme ---------- */
@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: max(0.9rem, env(safe-area-inset-top)) 1rem 0.9rem;
  }
  .app-header h1 {
    font-size: 1.15rem;
  }
  .controls {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .controls select {
    flex: 1 1 auto;
    min-width: 0;
  }
  .export-link {
    flex: 0 0 auto;
  }

  main {
    padding: 0.75rem;
  }
  #calendar {
    padding: 0.6rem;
  }

  /* FullCalendar-Toolbar auf dem Handy kompakter und umbrechend. */
  .fc .fc-toolbar.fc-header-toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
  }
  .fc .fc-toolbar-title {
    font-size: 1.05rem;
  }
  .fc .fc-button {
    padding: 0.3rem 0.55rem;
    font-size: 0.85rem;
  }

  /* Modal als bodennahe Karte, volle Breite. */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }
  .modal-team {
    font-size: 0.95rem;
  }
}
