/* Turnierbetrieb: Bedienpult, Spielkarten, Tabellen.
 *
 * Alles hier baut auf den globalen Tokens auf - keine eigenen Farben, keine
 * Sonderregeln je Theme. Was das Turnier braucht und app.css nicht hergibt,
 * sind Spielkarten mit Satzanzeige und ein Punktezaehler, der auch mit dem
 * Daumen bedienbar ist.
 */

/* --- Kopfzeile einer Turnierseite --------------------------------------- */

.tournament-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 16px;
  margin-bottom: 6px;
}

.tournament-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: .92rem;
}

.tournament-meta > span { white-space: nowrap; }

.tournament-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

/* --- Status ------------------------------------------------------------- */

.t-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--brand-soft);
  font-size: .8rem;
  font-weight: 700;
  white-space: nowrap;
}

.t-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.t-status[data-status="running"]::before { background: var(--success); }
.t-status[data-status="ready"]::before { background: var(--brand); }
.t-status[data-status="paused"]::before { background: var(--warning); }
.t-status[data-status="completed"]::before { background: var(--muted); }
.t-status[data-status="cancelled"]::before { background: var(--danger, var(--warning)); }

/* --- Spielkarten -------------------------------------------------------- */

.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.match-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: var(--surface-strong);
  display: grid;
  gap: 12px;
}

.match-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: .84rem;
}

/* Satzuebersicht: ein Kaestchen je Satz, der laufende hervorgehoben. */
.set-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.set-box {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 56px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

.set-box strong { font-size: .7rem; color: var(--muted); letter-spacing: .06em; }
.set-box span { font-size: 1.05rem; font-weight: 800; }
.set-box.is-active { border-color: var(--brand); background: var(--brand-soft); }

/* Eine Zeile je Team: Name links, Punktestand und Zaehler rechts. */
.team-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.team-row:first-of-type { border-top: 0; }
.team-name { font-weight: 700; overflow-wrap: anywhere; }
.team-points { font-size: 1.5rem; font-weight: 900; font-variant-numeric: tabular-nums; }

.score-buttons { display: flex; gap: 6px; }

/* Gross genug fuer den Daumen am Vereinsabend. */
.score-step {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 800;
  cursor: pointer;
}

.score-step:hover { border-color: var(--brand); }
.score-step:disabled { opacity: .4; cursor: not-allowed; }

.match-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.match-card-actions .btn { min-height: 40px; padding: 8px 14px; font-size: .88rem; }

/* --- Listen ------------------------------------------------------------- */

.t-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.t-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.t-list li:last-child { border-bottom: 0; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.inline-form input,
.inline-form select { min-width: 140px; width: auto; }

/* --- Live-Anzeige: gross und aus der Entfernung lesbar ------------------ */

.live-screen { display: grid; gap: 22px; }

.live-screen .match-card { padding: 20px; }
.live-screen .team-name { font-size: 1.35rem; }
.live-screen .team-points { font-size: 2.6rem; }
.live-screen .set-box span { font-size: 1.3rem; }

.live-standings th,
.live-standings td { font-size: 1.05rem; }

@media (min-width: 1200px) {
  .live-screen .team-name { font-size: 1.7rem; }
  .live-screen .team-points { font-size: 3.4rem; }
}

/* --- Schmale Geraete ---------------------------------------------------- */

@media (max-width: 820px) {
  .match-grid { grid-template-columns: 1fr; }
  .team-row { grid-template-columns: 1fr auto; }
  .score-buttons { grid-column: 1 / -1; justify-content: flex-end; }
  .inline-form input,
  .inline-form select { min-width: 0; width: 100%; }
  .inline-form > * { flex: 1 1 100%; }
  .tournament-actions .btn { flex: 1 1 100%; }
}

/* --- Formularhilfen ----------------------------------------------------- */
/*
 * Dieselben Bausteine wie im Kalendermodul: jede Modul-Stilvorlage steht fuer
 * sich, damit eine Seite mit nur einer davon vollstaendig aussieht.
 */

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
}

/* Ohne das zieht die globale Regel `input { width: 100% }` das Kaestchen
 * auf volle Breite und schiebt den Text in die naechste Zeile. */
.check-row input[type="checkbox"],
.check-row input[type="radio"] {
  width: auto;
  min-height: 0;
  margin: 0;
  flex: 0 0 auto;
}

.form-hint {
  margin: 0;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.45;
}

/* --- Startbereitschaft und Spielplan ------------------------------------ */

.readiness { margin-bottom: 14px; }
.readiness p { margin: 0 0 6px; }

/* Was fehlt, steht als Liste da - nicht als ein langer Satz. */
.problem-list {
  margin: 0;
  padding-left: 20px;
  color: var(--warning);
  display: grid;
  gap: 4px;
}

.manual-schedule { margin: 14px 0; }
.manual-schedule > summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.manual-schedule[open] > summary { margin-bottom: 10px; }

.tournament-notes {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--border);
  color: var(--muted);
  white-space: pre-line;
}

/* --- Tabelle ------------------------------------------------------------ */

/* Die Zahlenspalten rechtsbuendig: so stehen Stellen untereinander und ein
 * Rueckstand ist auf einen Blick erkennbar. */
.standings td:not(:nth-child(2)),
.standings th:not(:nth-child(2)) { text-align: right; }
.standings td:nth-child(2),
.standings th:nth-child(2) { text-align: left; }

@media (max-width: 820px) {
  .manual-schedule .inline-form > * { flex: 1 1 100%; }
}
