:root {
  --bg: #0b111a;
  --panel: #111a27;
  --panel2: #182231;
  --border: #27344a;
  --text: #e8eef7;
  --muted: #9aa4b6;
  --accent: #4f8cff;
  --accent-dark: #3a6fd8;   /* darker accent for better contrast on button */
  --accent-bright: #6ea2ff; /* świetlny akcent (gradienty, statystyki) */
  --violet: #b982ff;
  --teal: #4fcde0;
  --green: #2fd39a;
  --red: #ff6b79;
  --draw: #d4ab2f;
  --accent-soft: rgba(79,140,255,.12);
  --ring: rgba(79,140,255,.65);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px -6px rgba(0,0,0,.45);
  --shadow-md: 0 2px 4px rgba(0,0,0,.32), 0 14px 32px -18px rgba(0,0,0,.55);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font-sans: ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --grad-accent: linear-gradient(135deg, #5b9dff 0%, #3f6fe0 100%);
  --grad-accent-2: linear-gradient(135deg, #4f8cff 0%, #b982ff 100%);
  --pick1: #27c18a;
  --pickX: #c9a227;
  --pick2: #ff5d6c;
  --status-ok: #27c18a;
  --status-err: #ff5d6c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body.dark {
  background:
    radial-gradient(1000px 420px at 85% -120px, rgba(79,140,255,.10), transparent 60%),
    radial-gradient(900px 400px at -10% -80px, rgba(185,130,255,.08), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(79,140,255,.35); color: var(--text); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 18px; }
.wrap.wide { max-width: 1400px; }

/* top bar */
.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(11,17,26,.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 5;
  box-shadow: 0 1px 12px rgba(0,0,0,.35);
}
.topbar::after {
  content: "";
  display: block;
  height: 2px;
  background: var(--grad-accent-2);
  opacity: .85;
}
.topbar-inner { display: flex; align-items: center; gap: 22px; height: 58px; }
.brand {
  font-weight: 800; font-size: 20px; letter-spacing: 0.4px; color: var(--text);
  text-decoration: none; display: flex; align-items: baseline; gap: 6px;
}
.brand::before {
  content: ""; width: 18px; height: 18px; border-radius: 6px;
  background: var(--grad-accent-2); box-shadow: 0 0 14px rgba(79,140,255,.45);
  margin-right: 2px; align-self: center; flex: 0 0 auto;
}

.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: var(--muted); text-decoration: none; padding: 6px 12px;
  border-radius: 9px; font-weight: 600; font-size: 14px;
  transition: background-color .15s ease, color .15s ease;
}
.nav a:hover { color: var(--text); background: var(--accent-soft); }
.nav a.on {
  color: var(--text); background: var(--accent-soft);
}
.nav a.on::after {
  content: ""; display: block; height: 2px; margin-top: 2px;
  border-radius: 2px; background: var(--grad-accent);
}
.top-actions { display: flex; align-items: center; gap: 14px; }
.last-update { color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; }
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); margin-right: 6px;
  box-shadow: 0 0 8px rgba(47,211,154,.7);
  animation: pulse 2.4s ease-in-out infinite;
  flex: 0 0 auto;
}
.live-dot.off { background: var(--muted); box-shadow: none; animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
.btn {
  background: var(--grad-accent); color: #0b1118; border: 0; border-radius: 8px; padding: 8px 14px;
  font-weight: 700; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 14px -4px rgba(79,140,255,.55);
  transition: transform .12s ease, filter .15s ease, box-shadow .15s ease;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.6; cursor: progress; transform: none; }
.btn:focus-visible,
.nav a:focus-visible,
.elo-chip:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
}

/* spinner */
.spinner {
  width: 14px; height: 14px; border: 2px solid transparent; border-top-color: currentColor;
  border-radius: 50%; animation: spin 0.8s linear infinite; display: none;
}
.btn:disabled .spinner { display: inline-block; }
.btn:disabled .btn-text { opacity: 0.8; }

@keyframes spin { to { transform: rotate(360deg); } }

/* update status message */
.update-status { font-size: 12px; min-height: 18px; }
.update-status.success { color: var(--status-ok); }
.update-status.error { color: var(--status-err); }

