:root {
  --bg: #0b0f14;
  --bg-elevated: #121820;
  --bg-card: #161d27;
  --bg-row: #1a2330;
  --border: #263041;
  --border-strong: #344155;
  --text: #e8eef6;
  --text-muted: #8b9bb0;
  --text-dim: #64748b;
  --accent: #f5a524;
  --accent-soft: rgba(245, 165, 36, 0.15);
  --accent-glow: rgba(245, 165, 36, 0.35);
  --highlight: #2dd4a8;
  --highlight-soft: rgba(45, 212, 168, 0.14);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.15);
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --max: 920px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 15% -10%, rgba(245, 165, 36, 0.12), transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(45, 212, 168, 0.08), transparent 45%),
    radial-gradient(ellipse 50% 30% at 50% 100%, rgba(80, 120, 200, 0.06), transparent 40%);
  z-index: 0;
}

.container {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
  position: relative;
  z-index: 1;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
  background: rgba(11, 15, 20, 0.82);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent), #d97706);
  color: #1a1205;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.05rem;
  box-shadow: 0 0 24px var(--accent-glow);
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.1rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-ghost:hover {
  background: var(--bg-elevated);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Anders card */
.anders-card {
  margin-top: 1.5rem;
  padding: 1.35rem 1.4rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.anders-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--highlight));
}

