/* ============================================================
   Football Live — design tokens
   ============================================================ */
:root {
  --bg: #0b1220;
  --bg-grad-1: #0b1220;
  --bg-grad-2: #0f172a;
  --surface: #111c2e;
  --surface-2: #18243d;
  --surface-3: #1f2c4a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --accent: #10b981;
  --accent-hover: #34d399;
  --accent-soft: rgba(16, 185, 129, 0.14);
  --live: #f97316;
  --danger: #ef4444;
  --win: #10b981;
  --draw: #94a3b8;
  --loss: #ef4444;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --t-fast: 120ms ease;
  --t: 200ms ease;
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 80% -10%, rgba(16, 185, 129, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(59, 130, 246, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2));
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 18px; }
h2 { font-size: 17px; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ============================================================
   App layout
   ============================================================ */
.app {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 18px 80px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 4px 18px;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.brand-text h1 { line-height: 1; }
.brand-subtitle { font-size: 12px; color: var(--muted); margin-top: 3px; }

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

.status-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.status-pill::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}
.status-pill.status-offline::before { background: var(--muted-2); box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.2); }
.status-pill.status-error::before   { background: var(--danger);   box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2); }
.status-pill.status-offline { color: var(--muted); }
.status-pill.status-error   { color: var(--danger); }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-2);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn.spinning svg { animation: spin 0.7s linear infinite; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.ghost-btn:hover { background: var(--surface); border-color: var(--border-strong); color: var(--text); }

/* ============================================================
   Sections
   ============================================================ */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 2px;
}

.league-section { margin-top: 4px; }

.leagues-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.league-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  width: 100%;
  transition: transform var(--t), background var(--t-fast), border-color var(--t-fast), box-shadow var(--t);
  position: relative;
  overflow: hidden;
}
.league-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(16,185,129,0.06), transparent 50%);
  opacity: 0;
  transition: opacity var(--t);
  pointer-events: none;
}
.league-card:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.league-card:hover::after { opacity: 1; }
.league-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.league-card:active { transform: translateY(0); }

.league-emblem {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border-radius: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--border);
  overflow: hidden;
}
.league-emblem img { width: 100%; height: 100%; object-fit: contain; }

.league-info { min-width: 0; flex: 1; }
.league-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.league-area {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.league-skeleton {
  height: 68px;
  border-radius: var(--radius);
  background: linear-gradient(110deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border: 1px solid var(--border);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   Selected league + tabs
   ============================================================ */
.content-section { margin-top: 24px; }

.selected-league {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 14px;
}
.selected-league-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.selected-emblem {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-weight: 700;
  color: var(--accent);
  overflow: hidden;
  flex: 0 0 44px;
}
.selected-emblem img { width: 100%; height: 100%; object-fit: contain; }
.selected-league-info h2 {
  font-size: 19px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.selected-league-info .muted { margin-top: 3px; }

.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1;
  min-width: max-content;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.tab-content { margin-top: 14px; }

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 32px 12px;
  justify-content: center;
  color: var(--muted);
}
.spinner {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

/* ============================================================
   Standings table
   ============================================================ */
.standings-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.standings-group-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 14px 8px;
  background: var(--surface-2);
}
.standings-row, .standings-head {
  display: grid;
  grid-template-columns: 28px 1fr 36px 36px 36px 50px;
  align-items: center;
  gap: 6px;
  padding: 11px 14px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
}
.standings-row:first-of-type { border-top: 0; }
.standings-head {
  font-size: 11.5px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
  font-weight: 600;
  background: var(--surface);
}
.standings-row .rank { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.standings-row .team-cell {
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.standings-row .team-cell .crest {
  width: 22px; height: 22px;
  flex: 0 0 22px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  overflow: hidden;
}
.standings-row .team-cell .crest img { width: 100%; height: 100%; object-fit: contain; }
.standings-row .team-cell .name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.standings-row .num { text-align: center; font-variant-numeric: tabular-nums; color: var(--text-2); }
.standings-row .pts { text-align: center; font-weight: 700; color: var(--text); }

.standings-row .rank-cell { display: flex; align-items: center; gap: 4px; }
.standings-row .rank-cell .indicator {
  width: 3px; height: 14px; border-radius: 2px;
}
.standings-row[data-zone="champions-league"] .indicator { background: #3b82f6; }
.standings-row[data-zone="europa-league"] .indicator { background: #f97316; }
.standings-row[data-zone="conference-league"] .indicator { background: #22c55e; }
.standings-row[data-zone="relegation"] .indicator { background: var(--danger); }

/* ============================================================
   Match list
   ============================================================ */
.match-day {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 4px 6px;
}
.match-day:first-child { padding-top: 4px; }

.matches {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.match {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.match:hover { background: var(--surface-2); border-color: var(--border-strong); }
.match .side { display: flex; align-items: center; gap: 10px; min-width: 0; }
.match .side.home { justify-content: flex-end; text-align: right; }
.match .side.away { justify-content: flex-start; }
.match .crest {
  width: 28px; height: 28px;
  flex: 0 0 28px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--border);
  overflow: hidden;
}
.match .crest img { width: 100%; height: 100%; object-fit: contain; }
.match .name {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.match .center {
  display: flex; flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 70px;
  font-variant-numeric: tabular-nums;
}
.match .score {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.04em;
}
.match .score.live { color: var(--live); }
.match .score.home-win { color: var(--win); }
.match .score.away-win { color: var(--win); }
.match .score.draw { color: var(--draw); }
.match .meta { font-size: 11px; color: var(--muted); }
.match .meta .live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--live);
  margin-right: 4px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* ============================================================
   Scorers
   ============================================================ */
.scorer-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.scorer-row, .scorer-head {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
}
.scorer-row:first-of-type { border-top: 0; }
.scorer-head {
  font-size: 11.5px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
  font-weight: 600;
}
.scorer-row .rank {
  color: var(--muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.scorer-row .player-name {
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.scorer-row .player-name .crest {
  width: 22px; height: 22px;
  flex: 0 0 22px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--border);
  overflow: hidden;
}
.scorer-row .player-name .crest img { width: 100%; height: 100%; object-fit: contain; }
.scorer-row .player-name .meta {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; flex-direction: column;
}
.scorer-row .player-name .meta .team { color: var(--muted); font-size: 11.5px; }
.scorer-row .goals {
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.scorer-row .goals .pk { color: var(--muted); font-weight: 500; font-size: 11.5px; margin-left: 4px; }

/* ============================================================
   Empty + error states
   ============================================================ */
.empty-state, .error-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-state h3, .error-state h3 { color: var(--text); margin-bottom: 6px; font-size: 15px; }
.empty-state p, .error-state p { font-size: 13.5px; }
.error-state h3 { color: var(--danger); }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(120%);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transition: transform 220ms cubic-bezier(0.2, 0.9, 0.3, 1), opacity 220ms;
  opacity: 0;
  pointer-events: none;
  z-index: 50;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { border-color: rgba(239, 68, 68, 0.4); }
.toast.error::before {
  content: "⚠️";
  margin-right: 6px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 540px) {
  .app { padding: 14px 12px 60px; }
  .leagues-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .standings-row, .standings-head {
    grid-template-columns: 24px 1fr 30px 30px 30px 42px;
    gap: 4px;
    padding: 10px 12px;
    font-size: 12.5px;
  }
  .match { padding: 10px 12px; }
  .match .name { font-size: 12.5px; }
  .match .score { font-size: 16px; }
}

@media (max-width: 380px) {
  .league-card { padding: 12px; }
  .league-name { font-size: 13.5px; }
  .tabs .tab { padding: 8px 10px; font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
