/* SchachLive – Gestaltung
   Kühle Turniersaal-Töne, Salbei-Schiefer-Brett; das markante Element sind die
   Uhren im Stil einer digitalen Schachuhr: die laufende Seite leuchtet.

   Alle Farben stehen als Variablen in :root und werden für den Dunkelmodus
   unten überschrieben. Wer die Farben an den Verein anpassen will, ändert nur
   diese Blöcke. Die Bretter (SVG) nutzen dieselben Variablen über die Klassen
   .sq-l, .sq-d usw.

   Hell/Dunkel: ohne Wahl folgt die Seite dem Gerät (prefers-color-scheme).
   Wählt der Zuschauer im Ansicht-Menü ausdrücklich, setzt prefs.js
   data-theme="light" bzw. "dark" am <html>-Element – das hat Vorrang.

   Brettfarben: --board-l/--board-d sind nur gesetzt, wenn Verein (Admin) oder
   Zuschauer eigene Farben gewählt haben; sonst gelten die eingebauten Farben,
   die im Dunkelmodus etwas gedämpft sind. Eigene Farben gelten in beiden Modi.

   Gliederung: Grundlagen – Kopf – Turnierliste – Rundenliste – Rundenansicht
   (Karten, Spielerzeilen, Uhr) – Einzelpartie – Rundenübersicht-Zusätze –
   Analysebrett – Engine – Varianten – Einbettung – Admin */