/* layout */
main { padding: 26px 18px 40px; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 6px 0 22px; flex-wrap: wrap; }
.hero h1 { font-size: 30px; margin: 0 0 4px; letter-spacing: -0.5px; line-height: 1.15; text-shadow: 0 2px 24px rgba(79,140,255,.22); }
.hero-stats { display: flex; gap: 14px; flex-wrap: wrap; }
.stat {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 16px; min-width: 110px; text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, border-color .15s ease, box-shadow .2s ease;
}
.stat:hover { transform: translateY(-2px); border-color: var(--accent-bright); box-shadow: var(--shadow-md); }
.stat b {
  display: block; font-size: 22px; font-weight: 800; color: var(--accent-bright);
  font-variant-numeric: tabular-nums;
}
@supports (background-clip: text) {
  .stat b {
    background: var(--grad-accent-2);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}
.stat span { font-size: 12px; color: var(--muted); }
.stat-ico { color: var(--accent-bright); vertical-align: -3px; margin-right: 6px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid2-wide { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px; margin-bottom: 20px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.04);
  transition: box-shadow .2s ease;
}
.panel:hover { box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,.04); }
.panel h2 { display: flex; align-items: baseline; gap: 8px; font-size: 16px; margin: 0 0 12px; font-weight: 700; letter-spacing: .2px; }
.panel h2::before {
  content: ""; width: 3px; height: 15px; border-radius: 2px;
  background: var(--grad-accent-2); flex: 0 0 auto; align-self: center;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); box-shadow: none; }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.elo-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.elo-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 20px; font-size: 12px; font-weight: 600;
  padding: 3px 10px 3px 5px; cursor: pointer; font-family: inherit;
  transition: color .12s ease, border-color .12s ease, background-color .12s ease;
}
.elo-chip:hover { color: var(--text); border-color: var(--accent-bright); }
.elo-chip.active { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.elo-chip-swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.elo-chip.active .elo-chip-swatch { outline: 1px solid var(--text); outline-offset: 1px; }
.elo-chip-liga { font-size: 10px; font-weight: 500; opacity: 0.7; }
.hint { margin: 10px 0 0; }
.sub { font-size: 13px; color: var(--muted); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: 0.6px; }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.table tbody tr { transition: background-color .12s ease; }
.table tbody tr:hover { background: rgba(79,140,255,.05); }
.table.tight td { padding: 6px 10px; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--muted); width: 32px; }
.table tbody tr:nth-child(-n+3) .pos { color: var(--accent-bright); font-weight: 800; }
.up { color: var(--green); }
.down { color: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* dostępność: etykiety tylko dla czytników ekranu */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ranking ELO — brak zawijania wierszy na szerokim widoku */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.table.ranking th, .table.ranking td { white-space: nowrap; padding: 8px 8px; }

.team { color: var(--text); text-decoration: none; font-weight: 600; transition: color .12s ease; }
.team:hover { color: var(--accent); }
/* /trenerzy: jasne linki na ciemnym tle (szablon używa też klas Bootstrapowych bez stylów) */
.coaches-table a:not(.badge) { color: var(--text); }
.coaches-table a:not(.badge):hover { color: var(--accent); }
.coaches-filter { display: flex; align-items: center; gap: 8px; margin: 4px 0 18px; flex-wrap: wrap; }
.coaches-filter label { color: var(--muted); font-size: 13px; font-weight: 600; }
.filter-select {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
}
.filter-date { display: inline-flex; align-items: center; gap: 4px; }
.filter-date input[type="date"] {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color-scheme: dark;
}
.filter-date input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.7); }
.filter-date-clear {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 16px; padding: 4px 6px; line-height: 1;
}
.filter-date-clear:hover { color: var(--text); }
.pagination {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 8px; margin-top: 18px;
}
.pagination .page-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; padding: 6px 12px; border-radius: var(--radius-sm);
  background: var(--panel2); border: 1px solid var(--border); color: var(--muted);
  font-size: 13px; font-weight: 600; text-decoration: none;
  transition: color .12s ease, border-color .12s ease, background-color .12s ease;
}
.pagination .page-link:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.pagination .page-link.current {
  color: #0b1118; background: var(--grad-accent); border-color: transparent; font-weight: 800;
  box-shadow: 0 4px 14px -4px rgba(79,140,255,.55);
}
.pagination .page-info { color: var(--muted); font-size: 13px; flex-basis: 100%; text-align: center; }
.vs { color: var(--muted); margin: 0 6px; font-size: 12px; }
.score { font-weight: 800; margin: 0 8px; font-variant-numeric: tabular-nums; min-width: 38px; display: inline-block; text-align: center; }
.homescore { color: var(--green); }
.awayscore { color: var(--red); }
.drawscore { color: var(--draw); }

