:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --text: #11151c;
  --muted: #5d6573;
  --line: #dde1e7;
  --gold: #9a7b3c;
  --live: #d92d3a;
  --t1: #d4002a;
  --t1-tint: rgba(212, 0, 42, 0.08);
  --vn: #b88a00;
  --vn-tint: rgba(255, 196, 0, 0.16);
  --ok: #1f8a4c;
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e13;
    --surface: #151a22;
    --surface-2: #1e2530;
    --text: #eef1f5;
    --muted: #8d96a5;
    --line: #262e3a;
    --gold: #c8aa6e;
    --live: #ff4d5a;
    --t1: #ff3355;
    --t1-tint: rgba(255, 51, 85, 0.12);
    --vn: #ffcd00;
    --vn-tint: rgba(255, 205, 0, 0.1);
    --ok: #3ccf7a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

button, select { font: inherit; color: inherit; }

/* ---------- header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}

.top > *, .view { max-width: 760px; margin-inline: auto; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; }

.brand { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; font-weight: 800; letter-spacing: 0.2px; }
.brand img { border-radius: 7px; }

.status { font-size: 12px; color: var(--muted); text-align: right; }
.status.warn { color: var(--live); }

.tabs { display: flex; gap: 4px; margin-top: 10px; padding: 3px; background: var(--surface-2); border-radius: 10px; }
.tabs button {
  flex: 1;
  border: 0;
  background: none;
  padding: 7px 0;
  border-radius: 8px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* Một hàng cuộn ngang: giải | đội */
.filters { display: flex; gap: 6px; padding: 10px 0; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chips { display: flex; gap: 6px; flex: none; }
.chips.toggles:not([hidden]) { padding-left: 8px; margin-left: 2px; border-left: 1px solid var(--line); }

.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.toggle.hl-t1[aria-pressed="true"] { background: var(--t1); border-color: var(--t1); color: #fff; }
.chip.toggle.hl-vn[aria-pressed="true"] { background: var(--vn); border-color: var(--vn); color: #111; }

/* ---------- nội dung ---------- */
.view { padding: 8px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left)); }

.day h2, .stage h2 {
  margin: 18px 0 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}
.day h2.live-head { color: var(--live); }

.match {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: var(--radius);
  padding: 10px 12px 12px;
  margin-bottom: 8px;
}
.match.hl-vn { border-left-color: var(--vn); background: linear-gradient(90deg, var(--vn-tint), transparent 60%), var(--surface); }
.match.hl-t1 { border-left-color: var(--t1); background: linear-gradient(90deg, var(--t1-tint), transparent 60%), var(--surface); }
.match.is-live { border-color: var(--live); box-shadow: 0 0 0 1px var(--live) inset; }

.meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.meta time { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.meta .league { color: var(--gold); font-weight: 700; }
.meta .block { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--live);
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}
.badge-live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.2; } }

.teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-top: 8px; }

.team { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; font-size: 16px; }
.team.right { flex-direction: row-reverse; text-align: right; }
.team .code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team.lost { opacity: 0.45; }
.team.hl-t1 .code { color: var(--t1); }
.team.hl-vn .code { color: var(--vn); }

.logo { width: 32px; height: 32px; object-fit: contain; flex: none; }
/* Nhiều logo đội là bản trắng cho nền tối → chế độ sáng đặt logo trên nền tròn tối */
@media (prefers-color-scheme: light) {
  img.logo { background: #1b2029; border-radius: 50%; padding: 4px; }
}
.logo.tbd {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
}

.score { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; display: flex; gap: 6px; }
.score i { font-style: normal; color: var(--muted); }
.is-live .score { color: var(--live); }
.vs { font-size: 12px; font-weight: 700; color: var(--muted); }

/* Ẩn kết quả (chống spoil) */
.reveal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: transparent;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.reveal:hover { background: color-mix(in srgb, var(--gold) 14%, transparent); }
@media (max-width: 400px) { .reveal { padding: 6px 10px; font-size: 12px; gap: 4px; } }

.spoiler-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--muted);
}
.spoiler-bar button {
  flex: none;
  border: 0;
  background: var(--surface-2);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.more {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

.skeleton {
  height: 84px;
  border-radius: var(--radius);
  margin: 12px 0;
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- BXH ---------- */
.picker { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.picker select {
  flex: 1;
  max-width: 280px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 12px 10px; margin-bottom: 10px; }
.section h3 { font-size: 14px; margin: 10px 0 4px; }

.table { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }
.table th { font-size: 11px; color: var(--muted); text-align: left; font-weight: 600; padding: 8px 4px 4px; }
.table th:nth-child(n+3), .table td:nth-child(n+3) { text-align: center; width: 36px; }
.table th:first-child, .table td:first-child { width: 28px; color: var(--muted); }
.table td { padding: 7px 4px; border-top: 1px solid var(--line); }
.table .tname { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.table .tname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .tname em { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; flex: none; }
.table tr.qualified em { color: var(--ok); border: 1px solid var(--ok); }
.table tr.eliminated em { color: var(--muted); border: 1px solid var(--line); }
.table tr.eliminated .tname span { opacity: 0.55; }
.table .logo { width: 24px; height: 24px; }
.table tr.hl-t1 { background: var(--t1-tint); }
.table tr.hl-t1 .tname span { color: var(--t1); }
.table tr.hl-vn { background: var(--vn-tint); }
.table tr.hl-vn .tname span { color: var(--vn); }

.table .short { display: none; }
@media (max-width: 480px) {
  .table .full { display: none; }
  .table .short { display: inline; }
}

.note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

details summary { cursor: pointer; font-size: 13px; color: var(--muted); padding: 8px 0 4px; }
.mini-row { display: grid; grid-template-columns: 1fr 56px 1fr; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.mini-row .team { font-size: 14px; }
.mini-row .logo { width: 22px; height: 22px; }
.mini-score { text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.mini-row.is-live .mini-score { color: var(--live); }

@media (min-width: 700px) {
  .team { font-size: 17px; }
  .match { padding: 12px 16px 14px; }
}
