:root {
  --bg: #070b14;
  --bg-elev: #0d1422;
  --surface: #121a2b;
  --line: rgba(148, 163, 184, 0.12);
  --text: #c5cedd;
  --muted: #7d8aa0;
  --strong: #f4f7fb;
  --accent: #3b9eff;
  --live: #ff4d6d;
  --ok: #34d399;
  --warn: #fbbf24;
  --radius: 14px;
  --nav-h: 64px;
  --font: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --display: "Syne", var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1000px 480px at 10% -10%, rgba(59, 158, 255, 0.18), transparent 55%),
    radial-gradient(800px 420px at 100% 0%, rgba(255, 77, 109, 0.12), transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, a { font: inherit; color: inherit; }
a { text-decoration: none; }
img { display: block; max-width: 100%; }
button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom, 0px));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding:
    calc(14px + env(safe-area-inset-top, 0px))
    calc(20px + env(safe-area-inset-right, 0px))
    14px
    calc(20px + env(safe-area-inset-left, 0px));
  backdrop-filter: blur(16px);
  background: rgba(7, 11, 20, 0.92);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #3b9eff, #1d4ed8 55%, #ff4d6d);
  color: white;
  font-weight: 800;
  font-size: 14px;
}
.brand strong {
  display: block;
  color: var(--strong);
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: -0.02em;
}
.brand small { color: var(--muted); font-size: 11px; }

.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--strong);
  font-size: 12px;
  font-weight: 600;
}
.stage-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}
.stage-pill.live .dot {
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(255, 77, 109, 0.6);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(255, 77, 109, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 109, 0); }
}

.wrap {
  width: min(1100px, calc(100% - 28px));
  margin: 0 auto;
}

.hero {
  padding: 28px 0 8px;
}
.hero h1 {
  margin: 0 0 8px;
  color: var(--strong);
  font-family: var(--display);
  font-size: clamp(28px, 5vw, 42px);
  letter-spacing: -0.04em;
  line-height: 1.05;
}
.hero p {
  margin: 0;
  max-width: 54ch;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}
.stat {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.025);
}
.stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.stat strong {
  display: block;
  margin-top: 6px;
  color: var(--strong);
  font-size: 24px;
  letter-spacing: -0.03em;
}

.section {
  margin: 22px 0;
}
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head h2 {
  margin: 0;
  color: var(--strong);
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: -0.02em;
}
.section-head span { color: var(--muted); font-size: 12px; }

.card-list, .match-list, .hl-grid, .group-grid {
  display: grid;
  gap: 10px;
}

.match-card, .panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
  padding: 14px 16px;
  transition: border-color .15s ease, transform .15s ease;
}
.match-card:hover, .panel:hover { border-color: rgba(59,158,255,0.35); }

.match-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge.live { color: #fecdd3; background: rgba(255,77,109,0.16); }
.badge.done { color: #a7f3d0; background: rgba(52,211,153,0.12); }
.badge.soon { color: #bfdbfe; background: rgba(59,158,255,0.12); }

.match-sides {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}
.team {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.team.away { flex-direction: row-reverse; text-align: right; }
.team img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
}
.team span {
  color: var(--strong);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.score {
  min-width: 64px;
  text-align: center;
  color: var(--strong);
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.score.pending { color: var(--muted); font-size: 16px; }

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.tab {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
}
.tab.active {
  color: var(--strong);
  border-color: rgba(59,158,255,0.45);
  background: rgba(59,158,255,0.12);
}

.group-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.group-card h3 {
  margin: 0 0 10px;
  color: var(--strong);
  font-size: 14px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
th, td {
  padding: 7px 4px;
  text-align: center;
  border-bottom: 1px solid rgba(148,163,184,0.08);
}
th { color: var(--muted); font-weight: 600; }
td:nth-child(1), th:nth-child(1) { text-align: left; }
.team-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--strong);
}
.team-cell img { width: 18px; height: 18px; }
.pos-1, .pos-2 { color: var(--ok); }

.hl-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.hl-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: transform .15s ease;
}
.hl-card:hover { transform: translateY(-2px); }
.hl-card img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: #111;
}
.hl-card .body { padding: 12px; }
.hl-card strong {
  display: block;
  color: var(--strong);
  font-size: 13px;
  line-height: 1.35;
  margin-bottom: 6px;
}
.hl-card small { color: var(--muted); font-size: 11px; }

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(520px, calc(100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(13, 20, 34, 0.92);
  backdrop-filter: blur(16px);
  z-index: 30;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
}
.bottom-nav a {
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}
.bottom-nav a.active {
  color: var(--strong);
  background: rgba(59,158,255,0.12);
}
.bottom-nav svg { width: 18px; height: 18px; }

.empty, .loading, .error {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.error { color: #fecaca; border-color: rgba(248,113,113,0.3); }

.skel {
  height: 88px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(255,255,255,0.03), rgba(255,255,255,0.07), rgba(255,255,255,0.03));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  to { background-position: -200% 0; }
}

@media (max-width: 800px) {
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .team.away { flex-direction: row; text-align: left; }
  .match-sides { grid-template-columns: 1fr; gap: 8px; }
  .score { text-align: left; }
}

@media (min-width: 900px) {
  .desktop-nav {
    display: flex;
    gap: 6px;
  }
  .desktop-nav a {
    padding: 8px 12px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
  }
  .desktop-nav a.active {
    color: var(--strong);
    background: rgba(255,255,255,0.05);
  }
  .bottom-nav { display: none; }
  #app { padding-bottom: 40px; }
}

@media (max-width: 899px) {
  .desktop-nav { display: none; }
}
