:root {
  color-scheme: dark;
  --bg: #050505;
  --surface: #111111;
  --surface-alt: #1a1a1a;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.62);
  --line: rgba(255, 214, 0, 0.22);
  --accent: #ffd600;
  --accent-dark: #ffd600;
  --red: #ff6b6b;
  --red-bg: rgba(183, 53, 53, 0.16);
  --blue: #69a7ff;
  --blue-bg: rgba(37, 94, 168, 0.18);
  --warn: #ffd166;
  --warn-bg: rgba(164, 104, 9, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 10%, rgba(255, 214, 0, 0.055), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

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

button.active {
  border-color: var(--accent);
  background: rgba(255, 214, 0, 0.12);
  color: var(--accent-dark);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(255, 214, 0, 0.45);
  outline-offset: 2px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--text);
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 760;
  letter-spacing: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions,
.topbar-buttons,
.status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-buttons {
  gap: 8px;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  font-weight: 700;
}

.pill.live {
  background: rgba(255, 214, 0, 0.12);
  color: var(--accent-dark);
}

.pill.error {
  background: var(--red-bg);
  color: var(--red);
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  height: calc(100vh - 76px);
  min-height: calc(100vh - 76px);
  transition: grid-template-columns 180ms ease;
}

.sidebar {
  position: relative;
  min-height: 0;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #0b0b0b;
  overflow: hidden;
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 324px;
  overflow-y: auto;
}

.control-group {
  margin-bottom: 16px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 66px;
  gap: 8px;
  min-width: 0;
}

.inline > * {
  min-width: 0;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.summary-panel {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.summary-number {
  font-size: 26px;
  font-weight: 820;
}

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

.summary-meta {
  margin-top: 5px;
}

.content {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 20px 24px 32px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-height: 48px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

.footer-separator {
  color: var(--line);
}

.sidebar-results {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.sidebar-results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.sidebar-results-head h2 {
  margin: 0;
  font-size: 15px;
}

.sidebar-results-head span {
  color: var(--muted);
  font-size: 12px;
}

.team-results {
  display: grid;
  align-content: start;
  flex: 0 0 clamp(320px, calc(100vh - 300px), 680px);
  gap: 7px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.result-item {
  display: grid;
  width: 100%;
  min-height: 78px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.result-item:hover,
.result-item.selected {
  border-color: rgba(255, 214, 0, 0.48);
  background: rgba(255, 214, 0, 0.1);
  color: var(--text);
}

.result-number {
  min-width: 0;
  font-size: 18px;
  font-weight: 820;
  line-height: 1.1;
}

.result-name,
.result-location {
  grid-column: 1 / -1;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-meta {
  align-self: start;
  justify-self: start;
  width: fit-content;
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--surface-alt);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.compact-empty {
  padding: 14px;
}

.section {
  margin-bottom: 28px;
}

.detail-section {
  margin-bottom: 20px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

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

.message-area {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.message {
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.message.error {
  border-color: rgba(255, 107, 107, 0.45);
  background: var(--red-bg);
  color: var(--red);
}

.rankings-overlay[hidden] {
  display: none;
}

.rankings-overlay {
  position: fixed;
  z-index: 20;
  inset: 76px 0 0;
  display: grid;
  align-items: start;
  padding: 20px 24px 24px;
  background: rgb(5 5 5 / 88%);
  backdrop-filter: blur(8px);
}

.rankings-modal {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  max-height: calc(100vh - 120px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgb(0 0 0 / 55%);
}

.overview-modal {
  grid-template-rows: auto minmax(0, 1fr);
}

.overview-panel {
  display: grid;
  align-content: start;
  min-height: 0;
  gap: 14px;
  overflow: auto;
  padding: 14px;
}

.overview-summary {
  margin-bottom: 0;
}

.rankings-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #161616;
}

.rankings-modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.rankings-modal-head span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.ranking-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.ranking-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 78px;
  justify-content: center;
  font-weight: 800;
  white-space: nowrap;
}

.ranking-tabs button span {
  border-radius: 999px;
  padding: 1px 7px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 11px;
}

.ranking-tabs button.active span {
  background: rgba(255, 214, 0, 0.2);
  color: var(--accent-dark);
}

.rankings-panel {
  display: grid;
  min-height: 0;
  gap: 14px;
  overflow: auto;
  padding: 14px;
}

.ranking-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.ranking-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #161616;
}

.ranking-group-head h3 {
  margin: 0;
  font-size: 18px;
}

.ranking-group-head span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.ranking-group-head strong {
  white-space: nowrap;
}

.ranking-table-wrap {
  overflow-x: auto;
  max-height: min(58vh, 560px);
  overflow-y: auto;
}

.ranking-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

.ranking-table th:nth-child(1),
.ranking-table td:nth-child(1),
.ranking-table th:nth-child(4),
.ranking-table td:nth-child(4),
.ranking-table th:nth-child(5),
.ranking-table td:nth-child(5),
.ranking-table th:nth-child(6),
.ranking-table td:nth-child(6) {
  text-align: right;
  white-space: nowrap;
}

.overview-grid,
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.overview-cell,
.category-cell,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.overview-cell {
  padding: 14px;
}

.overview-cell h3 {
  margin: 0 0 12px;
  font-size: 14px;
}

.category-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.category-cell {
  padding: 14px;
}

.category-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.category-head h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 820;
}

.category-head span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.category-head strong {
  font-size: 24px;
  font-weight: 850;
  white-space: nowrap;
}

.country-top3 {
  display: grid;
  gap: 10px;
}

.country-row {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.country-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.country-row strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 760;
  text-align: right;
}

.mini-track {
  height: 9px;
  border-radius: 999px;
  background: var(--surface-alt);
  overflow: hidden;
}

.mini-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-label {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 9px;
  border-radius: 999px;
  background: var(--surface-alt);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.bar-value {
  text-align: right;
  font-weight: 760;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: rgba(255, 214, 0, 0.08);
}

.team-number {
  font-weight: 800;
}

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

.empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
}

.detail-panel {
  padding: 0;
  overflow: hidden;
}

.detail-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: #161616;
}

.detail-hero h3 {
  margin: 0;
  font-size: 42px;
  line-height: 1;
}

.detail-hero p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.detail-kicker {
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.detail-id {
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 16px 16px;
}

.detail-item {
  border-radius: 6px;
  padding: 10px;
  background: var(--surface-alt);
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-item strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.detail-block {
  margin: 0 16px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.detail-block h4 {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.detail-record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.record-line {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.record-line:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.record-line span {
  color: var(--muted);
}

.record-line strong {
  overflow-wrap: anywhere;
  font-weight: 700;
}

.history-strip {
  margin: 0 16px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #161616;
  color: var(--muted);
  font-size: 13px;
}

.history-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-strip strong,
.history-strip span {
  display: block;
}

.history-strip strong {
  color: var(--text);
  font-size: 14px;
}

.history-panel {
  display: grid;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric-tile {
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  background: var(--surface);
}

.metric-tile span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-tile strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: var(--text);
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.latest-event-line {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--surface);
}

.latest-event-line span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.latest-event-line strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.change-list {
  display: grid;
  gap: 6px;
}

.change-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 54px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface);
}

.change-row span,
.change-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.change-row strong {
  color: var(--text);
}

.change-row em {
  font-style: normal;
  font-weight: 800;
  text-align: right;
}

.change-row.up em {
  color: var(--accent-dark);
}

.change-row.down em {
  color: var(--red);
}

.history-records {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.mini-table {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}

.mini-table h5 {
  margin: 0;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
}

.mini-table table {
  width: 100%;
  table-layout: fixed;
  font-size: 12px;
}

.mini-table th:first-child,
.mini-table td:first-child {
  width: 58%;
}

.mini-table th:nth-child(2),
.mini-table td:nth-child(2) {
  width: 24%;
}

.mini-table th:nth-child(3),
.mini-table td:nth-child(3) {
  width: 18%;
}

.mini-table-cols-2 th:first-child,
.mini-table-cols-2 td:first-child {
  width: 76%;
}

.mini-table-cols-2 th:nth-child(2),
.mini-table-cols-2 td:nth-child(2) {
  width: 24%;
}

.mini-table-cols-4 th:first-child,
.mini-table-cols-4 td:first-child {
  width: 52%;
}

.mini-table-cols-4 th:nth-child(n + 2),
.mini-table-cols-4 td:nth-child(n + 2) {
  width: 16%;
}

.mini-table th,
.mini-table td {
  padding: 8px;
}

.mini-table tbody tr {
  cursor: default;
}

.mini-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-empty {
  padding: 10px;
}

@media (max-width: 920px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .layout,
  .overview-grid,
  .category-grid,
  .detail-grid,
  .detail-record-grid,
  .metric-grid,
  .history-records {
    grid-template-columns: 1fr;
  }

  .layout {
    height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  .sidebar-content {
    height: auto;
    min-width: 0;
    overflow: visible;
  }

  .content {
    padding: 16px;
  }

  .topbar-actions {
    align-items: flex-start;
    flex-direction: column;
    width: 100%;
  }

  .topbar-buttons {
    flex-wrap: wrap;
  }

  .rankings-overlay {
    inset: 128px 0 0;
    padding: 12px;
  }

  .rankings-modal {
    max-height: calc(100vh - 140px);
  }

  .bar-row {
    grid-template-columns: 110px minmax(0, 1fr) 44px;
  }

  .team-results {
    flex: none;
    max-height: none;
    overflow: visible;
  }

  .detail-hero {
    flex-direction: column;
  }

  .history-strip,
  .history-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .latest-event-line {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .detail-hero h3 {
    font-size: 34px;
  }

  .record-line:nth-last-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .record-line:last-child {
    border-bottom: 0;
  }
}
