/* Mannschaftstool SV Oberursel – helles Layout in den Trikotfarben: Weiß, Dunkelblau, Gold. Keine Frameworks. */

:root {
  --bg: #f3f4f7;
  --paper: #ffffff;
  --paper-2: #eceef3;
  --line: #d9dce4;
  --line-soft: #e9ebf0;      /* Spaltentrenner in Tabellen */
  --paper-stripe: #f7f8fb;   /* jede zweite Tabellenzeile */
  --text: #1b2236;
  --text-muted: #5f6678;
  --navy: #1b2236;
  --navy-2: #2a3450;
  --navy-ink: #ffffff;
  --accent: #c9a227;
  --accent-strong: #a8861b;
  --accent-soft: #f6efd6;
  --accent-ink: #1b2236;
  --win: #2f8f5b;
  --draw: #6b7280;
  --loss: #c0392b;
  --warn: #a8861b;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--text); background: var(--bg); }
a { color: var(--navy); text-decoration: none; border-bottom: 1px solid transparent; }
a:hover { border-bottom-color: var(--accent); }
a.link { color: var(--accent-strong); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; letter-spacing: -0.01em; color: var(--navy); }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; margin-top: 1.25rem; }
h2:first-child { margin-top: 0; }
h3 { font-size: 1rem; }
p { margin: .5rem 0; }
pre, code { font-family: var(--mono); font-size: .9em; }
pre { background: var(--paper-2); border: 1px solid var(--line); border-radius: 8px; padding: .75rem; overflow-x: auto; }
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.pre-line { white-space: pre-line; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.eyebrow { font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-strong); margin-bottom: .25rem; font-weight: 600; }
.eyebrow a { color: inherit; }
.h-sub { font-size: 1rem; margin-top: 1rem; }

/* Kopfzeile: Dunkelblau mit goldenem Saum, wie die Trikotstreifen */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .55rem 1.25rem; background: var(--navy); color: var(--navy-ink);
  border-bottom: 3px solid var(--accent); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--navy-ink); display: flex; align-items: center; gap: .55rem; }
