:root {
  --bg: #0f1115;
  --card: #181b22;
  --card-2: #1f232c;
  --line: #2a2f3a;
  --text: #e8eaee;
  --muted: #8b93a3;
  --accent: #ff4d4d;
  --live: #ff3b3b;
  --win: #3ddc84;
  --fav: #ffc83d;
  --cl: #2f80ed;
  --el: #f2994a;
  --rel: #eb5757;
  --tab-h: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 8px;
  border-bottom: 1px solid var(--line);
}
.title-row { display: flex; align-items: center; justify-content: space-between; }
h1 { font-size: 20px; margin: 0 0 8px; letter-spacing: .3px; }
.icon-btn { font-size: 22px; padding: 4px 8px; color: var(--muted); }
.icon-btn.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 6px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: 14px;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

main { padding: 12px 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px); max-width: 720px; margin: 0 auto; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabs button { color: var(--muted); font-size: 14px; font-weight: 600; }
.tabs button.on { color: var(--accent); }

.section { margin: 0 0 18px; }
.section > h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); margin: 0 0 6px; display: flex; gap: 8px; align-items: center;
}
.section > h2 .sub { text-transform: none; letter-spacing: 0; font-weight: 400; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.card + .card { margin-top: 8px; }

.match {
  display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; border-top: 1px solid var(--line);
}
.match:first-child { border-top: 0; }
.match .when { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.2; }
.match .when.live { color: var(--live); font-weight: 700; }
.team { display: flex; align-items: center; gap: 8px; min-width: 0; }
.team img { width: 20px; height: 20px; object-fit: contain; flex: 0 0 20px; }
.team .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team.win .name { font-weight: 700; }
.team.fav .name::after { content: " ★"; color: var(--fav); }
.teams { display: grid; gap: 4px; min-width: 0; }
.scores { display: grid; gap: 4px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.scores.live { color: var(--live); }
.meta { grid-column: 2 / 4; font-size: 12px; color: var(--muted); margin-top: -4px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); display: inline-block; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.board-head { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.board-head .ttl { font-weight: 700; }
.board-head .st { font-size: 12px; color: var(--muted); }
.board-head .st.live { color: var(--live); font-weight: 700; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 6px; text-align: right; white-space: nowrap; font-size: 14px; }
th { font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
td { border-top: 1px solid var(--line); }
tr:first-child td { border-top: 0; }
th:first-child, td:first-child { padding-left: 12px; }
th:last-child, td:last-child { padding-right: 12px; }
td.l, th.l { text-align: left; }
td.pos { width: 28px; color: var(--muted); border-left: 3px solid transparent; }
td.name-cell { max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; }
td.name-cell img { width: 18px; height: 18px; object-fit: contain; vertical-align: -4px; margin-right: 6px; }
td.pts { font-weight: 700; }
tr.fav td { background: rgba(255, 200, 61, .08); }
tr.fav td.name-cell::after { content: " ★"; color: var(--fav); }
tr[data-fav] { cursor: pointer; }
.hide-sm { display: none; }
@media (min-width: 480px) { .hide-sm { display: table-cell; } }

.legend { display: flex; flex-wrap: wrap; gap: 10px; padding: 8px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; background: var(--c); }

.empty { color: var(--muted); text-align: center; padding: 28px 12px; }
.err { color: var(--muted); font-size: 13px; padding: 10px 12px; }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin: 4px 0 14px; }

.seg { display: flex; gap: 6px; margin: 0 0 12px; overflow-x: auto; }
.seg button { padding: 5px 10px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: 13px; flex: 0 0 auto; }
.seg button.on { color: var(--text); border-color: var(--text); }

.list-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row .main { min-width: 0; }
.list-row .main .a { font-weight: 600; }
.list-row .main .b { font-size: 12px; color: var(--muted); }
.list-row .side { font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; }
.list-row .side.live { color: var(--live); font-weight: 700; }

.updated { text-align: center; color: var(--muted); font-size: 12px; margin-top: 8px; }
.list-row[data-fav] { cursor: pointer; }
.list-row.fav { background: rgba(255, 200, 61, .08); }
.list-row.fav .a::after { content: " ★"; color: var(--fav); }
a.list-row { color: inherit; text-decoration: none; }
.meta.inc { margin-top: 0; line-height: 1.45; }
.meta.inc .who { color: var(--text); font-weight: 600; }
.list-row.sub { padding-top: 6px; padding-bottom: 2px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
