/* =========================================================
   HCue Scoreboard – Styles (eigenständiges Modul)
   Baut auf den Basis-Variablen/Komponenten aus style.css auf.
   ========================================================= */

.sb-main { max-width: 1000px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
.sb-main .card { display: grid; gap: 1rem; align-content: start; }
.sb-main .card > * { min-width: 0; }   /* breite Inhalte (z. B. Protokolltabelle) dürfen
                                          schrumpfen/intern scrollen statt die Seite zu sprengen */
.sb-main .card > h2, .sb-main .card > p { margin: 0; }
.sb-title { display: inline-flex; align-items: center; gap: .6rem; font-weight: 650; letter-spacing: .04em; }

/* ---------- Setup ---------- */
.sb-row { display: flex; flex-wrap: wrap; gap: .8rem 1.2rem; align-items: flex-end; }
.sb-field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.sb-field > label { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--text-dim); }
.sb-field input[type="text"], .sb-field input[type="password"], .sb-field input[type="number"], .sb-field select {
  font: inherit; color: var(--text); background: var(--bg-inset);
  border: 1px solid var(--line); border-radius: 8px; padding: .45rem .6rem; min-width: 0;
}
.sb-field input:focus-visible, .sb-field select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.sb-p2wrap { position: relative; flex: 1 1 260px; }
.sb-sugg {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  background: var(--bg-raised); border: 1px solid var(--accent); border-radius: 8px;
  margin-top: 2px; overflow: hidden; box-shadow: var(--shadow);
}
.sb-sugg button { display: block; width: 100%; text-align: left; border: 0; border-radius: 0; background: transparent; }
.sb-sugg button:hover { background: rgba(79,155,220,.18); }
.sb-badge {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .72rem;
  color: var(--accent-strong); border: 1px solid var(--accent); border-radius: 999px;
  padding: .12rem .55rem; background: rgba(79,155,220,.12);
}
.sb-badge button { border: 0; background: transparent; color: inherit; padding: 0 .1rem; font-size: .9rem; line-height: 1; }

/* Turnier-Referenz in der Spielhistorie (Link solange das Turnier existiert) */
.sb-tour-tag {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 600;
  color: var(--accent-strong); text-decoration: none; margin-top: .15rem;
}
.sb-tour-tag:hover { text-decoration: underline; }
.sb-tour-tag.plain { color: var(--text-dim); }

.sb-modes { display: flex; flex-wrap: wrap; gap: .4rem; }
.sb-modes .opt-btn.active { font-weight: 650; }
.sb-plan-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.sb-plan-row input { width: 70px; }