.brand:hover { border-bottom-color: transparent; }
.brand-crest { height: 36px; width: auto; display: block; }
.nav { display: flex; gap: .15rem; flex-wrap: wrap; }
.nav a { padding: .45rem .75rem; border-radius: 6px; color: #c8cdda; border: none; font-weight: 500; }
.nav a:hover { color: #fff; background: var(--navy-2); }
.nav a.active { color: var(--accent); background: var(--navy-2); box-shadow: inset 0 -2px 0 var(--accent); }
.nav a.nav-cta { color: var(--accent-ink); background: var(--accent); font-weight: 600; }
.page { max-width: 1180px; margin: 0 auto; padding: 1.25rem; }
.footer { max-width: 1180px; margin: 2rem auto; padding: 0 1.25rem; color: var(--text-muted); font-size: .8rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.footer a { color: var(--text-muted); }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
@media (max-width: 480px) { .grid-2 { grid-template-columns: 1fr; } }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; margin-bottom: 1rem; box-shadow: 0 1px 2px rgba(27, 34, 54, .04);
}
.grid .card { margin-bottom: 0; }
.card-accent { border-top: 4px solid var(--accent); }
.card-own { border-color: #b9c4dd; }
.card-narrow { max-width: 640px; margin-left: auto; margin-right: auto; }
.toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Tabellen – wie Kreuztabellen und Ligatabellen der Schachwelt: ruhige Linien, Zahlen rechtsbündig */
/* Tabellen wie bei chess-results: feine Linien zwischen den Spalten, gestreifte Zeilen, Zahlenspalten schmal mit
   Luft – die Namensspalte bekommt die restliche Breite (Roman, 08.09.2026: „von den Zahlen erschlagen“). */
.table { width: 100%; border-collapse: collapse; margin: .5rem 0; }
.table th, .table td { padding: .5rem .85rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th + th, .table td + td { border-left: 1px solid var(--line-soft); }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; background: var(--paper-2); border-bottom: 2px solid var(--line); }
.table th.num, .table td.num { text-align: right; width: 1%; white-space: nowrap; }
.table tbody tr:nth-child(even) td { background: var(--paper-stripe); }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--navy); }
.table th[aria-sort=ascending]::after { content: " ▲"; font-size: .7em; }
.table th[aria-sort=descending]::after { content: " ▼"; font-size: .7em; }
.table-compact th, .table-compact td { padding: .35rem .5rem; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr.row-own td { background: var(--accent-soft); }
.table tbody tr.row-own td:first-child { border-left: 3px solid var(--accent); }
.table td.rank { color: var(--text-muted); width: 2rem; }
.table tr.muted td { color: var(--text-muted); }
.table-wrap, .table-scroll { overflow-x: auto; }
@media (max-width: 720px) { .card { overflow-x: auto; } }

/* Ergebnisse */
.results { white-space: nowrap; }
.res {
  display: inline-block; min-width: 1.35rem; padding: 0 .3rem; margin-right: 2px; text-align: center;
  border-radius: 5px; font-size: .8rem; font-weight: 600; background: var(--paper-2); color: var(--text-muted);
}
.res-win { background: #dff3e6; color: var(--win); }
.res-draw { background: #e8eaee; color: var(--draw); }
.res-loss { background: #f9e0dc; color: var(--loss); }
.delta { font-size: .8rem; }
.delta.pos { color: var(--win); }
.delta.neg { color: var(--loss); }

.tag {
  display: inline-block; font-size: .7rem; padding: .05rem .4rem; border-radius: 999px; margin-left: .3rem;
  background: var(--paper-2); color: var(--text-muted); vertical-align: middle; border: none;
}
.tag-warn { background: var(--accent-soft); color: var(--warn); }
.tag-own { background: var(--accent-soft); color: var(--accent-strong); }

.match-title { font-size: 1.35rem; display: flex; flex-wrap: wrap; gap: .35rem .5rem; align-items: baseline; }
.match-title .vs { color: var(--text-muted); font-weight: 400; }
.match-title .match-result { margin-left: auto; color: var(--accent-strong); font-variant-numeric: tabular-nums; }
.match-meta { color: var(--text-muted); }
.h-round { margin-top: 1.25rem; display: flex; gap: .75rem; align-items: baseline; }
.round-nav { display: flex; gap: .3rem; flex-wrap: wrap; }
.round-nav a { padding: .25rem .6rem; border-radius: 6px; background: var(--paper-2); border: none; color: var(--text-muted); }
.round-nav a.active { background: var(--navy); color: var(--navy-ink); font-weight: 600; }

/* Stat-Kacheln */
.stat-row { display: flex; gap: .75rem; flex-wrap: wrap; margin: .75rem 0; }
.stat { background: var(--paper-2); border-radius: 8px; padding: .5rem .9rem; min-width: 7rem; }
.stat-label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.stat-value { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--navy); }

/* Rennen um die 2000 */
.race { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .45rem; }
.race li { display: grid; grid-template-columns: minmax(8rem, 1.2fr) 3fr auto auto; gap: .6rem; align-items: center; }
.race-large li { grid-template-columns: minmax(9rem, 1.2fr) 3fr auto auto auto; }
.race-bar { height: 10px; border-radius: 999px; background: var(--paper-2); overflow: hidden; }
.race-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--navy-2), var(--accent)); border-radius: 999px; }
.race-dwz { font-weight: 700; font-variant-numeric: tabular-nums; }
.race-gap { color: var(--text-muted); font-size: .85rem; white-space: nowrap; }
.race-perf { font-size: .85rem; white-space: nowrap; }

.list { list-style: none; padding: 0; margin: .25rem 0; }
.list li { padding: .35rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.list li:last-child { border-bottom: none; }

/* Formulare */
.form .field { margin-bottom: .9rem; }
.form label, .card label { display: block; font-size: .85rem; color: var(--text-muted); margin-bottom: .25rem; }
input[type=text], input[type=search], input[type=password], input[type=date], textarea, select, input[type=file] {
  width: 100%; padding: .5rem .65rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--paper); color: var(--text); font: inherit;
}
textarea { font-family: var(--mono); font-size: .88rem; }
.form .help { font-size: .8rem; color: var(--text-muted); margin-top: .2rem; }
.form .error, .errorlist { color: var(--loss); font-size: .85rem; margin: .2rem 0 0; padding: 0; list-style: none; }
.has-error input, .has-error textarea { border-color: var(--loss); }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .5rem 0 1rem; }
.inline-form input[type=search] { flex: 1 1 260px; width: auto; }
.inline-form select { width: auto; background: var(--paper); color: inherit; border: 1px solid var(--line); border-radius: 6px; padding: .25rem .5rem; }
.btn {
  display: inline-block; padding: .5rem .9rem; border-radius: 8px; border: none; cursor: pointer;
  background: var(--navy); color: var(--navy-ink); font: inherit; font-weight: 600;
}
.btn:hover { background: var(--navy-2); border-bottom: none; }
.btn-secondary { background: var(--paper-2); color: var(--text); font-weight: 500; }
.btn-secondary:hover { background: #e2e5ec; }
.btn-secondary.active { outline: 2px solid var(--accent); }
.flash { padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; background: var(--paper); border: 1px solid var(--line); }
.flash-success { border-left: 3px solid var(--win); }
.flash-error { border-left: 3px solid var(--loss); }
.flash-warning { border-left: 3px solid var(--warn); }

/* Partien */
.viewer { max-width: 860px; margin: 1rem 0; }
/* Lichess PGN Viewer: sein CSS bringt nur dunkle Fallback-Farben mit – jede Variable muss für die helle Trikotpalette
   gesetzt sein, sonst steht dunkle Schrift auf dunklem Grund (Roman, 08.09.2026). */
.lpv {
  --board-color: #f0d9b5;
  --c-lpv-bg: var(--paper-2); --c-lpv-bg-movelist: var(--paper); --c-lpv-bg-player: var(--paper-2);
  --c-lpv-bg-controls: var(--paper-2); --c-lpv-bg-pane: var(--paper-2); --c-lpv-bg-variation: var(--paper-2);
  --c-lpv-pgn-text: var(--paper);
  --c-lpv-font: var(--text); --c-lpv-font-shy: var(--text-muted); --c-lpv-font-bg: var(--line);
  --c-lpv-past-moves: var(--text-muted);
  --c-lpv-border: var(--line); --c-lpv-side-border: var(--line);
  --c-lpv-accent: var(--navy); --c-lpv-accent-over: #ffffff;
  --c-lpv-current-move: var(--navy); --c-lpv-move-hover: var(--navy-2); --c-lpv-fbt-hover: var(--navy-2);
  --c-lpv-inaccuracy: #2a7ab0; --c-lpv-mistake: #b07a0b; --c-lpv-blunder: #c0392b;
  --c-lpv-good-move: #2e8b57; --c-lpv-brilliant: #1e8449; --c-lpv-interesting: #8e44ad;
}
.scoresheet { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.scoresheet-thumb { max-height: 240px; border-radius: 8px; border: 1px solid var(--line); }
.pgn { white-space: pre-wrap; }

/* Eröffnungsbaum */
.opening-tree { font-variant-numeric: tabular-nums; }
.opening-tree details { margin-left: 0; }
.opening-tree .ot-level { margin-left: 1.1rem; border-left: 1px solid var(--line); padding-left: .6rem; }
.opening-tree > .ot-level { margin-left: 0; border-left: none; padding-left: 0; }
.opening-tree summary { cursor: pointer; padding: .15rem .3rem; border-radius: 6px; list-style: none; }
.opening-tree summary::-webkit-details-marker { display: none; }
.opening-tree summary::before { content: "▸"; display: inline-block; width: 1rem; color: var(--text-muted); }
.opening-tree details[open] > summary::before { content: "▾"; }
.opening-tree summary:hover { background: var(--paper-2); }
.ot-leaf { padding: .15rem .3rem; }
.ot-move { font-weight: 600; }
.ot-count { color: var(--text-muted); margin-left: .35rem; }
.ot-score { color: var(--accent-strong); margin-left: .35rem; font-size: .85rem; }
.ot-game { color: var(--text-muted); font-size: .8rem; margin-left: .3rem; }
.opening-tree summary.ot-selected, .opening-tree .ot-leaf.ot-selected { background: var(--accent-soft); border-radius: 6px; }

/* Abtippen */
.transcribe-status { margin: .6rem 0; font-weight: 500; }
.transcribe-status.good { color: var(--win); }
.transcribe-status.bad { color: var(--loss); }
.transcribe-board svg { width: 100%; max-width: 340px; height: auto; border-radius: 6px; }

/* DWZ-Verlauf (SVG ohne Bibliothek) */
.chart { width: 100%; height: auto; overflow: visible; }
.chart-line { fill: none; stroke: var(--navy); stroke-width: 2; stroke-linejoin: round; }
.chart-dot { fill: var(--navy); }
.chart-jump { stroke: var(--accent-strong); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart-target { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 4 4; }
.chart-label { fill: var(--text-muted); font-size: 11px; }
.chart-value { fill: var(--text); font-size: 12px; font-weight: 600; }
.chart-mini { width: 120px; }

/* Startseite */
.grid-2 .span-2 { grid-column: 1 / -1; }
.match-venue { margin: 0.25rem 0 0.75rem; }

/* Eröffnungsbaum mit Brett */
.ot-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
@media (max-width: 820px) { .ot-layout { grid-template-columns: 1fr; } }
.ot-board-wrap { position: sticky; top: 4rem; }
.ot-filter { display: flex; flex-wrap: wrap; gap: .5rem; margin: .25rem 0 1rem; }
.ot-filter-item { cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .8rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--text-muted); font-size: .9rem; user-select: none; }
.ot-filter-item input { position: absolute; opacity: 0; width: 0; height: 0; }
.ot-filter-item:has(input:checked) { background: var(--navy); color: var(--navy-ink); border-color: var(--navy); }
.ot-filter-item:has(input:checked) .muted { color: #c8cdda; }
.ot-filter-item:hover { border-color: var(--accent); }
.board { display: grid; grid-template-columns: repeat(8, 1fr); width: 100%; max-width: 340px; aspect-ratio: 1 / 1;
  border: 1px solid var(--line); border-radius: 4px; overflow: hidden; user-select: none; }
.board .sq { display: flex; align-items: center; justify-content: center; aspect-ratio: 1 / 1; }
.board .light { background: #f0d9b5; }
.board .dark { background: #b58863; }
.board .sq { position: relative; cursor: pointer; }
.board .pc { display: block; width: 100%; height: 100%; background-size: contain; background-repeat: no-repeat; background-position: center; }
.board .sq.sel { box-shadow: inset 0 0 0 3px var(--accent); }
.board .sq.hint::after { content: ""; position: absolute; width: 28%; height: 28%; border-radius: 50%; background: rgba(27, 34, 54, .35); }
.board .sq.hint-capture::after { content: ""; position: absolute; inset: 0; border: 4px solid rgba(27, 34, 54, .35); border-radius: 50%; }
.board-actions { display: flex; gap: .5rem; margin-top: .5rem; }

/* Orakel: Endplatz-Balken */
.placebar { display: flex; height: 14px; width: 240px; border-radius: 4px; overflow: hidden; background: var(--paper-2); }
.placebar-wide { width: 340px; height: 20px; }
.placebar .pl { display: block; height: 100%; background: #c8cdda; color: #fff; font-size: .72rem; line-height: 20px; text-align: center; white-space: nowrap; overflow: hidden; }
.placebar .pl-up { background: var(--accent); }
.placebar .pl-stay { background: var(--navy-2); }
.placebar .pl-down { background: #d9534f; }

/* Aufstellungsprognose */
.cand { display: flex; gap: .5rem; align-items: baseline; white-space: nowrap; }
.cand-share { min-width: 3.4rem; font-weight: 600; color: var(--accent-strong); font-variant-numeric: tabular-nums; }

/* Höhepunkte (Reste, falls noch verlinkt) */
.hero-line { margin: .4rem 0 .8rem; }
.hero-badge { display: inline-block; margin-right: .5rem; padding: .15rem .5rem; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-size: .78rem; font-weight: 700; }
