.neo-table-live,
.neo-table-results,
.neo-table-starters,
.neo-table-lap {
  table-layout: auto;
}

.neo-table-live th,
.neo-table-live td,
.neo-table-results th,
.neo-table-results td,
.neo-table-starters th,
.neo-table-starters td,
.neo-table-lap th,
.neo-table-lap td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.neo-table-live th:nth-child(2),
.neo-table-live td:nth-child(2),
.neo-table-results th:nth-child(3),
.neo-table-results td:nth-child(3),
.neo-table-starters th:nth-child(2),
.neo-table-starters td:nth-child(2),
.neo-table-lap th:nth-child(3),
.neo-table-lap td:nth-child(3) {
  width: 38%;
}

.neo-table-live th:nth-child(2),
.neo-table-live td:nth-child(2),
.neo-table-results th:nth-child(3),
.neo-table-results td:nth-child(3),
.neo-table-starters th:nth-child(2),
.neo-table-starters td:nth-child(2),
.neo-table-lap th:nth-child(3),
.neo-table-lap td:nth-child(3) {
  white-space: nowrap;
}

.neo-table-live td:nth-child(2) a,
.neo-table-results td:nth-child(3) a,
.neo-table-lap td:nth-child(3) a,
.neo-table-starters td:nth-child(2) a {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.neo-table-live th:nth-child(6),
.neo-table-live td:nth-child(6),
.neo-table-results th:nth-child(6),
.neo-table-results td:nth-child(6),
.neo-table-lap th:nth-child(5),
.neo-table-lap td:nth-child(5),
.neo-table-splits th:nth-child(3),
.neo-table-splits td:nth-child(3) {
  min-width: 9ch;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  font-variant-numeric: tabular-nums;
}

.neo-table-live th:nth-child(4),
.neo-table-live td:nth-child(4),
.neo-table-live th:nth-child(5),
.neo-table-live td:nth-child(5),
.neo-table-results th:nth-child(1),
.neo-table-results td:nth-child(1),
.neo-table-results th:nth-child(5),
.neo-table-results td:nth-child(5),
.neo-table-starters th:nth-child(3),
.neo-table-starters td:nth-child(3),
.neo-table-starters th:nth-child(4),
.neo-table-starters td:nth-child(4),
.neo-table-starters th:nth-child(6),
.neo-table-starters td:nth-child(6),
.neo-table-lap th:nth-child(1),
.neo-table-lap td:nth-child(1),
.neo-table-lap th:nth-child(6),
.neo-table-lap td:nth-child(6),
.neo-table-lap th:nth-child(7),
.neo-table-lap td:nth-child(7),
.neo-table-lap th:nth-child(8),
.neo-table-lap td:nth-child(8),
.neo-table-lap th:nth-child(9),
.neo-table-lap td:nth-child(9),
.neo-table-splits th:nth-child(4),
.neo-table-splits td:nth-child(4),
.neo-table-splits th:nth-child(5),
.neo-table-splits td:nth-child(5),
.neo-table-splits th:nth-child(6),
.neo-table-splits td:nth-child(6) {
  display: none;
}

@media (min-width: 720px) {
  .neo-table-live th:nth-child(4),
  .neo-table-live td:nth-child(4),
  .neo-table-live th:nth-child(5),
  .neo-table-live td:nth-child(5),
  .neo-table-results th:nth-child(1),
  .neo-table-results td:nth-child(1),
  .neo-table-results th:nth-child(5),
  .neo-table-results td:nth-child(5),
  .neo-table-starters th:nth-child(3),
  .neo-table-starters td:nth-child(3),
  .neo-table-starters th:nth-child(4),
  .neo-table-starters td:nth-child(4),
  .neo-table-starters th:nth-child(6),
  .neo-table-starters td:nth-child(6),
  .neo-table-lap th:nth-child(1),
  .neo-table-lap td:nth-child(1),
  .neo-table-lap th:nth-child(6),
  .neo-table-lap td:nth-child(6),
  .neo-table-lap th:nth-child(7),
  .neo-table-lap td:nth-child(7),
  .neo-table-splits th:nth-child(4),
  .neo-table-splits td:nth-child(4),
  .neo-table-splits th:nth-child(5),
  .neo-table-splits td:nth-child(5) {
    display: table-cell;
  }
}

@media (min-width: 960px) {
  .neo-table-lap th:nth-child(8),
  .neo-table-lap td:nth-child(8),
  .neo-table-lap th:nth-child(9),
  .neo-table-lap td:nth-child(9),
  .neo-table-splits th:nth-child(6),
  .neo-table-splits td:nth-child(6) {
    display: table-cell;
  }
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.search-form {
  width: 100%;
}

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

.search-control input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-background);
  color: var(--ink);
  font: inherit;
}

