:root {
  --bg: #07120d;
  --bg-grad: radial-gradient(120% 80% at 50% 0%, #123524 0%, #07120d 55%);
  --card: #0f1f18;
  --card-hi: #132a20;
  --line: #1f3a2c;
  --txt: #e9f2ec;
  --muted: #7e9a8b;
  --green: #2ee06a;
  --green-dim: #1c7a45;
  --gold: #ffd24a;
  --live: #ff4242;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-grad);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 16px 10px;
  background: rgba(7, 18, 13, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header .sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.dot-live {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(255,66,66,.6);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,66,66,.55); }
  70% { box-shadow: 0 0 0 7px rgba(255,66,66,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,66,66,0); }
}

/* ---------- content ---------- */
.content {
  flex: 1;
  padding: 12px 12px calc(78px + var(--safe-bottom));
}

/* count + countdown banner */
.banner {
  background: linear-gradient(135deg, #143a26, #0d241a);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 2px 2px 4px;
}
.bn-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--muted);
}
.bn-row b { color: var(--gold); font-size: 16px; font-variant-numeric: tabular-nums; }
.bn-cal {
  color: var(--green); font-weight: 700; font-size: 13px; cursor: pointer;
  border: 1px solid var(--green-dim); border-radius: 999px; padding: 4px 11px;
}
.bn-next {
  margin-top: 9px; padding-top: 9px; border-top: 1px solid rgba(31,58,44,.6);
  font-size: 13px; color: var(--txt);
}
.bn-next #cd { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }

.bn-acts { display: inline-flex; gap: 6px; align-items: center; }
.bn-dl {
  color: var(--green); font-weight: 700; font-size: 13px; cursor: pointer;
  border: 1px solid var(--green-dim); border-radius: 999px; padding: 4px 9px;
}

/* per-match ICS + venue */
.m-ics { margin-left: auto; cursor: pointer; font-size: 13px; opacity: .8; }
.match-venue {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(31,58,44,.5);
  font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* per-group subscribe in standings */
.grp-sub {
  margin-left: auto; font-size: 11px; font-weight: 600; color: var(--green);
  cursor: pointer; border: 1px solid var(--green-dim); border-radius: 999px; padding: 2px 9px;
}
.group-title { display: flex; align-items: center; }

/* badges */
.badge-star {
  color: var(--gold); border: 1px solid rgba(255,210,74,.4);
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 5px;
}

/* team filter bar */
.team-filter {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-hi); border: 1px solid var(--green-dim);
  border-radius: 10px; padding: 8px 12px; margin: 6px 2px;
  font-size: 13px; color: var(--muted);
}
.team-filter b { color: var(--txt); }
.team-filter .tf-sub { color: var(--green); font-weight: 700; cursor: pointer; }
.team-filter .tf-clear { margin-left: auto; color: var(--muted); cursor: pointer; }

/* sheet action buttons */
.sheet-actions { display: flex; gap: 9px; margin-bottom: 14px; }
.sheet-actions .act {
  flex: 1; padding: 10px; border-radius: 10px; cursor: pointer;
  font-size: 13px; font-weight: 600; border: 1px solid var(--line);
  background: var(--card); color: var(--txt);
}
.sheet-actions .act-cal { background: var(--green); color: #04140b; border-color: var(--green); }

/* chips */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.chip.active {
  background: var(--green);
  color: #04140b;
  border-color: var(--green);
}

/* date header */
.date-head {
  position: sticky;
  top: 60px;
  z-index: 10;
  margin: 14px 2px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: .5px;
}
.date-head:first-child { margin-top: 2px; }

/* ---------- match card ---------- */
.match {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  margin-bottom: 9px;
}
.match.live { border-color: rgba(255,66,66,.45); background: var(--card-hi); }
.match-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 9px;
}
.badge-live {
  color: #fff; background: var(--live);
  font-weight: 700; font-size: 10px;
  padding: 1px 6px; border-radius: 5px;
  display: inline-flex; align-items: center; gap: 4px;
}
.badge-live::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: #fff; animation: pulse 1.6s infinite;
}
.badge-fin { color: var(--muted); border: 1px solid var(--line); padding: 0 6px; border-radius: 5px; font-size: 10px; }

