:root {
  --bg: #0e1319;
  --panel: #161e28;
  --panel-2: #1c2634;
  --border: #2a3648;
  --text: #e8eef5;
  --muted: #93a1b5;
  --accent: #4da3ff;
  --accent-2: #7fd08a;
  --warn: #f0b429;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.main-nav { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.main-nav a {
  color: var(--muted);
  font-size: 0.95rem;
  padding: 0.65rem 0.55rem; /* finger-sized tap target */
  display: inline-block;
}
.main-nav a.active { color: var(--text); font-weight: 600; }
.search-wrap { position: relative; margin-left: auto; }
#runner-search {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  width: 18rem;
  max-width: 60vw;
  font-size: 0.95rem;
  min-height: 44px;
}
#runner-search::placeholder { color: var(--muted); }
.search-results {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  width: 18rem;
  max-width: 60vw;
  max-height: 18rem;
  overflow-y: auto;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 100;
}
.search-results a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.search-results a:hover { background: rgba(96, 165, 250, 0.14); text-decoration: none; }
.search-results .sr-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results .sr-meta { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.search-loading { padding: 0.6rem 0.75rem; color: var(--muted); font-size: 0.9rem; }

.view { max-width: 1800px; margin: 0 auto; padding: 1.25rem 1.5rem 3rem; }
.view h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }
.view h2 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; }
.subtitle { color: var(--muted); margin: 0 0 1rem; }

.controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin: 1rem 0;
}
.dist-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.dist-tabs.box-row { margin: 0.6rem 0; }
.dist-tabs button, .controls select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.8rem;
  font-size: 0.92rem;
  cursor: pointer;
  min-height: 44px; /* finger-sized tap target */
}
.dist-tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1220;
  font-weight: 600;
}
.controls label { color: var(--muted); font-size: 0.9rem; }
.lb-find-box { display: inline-flex; vertical-align: middle; position: relative; gap: 0.5rem; }
.lb-find-box input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  font-size: 0.92rem;
  min-height: 44px;
  width: 18rem;
  max-width: 60vw;
}
.lb-find-box button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.8rem;
  font-size: 0.92rem;
  cursor: pointer;
  min-height: 44px;
}
.lb-find-box button:hover { border-color: var(--accent); color: var(--accent); }
.lb-suggest {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  max-width: 22rem;
  max-height: 18rem;
  overflow-y: auto;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 50;
}
.lb-suggest-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.lb-suggest-item:last-child { border-bottom: none; }
.lb-suggest-item:hover { background: rgba(96, 165, 250, 0.14); }
.lb-suggest-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-suggest-meta { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.county-tip {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  background: #0b1220;
  color: #ffffff;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.lb-msg { min-height: 1.4em; margin: 0 0 0.5rem; color: var(--muted); font-size: 0.92rem; }
tr.lb-hit td { background: rgba(96, 165, 250, 0.18); }
tr.lb-hit td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 100%;
  -webkit-overflow-scrolling: touch; /* smooth swipe-scroll on iOS */
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; background: var(--panel); }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
td.num, th.num { text-align: right; }
.rank-cell { color: var(--muted); width: 3.5rem; white-space: nowrap; }
.rank-inner { display: inline-flex; align-items: center; gap: 0.35rem; }
.rank-inner .medal { font-size: 1.05rem; line-height: 1; }
.pts-cell { font-weight: 700; color: var(--accent-2); }

.profile-head {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.profile-head-main { min-width: 0; }
.profile-head-side {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-shrink: 0;
}
.profile-prs {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  min-width: 10rem;
}
.pr-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.pr-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.9rem;
  padding: 0.15rem 0;
}
.pr-dist { color: var(--muted); }
.pr-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.profile-trophy {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  padding: 0 1rem;
}
.trophy-icon { line-height: 1; }
.trophy-bronze .trophy-icon { font-size: 3rem; filter: sepia(1) saturate(2.5) hue-rotate(-25deg) brightness(0.95); }
.trophy-silver .trophy-icon { font-size: 4rem; filter: grayscale(1) brightness(1.15); }
.trophy-gold .trophy-icon { font-size: 5rem; }
.trophy-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  margin-top: 0.25rem;
}
.trophy-bronze .trophy-count { color: #cd7f32; }
.trophy-silver .trophy-count { color: #c0c0c0; }
.trophy-gold .trophy-count { color: #ffd700; }
.podium-medal { font-size: 0.95em; margin-right: 0.15rem; }
.profile-head h1 { margin: 0; }
.profile-meta { color: var(--muted); margin-top: 0.3rem; display: flex; gap: 1.25rem; flex-wrap: wrap; }
.profile-meta strong { color: var(--text); }
.profile-filters { display: flex; align-items: center; gap: 0.75rem; margin: 0.5rem 0 0.75rem; flex-wrap: wrap; }
.profile-filters label { color: var(--muted); display: flex; align-items: center; gap: 0.5rem; }
.profile-filters select { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 0.35rem 0.5rem; }
.filter-note { color: var(--muted); font-size: 0.9rem; }

.ext-mark { color: var(--warn); font-weight: 700; }
.footnote { color: var(--muted); font-size: 0.85rem; margin-top: 0.75rem; }

.notice {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--warn);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  font-size: 0.93rem;
}
.notice strong { color: var(--warn); }

.race-list { display: flex; flex-direction: column; gap: 0; }
.race-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem 0.25rem;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.race-row .race-name { font-weight: 600; }
.race-row .race-sub { color: var(--muted); font-size: 0.85rem; }
.no-results { color: var(--muted); font-style: italic; }

.search-input {
  width: 100%;
  max-width: 420px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.55rem 0.8rem;
  font-size: 1rem;
  margin: 0.75rem 0 1rem;
  min-height: 44px;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 1.25rem 1rem 2rem;
}
.site-footer p { max-width: 1100px; margin: 0.4rem auto; }
.meta-note { color: var(--warn); font-size: 0.88rem; }
.footer-small { color: var(--muted); font-size: 0.82rem; }

.loading { color: var(--muted); padding: 2rem 0; text-align: center; }
.error { color: #ff8a8a; padding: 2rem 0; }

.about p { max-width: 70ch; }
.about ul { max-width: 70ch; }
.about li { margin-bottom: 0.5rem; }

@media (max-width: 640px) {
  .header-inner { gap: 0.6rem; }
  .search-wrap { margin-left: 0; width: 100%; }
  #runner-search { width: 100%; }
  .search-results { width: 100%; }
  th, td { padding: 0.55rem 0.5rem; font-size: 0.875rem; } /* keep readable without zoom */
  .view h1 { font-size: 1.3rem; }
  .controls { gap: 0.5rem; }
  .dist-tabs { width: 100%; }
  .dist-tabs button { flex: 1 1 auto; } /* full-width tappable tabs */
  .dist-tabs.box-row { width: 100%; }
  /* Profile header: stack vertically on phones so the 2026 Bests box and
     trophy sit below the name/meta instead of squeezing beside them */
  .profile-head { flex-direction: column; align-items: stretch; }
  .profile-head-side { flex-wrap: wrap; }
  .profile-prs { min-width: 0; flex: 1 1 12rem; }
  .profile-trophy { padding: 0; }
}

/* Wide desktop: let data tables breathe without stretching text */
@media (min-width: 1400px) {
  .view, .header-inner, .site-footer p { max-width: 1720px; }
}

/* ---------------- Counties ---------------- */
.county-picker { display: block; margin: 1rem 0; font-weight: 600; }
.county-picker select { font-size: 1rem; padding: 0.5rem; max-width: 100%; }
.county-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.25rem; }
.county-head .back-link { margin: 0 0 0.25rem; }
.county-head h1 { margin: 0; }
.county-switch { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.9rem; }
.county-switch select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.8rem;
  font-size: 0.92rem;
  cursor: pointer;
  min-height: 44px;
  max-width: 100%;
}
.county-map { max-width: 640px; margin: 1rem auto; }
.county-map svg { width: 100%; height: auto; display: block; }
.county-shape { stroke: #ffffff; stroke-width: 1.2; transition: stroke-width 0.1s; }
.county-shape:hover { stroke: #0d5fd0; stroke-width: 2.5; }
.map-legend { text-align: center; color: #555; font-size: 0.9rem; margin-bottom: 1rem; }
.legend-swatch { display: inline-block; width: 1.6rem; height: 0.8rem; margin: 0 0.3rem;
  vertical-align: middle; border: 1px solid #ccc; }
.medal { font-size: 1rem; line-height: 1; vertical-align: -0.1em; }
.accomp-list .medal { margin-right: 0.3rem; }
.profile-tabs { display: flex; gap: 0.5rem; margin: 1.25rem 0 0; }
.ptab {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px 8px 0 0;
  padding: 0.55rem 1.25rem;
  font-size: 0.95rem;
  cursor: pointer;
  border-bottom: none;
}
.ptab.active { background: var(--panel); color: var(--accent); font-weight: 600; }
.ptab:hover { color: var(--accent); }
.accomp-list { list-style: none; padding: 0; margin: 0.5rem 0 1.5rem; }
.accomp-list li {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.accomp-list li a { font-weight: 500; }
.accomp-scope { color: var(--muted); font-size: 0.85rem; }
#tab-accomp h3 { margin: 1.25rem 0 0.25rem; font-size: 1.1rem; }
#tab-accomp h4 { margin: 1rem 0 0.25rem; font-size: 0.95rem; color: var(--muted); }
.muted { color: var(--muted); }
