:root {
  --navy: #2f2f2f;
  --blue: #f5c400;
  --ink: #222;
  --muted: #5c6568;
  --line: #e3e3e3;
  --grid: #e7e7e7;
  --row: #f6f7f7;
  --selected: #fff6d0;
  --hover: #f3f4f4;
  --green: #0d6b24;
  --red: #ed1b24;
  --page: #e4e4e4;
  --card: #fff;
  --rank: 42px;
  --shadow: 0 2px 9px rgba(16, 47, 85, .08);
  --font: Arial, "Helvetica Neue", sans-serif;
  --page-width: 1240px;
}

* { box-sizing: border-box; }
html { font-family: var(--font); color: var(--ink); background: var(--page); overflow-x: hidden; }
body {
  margin: 0;
  min-width: 320px;
  max-width: 100%;
  overflow-x: hidden;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
  background: var(--page);
}
h1, h2, h3, .titlebar h1, .module-title h2, .table-heading { font-family: var(--font); color: var(--navy); }
button, select, input { font: inherit; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 72px;
  min-height: 72px;
  padding: 0 16px;
  background: var(--navy);
  border-top: 0;
  border-bottom: 0;
  box-shadow: none;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  width: auto;
  height: auto;
  overflow: visible;
  color: #fff;
  font-family: Montserrat, "Segoe UI", Arial, sans-serif;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.045em;
  line-height: 1;
  text-transform: lowercase;
  text-decoration: none;
  white-space: nowrap;
}
.brand img {
  position: static;
  display: block;
  width: auto;
  height: 36px;
  max-width: none;
  transform: none;
}
.menu-button { display: none; }
.main-nav { align-self: stretch; display: flex; gap: 22px; margin-left: 4px; }
.main-nav a {
  display: flex;
  align-items: center;
  padding: 0 2px;
  color: #f2f2f2;
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
  border-bottom: 3px solid transparent;
}
.main-nav a:hover { color: var(--blue); }
.main-nav a.active { color: #fff; font-weight: 700; border-bottom-color: var(--blue); }
.sidebar-nav { display: none; }

.layout { display: contents; }
.page-ads { display: none; }
.shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  gap: 14px;
  width: calc(100% - 40px);
  max-width: var(--page-width);
  margin: 14px auto 18px;
}
.page-content {
  min-width: 0;
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 0 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.league-sidebar {
  align-self: start;
  background: #fff;
  border: 1px solid #e4e4e4;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}
#countryList a,
#countryList button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--grid);
  padding: 7px 12px 7px 16px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font: 400 12px/1.35 var(--font);
  text-decoration: none;
  cursor: pointer;
}
.country-group { border: 0; background: #fff; }
.country-group summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  list-style: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  cursor: pointer;
  background: #f2f2f2;
  border-bottom: 1px solid #e4e4e4;
}
.country-group summary::-webkit-details-marker { display: none; }
.country-group summary::marker { content: ''; }
.country-group summary span { flex: 1; min-width: 0; }
.country-group summary::after {
  width: 6px;
  height: 6px;
  margin-left: auto;
  border-right: 2px solid #666;
  border-bottom: 2px solid #666;
  transform: rotate(45deg);
  content: '';
}
.country-group summary:hover { background: #e8e8e8; }
.country-group[open] summary {
  background: var(--navy);
  color: #fff;
  border-bottom-color: var(--navy);
}
.country-group[open] summary::after { border-color: var(--blue); transform: rotate(-135deg); margin-top: 4px; }
#countryList a > span { flex: 1; min-width: 0; }
#countryList a:hover { background: var(--hover); }
#countryList a.active {
  background: var(--selected);
  color: var(--navy);
  font-weight: 700;
}
.country-flag {
  width: 18px;
  height: 12px;
  object-fit: cover;
  flex-shrink: 0;
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgba(47, 47, 47, .16);
  background: #f3f4f4;
}
.league-logo {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
  background: transparent;
}
.league-logo[hidden],
.country-flag[hidden] { display: none !important; }
.directory-note { margin: 8px 12px 10px; font-size: 11px; line-height: 1.4; color: var(--muted); }

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
  border: 1px dashed #b7c0c4;
  background: #f3f4f4;
  color: #8a9396;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: center;
}
.ad-leader { height: 90px; }
.ad-box {
  width: 300px;
  max-width: 100%;
  height: 250px;
  justify-self: start;
}
.ad-rail { height: 160px; margin: 8px; }
.ad-sponsors {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  height: auto;
  margin: 12px 0 0;
  border: 0;
  background: transparent;
  letter-spacing: 0;
}
.ad-sponsors span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  padding: 8px;
  border: 1px dashed #b7c0c4;
  background: #f3f4f4;
  color: #8a9396;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: center;
}