.search-control button,
.watch button {
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  cursor: pointer;
}

#searchButton {
  width: 48px;
  min-width: 48px;
  height: 48px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#searchButton svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-results,
.watchlist {
  display: grid;
  gap: 12px;
}

.watch {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--soft-surface-background);
}

.watch-meta {
  color: var(--secondary-ink);
  margin: 4px 0 10px;
}

.watch-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.watch-actions a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

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

.stat {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--soft-surface-background);
}

.stat-label {
  color: var(--secondary-ink);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-value {
  margin-top: 6px;
  font-size: 1.35rem;
  font-weight: 700;
}

.stat-value.rank-value {
  text-align: center;
}

.flags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.route-panel[hidden] {
  display: none;
}

.athlete-route-map {
  min-height: 420px;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 34%),
    linear-gradient(180deg, color-mix(in srgb, var(--panel) 94%, white) 0%, color-mix(in srgb, var(--panel) 82%, #dbeafe) 100%);
}

.athlete-route-map .leaflet-control-attribution {
  font-size: 10px;
  line-height: 1.2;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.82);
  color: rgba(15, 23, 42, 0.62);
  border-top-left-radius: 8px;
}

.athlete-route-map .leaflet-control-attribution a {
  color: inherit;
}

.athlete-route-note {
  margin-bottom: 14px;
}

.athlete-elevation-panel[hidden] {
  display: none;
}

.athlete-elevation-panel {
  margin-top: 12px;
}

.athlete-elevation-meta {
  margin-bottom: 8px;
}

.athlete-elevation-chart {
  width: 100%;
  height: auto;
  min-height: 150px;
  aspect-ratio: 1000 / 220;
  display: block;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--soft-surface-background);
}

.flag {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.share-panel[hidden] {
  display: none;
}

.share-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.share-panel-head .note {
  margin-top: 6px;
}

.share-button,
.share-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.share-download[hidden] {
  display: none;
}

.share-button[disabled] {
  opacity: 0.6;
  cursor: wait;
}

.share-card-wrap {
  display: flex;
  justify-content: center;
}

.share-card {
  position: relative;
  overflow: hidden;
  width: min(100%, 380px);
  aspect-ratio: 9 / 16;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.12);
}

.share-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--share-card-background-image, url("/ukultra-share-bg.png"));
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center var(--share-background-position-y, 34%);
  opacity: var(--share-background-opacity, 0.28);
  pointer-events: none;
}

.share-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgb(255 255 255 / var(--share-overlay-opacity, 0.58));
  pointer-events: none;
}

