:root {
  --bg: #0b1020;
  --bg-card: rgba(255, 255, 255, 0.06);
  --bg-card-hover: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.1);
  --text: #eef2f8;
  --text-dim: #9aa5b8;
  --accent: #2ee59d;
  --accent-2: #ffd54a;
  --live: #ff4d6d;
  --radius: 16px;
  --tabbar-h: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(46, 229, 157, 0.12), transparent 60%),
    radial-gradient(900px 400px at -10% 10%, rgba(77, 119, 255, 0.14), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

/* ---------- Header ---------- */
.app-header {
  padding: calc(16px + env(safe-area-inset-top)) 16px 12px;
  max-width: 640px;
  margin: 0 auto;
}
.header-inner { position: relative; }
.app-header h1 { font-size: 22px; letter-spacing: 0.5px; }
.subtitle { color: var(--text-dim); font-size: 12px; margin-top: 4px; }
.tz-toggle {
  position: absolute; right: 0; top: 2px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; padding: 5px 10px;
  border-radius: 999px; cursor: pointer;
}
.tz-toggle:active { background: var(--bg-card-hover); }

.countdown {
  margin-top: 12px;
  background: linear-gradient(135deg, rgba(46, 229, 157, 0.18), rgba(77, 119, 255, 0.18));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  display: flex; align-items: baseline; gap: 10px;
}
.countdown-label { font-size: 13px; color: var(--text-dim); }
.countdown-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }

/* ---------- Layout ---------- */
main { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.view { display: none; }
.view.active { display: block; }
.hint { color: var(--text-dim); font-size: 12px; margin: 8px 2px 12px; line-height: 1.6; }

/* ---------- Filter chips ---------- */
.chips {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 4px 0 12px; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 13px;
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
  transition: all 0.15s;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #06281a; font-weight: 600; }

/* ---------- Schedule ---------- */
.date-header {
  position: sticky; top: 0; z-index: 5;
  font-size: 13px; font-weight: 600; color: var(--accent-2);
  padding: 10px 2px 8px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.match-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.match-card:active { background: var(--bg-card-hover); }
.match-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text-dim); margin-bottom: 8px;
}
.match-stage { color: var(--accent); font-weight: 600; }
.match-row { display: flex; align-items: center; gap: 8px; }
.team {
  flex: 1; display: flex; align-items: center; gap: 6px;
  font-size: 15px; font-weight: 500; min-width: 0;
}
.team.away { flex-direction: row-reverse; text-align: right; }
.team .flag { font-size: 20px; flex-shrink: 0; }
.team .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team.placeholder .name { color: var(--text-dim); font-size: 13px; font-weight: 400; white-space: normal; line-height: 1.3; }
.match-center {
  flex: 0 0 auto; min-width: 64px; text-align: center;
}
.match-score { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.match-penalty { font-size: 11px; color: var(--text-dim); }
.match-time { font-size: 14px; font-weight: 600; color: var(--text); }
.match-time.tbd { font-size: 12px; color: var(--text-dim); font-weight: 400; }
.badge {
  display: inline-block; font-size: 10px; padding: 2px 8px;
  border-radius: 999px; font-weight: 600;
}
.badge.live { background: var(--live); color: #fff; animation: pulse 1.2s infinite; }
.badge.finished { background: rgba(255, 255, 255, 0.12); color: var(--text-dim); }
.badge.gif { background: rgba(255, 213, 74, 0.18); color: var(--accent-2); }
@keyframes pulse { 50% { opacity: 0.55; } }
.empty {
  text-align: center; color: var(--text-dim);
  padding: 60px 20px; font-size: 14px; line-height: 1.8;
}

/* ---------- Standings ---------- */
.standings-list { display: grid; gap: 14px; padding-bottom: 16px; }
@media (min-width: 560px) { .standings-list { grid-template-columns: 1fr 1fr; } }
.group-table {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.group-table h3 {
  font-size: 14px; padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--accent);
}
.group-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.group-table th, .group-table td { padding: 8px 6px; text-align: center; font-weight: 400; }
.group-table th { color: var(--text-dim); font-size: 11px; }
.group-table td.team-cell { text-align: left; padding-left: 14px; white-space: nowrap; }
.group-table tr.qualified td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.group-table td.pts { font-weight: 700; }

/* ---------- Highlights ---------- */
.highlights-list { padding-bottom: 16px; }
.hl-match { margin-bottom: 24px; }
.hl-match-title {
  font-size: 15px; font-weight: 600; margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.hl-match-sub { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }
.gif-grid { display: grid; gap: 10px; }
@media (min-width: 560px) { .gif-grid { grid-template-columns: 1fr 1fr; } }
.gif-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
}
.gif-card img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block;
  background: rgba(255, 255, 255, 0.04);
}
.gif-card figcaption {
  padding: 8px 12px 10px; font-size: 12px; color: var(--text-dim);
  display: flex; gap: 8px; align-items: center;
}
.gif-minute {
  flex-shrink: 0; background: var(--accent); color: #06281a;
  font-weight: 700; font-size: 11px; padding: 1px 7px; border-radius: 999px;
}

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(13, 18, 36, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  display: flex;
}
.tab {
  flex: 1; background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 11px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tab-icon { font-size: 20px; }
.tab.active { color: var(--accent); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 30; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.modal-sheet {
  position: absolute; bottom: 0; left: 0; right: 0;
  max-height: 82dvh; overflow-y: auto;
  background: #131a30; border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto;
  animation: slideUp 0.22s ease-out;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }
.modal-close {
  position: absolute; right: 14px; top: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-dim); width: 30px; height: 30px; border-radius: 50%;
  cursor: pointer; font-size: 13px;
}
.modal-vs {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin: 8px 0 4px; font-size: 17px; font-weight: 600;
}
.modal-vs .flag { font-size: 30px; display: block; text-align: center; }
.modal-vs .side { flex: 1; text-align: center; min-width: 0; }
.modal-vs .score { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.modal-info { text-align: center; color: var(--text-dim); font-size: 12px; margin-bottom: 14px; line-height: 1.8; }
.modal-section-title { font-size: 14px; font-weight: 600; margin: 14px 0 10px; color: var(--accent-2); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 20px; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 78dvh; border-radius: 10px; }
.lightbox p { color: var(--text-dim); font-size: 13px; text-align: center; }

[hidden] { display: none !important; }