/* ---------- Zählbrett (8/9/10) ---------- */
.sb-meta { display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center; justify-content: space-between; }
.sb-meta .muted { font-size: .85rem; }
.sb-clocks { font-variant-numeric: tabular-nums; }   /* Timer springt beim Zählen nicht */
.sb-sides { display: flex; gap: .8rem; align-items: stretch; }
.sb-side {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .3rem; padding: 1.2rem .6rem; cursor: pointer; user-select: none;
  background: var(--bg-inset); border: 2px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, background .15s;
}
.sb-side:hover { border-color: var(--accent); }
.sb-side .sb-name { font-weight: 650; font-size: 1.05rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-side .sb-score { font-size: clamp(3.4rem, 16vw, 8rem); font-weight: 750; line-height: 1; font-variant-numeric: tabular-nums; }
.sb-side.winner { border-color: var(--ok); background: rgba(63,174,106,.1); }
/* Anstoß-Symbol (weiße Kugel + Queue) statt der 0, solange der Anstoß offen ist */
.sb-cue-icon { width: .92em; height: .92em; display: inline-block; vertical-align: middle; opacity: .9; }
/* Kurzes Hervorheben der Bestätigungs-Karte, wenn per Benachrichtigung geöffnet */
.sb-pending-flash { animation: sbPendingFlash 1.1s ease-in-out 2; }
@keyframes sbPendingFlash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79,155,220,0); }
  50% { box-shadow: 0 0 0 3px var(--accent); }
}
.sb-mid { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; min-width: 90px; text-align: center; }
.sb-disc-badge {
  font-weight: 700; font-size: .95rem; color: var(--accent-strong);
  border: 1px solid var(--accent); border-radius: 999px; padding: .2rem .7rem;
  background: rgba(79,155,220,.12); white-space: nowrap;
}
.sb-gamelist { display: flex; flex-wrap: wrap; gap: .25rem; }
.sb-gamelist span {
  font-size: .72rem; padding: .12rem .45rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg-inset); color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.sb-gamelist span.w1 { border-color: var(--ok); color: #7fd6a4; }        /* Spieler 1 = eigener/angemeldeter Benutzer */
.sb-gamelist span.w2 { border-color: var(--accent); color: var(--accent-strong); }   /* Gegner */

/* ---------- 14.1 endlos ---------- */
.sb-st-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: .8rem; align-items: stretch; }
.sb-st-player {
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  padding: .9rem .6rem; background: var(--bg-inset);
  border: 2px solid var(--line); border-radius: var(--radius); cursor: pointer; user-select: none;
}
.sb-st-player.active { border-color: var(--accent); background: rgba(79,155,220,.08); }
.sb-st-player .sb-name { font-weight: 650; }
.sb-st-player .sb-score { font-size: clamp(2.6rem, 11vw, 5.5rem); font-weight: 750; line-height: 1.05; font-variant-numeric: tabular-nums; }
.sb-st-player .sb-substats { font-size: .78rem; color: var(--text-dim); text-align: center; }
.sb-turn-tag { font-size: .68rem; color: var(--accent-strong); text-transform: uppercase; letter-spacing: .1em; min-height: 1em; }
.sb-fouldots { display: flex; gap: .25rem; min-height: 10px; }
.sb-fouldots i { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); display: inline-block; }
.sb-st-mid { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; min-width: 110px; }
.sb-bot { font-size: .78rem; color: var(--text-dim); text-align: center; }
.sb-bot b { display: block; font-size: 1.7rem; color: var(--text); font-variant-numeric: tabular-nums; }
.sb-target { font-size: .78rem; color: var(--text-dim); text-align: center; }

/* Spiel per Code öffnen (eigene Box unter „Neues Spiel") */
.sb-join { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.sb-join input {
  font: inherit; color: var(--text); background: var(--bg-inset); border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .7rem; width: 10rem; text-transform: uppercase; letter-spacing: .18em;
}

/* Teilen-Popup: großer, gut vorlesbarer Code */
.sb-share-code {
  font-size: clamp(1.8rem, 8vw, 2.6rem); font-weight: 750; letter-spacing: .28em;
  text-align: center; padding: .5rem .3rem .5rem .5rem; color: var(--accent-strong);
  background: var(--bg-inset); border: 1px solid var(--accent); border-radius: 10px;
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  user-select: all;
}
#sb-share-link { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }

/* Anstoß-Banner + Live-Badge */
.sb-break { border-color: var(--accent-strong); }
.sb-live-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: #ffb3b0; border: 1px solid var(--danger); border-radius: 999px; padding: .1rem .5rem;
}
.sb-live-badge::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--danger);
  animation: sb-live-pulse 1.4s ease-in-out infinite;
}
@keyframes sb-live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
/* Nach Spielende: „Beendet" statt „LIVE", ohne pulsierenden Punkt */
.sb-live-badge.finished { color: var(--text-dim); border-color: var(--line); }
.sb-live-badge.finished::before { background: var(--text-dim); animation: none; }
#sb-breaker { font-size: .85rem; }

.sb-actions { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: center; }
.sb-actions .sb-pot { font-size: 1.05rem; font-weight: 700; padding: .7rem 1.4rem; }
.sb-notice {
  border: 1px solid var(--accent); border-radius: 8px; padding: .6rem .8rem;
  background: rgba(79,155,220,.1); font-size: .9rem;
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: center;
}

