:root {
  --bg-main: #070b14;
  --bg-panel: #0f172a;
  --bg-card: #131d31;
  --bg-card-hover: #1a2742;
  --bg-elevated: #1e293b;
  --border: #26354d;
  --border-highlight: #38bdf8;
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent-blue: #38bdf8;
  --accent-indigo: #6366f1;
  --accent-emerald: #10b981;
  --accent-emerald-bg: rgba(16, 185, 129, 0.14);
  --accent-amber: #f59e0b;
  --accent-amber-bg: rgba(245, 158, 11, 0.15);
  --accent-rose: #f43f5e;
  --accent-rose-bg: rgba(244, 63, 94, 0.15);
  --accent-purple: #a855f7;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-lg: 0 20px 45px -15px rgba(0, 0, 0, 0.7);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 12% 10%, rgba(56, 189, 248, 0.08), transparent 28%),
    radial-gradient(circle at 88% 15%, rgba(16, 185, 129, 0.07), transparent 30%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
}

body.modal-open {
  overflow: hidden;
}

/* Header & Top Navigation */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 17, 32, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
}

.header-inner {
  max-width: 1480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, #10b981, #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
}

.brand-text-wrap {
  min-width: 0;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-badge {
  font-size: 0.68rem;
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

.brand-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border-color: transparent;
  color: #fff;
}

.btn-emerald {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.btn-emerald.active {
  background: #10b981;
  color: #052e16;
  font-weight: 700;
}

/* KPI Strip */
.kpi-strip {
  max-width: 1480px;
  margin: 16px auto 0;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.kpi-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.kpi-content {
  min-width: 0;
}

.kpi-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: rgba(56, 189, 248, 0.12);
  flex-shrink: 0;
}

/* Main Layout (Sidebar + Content) */
.main-layout {
  max-width: 1480px;
  margin: 18px auto 48px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.sidebar, .content-area {
  min-width: 0;
  width: 100%;
}

/* Left Hierarchy Sidebar */
.sidebar {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px;
  position: sticky;
  top: 78px;
}

.sidebar-title {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.league-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.league-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.16s ease;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  width: 100%;
  text-align: left;
}

.league-item:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

.league-item.active {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  font-weight: 600;
}

.league-item-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.league-flag {
  font-size: 1.15rem;
  flex-shrink: 0;
}

.league-country-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: block;
  line-height: 1.1;
}

.league-name-label {
  font-size: 0.84rem;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.league-count-badge {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: monospace;
  flex-shrink: 0;
}

/* Filter Bar */
.filter-bar {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.date-tabs {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.date-tab {
  padding: 8px 13px;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.date-tab.active {
  background: var(--accent-blue);
  color: #082f49;
  border-color: var(--accent-blue);
  font-weight: 700;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 200px;
  justify-content: flex-end;
}

.search-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 13px;
  color: var(--text-main);
  font-size: 0.84rem;
  width: 100%;
  max-width: 280px;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent-blue);
}

/* League Section Groups */
.league-group {
  margin-bottom: 24px;
}

.league-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: linear-gradient(90deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.4));
  border-left: 4px solid var(--accent-blue);
  border-radius: 8px;
  margin-bottom: 12px;
}

.league-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 700;
  min-width: 0;
}

.league-group-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Match Cards Grid */
.matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

.match-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.match-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
}

.match-card.high-conf {
  border-color: rgba(16, 185, 129, 0.42);
}

.match-card.high-conf::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #10b981, #38bdf8);
}

.card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.match-time-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-elevated);
  padding: 3px 8px;
  border-radius: 6px;
  font-family: monospace;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.match-time-badge.live {
  background: rgba(244, 63, 94, 0.2);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.match-time-badge.finished {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

.missing-alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-amber-bg);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 2px 7px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.71rem;
  white-space: nowrap;
}

