:root {
  --bg: #0f0f12;
  --surface: #1a1a1f;
  --surface2: #131317;
  --border: #252530;
  --text: #e8e8ec;
  --muted: #6b6b7a;
  --muted2: #888896;
  --accent: #6c5ce7;
  --accent-hover: #7d6ef7;
  --accent-dim: rgba(108, 92, 231, 0.14);
  --live: #22c55e;
  --live-red: #ef4444;
  --card-radius: 10px;
  --sidebar-width: 220px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── App layout ─────────────────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-top {
  padding: 1.1rem 1rem 0.9rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.brand-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.brand-text h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand-text .subtitle {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.date-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

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

.date-row input[type="date"] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.38rem 0.5rem;
  border-radius: 6px;
  font-size: 0.82rem;
  width: 100%;
  transition: border-color 0.15s;
}

.date-row input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
}

#refresh {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.42rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  width: 100%;
  transition: background 0.15s;
}

#refresh:hover {
  background: var(--accent-hover);
}

/* ── League sidebar nav ──────────────────────────────── */

.league-sidebar {
  padding: 0.5rem 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.league-section-label {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  padding: 0.7rem 0.5rem 0.3rem;
  opacity: 0.7;
}

.league-tab {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.6rem;
  font-size: 0.84rem;
  font-weight: 500;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--muted2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 1px;
}

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

.league-tab.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 600;
}

.tab-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Match count badge */
.tab-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 1.2rem;
  text-align: right;
  flex-shrink: 0;
}

.league-tab.active .tab-count {
  color: var(--muted2);
}

/* ── Tab icons ───────────────────────────────────────── */

.tab-icon-wrap {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 800;
  flex-shrink: 0;
  color: #fff;
  letter-spacing: -0.02em;
}

/* Live icon – pulsing red dot */
.tab-icon--live {
  background: rgba(239, 68, 68, 0.15);
  border-radius: 8px;
  position: relative;
}

.live-dot {
  width: 9px;
  height: 9px;
  background: var(--live-red);
  border-radius: 50%;
  animation: livePulse 1.6s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.35); opacity: 0.65; }
}

.league-tab--live-btn {
  color: var(--live-red);
  font-weight: 600;
}

.league-tab--live-btn:hover {
  background: rgba(239, 68, 68, 0.08);
  color: var(--live-red);
}

.league-tab--live-btn.active {
  background: rgba(239, 68, 68, 0.12);
  color: var(--live-red);
}

.league-tab--live-btn .tab-count {
  color: var(--live-red);
  opacity: 0.85;
}

/* All icon */
.tab-icon--all {
  background: rgba(108, 92, 231, 0.2);
  color: var(--accent);
  border-radius: 8px;
}