:root {
  --bg: #eef1ee;  /* Seitenhintergrund */
  --surface: #ffffff;  /* Flächen (Kästen, Kopfzeile) */
  --ink: #18201d;  /* Text */
  --muted: #5b6863;  /* Nebentext */
  --line: #d4dbd7;  /* Trennlinien, Rahmen */
  --link: #2a5873;
  --sq-l: var(--board-l, #e4e8de);  /* helle Felder */
  --sq-d: var(--board-d, #7d9585);  /* dunkle Felder */
  --hl: rgba(226, 184, 58, .55);  /* letzter Zug */
  --check: rgba(200, 55, 45, .55);  /* König im Schach */
  --live: #c8372d;  /* „läuft“, Titel, Warnungen */
  --clock-bg: #26302c;  /* stehende Uhr */
  --clock-ink: #a9bbb3;
  --clock-run-bg: #f1c34a;  /* laufende Uhr (das Leuchten) */
  --clock-run-ink: #1d1a10;
  --done: #8a9692;
  --radius-s: 4px;
  --radius-m: 8px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  color-scheme: light;
}
/* Dunkle Fassung – automatisch nach Einstellung des Geräts, außer der Zuschauer
   hat ausdrücklich „Hell“ gewählt … */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131816;
    --surface: #1b211f;
    --ink: #e3e9e5;
    --muted: #93a19b;
    --line: #2d3633;
    --link: #8cc0dc;
    --sq-l: var(--board-l, #b3bfb1);
    --sq-d: var(--board-d, #627a6a);
    --clock-bg: #0d1110;
    --clock-ink: #93a8a0;
    --done: #6c7874;
    color-scheme: dark;
  }
}
/* … oder ausdrücklich „Dunkel“ gewählt (gleiche Werte) */
:root[data-theme="dark"] {
  --bg: #131816;
  --surface: #1b211f;
  --ink: #e3e9e5;
  --muted: #93a19b;
  --line: #2d3633;
  --link: #8cc0dc;
  --sq-l: var(--board-l, #b3bfb1);
  --sq-d: var(--board-d, #627a6a);
  --clock-bg: #0d1110;
  --clock-ink: #93a8a0;
  --done: #6c7874;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; } /* Fußzeile bleibt auch bei wenig Inhalt unten */
a { color: var(--link); }
/* Deutlicher Fokusrahmen für die Bedienung mit Tastatur */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 2px;
}
h1, h2 { line-height: 1.15; }

/* ---------- Kopf ---------- */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
}
.brand svg { width: 22px; height: 22px; background: var(--sq-l); fill: var(--sq-d); border-radius: 3px; }
/* Hochgeladenes Logo: feste Höhe, Breite folgt dem Seitenverhältnis */
.brand img { display: block; height: 80px; width: auto; max-width: 200px; object-fit: contain; }
@media (max-width: 480px) { .brand img { height: 28px; max-width: 150px; } }
.logo-now { display: flex; align-items: center; gap: 12px; }
.logo-now img { height: 40px; width: auto; max-width: 220px; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 15px; color: var(--muted); }
.crumbs > * + *::before { content: "/"; margin-right: 6px; color: var(--line); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs [aria-current] { color: var(--ink); }

/* Hinweis „Keine Verbindung“ (von app.js ein-/ausgeblendet) */
.conn {
  margin: 0;
  padding: 8px 20px;
  background: var(--live);
  color: #fff;
  font-size: 14px;
}

.wrap { max-width: 860px; margin: 0 auto; padding: 32px 20px 48px; }
.wrap.wide { max-width: 1440px; }
.page-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: -.01em;
  margin: 0 0 8px;
}
.lead { color: var(--muted); margin: 0 0 20px; font-size: 18px; }
.desc { max-width: 65ch; margin-bottom: 24px; }
.sub { font-size: 17px; margin: 32px 0 12px; }
.empty { color: var(--muted); max-width: 60ch; }
.small { font-size: 14px; }
.actions { margin-top: 24px; font-size: 15px; }
.foot { padding: 20px; font-size: 13px; color: var(--muted); text-align: center; }

/* Ansicht-Menü (prefs.js): Knopf rechts im Kopf, Menü klappt darunter auf */
.prefs-wrap { position: relative; margin-left: auto; }
.prefs-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--ink);
  font: 600 14px var(--sans);
  cursor: pointer;
}
.prefs-btn:hover { border-color: var(--muted); }
.prefs-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.prefs-btn svg path { fill: currentColor; stroke: none; } /* halb gefüllter Kreis: Tag/Nacht */
.prefs {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  width: 300px;
  max-width: calc(100vw - 24px);
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.prefs[hidden] { display: none; }
.prefs fieldset { border: 0; margin: 0; padding: 0; }
.prefs fieldset + fieldset { margin-top: 14px; }
.prefs legend { font-weight: 700; font-size: 14px; margin-bottom: 8px; padding: 0; }
/* Hell/Automatisch/Dunkel als Segmentschalter; die Radios bleiben für Tastatur und Screenreader */
.seg { display: flex; }
.seg legend { width: 100%; }
.seg label { flex: 1; position: relative; }
.seg input, .bopt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span {
  display: block;
  padding: 7px 4px;
  text-align: center;
  font-size: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
}
.seg label + label span { border-left: 0; }
.seg label:first-of-type span { border-radius: var(--radius-s) 0 0 var(--radius-s); }
.seg label:last-of-type span { border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.seg input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg input:focus-visible + span, .bopt input:focus-visible ~ .bprev { outline: 3px solid var(--link); outline-offset: 2px; }
/* Farbsätze als kleine Vorschau-Bretter */
.boards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.boards legend { grid-column: 1 / -1; }
.bopt { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; position: relative; }
.bprev {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  background: conic-gradient(var(--d) 0 25%, var(--l) 0 50%, var(--d) 0 75%, var(--l) 0) 0 0 / 50% 50%;
  box-shadow: 0 0 0 1px var(--line);
}
.bopt input:checked ~ .bprev { box-shadow: 0 0 0 3px var(--ink); }
.custom { grid-column: 1 / -1; display: flex; gap: 12px; font-size: 13px; }
.custom label { display: flex; align-items: center; gap: 6px; }
.custom input { width: 36px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: none; cursor: pointer; }
/* Kein blauer Tipp-Kasten auf Mobilgeräten – die Auswahl ist durch den Rahmen sichtbar */
.seg label, .bopt { -webkit-tap-highlight-color: transparent; }
@media (max-width: 600px) {
  /* Schmal: Name und Ansicht-Knopf in einer Zeile, Brotkrümel darunter */
  .top .crumbs { order: 3; flex-basis: 100%; }
}
@media (max-width: 480px) { .prefs-btn span { display: none; } }

/* ---------- Turnierliste ---------- */
.tlist { list-style: none; margin: 24px 0 0; padding: 0; border-top: 1px solid var(--line); }
.tlist li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.tname { font-family: var(--serif); font-size: 22px; font-weight: 600; color: var(--ink); text-decoration: none; }
.tname:hover { text-decoration: underline; }
.tmeta { grid-column: 1; color: var(--muted); font-size: 15px; display: flex; flex-wrap: wrap; gap: 0 14px; }
.live-pill {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.live-pill::before, .status[data-s="live"]::before, .others .dot {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  display: inline-block;
}
@media (max-width: 560px) {
  .tlist li { grid-template-columns: 1fr; }
  .live-pill { grid-column: 1; grid-row: auto; justify-self: start; margin-top: 8px; }
}

/* ---------- Rundenliste ---------- */
.rlist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rlist a {
  display: grid;
  grid-template-columns: 100px 1fr auto auto;
  align-items: baseline;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}
.rlist a:hover { background: var(--surface); }
.rno { font-weight: 600; }
.rname, .rprog { color: var(--muted); font-size: 15px; }
@media (max-width: 560px) {
  .rlist a { grid-template-columns: 1fr auto; }
  .rname, .rprog { grid-column: 1; }
  .rlist .status { grid-column: 2; grid-row: 1; }
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  vertical-align: middle;
  letter-spacing: 0;
}
.status[data-s="live"] { color: var(--live); }

/* ---------- Rundenansicht ---------- */
.round-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; margin-bottom: 24px; }
.round-head .page-title { margin: 0; }
.rtabs { display: flex; flex-wrap: wrap; gap: 4px; }
.rtabs a {
  min-width: 36px;
  padding: 6px 8px;
  text-align: center;
  border-radius: var(--radius-s);
  color: var(--muted);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.rtabs a:hover { background: var(--surface); color: var(--ink); }
.rtabs a[aria-current] { background: var(--ink); color: var(--bg); }

/* Bretter der Rundenübersicht: so viele Spalten, wie mit mindestens 250 px passen */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 28px 20px;
}
.card {
  display: block;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius-m);
  padding: 6px;
  margin: -6px;
}
.card:hover { background: var(--surface); }
.card-h { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 0 2px 4px; }
.bno { font-weight: 600; color: var(--ink); }
.card .bw { line-height: 0; }
.card.done .board { opacity: .82; }
/* Brett mit neuem Zug leuchtet kurz auf (Klasse setzt app.js) */
.card.moved .bw { animation: moved 1.4s ease-out; }
@keyframes moved {
  from { box-shadow: 0 0 0 4px var(--clock-run-bg); }
  to { box-shadow: 0 0 0 4px transparent; }
}

.board { display: block; width: 100%; height: auto; border-radius: 2px; }
/* Felder und Markierungen der SVG-Bretter */
.sq-l { fill: var(--sq-l); }
.sq-d { fill: var(--sq-d); }
.sq-hl { fill: var(--hl); }
.sq-check { fill: var(--check); }
.co { font: 600 10px var(--sans); }
.co-l { fill: var(--sq-l); }
.co-d { fill: var(--sq-d); }

/* Spielerzeilen */
.pl {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 3px 2px;
  font-size: 14px;
}
.pl .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl .title { color: var(--live); font-weight: 700; font-size: .92em; }
.pl .elo { color: var(--muted); font-variant-numeric: tabular-nums; }
.pl .team { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.score {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
}
.tomove { width: 10px; height: 10px; border-radius: 50%; background: var(--clock-run-bg); }

/* Die Uhr */
.clock {
  font: 700 15px/1 var(--sans);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  padding: 6px 8px;
  border-radius: var(--radius-s);
  background: var(--clock-bg);
  color: var(--clock-ink);
  min-width: 64px;
  text-align: right;
}
.clock.run {
  background: var(--clock-run-bg);
  color: var(--clock-run-ink);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .08), 0 0 14px rgba(241, 195, 74, .45);
}
.clock.big { font-size: 22px; padding: 8px 12px; min-width: 104px; }

/* ---------- Einzelpartie ---------- */
/* Partieansicht: Brett links, Zugliste rechts.
   Das Brett ist so groß, dass Spielerleisten und Bedienknöpfe darunter noch ohne
   Scrollen ins Fenster passen: Fensterhöhe minus --chrome (Kopfzeile, Abstand,
   zwei Spielerleisten, Knopfleiste – gemessen rund 255 px, mit etwas Luft).
   Mindestens 280 px, damit es auf sehr flachen Fenstern bedienbar bleibt
   (dann wird gescrollt), höchstens 720 px. dvh berücksichtigt auf Mobilgeräten
   die ein- und ausfahrende Adressleiste; ältere Browser nehmen vh. */
.game {
  --chrome: 270px;
  --board-w: clamp(280px, calc(100vh - var(--chrome)), 720px);
  display: grid;
  grid-template-columns: minmax(0, var(--board-w)) minmax(260px, 380px);
  justify-content: center;
  gap: 32px;
  align-items: start;
}
@supports (height: 100dvh) {
  .game { --board-w: clamp(280px, calc(100dvh - var(--chrome)), 720px); }
}
/* Eingebettet (?embed=1) gibt es keine Kopfzeile und weniger Abstand */
body.embed .game { --chrome: 185px; }
.board-big { line-height: 0; }
.board-big .empty { line-height: 1.5; }
.pl-big { font-size: 17px; min-height: 52px; }
.pl-big .team { font-size: 14px; }
.controls { display: flex; gap: 6px; margin-top: 12px; }
.controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  min-width: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--ink);
  font: 600 14px var(--sans);
  cursor: pointer;
}
.controls button:hover { border-color: var(--muted); }
.controls svg { width: 18px; height: 18px; fill: currentColor; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.controls .flip svg, .controls .mark svg { fill: none; }
.controls .mark { margin-left: auto; }
.controls .mark[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
#btn-live span { display: none; }
/* „Aktuell“-Knopf leuchtet, wenn man nicht beim letzten Partiezug steht */
#btn-live.behind { background: var(--clock-run-bg); color: var(--clock-run-ink); border-color: transparent; }
#btn-live.behind span { display: inline; }

.side { min-width: 0; }
.meta { display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.note { font-size: 14px; padding: 10px 12px; border-left: 3px solid var(--live); background: var(--surface); }
/* Zugliste als Raster: Nummer | Weiß | Schwarz */
.moves {
  display: grid;
  grid-template-columns: 40px 1fr 1fr;
  align-content: start;
  max-height: min(56vh, 520px);
  overflow-y: auto;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 6px 0;
  font-size: 15px;
}
.moves .no { padding: 4px 10px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.moves .mv {
  text-align: left;
  padding: 4px 10px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-s);
}
.moves button.mv:hover { background: var(--bg); }
.moves .mv.on { background: var(--ink); color: var(--bg); }
.moves .mv.blank { color: var(--muted); cursor: default; }
.moves .final { grid-column: 1 / -1; text-align: center; font-weight: 700; padding: 10px; }
.moves > .empty { grid-column: 1 / -1; padding: 6px 12px; margin: 0; }

.others { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.others a {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}
.others a:hover { background: var(--surface); }
.others [aria-current] a { font-weight: 700; }
.others .bno { color: var(--muted); font-weight: 600; text-align: right; }
.others .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.others .r { font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .game { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  /* Einspaltig: Brett so breit wie möglich, aber nicht höher als das Fenster erlaubt */
  .board-col { width: 100%; max-width: var(--board-w); justify-self: center; }
  .moves { max-height: 40vh; }
}
@media (max-width: 480px) {
  .wrap { padding: 20px 12px 40px; }
  .controls button { min-width: 0; flex: 1; padding: 0 6px; }
  .controls .mark { margin-left: 0; }
  .controls .mark span, .controls .flip span { display: none; }
  .clock.big { font-size: 19px; min-width: 88px; }
}

/* Rundenübersicht: Werkzeuge, neue Runde, Bewertungsbalken */
.round-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.round-tools .switch[hidden] { display: none; }
.newround {
  margin: -8px 0 20px;
  padding: 10px 14px;
  border-radius: var(--radius-s);
  background: var(--clock-run-bg);
  color: var(--clock-run-ink);
  font-weight: 600;
}
.newround a { color: inherit; margin-left: 6px; }
.newround[hidden] { display: none; }

/* Zuschauerzahl (Auge + Zahl), nur wenn im Admin-Bereich eingeschaltet */
.viewers { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.viewers[hidden] { display: none; }
.viewers svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.actions .viewers { float: right; }

/* Mannschaftskampf: Paarungstabelle über den Brettern (zeichnet app.js, renderMatch).
   Kopf „Heim  4½ : 3½  Gast“, darunter je Brett Heimspieler – Ergebnis – Gastspieler.
   Der Farbpunkt zeigt, wer Weiß hat; laufende Partien sind markiert. */
.match { max-width: 880px; margin: 0 auto 32px; }
.match[hidden] { display: none; }
.match-h {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
}
.mteam.home { text-align: right; }
.mscore {
  font-variant-numeric: tabular-nums;
  padding: 2px 14px;
  border-radius: var(--radius-m);
  background: var(--ink);
  color: var(--bg);
  white-space: nowrap;
}
.mopen { display: block; text-align: center; font-size: 13px; color: var(--muted); margin-top: 6px; }
.ptab { width: 100%; border-collapse: collapse; margin-top: 14px; table-layout: fixed; font-size: 15px; }
.ptab td { padding: 7px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.ptab tr:last-child td { border-bottom: 1px solid var(--line); }
.ptab a { color: var(--ink); text-decoration: none; }
.ptab a:hover .name { text-decoration: underline; }
.ptab .mb { width: 3.2em; color: var(--muted); font-variant-numeric: tabular-nums; }
.ptab .mr { width: 6.5em; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ptab .mh { text-align: right; }
/* Spielerzelle: Farbpunkt und Name nebeneinander, Heim rechtsbündig zur Mitte hin */
.ptab .pc { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ptab .mh .pc { justify-content: flex-end; }
.ptab .pc a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptab .name { white-space: nowrap; }
.ptab .elo { color: var(--muted); }
.ptab tr.live .mr { color: var(--live); }
.mrun { font-weight: 600; font-size: 13px; }
/* Farbpunkt: Weiß hell mit Rand, Schwarz dunkel */
/* fester grauer Rand, damit beide Punkte in Hell und Dunkel gleich aussehen */
.cdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid #7d8884; vertical-align: middle; flex: none; }
.cdot.w { background: #fff; }
.cdot.b { background: #1b1f1d; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 600px) {
  .match-h { font-size: 18px; gap: 10px; }
  .mscore { padding: 2px 10px; }
  .ptab { font-size: 14px; }
  .ptab td { padding: 7px 4px; }
  .ptab .mb { width: 2.2em; }
  .ptab .mr { width: 4.6em; }
  .ptab .elo { display: none; }
  /* Namen dürfen umbrechen statt abgeschnitten zu werden */
  .ptab .pc { gap: 6px; }
  .ptab .pc a, .ptab .name { white-space: normal; overflow: visible; }
  .ptab .mh, .ptab .ma { font-size: 13px; line-height: 1.3; }
}
.card-h { align-items: baseline; gap: 8px; }
.card-h .res { margin-left: auto; }
/* Bewertung und Balken nur zeigen, wenn round.js .with-eval am Raster setzt */
.ceval, .cbar { display: none; }
.grid.with-eval .ceval {
  display: inline;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.grid.with-eval .bw { display: flex; gap: 3px; }
.grid.with-eval .bw .board { flex: 1; min-width: 0; }
.grid.with-eval .cbar {
  display: block;
  position: relative;
  width: 7px;
  flex: none;
  background: #3a3a3a;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--muted);
}
/* „erst nach Partieende“: laufende Bretter ohne Balken, aber mit gleichem Platz –
   sonst wären die Bretter unterschiedlich breit */
.grid.with-eval.eval-done .card:not(.done) .cbar { visibility: hidden; }
.grid.with-eval.eval-done .card:not(.done) .ceval { display: none; }
.cbar > div {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50%;
  background: #f3f3f3;
  transition: height .4s ease;
}
@media (prefers-reduced-motion: reduce) { .cbar > div, .evalbar > div { transition: none; } }

/* ---------- Analysebrett ---------- */
.board-row { display: flex; gap: 6px; align-items: stretch; }
.board-row .board-big { flex: 1; min-width: 0; }
.iboard { position: relative; }
/* touch-action: none – auf Touch-Geräten zieht der Finger die Figur, statt die Seite zu scrollen */
.iboard svg { touch-action: none; cursor: pointer; user-select: none; -webkit-user-select: none; }
.iboard svg.marking { cursor: crosshair; }
.iboard .ghost { pointer-events: none; }
.sq-sel { fill: rgba(20, 85, 30, .5); }
.dest { fill: rgba(20, 85, 30, .5); pointer-events: none; }
.dest-cap { fill: none; stroke: rgba(20, 85, 30, .5); stroke-width: 5; pointer-events: none; }
.promo {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .45);
  border-radius: 2px;
}
.promo[hidden] { display: none; }
.promo-box { display: flex; gap: 6px; padding: 10px; background: var(--surface); border-radius: var(--radius-m); }
.promo-box button {
  width: clamp(48px, 10vw, 72px);
  aspect-ratio: 1;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--sq-l);
  cursor: pointer;
}
.promo-box button:hover, .promo-box button:focus-visible { background: var(--clock-run-bg); }
.promo-box svg { width: 100%; height: 100%; display: block; }

/* Bewertungsbalken: dunkel = Schwarz; der helle Anteil (Weiß) wächst von unten */
.evalbar {
  width: 14px;
  flex: none;
  position: relative;
  overflow: hidden;
  background: #3a3a3a;
  border-radius: 2px;
  box-shadow: 0 0 0 1px var(--muted);
}
.evalbar[hidden] { display: none; }
.evalbar > div {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50%;
  background: #f3f3f3;
  transition: height .4s ease;
}
.evalbar.flip > div { bottom: auto; top: 0; }

.swatches { display: flex; gap: 8px; margin-top: 10px; }
.swatches[hidden] { display: none; }
.swatches button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  background: var(--c);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); }
.hint { font-size: 13px; color: var(--muted); max-width: 60ch; margin: 12px 0 0; }
/* Bedienhinweis mit Maustasten nur auf Geräten mit Maus */
@media (hover: none) { .hint { display: none; } }

/* Engine */
.engine {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.engine[hidden] { display: none; }
.eng-head { display: flex; align-items: center; gap: 12px; }
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 600 14px var(--sans);
  cursor: pointer;
}
.switch .knob {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  transition: background .15s;
}
.switch .knob::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .15s;
}
.switch[aria-pressed="true"] .knob { background: var(--sq-d); }
.switch[aria-pressed="true"] .knob::after { transform: translateX(14px); }
.switch:disabled { opacity: .5; cursor: not-allowed; }
.eng-eval { font: 700 18px var(--sans); font-variant-numeric: tabular-nums; margin-left: auto; }
.eng-info { font-size: 13px; color: var(--muted); min-width: 64px; text-align: right; }
.eng-note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.eng-name { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.eng-name[hidden] { display: none; }
.eng-opt { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-top: 6px; cursor: pointer; }
.eng-opt[hidden] { display: none; }
.eng-note[hidden] { display: none; }
.eng-lines { list-style: none; margin: 6px 0 0; padding: 0; font-size: 14px; }
.eng-lines:empty { display: none; }
.eng-lines li { display: flex; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); }
.eng-lines .ev { flex: none; width: 52px; font-weight: 700; font-variant-numeric: tabular-nums; }
.eng-lines .pv { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eng-lines button, .moves .mv.v {
  border: 0;
  background: none;
  padding: 1px 3px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: 3px;
}
.eng-lines button:hover, .moves .mv.v:hover { background: var(--bg); }
.vno { color: var(--muted); margin-right: 2px; }

/* Varianten in der Zugliste */
.moves .vars {
  grid-column: 1 / -1;
  margin: 2px 0 4px 40px;
  padding: 4px 6px;
  border-left: 2px solid var(--line);
  font-size: 14px;
}
.moves .vline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 2px; padding: 2px 0; }
.moves .vline + .vline { border-top: 1px dashed var(--line); }
.moves .mv.v { text-align: left; font-weight: 400; }
.moves .mv.v.on { background: var(--ink); color: var(--bg); }
.moves .mv.v.on .vno { color: inherit; }
.moves .nest { color: var(--muted); display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 2px; }
.moves .nest .mv.v { color: var(--ink); }
.moves .vdel {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 0 6px;
  cursor: pointer;
  border-radius: 3px;
}
.moves .vdel:hover { color: var(--live); background: var(--bg); }

/* Einbettung per iframe auf der Vereinsseite */
body.embed .wrap { padding: 12px; }
body.embed .page-title { font-size: 22px; }

@media (prefers-reduced-motion: reduce) {
  .card.moved .bw { animation: none; box-shadow: 0 0 0 3px var(--clock-run-bg); }
}

/* ---------- Admin ---------- */
.admin .wrap { max-width: 1040px; }
.admin h1 { font-family: var(--serif); font-size: 32px; margin: 0 0 20px; }
.admin h2 { font-size: 18px; margin: 36px 0 12px; }
/* Programmversion unten im Admin-Bereich */
.teamset { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 10px 14px 4px; margin: 0; }
.teamset legend { font-weight: 600; padding: 0 4px; }
.stat-now { font-size: 18px; margin: 0 0 6px; }
.stat-now b { font-family: var(--serif); font-size: 32px; margin-right: 4px; }
.admin-foot { max-width: 1040px; margin: 0 auto; padding: 8px 24px 32px; font-size: 12px; color: var(--muted); }
.flash { padding: 10px 14px; border-radius: var(--radius-s); background: var(--surface); border-left: 4px solid var(--sq-d); margin: 0 0 20px; }
.flash.err { border-left-color: var(--live); }
.form { display: grid; gap: 14px; max-width: 560px; }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.form label .hint { font-weight: 400; color: var(--muted); }
.form input, .form select, .form textarea {
  font: 15px var(--sans);
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}
.form textarea { min-height: 120px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.form .check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.form .check input { width: auto; }
.btn {
  display: inline-block;
  padding: 9px 16px;
  border: 0;
  border-radius: var(--radius-s);
  background: var(--ink);
  color: var(--bg);
  font: 600 15px var(--sans);
  cursor: pointer;
  text-decoration: none;
  justify-self: start;
}
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--live); color: #fff; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.inline { display: inline; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .err { color: var(--live); font-size: 13px; }
.code {
  display: block;
  padding: 12px 14px;
  background: var(--clock-bg);
  color: #dfe8e3;
  border-radius: var(--radius-s);
  font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-x: auto;
  white-space: pre;
}
.keybox { font: 15px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 760px) { .split, .form .row2 { grid-template-columns: 1fr; } }
.admin-nav { display: flex; gap: 16px; margin-left: auto; font-size: 15px; }

/* Brettfarben im Admin-Bereich: gleiche Vorschau wie im Ansicht-Menü, mehr Spalten */
.prefs-admin .boards { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); max-width: 460px; }
/* Die allgemeinen Formularstile (.form label/.form input) hier zurücknehmen */
.prefs-admin fieldset { border: 0; margin: 0; padding: 0; }
.prefs-admin .bopt { display: flex; font-weight: 400; }
.prefs-admin .custom label { display: flex; font-weight: 400; }
.prefs-admin .custom input { width: 44px; height: 32px; padding: 2px; }