.control-panel { background: transparent; border: 0; }
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
  min-height: 36px;
  margin: 0 -14px;
  padding: 8px 14px;
  background: #f7fafb;
  border-bottom: 1px solid #cbd3ce;
}
.title-lead {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}
.title-lead .league-logo,
.title-lead .team-logo,
.title-lead .team-logo-fallback { width: 22px; height: 22px; font-size: 10px; }
.title-lead .country-flag {
  width: 22px;
  height: 15px;
  object-fit: cover;
  background: none;
  box-shadow: 0 0 0 1px rgba(47, 47, 47, .16);
  border-radius: 1px;
}
.titlebar h1 {
  margin: 0;
  min-width: 0;
  max-width: 100%;
  color: var(--navy);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: break-word;
}
.titlebar.hero-title {
  min-height: 0;
  margin: 10px 0 0;
  padding: 0;
  background: transparent;
  border-bottom: 0;
}
.titlebar.hero-title h1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
}
.updated { font-size: 11px; color: #34566a; white-space: nowrap; }

.table-panel,
.module {
  background: var(--card);
  border: 1px solid #b7c5d1;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
}
.table-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  overscroll-behavior-x: contain;
}
table { border-collapse: collapse; width: 100%; }
th, td {
  height: 28px;
  padding: 4px 8px;
  border-right: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
  text-align: center;
}
th {
  height: 34px;
  color: #2f2f2f;
  background: #eff2f2;
  border-color: #e7e7e7;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}
td:nth-child(2), td:nth-child(3), th:nth-child(2), th:nth-child(3) { text-align: left; }
tbody tr:nth-child(odd) td { background: #fff; }
tbody tr:nth-child(even) td { background: var(--row); }
tbody tr:hover td { background: var(--hover); }
tbody tr.selected td { background: var(--selected); font-weight: 700; }
.positive, .negative {
  display: inline;
  min-width: 0;
  padding: 0;
  border-radius: 0;
  font-weight: 700;
  text-align: inherit;
  background: none;
}
.positive { color: var(--green); }
.negative { color: var(--red); }
.sticky-rank { position: sticky; left: 0; z-index: 2; width: var(--rank); min-width: var(--rank); }
.sticky-team { position: sticky; left: var(--rank); z-index: 2; min-width: 160px; }
.empty-state td, .no-data { height: 72px; white-space: normal; color: var(--muted); text-align: center; }

.lower-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 12px; }
.module-title {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px 2px;
  color: var(--navy);
  background: transparent;
  border-bottom: 0;
}
.module-title h2 { margin: 0; color: var(--navy); font-size: 15px; font-weight: 700; }
.module-title span { color: var(--muted); font-size: 11px; font-weight: 400; }
.module .data-table th {
  color: #2f2f2f;
  background: #eff2f2;
  border-color: #e7e7e7;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  cursor: default;
}
.legend { display: flex; gap: 12px; color: var(--muted); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 22px; height: 0; border-top: 3px solid var(--blue); }
.legend .expected-line { border-top: 2px dashed #7a8b9a; }
.chart-wrap { height: 220px; padding: 8px 12px; background: #fff; }
#trendChart { display: block; width: 100%; height: 100%; }

.site-footer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: calc(100% - 40px);
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 18px 2px 28px;
  color: #5c6568;
  font-size: 12px;
  line-height: 1.45;
  background: transparent;
  border-top: 0;
}
.site-footer p { margin: 0; max-width: 100%; }
.site-footer .footer-name {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #2f2f2f;
  font-size: 13px;
  font-weight: 700;
}
.site-footer .footer-name img { display: block; width: auto; height: 26px; }
.site-footer nav { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.site-footer .footer-copy { margin-top: 2px; }
.site-footer a { color: #2f2f2f; font-weight: 400; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid #e9af16;
  outline-offset: 2px;
}

@media (min-width: 1200px) {
  .app-header { padding-left: 72px; }
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1140px) minmax(220px, 300px);
    column-gap: 16px;
    align-items: start;
    justify-content: start;
    width: calc(100% - 88px);
    margin: 0 16px 0 72px;
  }
  .shell {
    width: auto;
    max-width: none;
    margin: 14px 0 18px;
  }
  .site-footer {
    grid-column: 1;
    width: auto;
    max-width: none;
    margin: 0;
  }
  .page-ads {
    display: grid;
    grid-column: 2;
    grid-row: 1 / span 2;
    position: sticky;
    top: 86px;
    gap: 12px;
    align-content: start;
    margin-top: 14px;
  }
  .page-ads .ad-slot { width: 100%; max-width: none; margin: 0; justify-self: stretch; }
  .page-ads .ad-box { height: 280px; }
  .page-ads .ad-rail { height: 250px; }
}

@media (max-width: 980px) {
  .app-header { padding-left: 12px; padding-right: 12px; gap: 14px; }
  .shell { width: calc(100% - 20px); gap: 10px; }
  .lower-grid { grid-template-columns: 1fr; }
  .site-footer { width: calc(100% - 20px); }
}

@media (max-width: 760px) {
  html, body { background: #fff; }
  body { font-size: 12px; }
  .app-header {
    height: 56px;
    min-height: 56px;
    padding: 0 8px;
    gap: 8px;
    border-top: 0;
    border-bottom: 0;
    box-shadow: none;
  }
  .menu-button {
    display: grid;
    width: 32px;
    height: 30px;
    margin-left: auto;
    border: 0;
    background: transparent;
    place-content: center;
    gap: 3px;
    border-radius: 0;
    cursor: pointer;
    flex-shrink: 0;
  }
  .menu-button span { display: block; width: 18px; height: 2px; background: #fff; }
  .brand { flex: 1 1 auto; width: auto; max-width: none; height: auto; font-size: 18px; letter-spacing: -.04em; }
  .brand img { height: 26px; }
  .main-nav { display: none; }
  .shell {
    grid-template-columns: 1fr;
    width: 100%;
    margin: 0;
    padding: 0;
    gap: 0;
    background: #fff;
  }
  .page-content {
    gap: 10px;
    padding: 12px 12px 16px;
    border: 0;
    box-shadow: none;
    background: #fff;
  }
  .sidebar-nav {
    display: grid;
    gap: 0;
    padding: 0;
    background: #fff;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-nav a {
    display: block;
    padding: 10px 12px;
    color: var(--navy);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px solid var(--grid);
  }
  .sidebar-nav a:hover { background: var(--hover); }
  .sidebar-nav a.active { background: var(--selected); color: var(--navy); }
  .league-sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    z-index: 35;
    width: min(280px, 86vw);
    height: calc(100dvh - 56px);
    max-height: calc(100dvh - 56px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    border-radius: 0;
    box-shadow: 4px 0 16px rgba(0, 0, 0, .18);
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  body.menu-open .league-sidebar { transform: none; }
  html.menu-open,
  body.menu-open {
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
  }
  body.menu-open .league-sidebar { touch-action: pan-y; }
  body.menu-open::after {
    content: "";
    position: fixed;
    inset: 56px 0 0 0;
    z-index: 34;
    background: rgba(47, 47, 47, .35);
  }
  .page-content,
  #app { min-width: 0; max-width: 100%; }
  .titlebar {
    flex-direction: row;
    align-items: center;
    margin: 0;
    padding: 8px 10px;
  }
  .titlebar h1 { font-size: 14px; text-align: left; }
  .titlebar.hero-title { margin: 8px 8px 0; padding: 0; }
  .titlebar.hero-title h1 { font-size: 22px; }
  .ad-sponsors { margin: 0; gap: 6px; }
  .ad-sponsors span { min-height: 72px; padding: 6px 4px; font-size: 9px; letter-spacing: .04em; }
  .ad-box { width: 100%; }
  .site-footer {
    width: 100%;
    padding: 12px 10px 18px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    background: #fff;
    border-top: 1px solid #c7ceca;
  }
  .site-footer nav { flex-wrap: wrap; }
  .module, .table-panel { border-left: 1px solid #b7c5d1; border-right: 1px solid #b7c5d1; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
