/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --bg:       #0f1117;
  --bg-outer: #232638;
  --bg2:      #1a1d27;
  --bg3:      #252836;
  --border:   #2e3245;
  --text:     #e8eaf0;
  --muted:    #6b7280;
  --accent:   #4f8ef7;
  --green:    #22c55e;
  --red:      #ef4444;
  --orange:   #f97316;
  --highlight:#2a3350;
  --font:     -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --r:        3px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  background: var(--bg-outer);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
#main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Top nav ───────────────────────────────────────────────── */
.tab-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.tab-bar-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: stretch;
}
.tab-bar .tabs-scroll {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar .tabs-scroll::-webkit-scrollbar { display: none; }
.tab-bar .tab {
  flex: 0 0 auto;
  padding: 10px 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  cursor: pointer;
}
.tab-bar .tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-bar .live-tab.active { color: var(--orange); border-bottom-color: var(--orange); }

/* ── Division selector ──────────────────────────────────────── */
.division-selector {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.grp-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.grp-tab {
  flex: 1;
  padding: 7px 0;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  user-select: none;
}
.grp-tab:hover        { color: var(--text); }
.grp-tab.active       { color: var(--text); border-bottom-color: var(--accent); }

.div-panel {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
}
.div-panel.active { display: flex; }

.div-pill {
  padding: 3px 9px;
  font-size: 11px;
  font-family: var(--font);
  background: var(--bg3);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.1s, background 0.1s, border-color 0.1s;
}
.div-pill:hover  { color: var(--text); border-color: #4a5070; }
.div-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Filter bar ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  padding: 7px 8px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  align-items: center;
  flex-wrap: wrap;
}
.filter-bar select {
  padding: 4px 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r);
  font-size: 12px;
  font-family: var(--font);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  width: 180px;
}
.filter-bar select:focus { outline: 1px solid var(--accent); }

/* ── League table ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.league-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.league-table th {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: right;
  padding: 7px 6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-weight: 600;
}
.league-table th.team-col { text-align: left; }
.league-table td {
  padding: 5px 6px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.league-table td.team-col { text-align: left; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.league-table td.pos { color: var(--muted); font-size: 12px; }
.league-table td.pts-col { font-weight: 700; color: var(--text); }
.league-table th:last-child,
.league-table td:last-child { padding-right: 14px; }
.league-table tbody tr:hover { background: var(--bg2); }
.league-table tr.promotion td:first-child          { border-left: 3px solid var(--green); }
.league-table tr.promotion-playoff td:first-child  { border-left: 3px solid #16a34a; }
.league-table tr.relegation-playoff td:first-child { border-left: 3px solid var(--orange); }
.league-table tr.relegation td:first-child         { border-left: 3px solid var(--red); }
.league-table tr.highlight { background: var(--highlight); }
.league-table tr.highlight td { color: var(--text); }

.table-legend {
  display: flex;
  gap: 16px;
  padding: 6px 8px;
  font-size: 11px;
  color: var(--muted);
}
.legend-promotion::before          { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--green);  border-radius: 1px; margin-right: 4px; }
.legend-promotion-playoff::before  { content: ""; display: inline-block; width: 8px; height: 8px; background: #16a34a;        border-radius: 1px; margin-right: 4px; }
.legend-relegation-playoff::before { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--orange); border-radius: 1px; margin-right: 4px; }
.legend-relegation::before         { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--red);    border-radius: 1px; margin-right: 4px; }

/* ── Fixture rows ──────────────────────────────────────────── */
.fixture-list { }
.fixture-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  grid-template-rows: auto 1fr;
  gap: 2px 10px;
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
}
.fixture-row:hover { background: var(--bg2); }
.fixture-date {
  grid-row: 1 / span 2;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}
