:root, html[data-theme="dark"] {
  --bg: #07110d;
  --bg2: #0b1813;
  --ink: #eef6ea;
  --muted: #9aaf9d;
  --lede: #c9d7c8;
  --line: rgba(255,255,255,.08);
  --card: rgba(14, 28, 22, .82);
  --header: rgba(7,17,13,.72);
  --good: #3dd68c;
  --bad: #ff5d5d;
  --draw: #e7c15a;
  --btn: #eef6ea;
  --btn-ink: #102018;
  --glow-a: rgba(200, 16, 46, .18);
  --glow-b: rgba(0, 51, 153, .2);
  --shadow: 0 20px 50px rgba(0,0,0,.18);
  --table-big: rgba(255,255,255,.04);
  --bar-track: #173126;
  --bar-h: #d7e6d4;
  --bar-a: #6aa88b;
  --bench: #d5e3d4;
  --chart-grid: rgba(255,255,255,.06);
  --grain: .08;
}

html[data-theme="light"] {
  --bg: #f4f1e8;
  --bg2: #faf7f0;
  --ink: #17241c;
  --muted: #5d6b60;
  --lede: #3d4a40;
  --line: rgba(20, 36, 28, .1);
  --card: rgba(255, 255, 255, .86);
  --header: rgba(250, 247, 240, .86);
  --good: #1f9d5c;
  --bad: #d13b3b;
  --draw: #c39214;
  --btn: #17241c;
  --btn-ink: #f4f1e8;
  --glow-a: rgba(200, 16, 46, .1);
  --glow-b: rgba(0, 51, 153, .1);
  --shadow: 0 16px 40px rgba(40, 50, 40, .08);
  --table-big: rgba(23, 36, 28, .04);
  --bar-track: #d7e2d6;
  --bar-h: #1b3d2c;
  --bar-a: #5d8f74;
  --bench: #3d4a40;
  --chart-grid: rgba(23, 36, 28, .08);
  --grain: .04;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Manrope, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 10% -10%, var(--glow-a), transparent 50%),
    radial-gradient(800px 420px at 90% 0%, var(--glow-b), transparent 46%),
    linear-gradient(180deg, var(--bg2), var(--bg) 30%);
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

