:root {
  --black: #05070d;
  --navy-950: #070d1f;
  --navy-900: #0a1430;
  --navy-800: #0f1d45;
  --navy-700: #16295e;
  --line: rgba(160, 185, 255, 0.1);
  --text: #eef2ff;
  --muted: #8592b5;
  --accent: #34a7ea;
  --accent-soft: rgba(52, 167, 234, 0.16);
  --win: #3ddc97;
  --draw: #f2c14e;
  --loss: #ff5d6c;
  --live: #ff3b4e;
  --radius: 16px;
  --top-h: 60px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(30, 60, 150, 0.55), transparent 60%),
    linear-gradient(180deg, var(--navy-950), var(--black) 55%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) 14px 0;
  background: rgba(5, 7, 13, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-crest { width: 36px; height: 36px; object-fit: contain; }
.topbar-title { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.1; }
.topbar-title strong {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 20px;
  letter-spacing: 0.06em;
}
.topbar-title span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--navy-900);
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}
.refresh svg { width: 16px; height: 16px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.refresh.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
  margin: 10px 14px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 93, 108, 0.12);
  border: 1px solid rgba(255, 93, 108, 0.35);
  font-size: 13px;
}

/* ---------- layout ---------- */
.view {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 12px calc(var(--nav-h) + var(--safe-b) + 28px);
}
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.loader { display: flex; justify-content: center; gap: 8px; padding: 80px 0; }
.loader span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite ease-in-out; }
.loader span:nth-child(2) { animation-delay: 0.15s; }
.loader span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1); } }

/* ---------- crests ---------- */
.crest { display: block; object-fit: contain; flex: none; }
.crest.sm { width: 26px; height: 26px; }
.crest.md { width: 40px; height: 40px; }
.crest.lg { width: 56px; height: 56px; }
.crest.xl { width: 96px; height: 96px; }
.crest-fallback {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--navy-700);
  color: var(--text);
  font-weight: 700;
  font-size: 11px;
}
.crest-fallback.lg, .crest-fallback.xl { font-size: 18px; }