.fixture-time { color: var(--muted); font-size: 11px; }
.fixture-teams {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.home, .away { font-weight: 500; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.vs { color: var(--muted); font-size: 11px; flex-shrink: 0; }
.score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  padding: 1px 7px;
  background: var(--bg3);
  border-radius: var(--r);
  font-size: 13px;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}
.fixture-venue {
  font-size: 11px;
  color: var(--muted);
  align-self: end;
}
.comp-name { font-size: 10px; color: var(--muted); display: block; }

/* ── Live badges ───────────────────────────────────────────── */
.live-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--r);
  background: var(--bg3);
  color: var(--muted);
  letter-spacing: 0.04em;
}
.live-badge.live-now {
  background: var(--orange);
  color: #fff;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Page header ───────────────────────────────────────────── */
.page-header {
  padding: 10px 8px 6px;
  border-bottom: 1px solid var(--border);
}
.page-title { font-size: 14px; font-weight: 600; }

/* ── My Team page ──────────────────────────────────────────── */
.fav-bar {
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.fav-unpin {
  font-size: 18px;
  line-height: 1;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.fav-unpin:hover { color: var(--muted); }
.fav-bar-team {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.home-picker {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 8px;
}
.picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.picker-row select {
  padding: 4px 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r);
  font-size: 12px;
  font-family: var(--font);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.home-sections { }
.home-section {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 8px 8px 5px;
}

/* Position card */
.position-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px 10px 8px;
}
.pos-number {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  width: 44px;
  text-align: center;
  flex-shrink: 0;
}
.pos-details { flex: 1; min-width: 0; }
.pos-team { font-weight: 600; font-size: 14px; display: block; }
.pos-division { font-size: 11px; color: var(--muted); }
.pos-stats {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 10px;
  color: var(--muted);
}
.stat-val { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.2; }

/* Empty / no-team state */
.empty-state {
  padding: 16px 8px;
  color: var(--muted);
  font-size: 13px;
}
.home-no-team { padding: 16px 8px; color: var(--muted); }

/* ── Responsive ────────────────────────────────────────────── */
@media (min-width: 601px) {
  #main { margin-top: 10px; margin-bottom: 10px; }
}

@media (max-width: 600px) {
  body { font-size: 12px; }

  .home, .away { max-width: 130px; }

  .hide-xs { display: none !important; }

  .pos-number { font-size: 28px; width: 36px; }
  .stat-val { font-size: 14px; }
}

@media (max-width: 420px) {
  .hide-sm { display: none !important; }
  .tab-bar .tab { padding: 10px 12px; font-size: 12px; }
}

/* ── Team links ─────────────────────────────────────────────── */
a.team-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
a.team-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Browse back button (pinned right in tab bar) ───────────── */
#browse-back-bar {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
}
.back-btn {
  padding: 10px 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
}
.back-btn:hover {
  color: var(--text);
  text-decoration: none;
}

/* ── Browse search ─────────────────────────────────────────── */
.search-bar {
  position: relative;
  padding: 8px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.search-input {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--muted); }
.search-results {
  position: absolute;
  left: 8px;
  right: 8px;
  top: calc(100% - 1px);
  z-index: 50;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--r) var(--r);
  overflow: hidden;
}
.search-result {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--bg3); }
.sr-team  { font-size: 13px; font-weight: 500; color: var(--text); }
.sr-label { font-size: 11px; color: var(--muted); margin-left: auto; white-space: nowrap; }

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
}
.site-footer-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 10px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}
.site-footer-inner a { color: var(--muted); }
.site-footer-inner a:hover { color: var(--text); }

/* ── Cups / knockout view ───────────────────────────────────── */
.cup-competition {
  padding: 12px 8px 4px;
  border-bottom: 1px solid var(--border);
}
.cup-competition:last-child { border-bottom: none; }

.cup-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

.cup-rounds {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cup-round-arrow {
  color: var(--border);
  font-size: 18px;
  text-align: center;
  line-height: 1;
  padding: 2px 0;
  user-select: none;
}

.cup-round {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.cup-round--upcoming {
  border-color: var(--accent);
  border-style: dashed;
}

.cup-round-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 10px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
.cup-round--upcoming .cup-round-header {
  background: var(--highlight);
  border-bottom-color: var(--accent);
}
.cup-round-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
}
.cup-round-date {
  font-size: 11px;
  color: var(--muted);
}

.cup-matches {
  padding: 4px 0;
}

.cup-match {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  font-size: 12px;
}
.cup-match:hover { background: var(--bg3); }

.cup-team { line-height: 1.3; }
.cup-team--home { text-align: right; }
.cup-team--away { text-align: left; }
.cup-team--winner { color: var(--text); font-weight: 600; }
.cup-team--loser  { color: var(--muted); }

.cup-score {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  text-align: center;
  min-width: 32px;
}
.cup-vs {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}