.share-card-top {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.share-event {
  color: var(--secondary-ink);
  font-size: 0.95rem;
  line-height: 1.45;
}

.share-athlete {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.share-athlete strong {
  font-size: 1.25rem;
}

.share-athlete span {
  color: var(--secondary-ink);
}

.share-time-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-time-label {
  color: var(--secondary-ink);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.share-time {
  font-size: clamp(2.6rem, 11vw, 4.2rem);
  line-height: 0.95;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.share-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.share-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.share-card-footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-ranks {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.share-rank {
  padding: 12px 10px;
  border-radius: 16px;
  background: var(--soft-surface-background);
  border: 1px solid var(--line);
  text-align: center;
}

.share-rank-label {
  color: var(--secondary-ink);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.share-rank-value {
  margin-top: 6px;
  font-size: 1.2rem;
  font-weight: 800;
}

.share-footer-note {
  color: var(--secondary-ink);
  font-size: 0.88rem;
}

.share-footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.share-footer-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: 0 0 auto;
}

.share-status {
  min-height: 1.2em;
  margin-top: 12px;
}

.leaflet-control-attribution {
  display: none;
}

@media (min-width: 840px) {
  .layout {
    grid-template-columns: 0.95fr 1.05fr;
  }

  .hero-grid {
    grid-template-columns: 1.1fr 0.9fr;
  }

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

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

@media (max-width: 840px) {
  .share-button,
  .share-download {
    width: 100%;
  }
}

@media (max-width: 760px) {
  body.neo-page {
    font-size: 17px;
  }

  .neo-page td {
    font-size: 1rem;
    line-height: 1.45;
  }

  .neo-page th {
    font-size: 0.76rem;
    letter-spacing: 0.11em;
  }

  .neo-page .meta,
  .neo-page .note {
    font-size: 0.98rem;
  }
}

@media (max-width: 860px), (hover: none) and (pointer: coarse) {
  html,
  body {
    overflow-x: hidden;
  }

  body.neo-page {
    font-size: 18px;
  }

  .neo-page main > *:not(#topbar) {
    margin-left: 0;
    margin-right: 0;
  }

  .neo-page .masthead,
  .neo-page .panel {
    padding-left: 14px;
    padding-right: 14px;
  }

  .neo-page .masthead:not(.neo-hero) h1 {
    font-size: clamp(2.7rem, 10.8vw, 4.4rem);
    line-height: 0.96;
  }

  .neo-page .panel h2 {
    font-size: 1.2rem;
  }

  .neo-page .meta,
  .neo-page .note {
    font-size: 1.05rem;
    line-height: 1.5;
  }

  .neo-page .public-filter {
    max-width: 100%;
    gap: 12px;
    padding: 12px 14px;
    font-size: 0.94rem;
  }

  .neo-page .public-filter select {
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    padding: 11px 12px;
    font-size: 0.98rem;
  }

  .neo-page .masthead-row > * {
    min-width: 0;
  }

  .neo-page .panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .neo-table-live td,
  .neo-table-splits td {
    font-size: 1.06rem;
    line-height: 1.48;
  }

  .neo-table-live th,
  .neo-table-splits th {
    font-size: 0.82rem;
    letter-spacing: 0.09em;
  }

  #athleteCard {
    font-size: 1.06rem;
    line-height: 1.5;
  }

  #athleteCard strong {
    font-size: 1.28rem;
    line-height: 1.2;
  }

  #athleteCard .meta {
    font-size: 0.99rem;
    line-height: 1.45;
  }

  .stats .stat {
    padding: 16px;
  }

  .stats .stat-label {
    font-size: 0.9rem;
  }

  .stats .stat-value {
    font-size: 1.6rem;
  }
}

@media (max-width: 420px) {
  body.neo-page {
    font-size: 18px;
  }

  .neo-page .masthead,
  .neo-page .panel {
    padding-left: 12px;
    padding-right: 12px;
  }

  .neo-page .meta,
  .neo-page .note,
  #athleteCard {
    font-size: 1rem;
    line-height: 1.48;
  }

  .neo-page .panel h2 {
    font-size: 1.16rem;
  }

  .neo-page .public-filter,
  .neo-page .public-filter select {
    font-size: 0.94rem;
  }

  .neo-table-live td,
  .neo-table-splits td {
    font-size: 0.98rem;
    line-height: 1.4;
  }

  .neo-table-live th,
  .neo-table-splits th {
    font-size: 0.74rem;
    letter-spacing: 0.08em;
  }

  .neo-table-live th,
  .neo-table-live td {
    padding: 10px 6px;
  }

  .neo-table-live th:nth-child(2),
  .neo-table-live td:nth-child(2) {
    width: 34%;
  }

  .neo-table-live th:nth-child(6),
  .neo-table-live td:nth-child(6) {
    min-width: 8ch;
  }

  .stats .stat-label {
    font-size: 0.86rem;
  }

  .stats .stat-value {
    font-size: 1.5rem;
  }
}