.badge {
  background: var(--panel2); border: 1px solid var(--border); color: var(--muted);
  font-size: 11px; padding: 2px 8px; border-radius: 20px; white-space: nowrap; letter-spacing: .2px;
}

/* prob bar */
.probbar { display: flex; height: 28px; border-radius: 10px; overflow: hidden; font-size: 11px; font-weight: 700; white-space: nowrap; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.pb { color: #0b1118; display: flex; align-items: center; padding: 0 6px; min-width: 34px; justify-content: center; }
.pb-h { background: var(--pick1); }
.pb-x { background: var(--pickX); }
.pb-a { background: var(--pick2); }

.pick { display: inline-block; min-width: 24px; text-align: center; font-weight: 800; border-radius: 6px; padding: 2px 6px; margin-right: 6px; color: #0b1118; font-size: 13px; }
.pick-1 { background: var(--pick1); }
.pick-X { background: var(--pickX); }
.pick-2 { background: var(--pick2); }
.ok { color: var(--green); font-weight: 800; }
.bad { color: var(--red); font-weight: 800; }

/* form badges */
.fm {
  display: inline-block; width: 26px; height: 26px; line-height: 26px;
  text-align: center; border-radius: 7px; margin-right: 3px; font-size: 12px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.fm-W { background: rgba(47,211,154,.20); color: var(--green); box-shadow: inset 0 0 0 1px rgba(47,211,154,.25); }
.fm-D { background: rgba(212,171,47,.20); color: var(--draw); box-shadow: inset 0 0 0 1px rgba(212,171,47,.25); }
.fm-L { background: rgba(255,107,121,.20); color: var(--red); box-shadow: inset 0 0 0 1px rgba(255,107,121,.25); }

/* results list */
.results { list-style: none; margin: 0; padding: 0; }
.results li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.results li:last-child { border-bottom: 0; }
.date { color: var(--muted); font-size: 12px; min-width: 86px; }

.footer {
  border-top: 1px solid var(--border); color: var(--muted); font-size: 12px;
  padding: 18px 0; text-align: center;
}
.footer .wrap { max-width: 1180px; }

/* ===== W2: responsywność mobile ===== */
#eloChart { max-width: 100%; }

@media (max-width: 900px) {
  /* topbar: nawigacja schodzi do własnego wiersza, akcje w prawym górnym rogu */
  .topbar-inner { flex-wrap: wrap; height: auto; min-height: 58px; row-gap: 8px; }
  .nav { flex-basis: 100%; order: 3; flex-wrap: wrap; }
  .top-actions { margin-left: auto; }
  /* dostępność: tap-target min. 44px dla głównych elementów interaktywnych */
  .btn, .nav a, .elo-chip { min-height: 44px; }
  .nav a { display: flex; align-items: center; }
}

@media (max-width: 640px) {
  /* info o aktualizacji w osobnej linii pod nav — nie ginie */
  .topbar-inner .last-update { order: 4; flex-basis: 100%; min-width: 0; }
  .table th, .table td { padding: 6px 8px; font-size: 13px; }
  .results li { gap: 8px; flex-wrap: wrap; }
}

@media (max-width: 480px) {
  /* wiersz 1 (brand + przycisk) musi zmieścić się w ~284px (320 - 2*18) */
  .topbar-inner { column-gap: 14px; }
  .brand { font-size: 16px; letter-spacing: 0.2px; }
  
  .btn { padding: 7px 10px; font-size: 12px; }
  .table.tight td { padding: 4px 6px; }
  .stat { min-width: 0; flex: 1 1 42%; }
  .probbar { font-size: 10px; }
  .pb { padding: 0 3px; min-width: 28px; }
  .score { white-space: nowrap; }
  .date { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .live-dot { animation: none; }
  .stat:hover, .btn:hover, .btn-ghost:hover { transform: none; }
}