/* League colored icons */
.tab-icon--worldcup   { background: linear-gradient(135deg, #f9a825, #e65100); font-size: 0.58rem; }
.tab-icon--epl        { background: #3d004e; }
.tab-icon--laliga     { background: #c0392b; }
.tab-icon--bundesliga { background: #c0392b; }
.tab-icon--seriea     { background: #1a237e; }
.tab-icon--ligue1     { background: #1565c0; }
.tab-icon--mls        { background: #004d99; font-size: 0.52rem; }
.tab-icon--ucl        { background: #01256e; }
.tab-icon--uel        { background: #c84b00; }

/* Active league tab – slightly brighter icon */
.league-tab.active .tab-icon--epl        { background: #6a0092; }
.league-tab.active .tab-icon--laliga     { background: #e74c3c; }
.league-tab.active .tab-icon--bundesliga { background: #e74c3c; }
.league-tab.active .tab-icon--seriea     { background: #283593; }
.league-tab.active .tab-icon--ligue1     { background: #1976d2; }
.league-tab.active .tab-icon--mls        { background: #0066cc; }
.league-tab.active .tab-icon--ucl        { background: #0d3899; }
.league-tab.active .tab-icon--uel        { background: #e05a00; }

/* ── Content area ────────────────────────────────────── */

.content-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 1.25rem 1.75rem 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.9rem;
  margin-bottom: 1.25rem;
}

.content-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.content-date-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.content-area main {
  padding: 0 1.75rem 1.75rem;
  max-width: 960px;
}

/* ── Match list (week view) ──────────────────────────── */

.date-group-heading {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 2rem 0 0.4rem 0;
}

.date-group-heading:first-child { margin-top: 0; }

.error {
  color: #f87171;
  padding: 0.75rem;
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--card-radius);
  margin-bottom: 1rem;
}

.empty {
  color: var(--muted);
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

/* Column headers row */
.match-col-headers {
  display: grid;
  grid-template-columns: 1fr 230px 100px 100px;
  gap: 0.5rem;
  padding: 0.35rem 1rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.mch-moneyline { text-align: center; }
.mch-lineup { text-align: center; }
.mch-analyse { text-align: center; }

/* Match list container */
.match-list {
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  overflow: hidden;
  margin-bottom: 0.5rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.3rem;
}

/* Individual match row */
.match-row {
  display: flex;
  flex-direction: column;
  padding: 0.45rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: background 0.12s;
}

.match-row:last-child { border-bottom: 1px solid var(--border); }

.match-row:hover { background: rgba(255,255,255,0.03); }

.match-row--live { background: rgba(34, 197, 94, 0.04); }
.match-row--final { opacity: 0.75; }

/* Meta row: time / league / score / game-view */
.mr-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.3rem;
  font-size: 0.78rem;
}

.mr-time {
  font-weight: 700;
  color: var(--text);
  min-width: 4.5rem;
  flex-shrink: 0;
}

.mr-time--live {
  color: var(--live);
}

.mr-time--final { color: var(--muted); }

.mr-league-name {
  font-size: 0.73rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex: 1;
}

.mr-score {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text);
  padding: 0.1rem 0.5rem;
  background: rgba(255,255,255,0.07);
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
}

.mr-score:hover { color: var(--accent); }

.mr-gameview {
  margin-left: auto;
  flex-shrink: 0;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted2);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.mr-gameview:hover {
  background: var(--accent-dim);
  color: var(--text);
  border-color: var(--accent);
}

/* Body: teams | moneyline | details | analyse */
.mr-body {
  display: grid;
  grid-template-columns: 1fr 230px 100px 100px;
  align-items: center;
  gap: 0.5rem;
}

/* Teams column */
.mr-teams {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.mr-team-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.mr-team-logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 3px;
}

.mr-team-logo-ph {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.mr-team-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  flex-shrink: 1;
  line-height: 1.7;
}

.mr-draw-spacer {
  height: 0.2rem;
}

/* Moneyline column */
.mr-moneyline {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.mr-moneyline[data-pending] .ml-pct,
.mr-moneyline[data-pending] .ml-draw-pct {
  opacity: 0.4;
}

.ml-cell {
  display: flex;
  align-items: center;
}

.ml-cell--draw { justify-content: center; }

.ml-btn {
  width: 100%;
  max-width: 200px;
  padding: 0.18rem 0.6rem;
  border: none;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  letter-spacing: 0.01em;
  transition: filter 0.12s;
}

/* Probability fill bar – only on team win buttons */
.ml-btn--home,
.ml-btn--away {
  position: relative;
  overflow: hidden;
}

.ml-btn--home::before,
.ml-btn--away::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--ml-w, 50%);
  background: rgba(255,255,255,0.14);
  border-radius: 6px 0 0 6px;
  pointer-events: none;
}

.ml-btn--home:hover,
.ml-btn--away:hover { filter: brightness(1.18); }

/* Default team button colors – overridden per-row by canvas extraction */
.ml-btn--home { background: #b91c1c; color: #fff; }
.ml-btn--away { background: #92400e; color: #fde68a; }

.ml-pct { float: right; font-weight: 800; }

/* Draw button – dark neutral (matches reference image) */
.ml-btn--draw {
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  cursor: default;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  max-width: 200px;
}

.ml-btn--draw:hover { filter: none; background: rgba(255,255,255,0.09); }

.ml-draw-pct { font-weight: 800; color: var(--text); margin-left: 0.15rem; }


/* Lineup column */
.mr-lineup {
  display: flex;
  align-items: center;
  justify-content: center;
}
.mr-lineup-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--muted2);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.7rem;
  border-radius: 5px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.mr-lineup-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(99, 179, 237, 0.07);
}

/* Home / Away badge on team rows */
.mr-ha-badge {
  flex-shrink: 0;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  margin-left: 0.4rem;
  line-height: 1.4;
}
.mr-ha-badge--home {
  background: rgba(99, 179, 237, 0.15);
  color: var(--accent);
  border: 1px solid rgba(99, 179, 237, 0.3);
}
.mr-ha-badge--away {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted2);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Analyse column */
.mr-analyse {
  display: flex;
  align-items: center;
  justify-content: center;
}
.mr-analyse-btn {
  background: transparent;
  border: 1px solid rgba(99, 179, 237, 0.3);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.7rem;
  border-radius: 5px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.mr-analyse-btn:hover {
  background: rgba(99, 179, 237, 0.15);
  border-color: var(--accent);
}

/* ── Team tabs ─────────────────────────────────────────────────────── */
.lu-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0;
  flex-shrink: 0;
}
.lu-tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted2);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.lu-tab--active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.lu-tab:hover:not(.lu-tab--active) { border-color: var(--accent); color: var(--accent); }

/* ── Squad card board ──────────────────────────────────────────────── */
.sq-board {
  background: #122a1a;
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid rgba(255,255,255,0.08);
}
.sq-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sq-team-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
}
.sq-ha-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.12);
}

/* Section */
.sq-section { margin-bottom: 0.6rem; }
.sq-section-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
  padding-left: 0.2rem;
}
.sq-section-label--gk  { color: #f59e0b; }
.sq-section-label--def { color: #4ade80; }
.sq-section-label--mid { color: #60a5fa; }
.sq-section-label--fwd { color: #f87171; }
.sq-section-label--sub { color: rgba(255,255,255,0.35); }

/* Player cards grid */
.sq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 0.35rem;
}
.sq-card {
  display: flex;
  align-items: center;
  gap: 0;
  border-radius: 5px;
  overflow: hidden;
  cursor: default;
}
.sq-card--gk  { background: rgba(180, 83, 9, 0.35);  border: 1px solid rgba(245,158,11,0.3); }
.sq-card--def { background: rgba(20, 83, 45, 0.6);   border: 1px solid rgba(74,222,128,0.2); }
.sq-card--mid { background: rgba(30, 58, 138, 0.5);  border: 1px solid rgba(96,165,250,0.2); }
.sq-card--fwd { background: rgba(127, 29, 29, 0.5);  border: 1px solid rgba(248,113,113,0.2); }

.sq-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-width: 32px;
  align-self: stretch;
  font-size: 0.8rem;
  font-weight: 800;
  color: rgba(255,255,255,0.9);
  background: rgba(0,0,0,0.25);
}
.sq-card--gk  .sq-num { color: #fbbf24; }
.sq-card--def .sq-num { color: #86efac; }
.sq-card--mid .sq-num { color: #93c5fd; }
.sq-card--fwd .sq-num { color: #fca5a5; }

.sq-info {
  display: flex;
  flex-direction: column;
  padding: 0.3rem 0.4rem;
  min-width: 0;
}
.sq-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sq-pos {
  font-size: 0.62rem;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  margin-top: 0.05rem;
}

/* Substitute pills */
.sq-subs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.sq-sub-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.18rem 0.5rem 0.18rem 0.35rem;
  border-radius: 20px;
  font-size: 0.72rem;
}
.sq-sub-num {
  font-weight: 800;
  color: rgba(255,255,255,0.7);
  font-size: 0.68rem;
}
.sq-sub-name {
  font-weight: 500;
  color: rgba(255,255,255,0.85);
}
.sq-sub-pos {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.4);
  font-weight: 600;
}

/* Footer bar */
.sq-footer {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sq-footer-item { display: flex; flex-direction: column; gap: 0.1rem; }
.sq-footer-label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
}
.sq-footer-val {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
}

/* Squad fallback source note (shown when using football-data.org squad) */
.sq-source-note {
  display: inline-block;
  margin: 0.35rem 0 0.5rem 0.1rem;
  padding: 0.18rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--muted2);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
}

/* ── Pitch board ─────────────────────────────────────────────────────────── */

.pb-root {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
}

.pb-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

.pb-team-name {
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
}

.pb-ha-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.45);
  border: 1px solid rgba(255,255,255,0.12);
}

/* Pitch container */
.pitch-wrap {
  position: relative;
  flex: 1;
  min-height: 340px;
  border-radius: 10px;
  overflow: hidden;
  background:
    repeating-linear-gradient(180deg,
      rgba(0,0,0,0.04) 0px, rgba(0,0,0,0.04) 32px,
      transparent       32px, transparent    64px
    ),
    linear-gradient(175deg, #166534 0%, #15803d 40%, #166534 70%, #14532d 100%);
  box-shadow: inset 0 0 40px rgba(0,0,0,0.3), 0 4px 20px rgba(0,0,0,0.4);
}

/* Player token */
.pp {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  z-index: 2;
  cursor: default;
}

.pp-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 900;
  color: #fff;
  border: 2px solid transparent;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.1);
  transition: transform 0.15s, box-shadow 0.15s;
  line-height: 1;
}
.pp:hover .pp-num {
  transform: scale(1.2);
  box-shadow: 0 4px 14px rgba(0,0,0,0.6), 0 0 0 2px rgba(255,255,255,0.3);
}
.pp--gk  .pp-num { background: linear-gradient(135deg,#92400e,#b45309); border-color: #fbbf24; }
.pp--def .pp-num { background: linear-gradient(135deg,#14532d,#15803d); border-color: #4ade80; }
.pp--mid .pp-num { background: linear-gradient(135deg,#1e3a8a,#1d4ed8); border-color: #60a5fa; }
.pp--fwd .pp-num { background: linear-gradient(135deg,#7f1d1d,#b91c1c); border-color: #f87171; }

.pp-name {
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 5px rgba(0,0,0,1), 0 0 10px rgba(0,0,0,0.8);
  white-space: nowrap;
  max-width: 68px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

/* Bottom scrollable block (subs + non-squad + footer) */
.pb-bottom {
  flex-shrink: 0;
  max-height: 36%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

/* Substitutes / not-called-up section */
.pb-subs { }
.pb-subs--other { opacity: 0.75; }

.pb-subs-label {
  display: block;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.3);
  margin-bottom: 0.3rem;
  text-align: center;
}

/* 2-column grid of player rows */
.pb-subs-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.18rem 1.2rem;
}

/* Single player row: [POS badge] [Name] [#] */
.pb-sub-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.pb-sub-pos {
  flex-shrink: 0;
  width: 2.4rem;
  font-size: 0.58rem;
  font-weight: 700;
  text-align: center;
  padding: 0.1rem 0.15rem;
  border-radius: 3px;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.02em;
}
.pb-sub-pos--gk  { background: rgba(180,83,9,0.25);  color: #fbbf24; }
.pb-sub-pos--def { background: rgba(21,128,61,0.25);  color: #4ade80; }
.pb-sub-pos--mid { background: rgba(29,78,216,0.25);  color: #60a5fa; }
.pb-sub-pos--fwd { background: rgba(185,28,28,0.25);  color: #f87171; }

.pb-sub-name {
  flex: 1;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pb-sub-num {
  flex-shrink: 0;
  font-size: 0.66rem;
  font-weight: 800;
  color: rgba(255,255,255,0.45);
}

/* Footer stats bar */
.pb-footer {
  display: flex;
  gap: 1.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
  justify-content: center;
}

.pb-fi { display: flex; flex-direction: column; gap: 0.1rem; }

.pb-fl {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
}

.pb-fv {
  font-size: 0.88rem;
  font-weight: 800;
  color: #fff;
}

/* Kept for substitute pill reference */
.lu-player {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.22rem 0.3rem;
  border-radius: 4px;
  transition: background 0.1s;
}
.lu-player:hover { background: rgba(255,255,255,0.04); }
/* pos tag — left of name */
.lu-pos {
  flex-shrink: 0;
  min-width: 32px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: rgba(99,179,237,0.1);
  border: 1px solid rgba(99,179,237,0.2);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  text-align: center;
}
.lu-player--sub .lu-pos {
  color: var(--muted2);
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.1);
}
.lu-pos--empty { min-width: 32px; flex-shrink: 0; }

/* player name — middle */
.lu-name {
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}
.lu-player--sub .lu-name { color: var(--muted2); }

/* jersey number — right of name */
.lu-jersey {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.lu-player--sub .lu-jersey { color: var(--muted); opacity: 0.6; }

/* Analyse events modal */
.analyse-details { padding: 0.25rem 0; }

/* Score clickable */
.score-clickable { cursor: pointer; }
.score-clickable:hover { color: var(--accent); }

/* ── Dialog ──────────────────────────────────────────── */

#lineups-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  color: var(--text);
  padding: 0;
  width: min(780px, 96vw);
  height: 92vh;
  max-width: 96vw;
  max-height: 92vh;
}

#lineups-dialog[open] {
  display: flex;
  flex-direction: column;
}

#lineups-dialog.lineup-dialog-wide {
  width: min(900px, 96vw);
}

#lineups-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.dialog-header h3 {
  margin: 0;
  font-size: 1.05rem;
  flex: 1;
  min-width: 120px;
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.view-toggle button {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  background: var(--surface);
  border: none;
  color: var(--muted2);
  cursor: pointer;
}

.view-toggle button:hover { color: var(--text); }
.view-toggle button.active { background: var(--accent); color: white; }

#download-lineup-image.hide-lineup-download { display: none !important; }

#close-lineups {
  display: none;
}

#lineups-content-wrap {
  padding: 0.85rem 1rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#lineups-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.match-details-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.no-goal-data-msg {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
}

.show-lineups-btn {
  display: block;
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.show-lineups-btn:hover { background: var(--accent-hover); }

.lineup-team-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.lineup-team-tabs button {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.lineup-team-tabs button:hover { color: var(--text); border-color: var(--accent); }
.lineup-team-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.match-details-heading {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 0.5rem 0;
}

.match-details-heading + .match-details-list { margin-top: 0; }

.match-details-list {
  list-style: none;
  margin: 0 0 1rem 0;
  padding: 0;
  font-size: 0.87rem;
}

.match-details-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.match-details-list li:last-child { border-bottom: none; }

.goal-time, .card-time, .event-time {
  display: inline-block;
  min-width: 2.5rem;
  font-weight: 600;
  color: var(--accent);
}

.goal-scorer { font-weight: 600; }
.goal-assist { color: var(--muted); font-size: 0.85em; }
.goal-team, .card-team { color: var(--muted); font-size: 0.85em; }

.card-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.73rem;
  font-weight: 600;
}

.card-yellow .card-badge { background: #fbc02d; color: #000; }
.card-red .card-badge    { background: #d32f2f; color: #fff; }

#lineups-content { min-height: 120px; }

.lineup-view-list .lineup-team { margin-bottom: 1.5rem; }
.lineup-view-list .lineup-team h4 { margin: 0 0 0.5rem 0; font-size: 0.95rem; color: var(--muted); }
.lineup-view-list .lineup-team ul { margin: 0; padding-left: 1.25rem; font-size: 0.9rem; }
.lineup-view-list .lineup-team ul li { margin-bottom: 0.2rem; }

.lineup-view-formation { display: flex; flex-direction: column; gap: 2rem; }

.formation-pitch {
  background: linear-gradient(180deg, rgba(34,139,34,0.15) 0%, rgba(34,139,34,0.08) 100%);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  position: relative;
}

.formation-pitch::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  pointer-events: none;
}

.formation-team-name { font-weight: 700; font-size: 0.9rem; margin-bottom: 0.75rem; color: var(--text); }
.formation-rows { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.formation-row  { display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }

.formation-player {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  min-width: 4.5rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.formation-player .jersey { font-weight: 700; color: var(--accent); }
.formation-player .name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 6rem; margin: 0 auto; }

.lineup-view-cards { display: flex; flex-direction: column; gap: 1.5rem; }

.player-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.player-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  text-align: center;
}

.player-card .jersey { font-size: 1.5rem; font-weight: 800; color: var(--accent); line-height: 1.2; }
.player-card .name   { font-size: 0.85rem; font-weight: 600; margin-top: 0.25rem; word-break: break-word; }
.player-card .pos    { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }
.lineup-cards-section h4 { font-size: 0.9rem; color: var(--muted); margin: 0 0 0.5rem 0; }

.lineups-empty-state { text-align: center; padding: 2rem 1rem; color: var(--muted); }

.lineups-empty-state .pitch-placeholder {
  width: 100%;
  max-width: 280px;
  height: 180px;
  margin: 0 auto 1rem;
  background: linear-gradient(180deg, rgba(34,139,34,0.2) 0%, rgba(34,139,34,0.08) 100%);
  border: 2px dashed var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.lineups-empty-state p { margin: 0 0 0.5rem 0; font-size: 0.95rem; }
.lineups-empty-state .hint { font-size: 0.8rem; opacity: 0.8; }
.lineups-loading, .lineups-unavailable { color: var(--muted); font-size: 0.9rem; }

/* Match kickoff alert toast (top-right) */
#match-alert-toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2500;
  max-width: min(420px, calc(100vw - 2rem));
  padding: 0.8rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.22);
  background: linear-gradient(135deg, #15803d, #16a34a);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
  box-shadow: 0 10px 28px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#match-alert-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 700px) {
  .app-layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .league-sidebar {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0.4rem 0.5rem;
    gap: 0.25rem;
    scrollbar-width: none;
  }

  .league-sidebar::-webkit-scrollbar { display: none; }
  .league-section-label { display: none; }

  .league-tab {
    flex-shrink: 0;
    width: auto;
    padding: 0.4rem 0.65rem;
    gap: 0.4rem;
  }

  .tab-icon-wrap { width: 22px; height: 22px; }
  .tab-count { display: none; }

  .content-header { padding: 0.9rem 1rem 0.7rem; }
  .content-area main { padding: 0 1rem 1rem; }
}
