:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --text: #142033;
  --muted: #5c677d;
  --line: rgba(20, 32, 51, 0.1);
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --danger: #b42318;
  --shadow: 0 24px 64px rgba(19, 31, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.16), transparent 30%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.shell-wide {
  width: min(100% - 32px, 1600px);
}

.page-switch {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.page-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
}

.page-link.is-active {
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.8fr);
  gap: 20px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.hero h1,
.empty-state h2,
.player-header h2,
.section-heading h3 {
  margin: 0;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.02;
  max-width: 12ch;
}

.lede {
  margin: 16px 0 0;
  max-width: 58ch;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.hero-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.hero-table h1 {
  max-width: 16ch;
}

.stat-chip,
.panel,
.metric-card,
.bout-card,
.result-item {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.stat-chip,
.metric-card {
  border-radius: 8px;
  padding: 16px;
}

.stat-chip-label,
.metric-card span,
.search-status,
.section-heading p,
.record-badge small,
.empty-state p,
.bout-meta,
.result-path,
.stats-empty {
  color: var(--muted);
}

.stat-chip strong,
.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.6rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 20px;
}

.panel {
  border-radius: 8px;
  padding: 20px;
}

.search-panel {
  position: sticky;
  top: 20px;
  align-self: start;
}

.search-label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.95rem;
  font-weight: 700;
}

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

.mode-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.mode-button.is-active {
  border-color: rgba(15, 118, 110, 0.45);
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent);
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.table-filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr) minmax(120px, 0.5fr);
  gap: 12px;
  align-items: end;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.filter-field {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 700;
}

.filter-field span {
  color: var(--muted);
}

.filter-field select {
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
}

.filter-field input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
}

#player-search {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

#player-search:focus {
  outline: 2px solid rgba(15, 118, 110, 0.2);
  border-color: var(--accent);
}

#clear-search {
  min-width: 78px;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.search-status {
  margin: 14px 0 10px;
  font-size: 0.92rem;
}

.search-results {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 260px);
  overflow: auto;
  padding-right: 2px;
}

.result-item {
  width: 100%;
  padding: 14px;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
}

.result-item.is-active {
  border-color: rgba(15, 118, 110, 0.45);
  background: rgba(15, 118, 110, 0.08);
}

.result-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-weight: 700;
  color: var(--text);
}

.result-subtitle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.empty-state {
  display: grid;
  place-items: start;
  min-height: 420px;
  align-content: center;
  gap: 8px;
}

.hidden {
  display: none;
}

.player-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.record-badge {
  min-width: 120px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--accent-soft);
  text-align: right;
}

.record-badge span {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
}

.summary-grid,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.player-view,
.event-view {
  min-width: 0;
}

.summary-grid {
  margin: 20px 0 24px;
}

.stats-section,
.bouts-section {
  margin-top: 24px;
}

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

.section-heading p {
  margin: 0;
  font-size: 0.92rem;
}

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.table-controls,
.table-panel {
  padding: 18px 20px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 300px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1480px;
}

.stats-table th,
.stats-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.stats-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7fafc;
}

.table-sort {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.table-sort.is-active {
  color: var(--accent);
}

.table-sort-indicator {
  min-width: 12px;
  text-align: right;
}

.table-player-cell {
  font-weight: 700;
  color: var(--text);
}

.table-number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.metric-card {
  min-height: 104px;
}

.metric-card.compact strong {
  font-size: 1.25rem;
}

.bouts-list {
  display: grid;
  gap: 12px;
}

.bouts-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.bout-card {
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
}

.bout-card.is-active {
  border-color: rgba(15, 118, 110, 0.45);
  background: rgba(15, 118, 110, 0.08);
}

.bout-topline,
.bout-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.bout-topline {
  align-items: start;
}

.bout-title {
  margin: 0;
  font-size: 1rem;
}

.outcome {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.outcome.win {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent);
}

.outcome.loss {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

.outcome.draw {
  background: rgba(120, 113, 108, 0.12);
  color: #57534e;
}

.outcome.no-contest {
  background: rgba(30, 64, 175, 0.10);
  color: #1d4ed8;
}

.bout-meta {
  margin: 10px 0 14px;
  font-size: 0.92rem;
}

.bout-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.bout-stat {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(20, 32, 51, 0.04);
}

.bout-stat span,
.result-path {
  display: block;
  font-size: 0.85rem;
}

.bout-stat strong {
  display: block;
  margin-top: 4px;
}

.bout-stat.dual strong {
  font-size: 0.92rem;
}

.bout-detail {
  position: sticky;
  top: 20px;
  padding: 18px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.bout-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.bout-detail-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 32, 51, 0.03);
}

.bout-detail-card h4 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.bout-detail-stats {
  display: grid;
  gap: 8px;
}

.bout-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(20, 32, 51, 0.08);
  font-size: 0.92rem;
  align-items: start;
}

.bout-detail-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.bout-detail-label {
  color: var(--muted);
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

.bout-detail-row strong {
  min-width: 72px;
  max-width: 48%;
  text-align: right;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

  .search-panel {
    position: static;
  }

  .bouts-layout {
    grid-template-columns: 1fr;
  }

  .bout-detail {
    position: static;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 24px, 1180px);
    padding-top: 20px;
  }

  .hero-meta,
  .filter-grid,
  .summary-grid,
  .stats-grid,
  .bout-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-filter-grid {
    grid-template-columns: 1fr;
  }

  .player-header,
  .section-heading,
  .bout-topline,
  .bout-meta {
    flex-direction: column;
    align-items: start;
  }

  .record-badge {
    width: 100%;
    text-align: left;
  }
}
