:root {
  --bg: #0c1110;
  --panel: #131a18;
  --panel-2: #1a2320;
  --line: #24302c;
  --text: #e9efec;
  --muted: #8b9a94;
  --accent: #34d17a;
  --accent-ink: #062713;
  --live: #ff5d5d;
  --radius: 12px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5f2;
    --panel: #ffffff;
    --panel-2: #eef2ee;
    --line: #dde4de;
    --text: #131a17;
    --muted: #63726b;
    --accent: #12924d;
    --accent-ink: #ffffff;
    --live: #d92d2d;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { display: block; }

/* top bar */
.bar {
  display: flex; align-items: center; gap: 16px 24px; flex-wrap: wrap;
  padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; text-decoration: none; }
.brand small { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 2px; }
.brand-mark { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; left: 8.5px; top: 6px; border: 5px solid transparent; border-left: 8px solid var(--accent-ink); }
.datenav { display: flex; align-items: center; gap: 4px; }
.icon, .ghost, .date {
  background: transparent; border: 1px solid var(--line); border-radius: 8px; height: 34px; padding: 0 12px;
}
.icon { width: 34px; padding: 0; font-size: 18px; line-height: 1; }
.icon:hover, .ghost:hover, .date:hover { background: var(--panel-2); }
.date { position: relative; min-width: 168px; font-weight: 600; font-variant-numeric: tabular-nums; }
.date input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.ghost { color: var(--muted); }
.tools { display: flex; align-items: center; gap: 16px; margin-left: auto; flex-wrap: wrap; }
#search { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; height: 34px; padding: 0 12px; width: 230px; }
#search:focus-visible, button:focus-visible, .match:focus-visible, .clip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; cursor: pointer; user-select: none; }
.switch input { accent-color: var(--accent); margin: 0; }

/* layout */
#app { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(320px, 400px) 1fr; }
#list { overflow-y: auto; border-right: 1px solid var(--line); padding: 8px 10px 40px; }
#detail { overflow-y: auto; padding: 22px clamp(16px, 4vw, 44px) 60px; }
.back { display: none; margin-bottom: 14px; }

/* match list */
.league { display: flex; align-items: center; gap: 8px; padding: 16px 8px 6px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.league img { width: 16px; height: 16px; object-fit: contain; }
.match {
  display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 8px 10px;
}
.match:hover { background: var(--panel); }
.match.active { background: var(--panel); border-color: var(--line); box-shadow: inset 3px 0 0 var(--accent); }
.match .when { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.match .when.live { color: var(--live); font-weight: 600; }
.teams { display: grid; gap: 3px; min-width: 0; }
.team { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 8px; }
.team span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team b { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 1ch; text-align: right; }
.team.lost span, .team.lost b { color: var(--muted); font-weight: 400; }
.crest { width: 18px; height: 18px; object-fit: contain; }
.crest.ph { border-radius: 50%; background: var(--line); }
.count { font-size: 11.5px; font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.count.none { color: var(--muted); background: transparent; font-weight: 400; }
.note { color: var(--muted); padding: 28px 12px; text-align: center; text-wrap: balance; }
.note b { color: var(--text); display: block; font-size: 15px; margin-bottom: 4px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto 10px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* scoreboard */
.score-meta { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 12.5px; margin-bottom: 14px; text-align: center; flex-wrap: wrap; }
.score-meta img { width: 18px; height: 18px; object-fit: contain; }
.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: clamp(12px, 3vw, 32px); max-width: 760px; margin: 0 auto 22px; }
.side { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; font-weight: 600; font-size: 16px; text-wrap: balance; }
.side img, .side .ph { width: 64px; height: 64px; object-fit: contain; }
.result { text-align: center; }
.result .nums { font-size: clamp(34px, 6vw, 52px); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.result .state { margin-top: 6px; font-size: 12px; color: var(--muted); }
.result .state.live { color: var(--live); font-weight: 600; }

/* player */
#player { max-width: 960px; margin: 0 auto 22px; }
.stage { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; }
.stage video, .stage iframe { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.stage .fallback { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; text-align: center; color: #cfd8d4; padding: 20px; }
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); font-weight: 600; border: 0; border-radius: 8px; padding: 9px 16px; text-decoration: none; }
.now { display: flex; align-items: center; gap: 12px; padding: 10px 2px 0; }
.now .title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now a { color: var(--muted); font-size: 12.5px; white-space: nowrap; text-decoration: none; }
.now a:hover { color: var(--text); text-decoration: underline; }
.now .icon { height: 30px; width: 30px; flex: none; }
.now .icon:disabled { opacity: .35; cursor: default; }

/* timeline */
.tl { max-width: 960px; margin: 0 auto; display: grid; gap: 8px; }
.tl h3 { margin: 6px 2px 2px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.ev { display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.ev.empty { background: transparent; border-style: dashed; }
.ev .min { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); padding-top: 1px; }
.ev.empty .min, .ev.moment .min { color: var(--muted); }
.ev .head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ev .head .crest { width: 20px; height: 20px; }
.ev .who { font-weight: 600; }
.ev .sc { font-variant-numeric: tabular-nums; color: var(--muted); }
.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; }
.ev .none { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.clips { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.clip { position: relative; width: 176px; background: transparent; border: 0; padding: 0; text-align: left; border-radius: 9px; }
.clip { display: block; }
.clip .thumb { display: block; position: relative; aspect-ratio: 16 / 9; border-radius: 9px; overflow: hidden; background: var(--panel-2) center / cover no-repeat; border: 1px solid var(--line); }
.clip .thumb::after { content: ""; position: absolute; left: 50%; top: 50%; width: 38px; height: 38px; margin: -19px; border-radius: 50%; background: rgba(0, 0, 0, .55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6.5v11l9-5.5z' fill='white'/%3E%3C/svg%3E") center / 22px no-repeat; transition: transform .12s; }
.clip:hover .thumb::after { transform: scale(1.12); }
.clip.playing .thumb { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.clip .cap { display: block; margin-top: 5px; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip.wide { width: 220px; }
.clip.wide .cap { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--text); font-size: 12.5px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px 14px; }
.grid .clip { width: auto; }

#toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 12.5px; color: var(--muted); box-shadow: 0 6px 24px rgba(0, 0, 0, .25); }

@media (max-width: 880px) {
  #app { grid-template-columns: 1fr; }
  #list { border-right: 0; }
  #app:not(.open) #detail { display: none; }
  #app.open #list { display: none; }
  .back { display: inline-block; }
  .tools { margin-left: 0; width: 100%; }
  #search { flex: 1; width: auto; }
  .ev { grid-template-columns: 40px 1fr; }
  .clip { width: calc(50% - 5px); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