/* ---------- Shot Clock (große, antippbare Zeit + Extensions je Spieler) ---------- */
.sb-shotclock {
  display: flex; align-items: center; justify-content: center; gap: .8rem;
  border: 1px solid var(--line); border-radius: 10px; padding: .5rem .8rem;
  background: rgba(0,0,0,.18);
}
.sb-sc-mid { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.sb-sc-time {
  font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1;
  color: var(--text); background: none; border: 0; cursor: pointer; padding: .2rem .9rem;
  border-radius: 10px; min-width: 96px;
}
.sb-sc-time:hover { background: rgba(79,155,220,.12); }
.sb-sc-time.paused { color: var(--text-dim); }
.sb-sc-time.warn { color: #e8c95a; }
.sb-sc-time.expired { color: #ff6b66; animation: sb-sc-pulse 1s ease-in-out infinite; }
@keyframes sb-sc-pulse { 50% { opacity: .45; } }
.sb-sc-pause { font-size: .72rem; padding: .2rem .6rem; }
.sb-sc-ext {
  flex: 1 1 0; min-width: 0; max-width: 180px;
  border: 1px solid var(--accent); border-radius: 8px; background: rgba(79,155,220,.1);
  color: var(--text); font-size: .78rem; padding: .45rem .5rem; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-sc-ext:hover:not(:disabled) { background: rgba(79,155,220,.2); }
.sb-sc-ext:disabled { cursor: default; opacity: .55; }
.sb-sc-ext.used { border-color: var(--line); color: var(--text-dim); background: none; text-decoration: line-through; }

/* Setup: Haken „Doppelte Zeit für den 1. Stoß nach dem Anstoß" */
.sb-check {
  display: flex; align-items: center; gap: .45rem; cursor: pointer;
  font-size: .85rem; align-self: center;
}
.sb-check input { flex: 0 0 auto; }

/* 14.1: Zählen über verbleibende Kugeln (Restzahl eintragen) */
.sb-remain { font-size: .78rem; color: var(--text-dim); text-align: center; }
.sb-remain label { display: block; margin-bottom: .25rem; }
.sb-remain-row { display: flex; gap: .3rem; justify-content: center; }
.sb-remain-row input { width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.sb-remain-row .ghost-btn { padding: .3rem .6rem; }

.sb-protocol { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.sb-protocol table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.sb-protocol th, .sb-protocol td { padding: .3rem .55rem; text-align: left; border-bottom: 1px solid var(--line); }
.sb-protocol th { position: sticky; top: 0; background: var(--bg-raised); color: var(--text-dim); font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
.sb-protocol td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sb-protocol tr.foul td { color: #ffb3b0; }

/* ---------- Statistik (zweizeilig: Kreisdiagramme, darunter Kennzahlen) ---------- */
.sb-stats { display: flex; flex-direction: column; gap: 1rem; }
/* Jede Zeile verteilt ihre Elemente gleichmäßig über die volle Breite und bricht
   responsiv um (auto-fit-Grid mit gleich breiten 1fr-Spalten). */
.sb-stat-row { display: grid; gap: .8rem 1rem; align-items: start; }
.sb-donut-row { grid-template-columns: repeat(5, 1fr); }
.sb-kpi-row {
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line); padding-top: .9rem;
}
/* Eine Disziplin-Kachel bündelt „Sätze" und (bei 8/9/10) „Spiele" */
.sb-disc-card { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.sb-disc-name { font-size: .74rem; font-weight: 650; letter-spacing: .02em; }
.sb-disc-donuts { display: flex; gap: .55rem; justify-content: center; }
.sb-donut { display: flex; flex-direction: column; align-items: center; gap: .02rem; min-width: 44px; }
.sb-donut svg { width: 46px; height: 46px; }
.sb-donut svg text { fill: var(--text); font-size: 12px; font-weight: 700; }
.sb-donut-sub { font-size: .6rem; text-transform: uppercase; letter-spacing: .06em; }
.sb-donut > span { font-size: .62rem; }
.sb-kpi { display: flex; flex-direction: column; gap: .12rem; min-width: 0; text-align: center; }
.sb-kpi > span:first-child {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim);
}
.sb-kpi > b { font-size: 1.35rem; line-height: 1.1; }
.sb-kpi-partners .sb-partner { display: block; font-size: .82rem; line-height: 1.35; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  /* Auf schmalen Geräten je Zeile zwei Spalten (Diagramme paarweise, Kennzahlen 2×2) */
  .sb-donut-row, .sb-kpi-row { grid-template-columns: repeat(2, 1fr); }
}

/* Auto-Save-Hinweis (statt Speichern-Button); schiebt die Buttons nach rechts */
.sb-savehint { font-size: .78rem; margin-right: auto; }

/* Read-only-Detailansicht: Seiten nicht antippbar, Hinweis verstecken */
#sb-board.readonly .sb-side { cursor: default; }
#sb-board.readonly .sb-side:hover { border-color: var(--line); }
#sb-board.readonly .sb-tap-hint { display: none; }

/* ---------- Abschluss / Historie ---------- */
.sb-final {
  text-align: center; padding: .8rem; border: 1px solid var(--ok); border-radius: 8px;
  background: rgba(63,174,106,.1); font-weight: 650;
}
.sb-hist-item {
  /* Datum | Namen | Ergebnis | Aktionen – Aktionsspalte mit fester Mindestbreite,
     damit die Ergebnisse über alle Zeilen sauber in EINER Spalte stehen */
  display: grid; grid-template-columns: minmax(110px, auto) 1fr auto minmax(12rem, auto);
  gap: .3rem 1rem; align-items: center;
  padding: .65rem .3rem; border-bottom: 1px solid var(--line); font-size: .9rem;
}
.sb-hist-item:last-child { border-bottom: 0; }
.sb-hist-item.clickable { cursor: pointer; border-radius: 6px; }
.sb-hist-item.clickable:hover { background: rgba(79,155,220,.07); }
.sb-hist-item .res { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; justify-self: end; }
.sb-hist-item .who { min-width: 0; overflow-wrap: anywhere; }
.sb-hist-item .meta { color: var(--text-dim); font-size: .78rem; }
.sb-hist-actions { display: flex; gap: .4rem; justify-self: end; grid-column: -2; }
.sb-hist-actions:empty { visibility: hidden; }
/* Status („wartet auf Bestätigung …", „laufend", „abgelehnt") in eigener Zeile darunter,
   damit die Ergebnisse sauber in einer Spalte untereinander stehen */
.sb-hist-tags { grid-column: 1 / -1; display: flex; gap: .4rem; flex-wrap: wrap; }
.sb-hist-item .tag {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .08em;
  border: 1px solid var(--line); border-radius: 999px; padding: .1rem .5rem; color: var(--text-dim);
}
.sb-hist-item .tag.warn { border-color: #c9a227; color: #e8c95a; }
.sb-hist-item .tag.err { border-color: var(--danger); color: #ffb3b0; }
.sb-hist-item .tag.run { border-color: var(--accent); color: var(--accent-strong); }

@media (max-width: 640px) {
  .sb-main { padding: .7rem; }
  .sb-sides { flex-direction: row; gap: .5rem; }
  .sb-mid { min-width: 56px; }
  .sb-side { padding: .9rem .4rem; }
  .sb-st-grid { grid-template-columns: 1fr; }
  .sb-st-mid { flex-direction: row; justify-content: space-around; }
  .sb-actions button, .sb-main .modal-actions button { padding: .6rem .8rem; }
  .sb-main .modal-actions { flex-wrap: wrap; }
  .sb-hist-item { grid-template-columns: 1fr auto; }
  .sb-hist-item .meta:first-child { grid-column: 1 / -1; }
  .sb-hist-actions { grid-column: 1 / -1; justify-self: start; visibility: visible; }
}
