:root {
  --bg: #0f1115;
  --bg-2: #0b0d11;
  --panel: #171a21;
  --panel-2: #1d212b;
  --line: #2a2f3a;
  --text: #e6e8ec;
  --muted: #8b93a1;
  --accent: #e8559a;
  --accent-2: #4a90f0;
  --bar: rgba(232, 85, 154, 0.16);
  --gold: #ffce54;
  --silver: #c7ccd1;
  --bronze: #d6884f;
  --pos: #5bd18a;
  --neg: #ff7b7b;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 8px 24px rgba(0, 0, 0, 0.25);
}

:root[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-2: #eef1f6;
  --panel: #ffffff;
  --panel-2: #f1f4f9;
  --line: #dfe4ec;
  --text: #1b2027;
  --muted: #69727f;
  --accent: #e0508f;
  --accent-2: #3b82f6;
  --bar: rgba(224, 80, 143, 0.12);
  --gold: #d99e00;
  --silver: #8f97a1;
  --bronze: #b96a31;
  --pos: #1c9d5b;
  --neg: #d94545;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.02), 0 8px 24px rgba(20, 30, 50, 0.08);
}

* { box-sizing: border-box; }

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

header.site {
  position: relative;
  padding: 28px 20px 0;
  max-width: 980px;
  margin: 0 auto;
}

h1 {
  margin: 0 0 4px;
  font-size: 1.85rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle { color: var(--muted); font-size: 0.9rem; margin: 0 0 18px; }

/* Team switcher inside the h1 — looks like the heading, acts like a select.
 * (h1 text is gradient-clipped/transparent, so the select needs its own color.) */
h1 .team-select {
  font: inherit;
  letter-spacing: inherit;
  color: var(--accent);
  background: transparent;
  border: none;
  border-bottom: 2px dashed var(--line);
  padding: 0 2px;
  cursor: pointer;
  outline: none;
}
h1 .team-select:hover,
h1 .team-select:focus { border-bottom-color: var(--accent); }
h1 .team-select option {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text);
  background: var(--panel);
}

.theme-toggle {
  position: absolute;
  top: 24px;
  right: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 1.05rem;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.theme-toggle:hover { background: var(--panel-2); border-color: var(--accent); }
.theme-toggle:active { transform: scale(0.94); }

/* ---- Nav as tabs ----------------------------------------------------- */
nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.nav-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.nav-label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  min-width: 46px;
  font-weight: 600;
}