.match-teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
}
.team {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.team.away { flex-direction: row-reverse; text-align: right; }
.team img { width: 26px; height: 26px; object-fit: contain; flex: 0 0 auto; }
.team .nm {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.center {
  text-align: center;
  min-width: 56px;
}
.score-num {
  font-size: 19px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}
.score-num.live { color: var(--live); }
.kick-time {
  font-size: 15px; font-weight: 700; color: var(--txt);
  font-variant-numeric: tabular-nums;
}
.kick-day { font-size: 10px; color: var(--muted); }

/* ---------- standings ---------- */
.group-block { margin-bottom: 18px; }
.group-title {
  font-size: 14px; font-weight: 800; margin: 0 2px 8px;
  display: flex; align-items: center; gap: 8px;
}
.group-title .tag {
  background: var(--green); color: #04140b;
  width: 22px; height: 22px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
}
table.stand {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
}
table.stand th, table.stand td {
  padding: 8px 4px;
  font-size: 12px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
table.stand th {
  color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
}
table.stand td.t-team {
  text-align: left; padding-left: 8px;
  display: flex; align-items: center; gap: 7px;
}
table.stand td.t-team img { width: 18px; height: 18px; object-fit: contain; }
table.stand td.t-team .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 96px; }
table.stand td.pts { font-weight: 800; color: var(--gold); }
table.stand tr.qualify td:first-child { box-shadow: inset 3px 0 0 var(--green); }
table.stand tr.qualify { background: rgba(46,224,106,.06); }
.col-pos { width: 26px; color: var(--muted); }

/* ---------- teams ---------- */
.team-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.team-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.team-card img { width: 30px; height: 30px; object-fit: contain; }
.team-card .nm { font-size: 14px; font-weight: 600; }

/* detail overlay */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 480px;
  background: var(--bg);
  border-top-left-radius: 20px; border-top-right-radius: 20px;
  border-top: 1px solid var(--line);
  max-height: 86vh; overflow-y: auto;
  padding: 16px 16px calc(24px + var(--safe-bottom));
  animation: slideup .22s ease;
}
@keyframes slideup { from { transform: translateY(100%);} to { transform: translateY(0);} }
.sheet-head {
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; background: var(--bg); padding-bottom: 12px;
  border-bottom: 1px solid var(--line); margin-bottom: 12px;
}
.sheet-head img { width: 40px; height: 40px; object-fit: contain; }
.sheet-head .nm { font-size: 18px; font-weight: 800; }
.sheet-head .coach { font-size: 12px; color: var(--muted); }
.sheet-close {
  margin-left: auto; background: var(--card); border: 1px solid var(--line);
  color: var(--muted); width: 30px; height: 30px; border-radius: 50%;
  font-size: 16px; cursor: pointer;
}
.pos-group { margin-bottom: 14px; }
.pos-label {
  font-size: 12px; font-weight: 700; color: var(--green);
  margin-bottom: 6px;
}
.player {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 4px; border-bottom: 1px solid rgba(31,58,44,.5);
  font-size: 14px;
}
.player .pn { color: var(--muted); font-size: 11px; }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  max-width: 480px; margin: 0 auto;
  display: flex;
  background: rgba(9, 21, 15, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.nav button {
  flex: 1;
  background: none; border: none;
  color: var(--muted);
  padding: 9px 0 11px;
  font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer;
}
.nav button .ic { font-size: 21px; line-height: 1; }
.nav button.active { color: var(--green); }

/* states */
.empty, .loading {
  text-align: center; color: var(--muted);
  padding: 50px 20px; font-size: 14px;
}
.spinner {
  width: 26px; height: 26px; margin: 0 auto 12px;
  border: 3px solid var(--line); border-top-color: var(--green);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg);} }