/* Teams Section inside Card */
.teams-container {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.team-info {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.team-logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px;
  flex-shrink: 0;
}

.team-name {
  font-size: 0.94rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.form-dots {
  display: flex;
  gap: 3px;
}

.form-dot {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.form-dot.W { background: rgba(16, 185, 129, 0.22); color: #34d399; }
.form-dot.D { background: rgba(148, 163, 184, 0.22); color: #cbd5e1; }
.form-dot.L { background: rgba(244, 63, 94, 0.22); color: #fb7185; }

.xg-pill {
  font-size: 0.71rem;
  font-family: monospace;
  color: var(--accent-blue);
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 6px;
  border-radius: 5px;
  white-space: nowrap;
}

.score-box {
  font-size: 1rem;
  font-weight: 800;
  font-family: monospace;
  min-width: 20px;
  text-align: center;
}

/* Primary Prediction Banner inside Card */
.prediction-banner {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prediction-banner.high-conf-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.13), rgba(14, 165, 233, 0.1));
  border-color: rgba(16, 185, 129, 0.4);
}

.pred-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.pred-pick-badge {
  font-size: 0.88rem;
  font-weight: 800;
  color: #34d399;
  display: flex;
  align-items: center;
  gap: 5px;
}

.pred-conf-score {
  font-size: 0.73rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  white-space: nowrap;
}

.pred-conf-score.med {
  background: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
}

.prob-mini-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.prob-mini-item {
  background: rgba(30, 41, 59, 0.65);
  border-radius: 6px;
  padding: 4px 3px;
  text-align: center;
  min-width: 0;
}

.prob-mini-label {
  font-size: 0.63rem;
  color: var(--text-muted);
  display: block;
  white-space: nowrap;
}

.prob-mini-val {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: monospace;
}

/* Modal Overlay & Unified Scroll Container */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(3, 7, 18, 0.84);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-overlay.open {
  display: flex;
}

.modal-window {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  max-width: 1060px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85);
  overflow: hidden;
}

.modal-header {
  padding: 14px 20px;
  background: linear-gradient(135deg, #131d31, #0f172a);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.modal-breadcrumb {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--accent-blue);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-close {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: #fff;
  border-color: var(--accent-rose);
}

.modal-scroll-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Match Scoreboard Hero inside Modal */
.match-hero {
  padding: 18px 22px;
  background: radial-gradient(circle at center, rgba(56, 189, 248, 0.1), transparent 70%);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.hero-team {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.hero-team.away {
  flex-direction: row-reverse;
  text-align: right;
}

.hero-logo {
  width: 50px;
  height: 50px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 5px;
  flex-shrink: 0;
}

.hero-team-name {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.25;
}

.hero-team-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.hero-center {
  text-align: center;
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 13px;
}

.hero-pick-pill {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  background: #10b981;
  color: #052e16;
  font-weight: 800;
  font-size: 0.82rem;
  margin-bottom: 5px;
}

.hero-xg-compare {
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--accent-blue);
}

/* Modal Navigation Tabs (Sticky inside scroll container) */
.modal-tabs {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  gap: 6px;
  padding: 10px 20px;
  background: rgba(7, 11, 20, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

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

.modal-tab {
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.modal-tab.active {
  background: rgba(56, 189, 248, 0.16);
  color: var(--accent-blue);
  border-color: rgba(56, 189, 248, 0.45);
}

.modal-body {
  padding: 18px 22px 28px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Detail Grids & Cards */
.detail-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 15px;
  margin-bottom: 15px;
  min-width: 0;
}

.panel-title {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-report-box {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(56, 189, 248, 0.08));
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.ai-summary-text {
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.6;
  margin-bottom: 12px;
}

.ai-bullets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-bullets li {
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: rgba(15, 23, 42, 0.65);
  padding: 9px 11px;
  border-radius: 8px;
  border-left: 3px solid var(--accent-blue);
  line-height: 1.45;
}

/* Progress Bars for Probabilities */
.prob-bar-row {
  margin-bottom: 10px;
}

.prob-bar-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.prob-bar-track {
  height: 8px;
  background: var(--bg-main);
  border-radius: 999px;
  overflow: hidden;
}

.prob-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0ea5e9, #10b981);
}

/* Top Scores Flex Grid */
.top-scores-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

/* Responsive Table Wrapper */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Score Matrix 5x5 Heatmap */
.matrix-table {
  width: 100%;
  min-width: 300px;
  border-collapse: collapse;
  font-family: monospace;
  font-size: 0.76rem;
}

.matrix-table th, .matrix-table td {
  border: 1px solid var(--border);
  padding: 6px 4px;
  text-align: center;
}

.matrix-table th {
  background: var(--bg-main);
  color: var(--text-muted);
}

/* Missing Player Table */
.injury-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}

.crit-badge {
  font-family: monospace;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.crit-high { background: var(--accent-rose-bg); color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.35); }
.crit-med { background: var(--accent-amber-bg); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }

/* Standings / H2H Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.data-table th, .data-table td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.empty-state {
  text-align: center;
  padding: 40px 16px;
  background: var(--bg-panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
}

/* ========================================================================== */
/* TABLET & MOBILE RESPONSIVENESS (<= 1024px and <= 640px)                    */
/* ========================================================================== */

@media (max-width: 1024px) {
  .kpi-strip {
    grid-template-columns: repeat(2, 1fr);
    padding: 0 16px;
  }

  .main-layout {
    grid-template-columns: 1fr;
    padding: 0 16px;
    gap: 14px;
  }

  /* Convert vertical sticky sidebar into a sleek horizontal scrollable ribbon */
  .sidebar {
    position: static;
    padding: 12px;
  }

  .league-list {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
    padding-bottom: 2px;
  }

  .league-list::-webkit-scrollbar {
    display: none;
  }

  .league-item {
    width: auto;
    flex: 0 0 auto;
    padding: 7px 12px;
    background: var(--bg-card);
    border-color: var(--border);
  }

  .league-country-label {
    font-size: 0.63rem;
  }

  .league-name-label {
    font-size: 0.8rem;
  }
}

@media (max-width: 768px) {
  .detail-grid-2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .match-hero {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 14px 15px;
  }

  .hero-center {
    grid-column: 1 / -1;
    order: 3;
    padding: 9px 12px;
  }

  .hero-team, .hero-team.away {
    flex-direction: column;
    text-align: center;
    gap: 6px;
  }

  .hero-logo {
    width: 42px;
    height: 42px;
  }

  .hero-team-name {
    font-size: 0.96rem;
  }

  .hero-team-sub {
    font-size: 0.68rem;
  }
}

@media (max-width: 640px) {
  .top-header {
    padding: 10px 12px;
  }

  .header-inner {
    gap: 10px;
  }

  .brand-sub {
    display: none;
  }

  .brand-title {
    font-size: 1.02rem;
  }

  .header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .header-actions .btn {
    padding: 7px 4px;
    font-size: 0.72rem;
    border-radius: 8px;
    gap: 3px;
  }

  .kpi-strip {
    margin-top: 10px;
    padding: 0 12px;
    gap: 8px;
  }

  .kpi-card {
    padding: 10px 11px;
  }

  .kpi-label {
    font-size: 0.65rem;
  }

  .kpi-value {
    font-size: 1.15rem;
  }

  .kpi-sub {
    font-size: 0.64rem;
  }

  .kpi-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .main-layout {
    margin-top: 12px;
    padding: 0 12px;
  }

  .filter-bar {
    padding: 10px 12px;
    gap: 10px;
  }

  .date-tabs {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

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

  .date-tab {
    padding: 7px 11px;
    font-size: 0.76rem;
  }

  .filter-controls {
    width: 100%;
  }

  .search-input {
    max-width: 100%;
    font-size: 0.82rem;
  }

  .league-group-header {
    padding: 8px 11px;
  }

  .league-group-title {
    font-size: 0.84rem;
  }

  .league-group-meta {
    font-size: 0.72rem;
  }

  .matches-grid {
    grid-template-columns: 1fr;
    gap: 11px;
  }

  .match-card {
    padding: 12px;
    gap: 10px;
  }

  .team-name {
    font-size: 0.88rem;
  }

  /* Hide form dots on very narrow phones so team names never get cut off */
  .match-card .form-dots {
    display: none;
  }

  /* Full-height Bottom Sheet Modal on Mobile Phones */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-window {
    max-width: 100%;
    width: 100%;
    height: 94dvh;
    max-height: 94dvh;
    border-radius: 18px 18px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .modal-header {
    padding: 12px 14px;
  }

  .modal-tabs {
    padding: 8px 12px;
  }

  .modal-tab {
    padding: 7px 11px;
    font-size: 0.76rem;
  }

  .modal-body {
    padding: 14px 12px 32px;
  }

  .panel-box, .ai-report-box {
    padding: 12px;
  }

  .top-scores-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
