:root {
  --bg: #050505;
  --surface: #0a0a0c;
  --surface-2: #111114;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text: #ffffff;
  --text-2: #b4b4b8;
  --text-dim: #77777c;
  --accent: #ff5500;
  --team-a: #ff5500;
  --team-b: #4c8dff;
  --team-n: #77777c;
  --win: #22c55e;
  --loss: #ef4444;
  --draw: #a3a3a3;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --font: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

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

html, body { margin: 0; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

code, .mono { font-family: var(--mono); font-size: 0.92em; }
code { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; }
.dim { color: var(--text-dim); }

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(5, 5, 5, 0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; height: 64px;
  padding: 0 24px;
  display: flex; align-items: center; gap: 14px;
}
.brand img { height: 22px; width: auto; display: block; }
.brand-sep { width: 1px; height: 20px; background: var(--border-strong); }
.brand-product { font-weight: 500; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.pill {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent); background: rgba(255, 85, 0, 0.08); border: 1px solid rgba(255, 85, 0, 0.25);
  border-radius: 4px; padding: 2px 6px;
}

.wrap { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 48px 24px 64px; }

/* ── Intro / drop zone ───────────────────────────────────── */
.intro { max-width: 640px; margin: 24px auto 0; text-align: center; }
.intro h1 { font-size: clamp(28px, 5vw, 40px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 12px; }
.lede { color: var(--text-2); font-size: 15px; margin: 0 0 32px; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 48px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 180ms var(--ease), background-color 180ms var(--ease), transform 180ms var(--ease);
}
.drop:hover, .drop:focus-visible { border-color: rgba(255, 85, 0, 0.6); background: #0d0b0a; outline: none; }
.drop:active { transform: scale(0.99); }
.drop-icon { color: var(--accent); margin-bottom: 8px; }
.drop-title { font-size: 17px; font-weight: 600; }
.drop-sub { color: var(--text-dim); }
.drop-sub u { color: var(--text-2); text-underline-offset: 3px; }

.notes { margin-top: 24px; display: grid; gap: 10px; text-align: left; }
.notes p { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; color: var(--text-2); font-size: 13px; }
.note-label { font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); min-width: 120px; }

.dragveil {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 5, 5, 0.8);
  border: 2px dashed var(--accent);
  pointer-events: none;
}
.dragveil span { font-size: 20px; font-weight: 600; }

/* ── Status / error ──────────────────────────────────────── */
.status, .error {
  max-width: 560px; margin: 48px auto 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 28px;
}
.status { display: flex; align-items: center; gap: 18px; }
.status-title { font-weight: 600; }
.status-sub { color: var(--text-dim); font-size: 13px; word-break: break-all; }
.spinner {
  width: 28px; height: 28px; flex: 0 0 auto;
  border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-title { font-weight: 600; font-size: 16px; margin-bottom: 8px; }
.error-text { color: var(--text-2); font-family: var(--mono); font-size: 12.5px; word-break: break-word; margin-bottom: 20px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px;
  background: #fff; color: #000;
  border: 1px solid #fff; border-radius: 10px;
  font: 600 13px/1 var(--font);
  cursor: pointer;
  transition: background-color 180ms var(--ease), color 180ms var(--ease), border-color 180ms var(--ease), transform 180ms var(--ease);
}
.btn:hover { background: #e8e8e8; }
.btn:active { transform: scale(0.97); transition-duration: 90ms; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font: 500 12px var(--font); cursor: pointer; }

/* ── Report layout ───────────────────────────────────────── */
.report { display: flex; flex-direction: column; gap: 28px; }
.filebar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.filebar-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.filebar-name .mono { color: var(--text-2); word-break: break-all; }
.filebar-name .dim { font-size: 12px; }
.filebar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; }
.notice {
  padding: 12px 16px; border-radius: 12px; font-size: 13px; color: var(--text-2);
  background: rgba(255, 85, 0, 0.06); border: 1px solid rgba(255, 85, 0, 0.2);
}
.notice a { color: var(--accent); }

/* Keep jumped-to sections clear of the sticky top bar. */
.section { scroll-margin-top: 80px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; }
.section-head h3 { margin: 0; font-size: 13px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); }
.section-note { font-size: 12px; color: var(--text-dim); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; font-size: 12px; color: var(--text-dim); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 auto; background: var(--team-n); }
.dot.t0 { background: var(--team-a); }
.dot.t1 { background: var(--team-b); }

/* ── Summary ─────────────────────────────────────────────── */
.summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px; padding: 28px 32px; }
.summary-main { min-width: 0; }
.eyebrow { font-size: 12px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.summary-map { margin: 0 0 8px; font-size: clamp(26px, 4vw, 36px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.summary-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text-dim); font-size: 13px; }
.awards { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 16px; font-size: 13px; }
.award-item { display: inline-flex; align-items: center; gap: 8px; }
.award { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; padding: 2px 6px; border-radius: 4px; }
.award-mvp { background: rgba(255, 196, 0, 0.12); color: #ffc400; border: 1px solid rgba(255, 196, 0, 0.3); }
.award-svp { background: rgba(200, 200, 210, 0.1); color: #cfcfd6; border: 1px solid rgba(200, 200, 210, 0.25); }

.summary-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 12px; }
.score { display: flex; align-items: center; gap: 14px; }
.score-team { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.score-num { font-size: 44px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; color: var(--text-dim); }
.score-team.is-winner .score-num { color: var(--text); }
.score-label { margin-top: 6px; font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.score-team.t0 .score-label { color: var(--team-a); }
.score-team.t1 .score-label { color: var(--team-b); }
.score-sep { font-size: 32px; color: var(--text-dim); margin-top: -18px; }

.result { display: inline-flex; align-items: baseline; gap: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); font-size: 13px; }
.result-word { font-weight: 600; }
.result-for { color: var(--text-dim); }
.result-victory { border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.08); }
.result-victory .result-word { color: var(--win); }
.result-defeat { border-color: rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.08); }
.result-defeat .result-word { color: var(--loss); }
.result-draw .result-word { color: var(--draw); }

/* ── Rounds strip ────────────────────────────────────────── */
.rounds { display: flex; flex-wrap: wrap; gap: 6px; }
.round-cell {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim);
  font: 500 13px var(--font); font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: border-color 180ms var(--ease), background-color 180ms var(--ease), transform 180ms var(--ease);
}
.round-cell:hover { border-color: var(--border-strong); }
.round-cell:active { transform: scale(0.95); transition-duration: 90ms; }
.round-cell.t0 { background: rgba(255, 85, 0, 0.14); border-color: rgba(255, 85, 0, 0.35); color: #ffb08a; }
.round-cell.t1 { background: rgba(76, 141, 255, 0.14); border-color: rgba(76, 141, 255, 0.35); color: #a9c6ff; }
.round-cell.is-selected { outline: 2px solid #fff; outline-offset: 2px; }

/* ── Scoreboard ──────────────────────────────────────────── */
.tables { display: grid; gap: 16px; }
.team-table { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; }
.team-table.t0 { border-top: 2px solid var(--team-a); }
.team-table.t1 { border-top: 2px solid var(--team-b); }
.team-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 12px; }
.team-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.team-rounds { color: var(--text-dim); font-size: 13px; }
.team-result { margin-left: auto; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.team-result.result-victory { color: var(--win); }
.team-result.result-defeat { color: var(--loss); }
.team-result.result-draw { color: var(--draw); }

.table-scroll { overflow-x: auto; }
/* Fixed layout so both team tables line their stat columns up. */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; table-layout: fixed; }
th:not(.col-player) { width: 60px; }
th:nth-last-child(-n+2) { width: 84px; }
th, td { padding: 10px 12px; text-align: right; white-space: nowrap; }
th { font-size: 11px; font-weight: 500; letter-spacing: 0.08em; color: var(--text-dim); border-bottom: 1px solid var(--border); }
td { border-bottom: 1px solid rgba(255, 255, 255, 0.04); color: var(--text-2); }
tbody tr:last-child td { border-bottom: 0; }
th.col-player, td.col-player { text-align: left; padding-left: 20px; white-space: normal; min-width: 180px; }
th:last-child, td:last-child { padding-right: 20px; }
tr.is-you td { background: rgba(255, 255, 255, 0.03); }
.pname { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pname-text { color: var(--text); font-weight: 500; word-break: break-word; }
.pchars { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.tag { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; padding: 1px 5px; border-radius: 4px; }
.tag-you { background: rgba(255, 255, 255, 0.1); color: #fff; }
.tag-mvp { background: rgba(255, 196, 0, 0.12); color: #ffc400; }
.tag-svp { background: rgba(200, 200, 210, 0.1); color: #cfcfd6; }

/* ── Damage ──────────────────────────────────────────────── */
.dmg-list { padding: 8px 0; }
.dmg-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.1fr) minmax(120px, 2fr) auto;
  grid-template-areas: "who bar total" "split split weapons";
  gap: 6px 16px; align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.dmg-row:last-child { border-bottom: 0; }
.dmg-who { grid-area: who; display: flex; align-items: center; gap: 8px; min-width: 0; }
.dmg-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dmg-bar-wrap { grid-area: bar; height: 6px; background: rgba(255, 255, 255, 0.05); border-radius: 3px; overflow: hidden; }
.dmg-bar { height: 100%; border-radius: 3px; background: var(--team-n); }
.dmg-bar.t0 { background: var(--team-a); }
.dmg-bar.t1 { background: var(--team-b); }
.dmg-total { grid-area: total; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.dmg-split { grid-area: split; display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-dim); padding-left: 16px; }
.dmg-weapons { grid-area: weapons; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 14px; font-size: 12px; }
.weapon { display: inline-flex; gap: 6px; }
.weapon-name { color: var(--text-2); }

/* ── Kill feed ───────────────────────────────────────────── */
.timeline { padding: 4px 0; }
.round-block { padding: 14px 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.round-block:last-child { border-bottom: 0; }
.rb-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 8px; font-size: 13px; }
.rb-title { font-weight: 600; }
.rb-dur { margin-left: auto; font-variant-numeric: tabular-nums; }
.chip { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); }
.chip.t0 { color: #ffb08a; border-color: rgba(255, 85, 0, 0.35); background: rgba(255, 85, 0, 0.08); }
.chip.t1 { color: #a9c6ff; border-color: rgba(76, 141, 255, 0.35); background: rgba(76, 141, 255, 0.08); }

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.feed li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 5px 0; font-size: 13px; }
.feed time { width: 48px; flex: 0 0 auto; color: var(--text-dim); font-family: var(--mono); font-size: 12px; }
.feed-icon { display: inline-flex; color: var(--text-dim); }
.feed-kill .feed-icon { color: var(--text); }
.feed-bomb { color: var(--text-2); }
.feed-bomb .feed-icon { color: var(--accent); }
.who { font-weight: 500; word-break: break-word; }
.who.t0 { color: #ff8a4c; }
.who.t1 { color: #7eaaff; }
.who.tn { color: var(--text-2); }

/* ── Movement ────────────────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.select {
  height: 34px; padding: 0 30px 0 12px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23999' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text); border: 1px solid var(--border-strong); border-radius: 10px;
  font: 500 13px var(--font); appearance: none; cursor: pointer;
}
.select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.select-sm { height: 32px; padding-right: 26px; background-position: right 10px center; }

.mv { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 12px; }
/* Cap the square map by viewport height so the playback bar stays on screen. */
.mv-stage { position: relative; overflow: hidden; padding: 0; width: 100%; max-width: calc(100vh - 200px); justify-self: center; }
#mv-canvas { display: block; width: 100%; aspect-ratio: 1; }
.mv-nomap {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  font-size: 12px; color: var(--text-2);
  background: rgba(5, 5, 5, 0.8); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.mv-side { padding: 16px; display: flex; flex-direction: column; gap: 10px; align-self: start; }
.mv-side-title { font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.mv-players { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.mv-player {
  display: grid; grid-template-columns: 10px minmax(0, 1fr); grid-template-areas: "sw name" ". char";
  column-gap: 10px; align-items: center; text-align: left;
  padding: 6px 8px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--text); font: 500 13px var(--font); cursor: pointer;
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease);
}
.mv-player:hover { background: rgba(255, 255, 255, 0.04); }
.mv-player.is-focus { background: rgba(255, 255, 255, 0.07); border-color: var(--border-strong); }
.mv-swatch { grid-area: sw; width: 10px; height: 10px; border-radius: 50%; }
.mv-player-name { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-player-char { grid-area: char; font-size: 11px; font-weight: 400; color: var(--text-dim); }
.mv-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 13px; color: var(--text-2); }
.mv-toggles label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.mv-toggles input { accent-color: var(--accent); }

.mv-controls { margin-top: 12px; display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-radius: 14px; }
.mv-play {
  width: 38px; height: 38px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: #fff; color: #000; cursor: pointer;
  transition: transform 180ms var(--ease), background-color 180ms var(--ease);
}
.mv-play:hover { background: #e8e8e8; }
.mv-play:active { transform: scale(0.94); transition-duration: 90ms; }
.mv-play .icon-pause, .is-playing .mv-play .icon-play { display: none; }
.is-playing .mv-play .icon-pause { display: block; }
.mv-clock { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); min-width: 92px; font-variant-numeric: tabular-nums; }
.mv-seek { flex: 1; min-width: 0; accent-color: var(--accent); cursor: pointer; }

/* ── Technical details ───────────────────────────────────── */
.tech { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 0 20px; }
.tech summary { cursor: pointer; padding: 16px 0; font-size: 13px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0 0 20px; font-size: 13px; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.diag { margin-bottom: 20px; }
.diag-title { font-size: 12px; color: var(--accent); margin-bottom: 6px; }
.diag ul { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 12.5px; }

.footer {
  max-width: 1120px; width: 100%; margin: 0 auto; padding: 24px;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2);
}
.footer-dim { color: var(--text-dim); }

/* ── Small screens ───────────────────────────────────────── */
@media (max-width: 720px) {
  .wrap { padding: 28px 16px 48px; }
  .topbar-inner { padding: 0 16px; }
  .brand-product { display: none; }
  .summary { padding: 22px 20px; }
  .summary-side { align-items: flex-start; }
  .hide-sm { display: none; }
  th.col-player, td.col-player { min-width: 140px; padding-left: 16px; }
  th:not(.col-player) { width: 36px; }
  th:nth-last-child(-n+2) { width: 64px; }
  th, td { padding-left: 6px; padding-right: 6px; }
  /* Score is hidden here, so DMG is the visible last column. */
  th:nth-last-child(2), td:nth-last-child(2) { padding-right: 16px; }
  .dmg-row { grid-template-columns: 1fr auto; grid-template-areas: "who total" "bar bar" "split split" "weapons weapons"; padding: 12px 16px; }
  .dmg-split { padding-left: 0; }
  .dmg-weapons { justify-content: flex-start; }
  .round-block { padding: 12px 16px; }
  .mv { grid-template-columns: 1fr; }
  .mv-players { display: grid; grid-template-columns: 1fr 1fr; }
  .mv-controls { gap: 10px; padding: 8px 10px; }
  .mv-clock { min-width: 0; font-size: 11.5px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
  .spinner { animation-duration: 1.6s !important; }
}