.top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  backdrop-filter: blur(16px);
  background: var(--header);
  z-index: 5;
}
.brand { display: grid; line-height: 1.1; }
.brand-kicker { color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.brand strong { font-family: Manrope, sans-serif; font-size: 28px; }
nav { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.nav-game {
  display: flex; align-items: center;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  font-weight: 800; font-size: 13px;
}
.nav-game[aria-current="page"] {
  background: var(--btn); color: var(--btn-ink); border-color: transparent;
}
.nav-team {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px;
}
.nav-team:hover { border-color: var(--c); }
.nav-team img { width: 22px; height: 22px; object-fit: contain; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.sync { margin: 0; }
.sync button, .theme-btn {
  background: var(--btn); color: var(--btn-ink); border: 0; border-radius: 999px;
  width: 88px; height: 40px; padding: 0;
  font-size: 14px; font-weight: 700; line-height: 40px;
  text-align: center; cursor: pointer;
}

.wrap { width: min(1180px, calc(100% - 36px)); margin: 28px auto 60px; display: grid; gap: 22px; }
.hero-card, .panel, .team-card, .match-card, .scoreboard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.hero-card h1, .team-hero h1 {
  font-family: Manrope, sans-serif;
  font-size: clamp(34px, 6vw, 62px);
  line-height: .95;
  margin: 8px 0 12px;
}
.kicker { color: var(--muted); letter-spacing: .14em; text-transform: uppercase; font-size: 11px; margin: 0; }
.finger-teaser {
  display: grid;
  gap: 4px;
  padding: 20px 22px;
  border-radius: 22px;
  background: linear-gradient(135deg, #003399 0%, #0a2a6e 60%);
  color: #fff;
  border: 2px solid #f7d117;
  box-shadow: var(--shadow);
}
.finger-teaser-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #f7d117;
}
.finger-teaser strong { font-size: 22px; letter-spacing: -.02em; }
.finger-teaser span:last-child { color: rgba(255,255,255,.78); font-size: 14px; }
.brawl-teaser {
  display: grid;
  gap: 4px;
  padding: 20px 22px;
  border-radius: 22px;
  background: linear-gradient(135deg, #1a0a3c 0%, #003399 55%, #c8102e 140%);
  color: #fff;
  border: 2px solid #f7d117;
  box-shadow: var(--shadow);
}
.brawl-teaser .finger-teaser-kicker { color: #f7d117; }
.brawl-teaser strong { font-size: 22px; letter-spacing: -.02em; }
.brawl-teaser span:last-child { color: rgba(255,255,255,.78); font-size: 14px; }
.lede { color: var(--lede); max-width: 720px; }
.slim { padding: 18px 22px; }
.slim h1 { font-size: 42px; }

.team-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.team-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px 14px;
  align-items: center;
  overflow: hidden;
  position: relative;
}
.team-card:before {
  content: "";
  position: absolute; inset: auto -20% -40% 40%;
  height: 140px;
  background: radial-gradient(circle, var(--c2), transparent 70%);
  opacity: .18;
}
.crest { width: 64px; height: 64px; object-fit: contain; }
.crest.xl { width: 96px; height: 96px; }
.pos, .mini { color: var(--muted); margin: 0; font-size: 13px; }
.team-card h2 { margin: 4px 0; font-size: 22px; }
.stat-col { text-align: right; display: grid; }
.stat-col small { color: var(--muted); }
.form { grid-column: 1 / -1; display: flex; gap: 6px; }
.form .f, .form.lg .f {
  width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; font-style: normal;
}
.f.W { background: var(--good); color: #062114; }
.f.D { background: var(--draw); color: #2a2106; }
.f.L { background: var(--bad); color: #2a0707; }
.team-hero { display: flex; gap: 20px; align-items: center; border-top: 4px solid var(--c); }

.chart-box { position: relative; height: 200px; max-width: 640px; }
.chart-box canvas { display: block; width: 100% !important; height: 100% !important; }
.cmp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cmp-grid h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.rank-block { min-width: 0; }
.rank-row {
  display: grid;
  grid-template-columns: 36px 1fr 42px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.rank-row span { font-weight: 800; font-size: 13px; }
.rank-row b { text-align: right; font-size: 13px; }
.rank-track {
  height: 16px;
  border-radius: 99px;
  background: var(--bar-track);
  overflow: hidden;
}
.rank-track i { display: block; height: 100%; border-radius: 99px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.panel-head h2 { margin: 0 0 12px; font-size: 20px; }
.panel-head p, .panel-head a { color: var(--muted); font-size: 13px; }
.split { display: grid; grid-template-columns: 1.3fr .7fr; gap: 14px; }
.split.pitches { grid-template-columns: 1fr 1fr; }
.split.pitches > .panel { min-width: 0; }
.lead-grid, .split-eq {
  display: grid;
  gap: 14px;
}
.lead-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split-eq { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lead-grid > .panel, .split-eq > .panel { min-width: 0; }
.week-latest { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.match-list, .match-grid { display: grid; gap: 10px; }
.match-row, .match-card {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.match-card { display: flex; flex-direction: column; }
.mr-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mr-line {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
}
.mr-line img { width: 28px; height: 28px; object-fit: contain; }
.mr-line b { font-size: 15px; min-width: 0; }
.mr-line strong { font-size: 20px; font-variant-numeric: tabular-nums; min-width: 1.2em; text-align: right; }
.side { display: flex; align-items: center; gap: 8px; }
.side.right { justify-content: end; }
.side img, .table img, .leader img, .bench img { width: 24px; height: 24px; object-fit: contain; border-radius: 50%; }
.score, .big-score { font-family: Manrope, sans-serif; font-size: 28px; }
.xg, .when, .chips { color: var(--muted); font-size: 12px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips span { border: 1px solid var(--line); padding: 4px 8px; border-radius: 999px; }
.duel { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.duel > div:not(.big-score) {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}
.duel > div:not(.big-score) b { line-height: 1.2; }
.duel img { width: 48px; height: 48px; object-fit: contain; flex: 0 0 auto; }
.mini-ev { margin: 0; padding-left: 16px; color: var(--muted); font-size: 13px; }

.leader { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.leader li { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.leader img { width: 36px; height: 36px; object-fit: cover; }
.leader small, td small { display: block; color: var(--muted); }
.leader div { min-width: 0; }
.leader b, .leader small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leader.squad { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.leader.squad li { margin: 0; }
.plink { border-bottom: 1px dashed rgba(255,255,255,.18); }
html[data-theme="light"] .plink { border-bottom-color: rgba(23,36,28,.18); }
.plink:hover { border-bottom-style: solid; }
.match-row.derby { border-color: rgba(245, 199, 24, .35); }
.match-row.live, .live-panel { border-color: rgba(255, 93, 93, .4); }
.live-dot {
  display: inline-flex; align-items: center; gap: 6px;
  color: #ff6b6b; font-style: normal; font-weight: 800; letter-spacing: .02em;
}
.live-dot::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #ff4d4d; box-shadow: 0 0 0 0 rgba(255,77,77,.7);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,77,77,.55); }
  70% { box-shadow: 0 0 0 8px rgba(255,77,77,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,77,77,0); }
}
.xi-pitch {
  position: relative;
  display: grid;
  grid-template-areas: "gk def mid fwd";
  grid-template-columns: 0.9fr 1.15fr 1.1fr 1.1fr;
  align-items: stretch;
  aspect-ratio: 105 / 68;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.28);
  background: repeating-linear-gradient(90deg, #247a3f 0 12.5%, #1f6b36 12.5% 25%);
}
.xi-lines {
  position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
  stroke: rgba(255,255,255,.58); stroke-width: 0.35; color: rgba(255,255,255,.75);
}
.xi-lines.port { display: none; }
.xi-line {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  justify-content: space-evenly; align-items: center;
  min-width: 0; padding: 8px 2px;
}
.xi-line.gk { grid-area: gk; }
.xi-line.def { grid-area: def; }
.xi-line.mid { grid-area: mid; }
.xi-line.fwd { grid-area: fwd; }
.xi-pl {
  display: grid; justify-items: center; gap: 2px; min-width: 0; text-align: center;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.65);
}
.xi-pl img {
  width: 48px; height: 48px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--c, #fff); background: #111;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.xi-pl b { font-size: 12px; line-height: 1.15; max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xi-pl small { color: rgba(255,255,255,.8); font-size: 11px; }
.xi-pl em {
  font-style: normal; font-size: 11px; font-weight: 800;
  background: var(--c, #111); color: #fff; border-radius: 999px; padding: 1px 6px;
}
.derby-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.player-hero { display: flex; gap: 20px; align-items: center; }
.player-face { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; background: var(--bar-track); }
.stat-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.stat-pills span { border: 1px solid var(--line); padding: 6px 10px; border-radius: 999px; font-size: 13px; color: var(--muted); }
.stat-pills b { color: var(--ink); }
.empty { color: var(--muted); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table tr.big { background: var(--table-big); }
.table td img { vertical-align: middle; flex: 0 0 auto; }
.team-cell { overflow: hidden; }
.team-link {
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.team-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.table.tight td { font-size: 13px; }
.table-wrap { overflow: auto; }

.weeks { display: flex; flex-wrap: wrap; gap: 6px; }
.weeks a {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line); color: var(--muted);
}
.weeks a.on, .weeks a:hover { background: var(--btn); color: var(--btn-ink); }

.scoreboard {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; text-align: center;
}
.sb-team { display: grid; justify-items: center; gap: 8px; }
.sb-team img { width: 84px; height: 84px; object-fit: contain; }
.sb-score { font-family: Manrope, sans-serif; font-size: 72px; margin: 0; line-height: .9; }
.sb-score span { opacity: .35; margin: 0 8px; }
.xg-line { color: var(--draw); margin: 6px 0 0; }

.timeline { display: grid; gap: 8px; }
.ev {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.ev-side { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ev-side.home { justify-content: flex-end; text-align: right; }
.ev-side.away { justify-content: flex-start; text-align: left; }
.ev-side img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.ev-side > div { min-width: 0; }
.ev small { display: block; color: var(--muted); }
.ev .min {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
  font-weight: 700;
}
.swap {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.ev-side.home .swap { justify-content: flex-end; }
.swap em { color: var(--muted); font-style: normal; }
.swap span { display: grid; gap: 2px; }
.card-dot { width: 12px; height: 16px; border-radius: 2px; display: inline-block; flex: 0 0 auto; }
.card-dot.yellow { background: #f5d76e; }
.card-dot.red { background: #e23d3d; }

.stat-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 28px; margin-bottom: 18px; }
.bar-row { display: grid; grid-template-columns: 64px 1fr 64px; gap: 8px; align-items: center; }
.bar-row .track { height: 8px; background: var(--bar-track); border-radius: 99px; overflow: hidden; display: flex; }
.bar-row .h { background: var(--bar-h); }
.bar-row .a { background: var(--bar-a); margin-left: auto; }
.bar-row b { font-size: 13px; }
.bar-row span { grid-column: 1 / -1; color: var(--muted); font-size: 12px; text-align: center; }

.pitch {
  position: relative;
  height: 420px;
  border-radius: 18px;
  overflow: hidden;
  background:
    linear-gradient(#2f8a4a, #1f6b36);
  border: 2px solid rgba(255,255,255,.2);
}
.pitch:before {
  content: "";
  position: absolute; inset: 8%;
  border: 1px solid rgba(255,255,255,.25);
}
.pitch:after {
  content: "";
  position: absolute; left: 50%; top: 0; bottom: 0; width: 1px;
  background: rgba(255,255,255,.25);
}
.pl {
  position: absolute; transform: translate(-50%, -50%);
  width: 54px; text-align: center; z-index: 1;
}
.pl img {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
  border: 2px solid #fff; background: #123;
}
.pl span, .pl em, .pl b { display: block; color: #fff; text-shadow: 0 1px 4px #000; }
.pl em { font-size: 10px; font-style: normal; }
.pl span { font-size: 11px; white-space: nowrap; }
.pl b { font-size: 10px; color: #f5d76e; }

.bench ul { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; list-style: none; padding: 0; }
.bench li { display: flex; gap: 8px; align-items: center; color: var(--bench); font-size: 13px; }
.shotmap {
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 105 / 68;
  margin: 0 auto;
  border-radius: 16px;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, #247a3f 0 12.5%, #1f6b36 12.5% 25%);
  border: 2px solid rgba(255,255,255,.28);
}
.shotmap .pitch-lines {
  position: absolute; inset: 0; width: 100%; height: 100%;
  stroke: rgba(255,255,255,.55); stroke-width: 0.35; color: rgba(255,255,255,.7);
}
.shot-layer { position: absolute; inset: 0; }
.shot {
  position: absolute; transform: translate(-50%, -50%);
  border-radius: 50%; border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.shot.home { background: #8fd3ff; }
.shot.away { background: #ff8f8f; }
.shot.goal { background: #f5d76e; border-color: #fff; z-index: 2; }
.shot-legend {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  color: var(--muted); font-size: 13px; margin: 10px 0 0;
}
.shot-legend .shot {
  position: static; transform: none; width: 12px; height: 12px; display: inline-block;
}

.foot {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto 28px;
  color: var(--muted);
  display: flex; justify-content: space-between; gap: 12px; font-size: 12px;
}

@media (max-width: 860px) {
  .team-grid, .split, .scoreboard, .pitches, .lead-grid, .split-eq, .week-latest { grid-template-columns: 1fr; }
  .top {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand actions"
      "nav nav";
    gap: 10px 12px;
    padding: 12px 14px;
    align-items: center;
  }
  .brand { grid-area: brand; }
  .brand strong { font-size: 22px; }
  nav {
    grid-area: nav;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    flex: none;
  }
  .nav-team {
    justify-content: center;
    padding: 8px 4px;
    min-height: 40px;
  }
  .top-actions {
    grid-area: actions;
    width: auto;
    margin: 0;
  }
  .theme-btn, .sync button {
    width: 80px; height: 36px; line-height: 36px; font-size: 13px;
  }
  .sb-score { font-size: 48px; }
  .pitch { height: 320px; }
  .stat-bars { grid-template-columns: 1fr; }
  .cmp-grid, .derby-list, .leader.squad { grid-template-columns: 1fr; }
  .xi-pitch {
    aspect-ratio: 68 / 105;
    grid-template-areas:
      "fwd"
      "mid"
      "def"
      "gk";
    grid-template-columns: 1fr;
    grid-template-rows: 1.1fr 1.1fr 1.15fr 0.9fr;
    background: repeating-linear-gradient(180deg, #247a3f 0 12.5%, #1f6b36 12.5% 25%);
  }
  .xi-lines.land { display: none; }
  .xi-lines.port { display: block; }
  .xi-line { flex-direction: row; padding: 4px 8px; }
  .xi-pl { min-width: 52px; }
  .xi-pl img { width: 40px; height: 40px; }
  .xi-pl b { font-size: 11px; max-width: 64px; }
  .table th, .table td { padding: 8px 3px; font-size: 12px; }
  .table th:nth-child(n+3), .table td:nth-child(n+3) {
    width: 1%;
    white-space: nowrap;
    text-align: center;
    padding-left: 4px;
    padding-right: 4px;
  }
  .table th:first-child, .table td:first-child { width: 1%; white-space: nowrap; }
  .ev { grid-template-columns: 48px 1fr; }
  .ev .min { grid-row: 1; grid-column: 1; }
  .ev-side.home, .ev-side.away { grid-column: 2; justify-content: flex-start; text-align: left; }
  .ev-side.home:empty, .ev-side.away:empty { display: none; }
  .ev-side.home .swap { justify-content: flex-start; }
}