.anders-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.anders-identity {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.jersey {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(245, 165, 36, 0.35);
  border-radius: 12px;
  padding: 0.45rem 0.65rem;
  min-width: 3.4rem;
  text-align: center;
}

.anders-identity h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.anders-meta {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.delta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.badge-new {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--highlight-soft);
  border: 1px solid rgba(45, 212, 168, 0.4);
  color: var(--highlight);
  font-size: 0.78rem;
  font-weight: 700;
  animation: pulse-in 0.45s ease;
}

@keyframes pulse-in {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.stat-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-box.accent {
  background: linear-gradient(160deg, rgba(245, 165, 36, 0.12), var(--bg-elevated));
  border-color: rgba(245, 165, 36, 0.35);
}

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

.stat-value {
  font-family: var(--mono);
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-box.accent .stat-value {
  color: var(--accent);
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.anders-note {
  margin: 1rem 0 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.35rem;
  margin: 1.5rem 0 1rem;
  padding: 0.3rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 0.9rem;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
}

/* Panels */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem 1.3rem;
  margin-bottom: 1.25rem;
}

.panel[hidden] {
  display: none;
}

.panel-head {
  margin-bottom: 1rem;
}

.panel-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.snapshot-note {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.stats-table th,
.stats-table td {
  padding: 0.65rem 0.55rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.stats-table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 600;
}

.stats-table th.num,
.stats-table td.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.stats-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

.stats-table tbody tr:last-child td {
  border-bottom: none;
}

.rank-cell {
  font-family: var(--mono);
  color: var(--text-dim);
  width: 2.5rem;
}

.player-cell {
  font-weight: 600;
}

.player-num {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.85rem;
  margin-left: 0.25rem;
}

.team-cell {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.note-tag {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-soft);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  vertical-align: middle;
}

.row-anders {
  background: var(--accent-soft) !important;
}

.row-anders td {
  border-bottom-color: rgba(245, 165, 36, 0.25);
}

.row-anders .player-cell {
  color: var(--accent);
}

.utv-bar-cell {
  min-width: 4rem;
}

.muted-row {
  opacity: 0.55;
}

.muted-row .player-cell {
  font-weight: 500;
  font-style: italic;
}

/* Chart */
.chart-wrap {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  height: 140px;
  padding: 0.5rem 0.25rem 0.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.chart-bar {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 0.25rem;
}

.chart-bar-fill {
  width: 100%;
  max-width: 28px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--accent), #b45309);
  min-height: 2px;
  transition: height 0.4s ease;
}

.chart-bar.empty .chart-bar-fill {
  background: var(--border);
  min-height: 4px;
  opacity: 0.5;
}

.chart-bar.current .chart-bar-fill {
  background: linear-gradient(180deg, var(--highlight), #0d9488);
}

.chart-label {
  font-size: 0.58rem;
  color: var(--text-dim);
  font-family: var(--mono);
  writing-mode: horizontal-tb;
  text-align: center;
  line-height: 1.1;
}

.chart-val {
  font-size: 0.65rem;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text-muted);
}

/* Two UTV */
.two-utv {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.two-utv h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.two-utv ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.two-utv li {
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
}

/* Howto */
.howto.card {
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 2rem;
}

.howto h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.howto p {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.howto p:last-child {
  margin-bottom: 0;
}

.howto code {
  font-family: var(--mono);
  font-size: 0.8em;
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: var(--accent);
}

.badge-demo {
  display: inline-flex;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--highlight-soft);
  color: var(--highlight);
  font-size: 0.72rem;
  font-weight: 700;
}

.howto-hint {
  font-size: 0.8rem !important;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2.5rem;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.site-footer p {
  margin: 0 0 0.4rem;
}

.footer-fine {
  opacity: 0.8;
}

/* Responsive */
@media (max-width: 640px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .anders-identity h2 {
    font-size: 1.15rem;
  }

  .brand h1 {
    font-size: 1.1rem;
  }

  .chart-label {
    font-size: 0.5rem;
  }

  .chart-val {
    font-size: 0.55rem;
  }

  .panel {
    padding: 1rem 0.85rem 1.1rem;
  }

  .anders-card {
    padding: 1.1rem 1rem;
  }
}

@media (min-width: 641px) and (max-width: 760px) {
  .stat-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Hammarby intern tabell */
.hammarby-panel {
  margin-top: 1.5rem;
}

.hammarby-panel .panel-head h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hammarby-panel .panel-head h3::before {
  content: "";
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 3px;
  background: linear-gradient(145deg, #22c55e, #15803d);
}

.stats-table tfoot td {
  border-top: 1px solid var(--border-strong);
  border-bottom: none;
  color: var(--text-muted);
  font-weight: 600;
}

.pos-tag {
  margin-left: 0.4rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-dim);
  font-family: var(--mono);
}

.zero {
  color: var(--text-dim);
}

.hammarby-meta {
  margin: 0.85rem 0 0;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* All-time: avstånd till nästa plats / pallplats */
.chase-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.chase-box .stat-sub {
  color: var(--text-muted);
}
.chase-box .chase-tie {
  color: var(--text-dim);
  font-size: 0.75rem;
}
.chase-box.podium {
  border-color: rgba(245, 165, 36, 0.35);
}
.chase-box.podium .stat-value {
  color: var(--accent);
}
.chase-note {
  margin: 0.6rem 0 0;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.alltime-chase {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
@media (max-width: 480px) {
  .chase-grid {
    grid-template-columns: 1fr;
  }
}

/* Matchartiklar */
.articles-panel {
  margin-top: 1.5rem;
}
.articles-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.match-article + .match-article {
  border-top: 1px solid var(--border);
  padding-top: 1.35rem;
}
.article-meta {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--mono);
}
.article-result {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}
.match-article h4 {
  margin: 0 0 0.75rem;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
.article-body p {
  margin: 0 0 0.8rem;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
}
.article-body p:last-child {
  margin-bottom: 0;
}
.article-quote {
  margin: 0.7rem 0 0.95rem;
  padding: 0.7rem 0.85rem 0.7rem 0.95rem;
  border-left: 3px solid var(--highlight);
  background: var(--highlight-soft);
  border-radius: 0 8px 8px 0;
}
.article-quote blockquote {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  font-style: italic;
}
.article-quote figcaption {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: normal;
}
.article-source {
  font-size: 0.8em;
  font-style: normal;
  color: var(--text-muted);
}
.article-source a {
  color: var(--highlight);
}
.article-section-label {
  margin: 1.2rem 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--highlight);
}
.article-satire-label {
  margin: 1.2rem 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.article-quote-satire {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}
.article-footnote {
  margin: 1.1rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-dim);
}
@media (max-width: 640px) {
  .match-article h4 {
    font-size: 1.05rem;
  }
  .article-body p,
  .article-quote blockquote {
    font-size: 0.92rem;
  }
}