/* ---------- filters ---------- */
.filters {
  padding: 16px 12px 12px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--navy-800), var(--navy-950));
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.crest-btn {
  border: 0;
  background: none;
  padding: 6px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.15s, opacity 0.2s, background 0.2s;
}
.crest-btn:active { transform: scale(0.94); }
.crest-btn.dim { opacity: 0.35; }
.crest-btn.active { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.focus-btn { margin: 0 auto 12px; padding: 10px 22px 8px; }
.focus-btn .crest { filter: drop-shadow(0 6px 18px rgba(52, 167, 234, 0.35)); }
.focus-name {
  margin-top: 6px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.crest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 4px;
  justify-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.filter-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  min-height: 30px;
}
.filter-state strong { color: var(--text); }
.chip {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  cursor: pointer;
}

/* ---------- hero ---------- */
.hero {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius);
  background:
    radial-gradient(90% 120% at 50% 0%, rgba(52, 167, 234, 0.22), transparent 60%),
    linear-gradient(160deg, var(--navy-700), var(--navy-950));
  border: 1px solid rgba(52, 167, 234, 0.35);
  text-align: center;
}
.hero.live { border-color: rgba(255, 59, 78, 0.6); }
.hero-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.hero.live .hero-label { color: var(--live); }
.hero-body { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 12px; }
.hero-team { display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; line-height: 1.15; }
.hero-mid { display: flex; flex-direction: column; align-items: center; }
.hero-time { font-family: 'Barlow Condensed', sans-serif; font-weight: 800; font-size: 34px; line-height: 1; }
.hero-day { font-size: 12px; color: var(--muted); margin-top: 4px; }
.btn-yt {
  display: inline-block;
  margin-top: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  background: #e62117;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  font-size: 14px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: blink 1.2s infinite; display: inline-block; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- day + match ---------- */
.day { margin-top: 18px; }
.day-title {
  position: sticky;
  top: calc(var(--top-h) + var(--safe-t));
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 -12px 8px;
  padding: 10px 16px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: linear-gradient(180deg, rgba(5, 7, 13, 0.95), rgba(5, 7, 13, 0.75));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.day-title span { font-family: 'Barlow', sans-serif; font-size: 12px; color: var(--muted); text-transform: none; letter-spacing: 0; }

.match {
  position: relative;
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 10px 12px 10px 10px;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(22, 41, 94, 0.55), rgba(10, 20, 48, 0.8));
  border: 1px solid var(--line);
  transition: box-shadow 0.3s;
}
.match.is-focus { border-color: rgba(52, 167, 234, 0.45); background: linear-gradient(160deg, rgba(30, 62, 140, 0.7), rgba(10, 20, 48, 0.9)); }
.match.is-focus::before {
  content: '';
  position: absolute;
  left: 0; top: 10px; bottom: 10px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}
.match.live { border-color: rgba(255, 59, 78, 0.6); }
.match.flash, .tv-card.flash { box-shadow: 0 0 0 2px var(--accent), 0 0 24px rgba(52, 167, 234, 0.5); }
.match-time { display: flex; flex-direction: column; align-items: center; gap: 4px; border-right: 1px solid var(--line); padding-right: 8px; }
.clock { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 19px; font-variant-numeric: tabular-nums; }
.match.finished .clock { color: var(--muted); font-size: 16px; }
.status { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; text-align: center; line-height: 1.1; }
.status-finished { color: var(--muted); }
.status-live { color: #fff; background: var(--live); padding: 2px 6px; border-radius: 6px; animation: blink 1.6s infinite; }
.status-pending { color: var(--draw); }
.match-teams { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.team-row { display: flex; align-items: center; gap: 9px; min-width: 0; }
.team-name { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 500; line-height: 1.15; overflow-wrap: anywhere; }
.team-row.focus .team-name { font-weight: 700; color: #fff; }
.team-row.win .team-name, .team-row.win .score { font-weight: 700; color: #fff; }
.team-row.lose .team-name, .team-row.lose .score { color: var(--muted); }
.score { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 20px; min-width: 22px; text-align: right; font-variant-numeric: tabular-nums; }
.yt-mini {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(230, 33, 23, 0.15);
  border: 1px solid rgba(230, 33, 23, 0.5);
}
.yt-mini svg { width: 20px; height: 20px; fill: #ff4d43; }
.crest-wrap { position: relative; display: block; }
.crest-tag {
  position: absolute;
  right: -4px;
  bottom: -3px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: #03101c;
  font-size: 11px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--navy-900);
}

/* ---------- jump button ---------- */
.jump-now {
  position: fixed;
  right: 14px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  z-index: 25;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #03101c;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(52, 167, 234, 0.4);
  cursor: pointer;
}

/* ---------- table ---------- */
.table-card {
  padding: 14px 6px 10px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--navy-800), var(--navy-950));
  border: 1px solid var(--line);
}
.section-title {
  margin: 0 8px 10px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 20px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.standings { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.standings th {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 3px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.standings td { padding: 9px 3px; text-align: center; font-size: 14px; border-bottom: 1px solid var(--line); }
.standings tr:last-child td { border-bottom: 0; }
.standings .c-team { text-align: left; width: 100%; }
.standings .c-rank { width: 30px; }
.c-rank span {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 8px;
  font-weight: 700; font-size: 13px;
  background: rgba(255, 255, 255, 0.05);
}
.podium.p1 .c-rank span { background: linear-gradient(135deg, #f7d774, #c79a2b); color: #1b1404; }
.podium.p2 .c-rank span { background: linear-gradient(135deg, #e3e8f0, #9aa6b8); color: #10151f; }
.podium.p3 .c-rank span { background: linear-gradient(135deg, #e7a57a, #a8623a); color: #1d0f06; }
td.c-pts { font-weight: 800; font-size: 16px; color: #fff; }
.standings th.c-pts { color: var(--accent); }
.pos { color: var(--win); }
.neg { color: var(--loss); }
.team-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.team-cell > div { display: flex; flex-direction: column; min-width: 0; }
.team-cell .team-name { font-size: 13.5px; white-space: normal; line-height: 1.15; }
.form { display: flex; gap: 3px; margin-top: 4px; }
.form i { width: 7px; height: 7px; border-radius: 50%; }
.f-w { background: var(--win); }
.f-d { background: var(--draw); }
.f-l { background: var(--loss); }
.standings tr.focus td { background: rgba(52, 167, 234, 0.14); }
.standings tr.focus td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.standings tr.focus .team-name { font-weight: 700; color: #fff; }
.legend { margin: 10px 8px 0; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
@media (max-width: 420px) {
  .c-goals { display: none; }
  .standings td { font-size: 13.5px; padding: 9px 2px; }
  .standings th { padding: 6px 2px; }
  .standings td:not(.c-team):not(.c-rank) { min-width: 24px; }
}

/* ---------- TurboTV ---------- */
.tv-head { display: flex; align-items: center; gap: 14px; padding: 6px 4px 14px; }
.tv-crest { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 6px 18px rgba(52, 167, 234, 0.35)); }
.tv-head h2 { margin: 0; font-family: 'Barlow Condensed', sans-serif; font-size: 30px; letter-spacing: 0.04em; }
.tv-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.tv-card {
  display: block;
  margin-bottom: 14px;
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  background: linear-gradient(160deg, var(--navy-800), var(--navy-950));
  border: 1px solid var(--line);
  transition: transform 0.15s, box-shadow 0.3s;
}
.tv-card:active { transform: scale(0.985); }
.tv-card.current { border-color: var(--accent); }
.tv-card.live { border-color: var(--live); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #000; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0.88; }
.thumb-empty {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, var(--navy-700), var(--black) 75%);
}
.play {
  position: absolute; inset: 0; margin: auto;
  width: 58px; height: 40px; border-radius: 12px;
  background: rgba(230, 33, 23, 0.92);
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}
.play svg { width: 22px; height: 22px; fill: #fff; }
.badge {
  position: absolute; top: 10px; left: 10px;
  padding: 4px 9px; border-radius: 8px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.06em;
  display: inline-flex; align-items: center; gap: 6px;
}
.badge.live { background: var(--live); color: #fff; }
.badge.live .dot { background: #fff; }
.badge.result { left: auto; right: 10px; font-family: 'Barlow Condensed', sans-serif; font-size: 18px; color: #04140c; }
.r-w { background: var(--win); }
.r-d { background: var(--draw); }
.r-l { background: var(--loss); color: #fff !important; }
.tv-info { padding: 12px 14px 14px; }
.tv-teams { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-weight: 600; font-size: 15px; }
.tv-teams em { font-style: normal; color: var(--muted); font-size: 12px; margin: 0 2px; }
.tv-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.tv-cta { color: var(--accent); font-weight: 600; white-space: nowrap; }
.tv-card.current .tv-info::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.tv-card.current .tv-info[data-label='']::before { display: none; }
.tv-card.compact { display: grid; grid-template-columns: 112px 1fr; align-items: stretch; margin-bottom: 10px; }
.tv-card.compact .thumb { aspect-ratio: auto; min-height: 76px; }
.tv-card.compact .thumb img, .tv-card.compact .thumb-empty { position: absolute; inset: 0; }
.tv-card.compact .thumb-empty .crest { width: 38px; height: 38px; }
.tv-card.compact .play { width: 36px; height: 26px; border-radius: 8px; }
.tv-card.compact .play svg { width: 15px; height: 15px; }
.tv-card.compact .badge { top: 6px; left: 6px; font-size: 10px; padding: 3px 6px; }
.tv-card.compact .badge.result { left: auto; right: 6px; font-size: 14px; }
.tv-card.compact .tv-info { padding: 9px 12px; display: flex; flex-direction: column; justify-content: center; }
.tv-card.compact .tv-teams { font-size: 13.5px; gap: 5px; }
.tv-card.compact .tv-teams .crest { width: 20px; height: 20px; }
.tv-card.compact .tv-meta { margin-top: 6px; font-size: 11.5px; flex-wrap: wrap; }
.tv-card.finished.compact { opacity: 0.9; }

/* ---------- bottom nav ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(5, 7, 13, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  position: relative;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: #fff; }
.tabbar a.active svg { stroke: var(--accent); }
.tabbar a.active::before {
  content: '';
  position: absolute; top: 0;
  width: 36px; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--accent);
}

@media (min-width: 700px) {
  .crest.xl { width: 120px; height: 120px; }
  .view { padding-top: 22px; }
}
