:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f7f8fa;
  --surface-strong: #eef2f8;
  --text: #17191d;
  --muted: #68707c;
  --border: #d9dee7;
  --border-strong: #b6bfcc;
  --accent: #2357d9;
  --accent-soft: #edf2ff;
  --pro: #177a4c;
  --pro-soft: #e8f6ef;
  --con: #bd4437;
  --con-soft: #fff0ed;
  --tie: #765c16;
  --tie-soft: #fff7db;
  --radius: 6px;
  --ui-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --reading-font: Charter, "Bitstream Charter", "Iowan Old Style", Georgia, serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--ui-font);
  font-size: 14px;
  line-height: 1.5;
}

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

button,
a,
input,
select {
  outline-offset: 2px;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) auto auto;
  align-items: center;
  gap: 28px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-strong);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand img {
  width: 40px;
  height: 40px;
  object-fit: cover;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
  font-weight: 720;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.site-header nav {
  display: flex;
  gap: 18px;
  font-size: 13px;
}

.ledger-status {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.filters {
  min-height: 62px;
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) minmax(140px, 0.7fr) minmax(150px, 0.8fr) auto minmax(150px, 0.8fr) 36px;
  align-items: end;
  gap: 10px;
  padding: 10px 24px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.filters label {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.filters label > span,
.winner-filter legend {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.filters input,
.filters select {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 13px;
}

.search-control {
  position: relative;
}

.search-control svg {
  position: absolute;
  left: 10px;
  bottom: 9px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
}

.search-control input {
  padding-left: 34px;
}

.winner-filter {
  min-width: 196px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 0;
  margin: 0;
  border: 0;
}

.winner-filter legend {
  margin-bottom: 4px;
}

.winner-filter button {
  height: 34px;
  border: 1px solid var(--border-strong);
  border-right: 0;
  background: var(--bg);
  font-size: 12px;
  cursor: pointer;
}

.winner-filter button:first-of-type {
  border-radius: var(--radius) 0 0 var(--radius);
}

.winner-filter button:last-of-type {
  border-right: 1px solid var(--border-strong);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.winner-filter button.active {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.icon-button {
  width: 36px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.workspace {
  height: calc(100vh - 135px);
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(380px, 42%) minmax(0, 58%);
}

.match-browser,
.match-detail {
  min-width: 0;
  overflow: auto;
}

.match-browser {
  border-right: 1px solid var(--border-strong);
}

.pane-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
}

.pane-heading h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 750;
  text-transform: uppercase;
}

.pane-heading span {
  color: var(--muted);
  font-size: 12px;
}

.match-row {
  width: 100%;
  display: grid;
  gap: 7px;
  padding: 14px 18px 15px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
}

.match-row:hover {
  background: var(--surface);
}

.match-row.selected {
  box-shadow: inset 3px 0 0 var(--accent);
  background: var(--accent-soft);
}

.match-row-top,
.match-row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.match-row time,
.match-row-meta {
  color: var(--muted);
  font-size: 11px;
}

.match-row h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 680;
}

.match-row-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.winner-label {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.winner-label.pro {
  color: var(--pro);
  background: var(--pro-soft);
}

.winner-label.con {
  color: var(--con);
  background: var(--con-soft);
}

.winner-label.tie {
  color: var(--tie);
  background: var(--tie-soft);
}

.detail-loading,
.empty-state {
  min-height: 320px;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 40px;
  color: var(--muted);
  text-align: center;
}

.empty-state h3,
.empty-state p {
  margin: 0;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px 20px;
}

.match-id {
  margin: 0 0 7px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.detail-header h2 {
  max-width: 840px;
  margin: 0;
  font-size: clamp(21px, 2.2vw, 31px);
  line-height: 1.18;
  font-weight: 740;
}

.metadata-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.source-link {
  flex: 0 0 auto;
  font-size: 12px;
}

.sides-row {
  display: grid;
  grid-template-columns: 1fr minmax(140px, 0.55fr) 1fr;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.side,
.verdict {
  min-height: 84px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 14px 24px;
}

.side span,
.verdict span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 820;
}

.side strong,
.verdict strong {
  font-size: 15px;
}

.side small,
.verdict small {
  color: var(--muted);
  font-size: 11px;
}

.side.pro {
  box-shadow: inset 3px 0 0 var(--pro);
  background: var(--pro-soft);
}

.side.con {
  box-shadow: inset -3px 0 0 var(--con);
  background: var(--con-soft);
  text-align: right;
}

.verdict {
  justify-items: center;
  text-align: center;
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.detail-nav {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  min-height: 47px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border-strong);
}

.detail-nav button {
  align-self: stretch;
  padding: 0 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-size: 12px;
  font-weight: 680;
  cursor: pointer;
}

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

.detail-nav a {
  margin-left: auto;
  font-size: 12px;
}

#detail-panel {
  padding: 2px 28px 60px;
}

.turn {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 20px;
  padding: 24px 0 26px;
  border-bottom: 1px solid var(--border);
}

.turn-label {
  display: grid;
  align-content: start;
  gap: 4px;
}

.turn-label strong {
  font-size: 11px;
}

.turn.pro .turn-label strong {
  color: var(--pro);
}

.turn.con .turn-label strong {
  color: var(--con);
}

.turn-label span,
.turn-label small {
  color: var(--muted);
  font-size: 10px;
}

.turn-body {
  font-family: var(--reading-font);
  font-size: 16px;
  line-height: 1.72;
}

.turn-body p {
  margin: 0 0 13px;
}

.score-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}

.score-summary > div {
  display: grid;
  gap: 3px;
  padding: 19px 18px;
  border-right: 1px solid var(--border);
}

.score-summary > div:last-child {
  border-right: 0;
}

.score-summary span {
  color: var(--muted);
  font-size: 11px;
}

.score-summary strong {
  font-size: 21px;
}

.judge-section {
  padding: 22px 0 24px;
  border-bottom: 1px solid var(--border);
}

.judge-section h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.judge-section p {
  margin: 6px 0;
}

.judge-section dl {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 7px 18px;
  margin: 16px 0 0;
}

.judge-section dt {
  color: var(--muted);
  font-size: 12px;
}

.judge-section dd {
  margin: 0;
  font-size: 13px;
}

.error-state {
  margin: 28px 0;
  padding: 18px;
  color: var(--con);
  background: var(--con-soft);
  border-left: 3px solid var(--con);
}

@media (max-width: 1080px) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .site-header nav {
    display: none;
  }

  .filters {
    grid-template-columns: 1.5fr repeat(2, minmax(130px, 0.7fr)) auto 36px;
  }

  .winner-filter {
    display: none;
  }

  .workspace {
    grid-template-columns: minmax(330px, 40%) minmax(0, 60%);
  }
}

@media (max-width: 760px) {
  .site-header {
    min-height: 64px;
    padding: 9px 14px;
  }

  .brand p,
  .ledger-status {
    display: none;
  }

  .filters {
    grid-template-columns: 1fr 1fr 36px;
    padding: 9px 12px;
  }

  .filters label:nth-of-type(3),
  .filters label:nth-of-type(4) {
    display: none;
  }

  .workspace {
    height: auto;
    min-height: 0;
    display: block;
  }

  .match-browser,
  .match-detail {
    overflow: visible;
  }

  .match-browser {
    max-height: 48vh;
    overflow: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border-strong);
  }

  .detail-header {
    padding: 20px 16px 16px;
  }

  .source-link {
    display: none;
  }

  .sides-row {
    grid-template-columns: 1fr 1fr;
  }

  .verdict {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 62px;
    border: 0;
    border-top: 1px solid var(--border);
  }

  .detail-nav {
    padding: 0 8px;
    overflow-x: auto;
  }

  .detail-nav button {
    padding: 0 10px;
  }

  #detail-panel {
    padding: 2px 16px 40px;
  }

  .turn {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 12px;
  }

  .turn-body {
    font-size: 15px;
  }
}
