/* Mørkt tema i samme palet som leaderboard-PNG'en (autoflow/image.py).
   Farverne er de validerede mørke steps: surface #1a1a19, blå #3987e5,
   rød #e66767, neutral #383835. Tekst bruger tekst-tokens - aldrig
   seriefarven - så farve aldrig er eneste bærer af information. */

:root {
  --surface:        #1a1a19;
  --surface-raised: #212120;
  --surface-hover:  #272725;
  --rule:           #383835;
  --text:           #ffffff;
  --text-2:         #c3c2b7;
  --muted:          #8a8a80;
  --pos:            #3987e5;  /* over gennemsnittet / sejr */
  --neg:            #e66767;  /* under gennemsnittet / tab */
  --good:           #199e70;
  --warn:           #c98500;
  --radius:         10px;
  --gutter:         16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--pos); text-decoration: none; }
a:hover { text-decoration: underline; }

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px var(--gutter) 48px;
}

/* --- Topbar --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px;
  padding: 12px var(--gutter);
  background: rgba(26, 26, 25, 0.95);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(6px);
}
.brand { color: var(--text); font-weight: 600; font-size: 17px; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.topbar nav a { color: var(--text-2); font-size: 14px; padding: 2px 0; }
.topbar nav a.on { color: var(--text); border-bottom: 2px solid var(--pos); }

/* --- Bannere og kort --- */
.banner {
  max-width: 1080px; margin: 16px auto 0; padding: 12px 16px;
  border-radius: var(--radius); border: 1px solid var(--rule);
  background: var(--surface-raised); font-size: 14px;
}
.banner.warn { border-color: var(--warn); }

.card {
  background: var(--surface-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 28px 0 12px; }
h3 { font-size: 15px; margin: 20px 0 8px; color: var(--text-2); }
.sub { color: var(--text-2); margin: 0 0 20px; font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* --- Tabeller --- */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child,
th.left, td.left { text-align: left; }
thead th {
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--rule);
}
tbody tr { border-bottom: 1px solid rgba(56, 56, 53, .5); }
tbody tr:hover { background: var(--surface-hover); }
td.num, th.num { font-variant-numeric: tabular-nums; font-family: Consolas, ui-monospace, monospace; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.win { color: var(--good); }
.loss { color: var(--neg); }

/* Power-søjle i leaderboardet: divergerende om en nullinje, som i PNG'en. */
.bar { position: relative; width: 120px; height: 12px; min-width: 120px; }
.bar::before {
  content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px;
  width: 1px; background: var(--rule);
}
.bar span {
  position: absolute; top: 0; height: 12px; border-radius: 0 3px 3px 0;
  background: var(--pos);
}
.bar span.down { border-radius: 3px 0 0 3px; background: var(--neg); }

/* --- Badges --- */
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; border: 1px solid var(--rule); color: var(--text-2);
  vertical-align: middle;
}
.badge.role { min-width: 42px; text-align: center; }
.badge.guest { border-color: var(--warn); color: var(--warn); }
.badge.prov { border-color: var(--muted); }

abbr[title] { text-decoration: underline dotted var(--muted); cursor: help; }

/* --- Sådan læses det --- */
details.howto { border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px 16px; }
details.howto summary { cursor: pointer; color: var(--text-2); font-size: 14px; }
details.howto dl { margin: 12px 0 0; font-size: 14px; }
details.howto dt { color: var(--text); font-weight: 600; margin-top: 10px; }
details.howto dd { margin: 2px 0 0; color: var(--text-2); }

/* --- Grafer --- */
.chart-wrap { position: relative; height: 320px; }
.chart-wrap.small { height: 240px; }

/* --- Filtre --- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
select, input[type="search"], input[type="date"] {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--rule); border-radius: 8px;
  padding: 7px 10px; font: inherit; font-size: 14px; min-width: 150px;
}
button {
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--rule); border-radius: 8px;
  padding: 7px 12px; font: inherit; font-size: 14px; cursor: pointer;
}
button:hover { background: var(--surface-hover); color: var(--text); }

/* --- Kamplister --- */
.game-row td.result { font-weight: 600; }
.teamline { color: var(--text-2); font-size: 13px; }

/* Scoreboard: to holdblokke */
.team-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 12px; border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--rule); border-bottom: none;
  background: var(--surface-raised);
}
.team-head.won { border-left: 3px solid var(--good); }
.team-head.lost { border-left: 3px solid var(--neg); }
.team-block { margin-bottom: 22px; }
.team-block .scroll { border: 1px solid var(--rule); border-radius: 0 0 var(--radius) var(--radius); }

/* --- Grid til profil-kort --- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.stat { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.metric-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 14px; }
.metric-row .val { color: var(--text-2); font-variant-numeric: tabular-nums; }

@media (max-width: 620px) {
  main { padding-top: 16px; }
  h1 { font-size: 22px; }
  .hide-sm { display: none; }
  .bar { width: 72px; min-width: 72px; }
  th, td { padding: 7px 8px; }
}

/* Skillelinjen mellem rangerede og provisional spillere: samme tabel, så
   kolonnerne står i flugt - ligesom i leaderboard-PNG'en. */
tr.divider td {
  padding-top: 18px;
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--rule);
}
tr.divider:hover { background: none; }
tr.prov-row td { color: var(--text-2); }
tr.prov-row .bar span { opacity: .65; }

/* --- Fod --- */
footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px var(--gutter) 40px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--text-2);
}
footer p { margin: 4px 0; }

/* Intet må skubbe siden bredere end skærmen. Brede tabeller scroller inde i
   deres egen .scroll-boks - ikke ved at gøre hele siden bredere. */
html, body { max-width: 100%; }
main > *, footer > * { max-width: 100%; }
.chart-wrap { max-width: 100%; }
