:root {
  color-scheme: light;
  --black: #000000;
  --orange: #ea5b24;
  --olive: #3e4934;
  --graphite: #3c3c3b;
  --white: #ffffff;
  --paper: #f6f6f3;
  --line: #d8d8d3;
  --orange-soft: #fce7de;
  --green-soft: #e6ebdf;
  --danger: #9f2f20;
  font-family: "Arimo", Arial, sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--black);
  background: var(--paper);
  font-family: "Arimo", Arial, sans-serif;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 {
  margin-bottom: 0;
  font-family: "Golos UI", "Arial Narrow", Arial, sans-serif;
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 0.94;
}
h1 { font-size: clamp(1.15rem, 2.15vw, 2rem); }
h2 { font-size: clamp(1.4rem, 2.2vw, 2rem); }
h3 { font-size: 1rem; text-transform: uppercase; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem clamp(1rem, 4vw, 4rem);
  background: var(--white);
  border-bottom: 3px solid var(--black);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-row { display: flex; align-items: center; gap: clamp(1rem, 3vw, 3rem); min-width: 0; }
.brand-logo { display: block; width: clamp(150px, 16vw, 220px); height: auto; flex: 0 0 auto; }
.header-copy { padding-left: clamp(1rem, 2vw, 2rem); border-left: 1px solid var(--black); min-width: 0; }
.eyebrow {
  margin-bottom: 0.35rem;
  color: var(--orange);
  font-family: "Golos UI", "Arial Narrow", Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: -0.015em;
  font-weight: 600;
  font-size: 0.72rem;
}

.page-shell { width: min(1540px, 100%); margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 4rem) 4rem; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-bottom: 1rem; background: var(--black); border: 1px solid var(--black); }
.stat-card { min-height: 8rem; padding: 1.1rem 1.25rem; display: flex; flex-direction: column; background: var(--white); }
.stat-card span { color: var(--graphite); font-size: 0.75rem; text-transform: uppercase; font-weight: 700; }
.stat-card strong { margin-top: auto; font-family: "Golos UI", "Arial Narrow", Arial, sans-serif; font-size: 2.2rem; letter-spacing: -0.05em; line-height: 1; }
.stat-card .stat-name { font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-card small { margin-top: 0.25rem; color: var(--graphite); }
.stat-card-accent { background: var(--orange); }
.stat-card-accent span, .stat-card-accent small { color: var(--black); }
.stat-card-dark { color: var(--white); background: var(--black); }
.stat-card-dark span, .stat-card-dark small { color: var(--white); }

.panel { margin-bottom: 1rem; padding: 1.4rem; background: var(--white); border: 1px solid var(--black); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.panel-heading-wrap { flex-wrap: wrap; }
.section-note { margin: 0.55rem 0 0; color: var(--graphite); font-size: 0.8rem; }
.mobile-result-entry { display: none; }

.leaderboard-panel { display: grid; grid-template-columns: minmax(190px, 0.32fr) minmax(0, 1fr); gap: 1.5rem; background: var(--olive); color: var(--white); }
.leaderboard-panel .eyebrow { color: var(--white); }
.leaderboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: rgba(255, 255, 255, 0.45); }
.leaderboard-card { padding: 1rem; background: var(--olive); }
.leaderboard-card h3 { padding-bottom: 0.7rem; border-bottom: 1px solid rgba(255,255,255,0.55); }
.leaderboard-card ol { margin: 0.5rem 0 0; padding-left: 1.7rem; }
.leaderboard-card li { min-height: 2.25rem; padding: 0.5rem 0; border-bottom: 1px solid rgba(255,255,255,0.25); }
.leaderboard-card li:last-child { border-bottom: 0; }
.leaderboard-card li::marker { color: var(--orange); font-weight: 700; }
.leaderboard-card li span { display: inline-block; width: calc(100% - 6.8rem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.leaderboard-card li strong { float: right; font-size: 0.82rem; }

.stack-form { display: grid; gap: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
label { display: grid; gap: 0.42rem; font-weight: 700; font-size: 0.78rem; text-transform: uppercase; }
input, select {
  width: 100%;
  min-height: 2.6rem;
  border: 1px solid var(--graphite);
  border-radius: 0;
  padding: 0.65rem 0.72rem;
  color: var(--black);
  background: var(--white);
  font: inherit;
  outline: none;
}
input:focus, select:focus { border-color: var(--orange); box-shadow: inset 4px 0 0 var(--orange); }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  border: 1px solid var(--black);
  border-radius: 0;
  background: var(--white);
  color: var(--black);
  padding: 0.62rem 1rem;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { color: var(--white); background: var(--black); }
.button-primary { color: var(--black); background: var(--orange); border-color: var(--black); }
.button-primary:hover { color: var(--white); background: var(--black); }
.button-quiet { background: transparent; min-height: 2.25rem; }
.button-small { min-height: 2.15rem; padding: 0.42rem 0.62rem; font-size: 0.74rem; }
.button-danger { color: var(--danger); border-color: var(--danger); }
.button-danger:hover { color: var(--white); background: var(--danger); border-color: var(--danger); }
.text-link { color: var(--orange); font-size: 0.8rem; font-weight: 700; }

.participant-picker { display: block; position: relative; width: 100%; text-transform: none; }
.participant-suggestions {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 18rem;
  overflow-y: auto;
  color: var(--black);
  background: var(--white);
  border: 1px solid var(--black);
}
.participant-option, .suggestion-message {
  display: block;
  width: 100%;
  padding: 0.75rem;
  color: var(--black);
  background: var(--white);
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font: inherit;
  font-size: 0.82rem;
}
.participant-option { cursor: pointer; }
.participant-option:hover, .participant-option:focus { color: var(--white); background: var(--olive); outline: 0; }
.suggestion-message { color: var(--graphite); }

.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th, td { padding: 0.72rem 0.62rem; border-bottom: 1px solid var(--line); text-align: left; font-size: 0.82rem; vertical-align: middle; }
th { color: var(--graphite); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; }
tbody tr:last-child td { border-bottom: 0; }
.editable-table th:first-child, .editable-table td:first-child { width: 37%; }
.editable-table th:nth-child(2), .editable-table td:nth-child(2) { width: 16%; }
.editable-table th:nth-child(3), .editable-table td:nth-child(3) { width: 12%; }
.editable-table input, .editable-table select { min-height: 2.25rem; padding: 0.45rem 0.55rem; font-size: 0.8rem; }
.new-result-row { background: var(--orange-soft); border-bottom: 2px solid var(--orange); }
.new-result-row td { padding-top: 0.85rem; padding-bottom: 0.85rem; }
.actions-cell { display: flex; justify-content: flex-end; gap: 0.35rem; white-space: nowrap; }
.legacy-label { display: block; margin-top: 0.2rem; color: var(--danger); font-size: 0.68rem; }
.empty-cell, .empty-state { color: var(--graphite); text-align: center; padding: 2rem; }
.empty-state { border: 1px dashed var(--graphite); }
.muted { color: var(--graphite); }

.filter-tabs { display: flex; gap: 0; border: 1px solid var(--black); }
.filter-tabs a { padding: 0.55rem 0.78rem; color: var(--black); border-right: 1px solid var(--black); text-decoration: none; font-size: 0.76rem; font-weight: 700; }
.filter-tabs a:last-child { border-right: 0; }
.filter-tabs a.active { color: var(--white); background: var(--black); }
.search-input { width: min(430px, 100%); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.pagination a { color: var(--orange); font-weight: 700; }
.pagination span { color: var(--graphite); font-size: 0.8rem; }
.mobile-results { display: none; }

.flash { margin-bottom: 1rem; padding: 0.8rem 1rem; border: 1px solid var(--black); font-weight: 700; }
.flash-success { background: var(--green-soft); }
.flash-error { color: var(--danger); background: #fbe9e7; border-color: var(--danger); }

.login-page { display: grid; place-items: center; padding: 1rem; background: var(--orange); }
.login-card { width: min(460px, 100%); padding: 2.2rem; background: var(--white); border: 2px solid var(--black); }
.login-logo { width: min(280px, 82%); margin-bottom: 2.8rem; }
.login-card h1 { margin-bottom: 0.7rem; font-size: 2rem; }
.login-card .muted { margin-bottom: 1.5rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 1080px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .leaderboard-panel { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .topbar { position: static; align-items: flex-start; padding: 0.9rem 1rem; }
  .brand-row { display: block; }
  .brand-logo { width: 145px; }
  .header-copy { margin-top: 0.75rem; padding: 0; border-left: 0; }
  .header-copy .eyebrow { display: none; }
  .topbar h1 { max-width: 14rem; font-size: 1.15rem; }
  .topbar .button { min-height: 2rem; padding: 0.42rem 0.62rem; font-size: 0.72rem; }
  .page-shell { padding: 1rem 0.75rem 3rem; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card { min-height: 6.7rem; padding: 0.85rem; }
  .stat-card strong { font-size: 1.65rem; }
  .stat-card .stat-name { font-size: 0.96rem; }
  .panel { padding: 1rem; }
  .mobile-result-entry { display: block; border-top: 8px solid var(--orange); }
  .form-row, .leaderboard-grid { grid-template-columns: 1fr; }
  .leaderboard-panel { display: block; }
  .leaderboard-panel .panel-heading { margin-bottom: 1rem; }
  .desktop-results { display: none; }
  .mobile-results { display: grid; gap: 1px; background: var(--line); }
  .mobile-result-card { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.85rem; background: var(--white); }
  .mobile-result-card strong, .mobile-result-card span { display: block; }
  .mobile-result-card span { margin-top: 0.2rem; color: var(--graphite); font-size: 0.76rem; }
  .mobile-result-actions { display: flex; gap: 0.3rem; }
  .mobile-result-actions .button { padding: 0.38rem 0.48rem; }
  .filter-tabs { width: 100%; }
  .filter-tabs a { flex: 1; text-align: center; }
  .participants-panel table { min-width: 660px; }
  .pagination { justify-content: space-between; }
}

@media (max-width: 430px) {
  .mobile-result-card { align-items: flex-start; flex-direction: column; }
  .mobile-result-actions { width: 100%; }
  .mobile-result-actions .button { flex: 1; }
}
