:root {
  --bg: #0e1116;
  --panel: #161b22;
  --line: #232a34;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #3fb950;
  --gold: #f1c40f;
  --live: #f85149;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;   /* poziomo scrollują się tylko tabele (.table-scroll), nie cała strona */
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

#detail-title { text-align: center; }

h1 { margin: 0; font-size: 1.5rem; }
h1 .sub { color: var(--muted); font-weight: 400; font-size: 1rem; margin-left: 6px; }

.meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot.err { background: var(--live); }
.dot.live { background: var(--live); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.tabs { display: flex; justify-content: center; gap: 4px; max-width: 860px; margin: 0 auto; padding: 16px 24px 0; }
.tab {
  background: none; border: 1px solid var(--line); border-bottom: none;
  color: var(--muted); padding: 10px 18px; font-size: .9rem; font-weight: 600;
  border-radius: 8px 8px 0 0; cursor: pointer;
}
.tab.active { background: var(--panel); color: var(--text); }

main { max-width: 860px; margin: 0 auto; padding: 24px; }
main { max-width: 1100px; }

section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 24px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: center; font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
td { border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
.left { text-align: left; }

#leaderboard tbody tr { cursor: pointer; transition: background .15s; }
#leaderboard tbody tr:hover { background: #1c2330; }
#leaderboard tbody tr.selected { background: #1c2330; }

.rank { color: var(--muted); }
.rank-1 { color: var(--gold); font-weight: 700; }
.player { font-weight: 600; text-align: left; }
.points { font-weight: 700; font-size: 1.1rem; }
.exact { color: var(--gold); }

.bump { animation: bump .6s ease; }
@keyframes bump { 0% { background: rgba(63,185,80,.35); } 100% { background: transparent; } }

.pill { font-size: .72rem; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.live { color: var(--live); border-color: var(--live); }
.pill.fin { color: var(--accent); border-color: var(--accent); }

.pts-2 { color: var(--gold); font-weight: 700; }
.pts-1 { color: var(--accent); font-weight: 600; }
.pts-0 { color: var(--muted); }

/* --- Zakładka Mecze --- */
/* poziomy scroll: na wąskim ekranie nie da się zmieścić wszystkich graczy,
   więc tabelę przewijamy w bok, a kolumnę „Mecz” przyklejamy na stałe */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#matches-table { font-size: .9rem; }
#matches-table th, #matches-table td { padding: 9px 10px; white-space: nowrap; }
#matches-table .fixture { text-align: left; min-width: 190px; }
#matches-table .fixture .time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 4px; }
#matches-table .result { font-weight: 700; }
#matches-table th.player-col { writing-mode: initial; }

/* przyklejona pierwsza kolumna (Mecz) — musi mieć nieprzezroczyste tło,
   żeby przewijane kolumny nie prześwitywały pod spodem */
#matches-table th.left,
#matches-table .fixture {
  position: sticky; left: 0; z-index: 1;
  background: var(--panel);
}
#matches-table th.left { z-index: 2; }
#matches-table tr.upcoming-row .fixture { background: #182230; }
#matches-table .fixture::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0;
  width: 1px; background: var(--line);
}

td.cell-g { background: rgba(63,185,80,.22); color: #7ee787; font-weight: 700; }
td.cell-y { background: rgba(241,196,15,.20); color: var(--gold); font-weight: 700; }
td.cell-r { background: rgba(248,81,73,.18); color: #ff7b72; }
td.cell-na { color: var(--muted); }
td.cell-up { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

#matches-table tr.upcoming-row td { background: rgba(88,166,255,.06); }
.pill.next { color: #58a6ff; border-color: #58a6ff; }

#matches-table tr.date-row td {
  text-align: left;
  background: #0e1116;
  color: var(--muted);
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--line);
  padding: 14px 10px 8px;
  position: sticky; left: 0; z-index: 2;
}

/* --- telefon: ciaśniej, żeby zmieścić więcej kolumn na ekranie --- */
@media (max-width: 600px) {
  header { padding: 14px 16px; }
  .meta { width: 100%; }            /* długi timestamp zawija się zamiast rozpychać stronę */
  main { padding: 12px; }
  .tabs { padding: 12px 12px 0; }
  #matches-table { font-size: .82rem; }
  #matches-table th, #matches-table td { padding: 7px 8px; }
  #matches-table .fixture { min-width: 150px; white-space: normal; }
}

.legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
          padding: 14px; color: var(--muted); font-size: .82rem; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px;
          vertical-align: -2px; margin-right: 5px; }
.swatch.g { background: rgba(63,185,80,.5); }
.swatch.y { background: rgba(241,196,15,.5); }
.swatch.r { background: rgba(248,81,73,.5); }

footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 16px; }
.cracovia {
  position: fixed; right: 8px; bottom: 6px;
  font-size: .55rem; color: var(--muted); opacity: .6;
  pointer-events: none; z-index: 10;
}
