:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eceef3;
  --line: #d8dce5;
  --text: #121826;
  --muted: #5d6679;
  --accent: #a5781f;
  --blue: #2563eb;
  --red: #dc2626;
  --blue-soft: rgba(37, 99, 235, .12);
  --red-soft: rgba(220, 38, 38, .12);
  --baron: #7c3aed;
  --shadow: 0 10px 30px rgba(15, 23, 42, .12);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070b14;
    --surface: #0f1626;
    --surface-2: #162036;
    --line: #233049;
    --text: #e8ecf4;
    --muted: #8e9ab3;
    --accent: #c9a45c;
    --blue: #4f8cff;
    --red: #ff5d5d;
    --blue-soft: rgba(79, 140, 255, .16);
    --red-soft: rgba(255, 93, 93, .16);
    --baron: #a78bfa;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}

button:hover { border-color: var(--accent); }

button.ghost { background: transparent; }

a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 700;
  letter-spacing: .02em;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--blue) 0 45%, var(--accent) 45% 55%, var(--red) 55%);
}

.paste { display: flex; gap: 8px; flex: 1; max-width: 460px; }

.paste input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
}

.app { max-width: 1180px; margin: 0 auto; padding: 18px 16px 60px; }

.leagues { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

.chip { border-radius: 999px; padding: 5px 14px; font-weight: 600; font-size: 13px; }

.chip[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #10131a; }

.day { margin: 22px 0 8px; color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

.match {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.match-teams { display: flex; align-items: center; gap: 10px; font-weight: 700; min-width: 0; }

.match-teams img { width: 26px; height: 26px; object-fit: contain; }

.match-teams .vs { color: var(--muted); font-weight: 500; font-size: 13px; }

.match-meta { color: var(--muted); font-size: 13px; }

.match-games { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.game-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.game-link:hover { border-color: var(--accent); }

.game-link .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }

.game-link .dot.ready { background: #22c55e; }

.more { text-align: center; margin-top: 16px; }

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

.watch-head { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }

.matchup { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }

.matchup h1 { font-size: 20px; margin: 0; }

.matchup .blue { color: var(--blue); }

.matchup .red { color: var(--red); }

.matchup small { color: var(--muted); }

.watch-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.game-tabs { display: flex; gap: 6px; }

.game-tabs button[aria-selected="true"] { border-color: var(--accent); color: var(--accent); }

select { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; max-width: 200px; }

.player-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.player-frame > div, .player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 14px 0 8px;
  font-variant-numeric: tabular-nums;
}

.hud-side { display: flex; gap: 14px; align-items: center; font-weight: 700; }

.hud-side.red { justify-content: flex-end; }

.hud-side .code { font-size: 17px; }

.hud-side.blue .code { color: var(--blue); }

.hud-side.red .code { color: var(--red); }

.stat { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); font-weight: 600; }

.stat svg { width: 15px; height: 15px; }

.stat b { color: var(--text); }

.hud-clock { font-size: 22px; font-weight: 800; letter-spacing: .04em; text-align: center; }

.hud-clock small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .08em; }

.timeline {
  position: relative;
  height: 132px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  user-select: none;
  touch-action: none;
  cursor: pointer;
  overflow: hidden;
}

.tl-lane { position: absolute; left: 0; right: 0; }

.tl-lane.blue { top: 0; height: 50%; background: linear-gradient(to bottom, transparent, var(--blue-soft)); }

.tl-lane.red { bottom: 0; height: 50%; background: linear-gradient(to top, transparent, var(--red-soft)); }

.tl-axis { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--line); }

.tl-tick { position: absolute; top: 50%; transform: translate(-50%, -50%); font-size: 10px; color: var(--muted); background: var(--surface); padding: 0 3px; pointer-events: none; }

.tl-progress { position: absolute; top: 0; bottom: 0; left: 0; background: color-mix(in srgb, var(--accent) 10%, transparent); pointer-events: none; }

.tl-head { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent); pointer-events: none; box-shadow: 0 0 8px var(--accent); }

.marker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: transparent;
}

.marker svg { width: 16px; height: 16px; }

.marker.blue { color: var(--blue); }

.marker.red { color: var(--red); }

.marker.kill { background: var(--surface); border: 1.5px solid currentColor; width: 18px; height: 18px; }

.marker.kill svg { width: 11px; height: 11px; }

.marker .count { position: absolute; top: -7px; right: -8px; font-size: 10px; font-weight: 800; background: currentColor; border-radius: 8px; padding: 0 4px; line-height: 14px; }

.marker .count span { color: var(--surface); }

.marker.baron { color: var(--baron); }

.marker.future { opacity: .35; }

.marker.hidden { display: none; }

.marker:hover, .marker:focus-visible { transform: translate(-50%, -50%) scale(1.25); z-index: 3; outline: none; }

.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 8px 10px;
  font-size: 13px;
  max-width: 320px;
}

.tooltip li { list-style: none; display: flex; gap: 8px; }

.tooltip ul { margin: 0; padding: 0; }

.tooltip time, .feed time { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 42px; }

.controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }

.filters button { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; padding: 4px 10px; border-radius: 999px; }

.filters button svg { width: 14px; height: 14px; }

.filters button[aria-pressed="false"] { opacity: .45; }

.switch { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; cursor: pointer; }

.sync { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin: 10px 0 16px; }

.sync summary { cursor: pointer; font-weight: 600; font-size: 14px; }

.sync-body p { color: var(--muted); font-size: 13px; margin: 8px 0; }

.sync-body .sync-alternative { color: var(--text); }

.sync-body .sync-alternative:empty { display: none; }

.sync-alternative a { color: var(--accent); font-weight: 600; }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-right: 6px; }

.badge.ok { background: rgba(34, 197, 94, .16); color: #16a34a; }

.badge.estimated { background: rgba(234, 179, 8, .18); color: #ca8a04; }

.clock-form { display: flex; gap: 8px; margin-bottom: 10px; }

.clock-form input { width: 90px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }

.nudges { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.nudges span { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }

.feed { list-style: none; margin: 0; padding: 0; columns: 2 320px; column-gap: 16px; }

.feed li {
  break-inside: avoid;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-left: 3px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.feed li:hover { background: var(--surface-2); }

.feed li.blue { border-left-color: var(--blue); }

.feed li.red { border-left-color: var(--red); }

.feed li.future { opacity: .5; }

.feed li.hidden { display: none; }

.feed svg { width: 14px; height: 14px; flex: none; }

.notice { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; color: var(--muted); }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .paste { max-width: none; flex-basis: 100%; }
  .match { grid-template-columns: 1fr; }
  .match-games { justify-content: flex-start; }
  .hud { grid-template-columns: 1fr 1fr; }
  .hud-clock { grid-column: 1 / -1; order: -1; }
  .hud-side { gap: 8px; font-size: 13px; }
  .timeline { height: 112px; }
}