a.tab {
  text-decoration: none;
  color: var(--muted);
  padding: 9px 12px;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
a.tab:hover { color: var(--text); }
a.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* ---- Stat cards ------------------------------------------------------ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.card-value { font-size: 1.55rem; font-weight: 750; letter-spacing: -0.01em; }
.card-value.accent { color: var(--accent); }
.card-value.gold { color: var(--gold); }
.card-label { color: var(--muted); font-size: 0.8rem; }
.card-sub { color: var(--muted); font-size: 0.76rem; line-height: 1.35; overflow-wrap: anywhere; }

/* Section heading between groups of record cards (highlights page). */
.section-h {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin: 24px 0 10px;
}

.summary {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}
.muted-note {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  border-left: 2px solid var(--line);
  padding-left: 10px;
}

/* ---- Year range filter ------------------------------------------------ */
.year-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.year-label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.year-dash { color: var(--muted); }
.year-select {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.year-select:hover,
.year-select:focus { border-color: var(--accent); }
.year-reset {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.year-reset:hover { color: var(--text); border-color: var(--accent); }

/* ---- Tournament-type filter ------------------------------------------- */
.type-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.type-chip {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}
.type-chip:hover { opacity: 0.85; }
/* Deselected type: dimmed, outline only. */
.type-chip.off {
  background: var(--panel);
  border-color: var(--line);
  color: var(--muted);
}
.type-chip.off:hover { color: var(--text); border-color: var(--accent); opacity: 1; }

/* ---- Player links + detail page --------------------------------------- */
.plink {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--line);
  transition: color 0.15s, border-color 0.15s;
}
.plink:hover { color: var(--accent); border-bottom-color: var(--accent); }
.back {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.back:hover { color: var(--accent); }
.player-name { margin: 2px 0 16px; font-size: 1.45rem; }

/* ---- Filter ---------------------------------------------------------- */
.table-toolbar { margin-bottom: 12px; }
.filter {
  width: 100%;
  max-width: 280px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
.filter:focus { border-color: var(--accent); }
.filter::placeholder { color: var(--muted); }

/* ---- Table ----------------------------------------------------------- */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
  box-shadow: var(--shadow);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 12px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th.num { text-align: right; }
thead th:hover { color: var(--text); }
thead th .arrow { opacity: 0.6; font-size: 0.75em; margin-left: 4px; }

/* Group header row (spanning cells above related columns). */
thead tr.groups th {
  text-align: center;
  padding: 8px 14px 2px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: none;
  cursor: default;
}
thead tr.groups th:hover { color: var(--muted); }
th.sep, td.sep { border-left: 1px solid var(--line); }

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--panel-2) 45%, transparent); }
tbody tr:hover { background: var(--panel-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.bar { background-clip: padding-box; }
td.rank { color: var(--muted); width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
td.rank.p1 { color: var(--gold); font-weight: 700; }
td.rank.p2 { color: var(--silver); font-weight: 700; }
td.rank.p3 { color: var(--bronze); font-weight: 700; }
td.name { font-weight: 600; }
td.strong { color: var(--accent); font-weight: 600; }
td .sub { color: var(--muted); font-size: 0.85em; font-weight: 400; }
td.pos { color: var(--pos); }
td.neg { color: var(--neg); }

.empty {
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.medal { font-variant-numeric: tabular-nums; }
.medal.gold b { color: var(--gold); }
.medal.silver b { color: var(--silver); }
.medal.bronze b { color: var(--bronze); }
.medal.zero { color: var(--muted); opacity: 0.5; }
/* Year x series matrix: the series did not run at all that year (vs. "—" = it
   ran and the team did not enter). */
.nots { color: var(--muted); opacity: 0.35; }
/* The team's best result in a series — underlined in its column; a placement
   outside the medals also takes the accent colour, since it has none of its own. */
.medal.best, b.place.best { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
b.place.best { color: var(--accent); }

.error {
  background: color-mix(in srgb, var(--neg) 14%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--neg) 40%, var(--line));
  color: var(--neg);
  padding: 16px;
  border-radius: 10px;
}
.error code { background: rgba(127, 127, 127, 0.16); padding: 2px 6px; border-radius: 4px; }

footer { max-width: 980px; margin: 0 auto; padding: 20px; color: var(--muted); font-size: 0.8rem; }
footer a { color: var(--muted); }

/* ---- Selátka additions ------------------------------------------------- */
:root { --s-game: #e8559a; --s-qual: #4a90f0; --grid: rgba(255, 255, 255, 0.06); }
:root[data-theme="light"] { --s-game: #e0508f; --s-qual: #3b82f6; --grid: rgba(0, 0, 0, 0.07); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 0 0 18px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 4px; font-size: 1.05rem; font-weight: 650; }
.panel .muted-note { margin: 0 0 10px; }

/* Charts: inline SVG, recessive grid, thin marks; text in text tokens. */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis text, .chart .lbl { fill: var(--muted); font-size: 11px; }
.chart .val { fill: var(--text); font-size: 11px; font-weight: 600; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.game { stroke: var(--s-game); }
.chart .line.qual { stroke: var(--s-qual); }
.chart .line.median { stroke: var(--muted); stroke-dasharray: 4 4; stroke-width: 1.5; }
.chart .dot { stroke: var(--panel); stroke-width: 2; }
.chart .dot.game { fill: var(--s-game); }
.chart .dot.qual { fill: var(--s-qual); }
.chart .hit { fill: transparent; cursor: default; }
.chart .cross { stroke: var(--muted); stroke-width: 1; opacity: 0; pointer-events: none; }
.chart rect.faster { fill: var(--pos); }
.chart rect.slower { fill: var(--neg); }
.chart rect.neutral { fill: var(--muted); opacity: 0.5; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); margin: 0 0 8px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.game { background: var(--s-game); }
.legend i.qual { background: var(--s-qual); }
.legend i.median { background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 7px); }
.legend i.faster { background: var(--pos); height: 10px; width: 10px; }
.legend i.slower { background: var(--neg); height: 10px; width: 10px; }
.tip {
  position: absolute;
  pointer-events: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  box-shadow: var(--shadow);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.08s;
  z-index: 5;
}
.tip b { font-weight: 650; }
.tip .k { color: var(--muted); }

/* Ročníky: story under the row */
details.story { margin-top: 4px; color: var(--muted); font-size: 0.85rem; max-width: 520px; white-space: normal; }
details.story summary { cursor: pointer; color: var(--accent); font-size: 0.8rem; }
td.wrap { white-space: normal; min-width: 120px; }
.src { font-size: 0.7rem; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 4px; vertical-align: middle; }
.best-mark { color: var(--gold); }

/* Ročník detail */
.game-pick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 16px; }
.game-pick select {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font: inherit;
}
.game-pick button {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; font: inherit;
}
.game-pick button:disabled { opacity: 0.35; cursor: default; }
.chronicle { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 0.92rem; }
.chronicle dt { color: var(--muted); }
.chronicle dd { margin: 0; }

/* Kvalifikace matrix */
td.q { text-align: center; font-weight: 700; width: 26px; padding-left: 4px; padding-right: 4px; }
td.q.yes { color: var(--pos); }
td.q.no { color: var(--neg); opacity: 0.55; }
td.q.na { color: var(--muted); opacity: 0.35; }
.done-badge { color: var(--gold); font-weight: 650; }

@media (max-width: 600px) {
  .panel { padding: 12px; }
  .chronicle { grid-template-columns: 1fr; }
  .chronicle dt { margin-top: 6px; }
}

/* Dense tables (qualification matrix): tighter cells, no wrapping in numeric cells. */
.compact thead th, .compact tbody td { padding-left: 6px; padding-right: 6px; }
.compact td.num { white-space: nowrap; }
td.num { white-space: nowrap; }
.game-pick { flex-wrap: nowrap; }
.game-pick select { flex: 1 1 auto; min-width: 0; max-width: 520px; text-overflow: ellipsis; }
