:root {
  --blue: #005293;
  --yellow: #fecb00;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #1a1c1e;
  --muted: #5b6168;
  --line: #dde1e6;
  --accent: #005293;
  --accent-text: #ffffff;
  --chip: #fecb00;
  --chip-text: #261a00;
  --danger-bg: #ffdad6;
  --danger-text: #410002;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 4%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1e23;
    --surface-2: #232830;
    --text: #e3e6ea;
    --muted: #9aa2ab;
    --line: #2e343c;
    --accent: #a3c9ff;
    --accent-text: #00315c;
    --chip: #fecb00;
    --chip-text: #261a00;
    --danger-bg: #5c1a14;
    --danger-text: #ffdad6;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }

.muted { color: var(--muted); }
.pad { padding: 16px; }
.num { font-variant-numeric: tabular-nums; }

/* --- Toppmeny --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 16px;
  min-height: 56px;
}

.wordmark {
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.wordmark span { color: var(--yellow); }
.wordmark:hover { text-decoration: none; }

.tabs { display: flex; gap: 4px; }
.tabs a {
  color: rgb(255 255 255 / 80%);
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 500;
}
.tabs a:hover { background: rgb(255 255 255 / 12%); text-decoration: none; }
.tabs a.active { background: var(--yellow); color: #261a00; }

/* Mobil: menyn ligger i botten, som i appen. */
@media (max-width: 700px) {
  .topbar { justify-content: center; }
  .tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 10;
  }
  .tabs a { color: var(--muted); font-size: 13px; padding: 8px 10px; }
  .tabs a.active { background: var(--chip); color: var(--chip-text); }
  body { padding-bottom: 64px; }
}

main {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
  flex: 1;
}
main:focus { outline: none; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 24px 16px;
}

h1 { font-size: 24px; margin: 4px 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 15px; color: var(--accent); margin: 20px 0 8px; font-weight: 600; }

/* --- Kontroller --- */

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }

select, input[type="search"] {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
}
input[type="search"] { flex: 1 1 200px; min-width: 0; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.on { background: var(--chip); color: var(--chip-text); font-weight: 600; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.chip.on { background: var(--chip); color: var(--chip-text); border-color: transparent; font-weight: 600; }

/* --- Kort och listor --- */

.card {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
}
.card + .card { margin-top: 12px; }
.card-body { padding: 16px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: inherit;
}
.list-row:first-child { border-top: 0; }
a.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; }
.list-row .sub { color: var(--muted); font-size: 13px; }
.list-row .big { font-size: 18px; font-weight: 600; }

/* --- Spelarbild --- */

.avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-2);
  object-fit: cover;
  display: inline-grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  overflow: hidden;
}
.avatar.lg { width: 96px; height: 96px; font-size: 26px; }
button.avatar { border: 0; padding: 0; cursor: zoom-in; }

/* --- Tabell --- */

.table-wrap { overflow-x: auto; }
table.stats { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.stats th, .stats td { padding: 8px 6px; text-align: right; white-space: nowrap; }
@media (min-width: 701px) { .stats th:not(.player):not(.rank), .stats td:not(.player):not(.rank) { min-width: 44px; padding: 8px 10px; } }
.stats th {
  position: sticky;
  top: 0;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}
.stats th.on { color: var(--accent); }
.stats td.on { color: var(--accent); font-weight: 700; }
.stats td { border-top: 1px solid var(--line); }
.stats .rank { color: var(--muted); width: 28px; text-align: right; }
.stats .player { text-align: left; width: 100%; }
.stats .player a { display: flex; align-items: center; gap: 10px; color: inherit; }
.stats .player a:hover { text-decoration: none; }
.stats .player a:hover .title { text-decoration: underline; }
.stats .player .title { font-weight: 600; }
.stats .player .sub { color: var(--muted); font-size: 12px; }
.stats tbody tr:hover { background: var(--surface-2); }
@media (max-width: 700px) {
  .stats .opt { display: none; }
  .stats .avatar { width: 32px; height: 32px; }
}

/* --- Spelarsida --- */

.player-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.player-head h1 { margin: 0; display: flex; align-items: center; gap: 8px; }
.player-head .facts { color: var(--muted); font-size: 14px; }

.star {
  border: 0;
  background: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
}
.star.on { color: #e0a800; }

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 8px;
  text-align: center;
}
@media (min-width: 701px) { .grid { grid-template-columns: repeat(8, 1fr); } }
.grid .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.grid .l { font-size: 12px; color: var(--muted); }

.injury { background: var(--danger-bg); color: var(--danger-text); border: 0; }

table.plain { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.plain th, .plain td { padding: 6px 4px; text-align: center; }
.plain th { font-size: 12px; color: var(--muted); font-weight: 600; }
.plain td.l, .plain th.l { text-align: left; }
.plain tr + tr td { border-top: 1px solid var(--line); }
.plain .league { display: block; font-size: 12px; color: var(--muted); }

.hof-link { margin-bottom: 12px; }
.hof-avatar { width: 64px; height: 64px; }
.badge {
  display: inline-block;
  background: var(--chip);
  color: var(--chip-text);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
  vertical-align: 2px;
}

.award + .award { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }

.event .label { color: var(--accent); font-weight: 600; font-size: 13px; }
.event .meta { color: var(--muted); font-size: 12px; margin-left: 6px; }
.event .who { font-weight: 600; }
.event .summary { color: var(--muted); font-size: 13px; }

/* --- Bildvisning --- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(0 0 0 / 92%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  cursor: zoom-out;
  overflow-x: auto;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: min(92vw, 1296px); max-height: 86vh; border-radius: 8px; }
.lightbox .hint { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: #bbb; font-size: 13px; }
