:root {
  --paper: #f3eee5;
  --paper-strong: #fffaf2;
  --ink: #1a1f24;
  --ink-soft: #5e6770;
  --track: #2a3139;
  --accent: #d65f21;
  --accent-deep: #a13a08;
  --success: #1b6f49;
  --warning: #9b6200;
  --danger: #b13b1b;
  --line: rgba(26, 31, 36, 0.11);
  --line-strong: rgba(26, 31, 36, 0.22);
  --shadow: 0 24px 80px rgba(21, 25, 29, 0.12);
  --posw: 60px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(214, 95, 33, 0.18), transparent 28rem),
    radial-gradient(circle at top right, rgba(27, 111, 73, 0.12), transparent 18rem),
    linear-gradient(180deg, #ece4d7 0%, var(--paper) 42%, #efe7d8 100%);
}

.shell {
  width: min(1440px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

.topbar,
.hero,
.grid {
  margin-bottom: 1rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.topbar h1,
.hero h2,
.section-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.05;
}

.topbar h1 {
  font-size: clamp(2.3rem, 4.8vw, 4rem);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.subline,
.hint,
.updated-pill,
.display-toolbar-status,
.display-toggle,
.row-subtle {
  color: var(--ink-soft);
}

.subline {
  margin: 0.45rem 0 0;
  font-size: 1rem;
}

.event-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
}

.event-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(42, 49, 57, 0.08);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
}

.event-chip-muted {
  background: rgba(214, 95, 33, 0.11);
  color: var(--accent-deep);
}

.updated-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 700;
}

.summary-card,
.panel {
  background: rgba(255, 250, 242, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.summary-card {
  padding: 1rem 1rem 1.05rem;
  border-radius: 1.5rem;
}

.summary-card .small-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.summary-card strong {
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  line-height: 1;
}

.summary-card p {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.notice {
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(214, 95, 33, 0.24);
  border-radius: 1rem;
  background: rgba(255, 247, 241, 0.98);
  color: var(--accent-deep);
  font-size: 0.92rem;
  line-height: 1.45;
}

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

.panel {
  border-radius: 1.75rem;
  padding: 1rem 1.05rem 1.15rem;
}

.panel-wide {
  grid-column: span 12;
}

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

.section-heading h2 {
  font-size: 1.7rem;
}

.bar {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
}

.display-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  background: rgba(42, 49, 57, 0.05);
  font-size: 0.88rem;
  font-weight: 600;
}

.display-toggle input {
  width: auto;
}

button,
select,
input {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  padding: 0.8rem 0.95rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.96rem;
}

input {
  width: 150px;
}

button {
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.seg {
  display: inline-flex;
  border: 1px solid rgba(42, 49, 57, 0.12);
  border-radius: 999px;
  background: rgba(42, 49, 57, 0.07);
  overflow: hidden;
}

.seg button {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding-inline: 1rem;
}

.seg button.active {
  background: linear-gradient(135deg, var(--track), #3c4650);
  color: white;
}

.class-wrap {
  min-width: 190px;
}

.class-wrap select {
  width: 100%;
}

.hint {
  margin: 0 0 0.95rem;
  font-size: 0.92rem;
  line-height: 1.5;
}

.display-toolbar-status {
  font-size: 0.85rem;
}

.display-podium,
.recent-run-list,
.display-officer-comparison {
  display: grid;
  gap: 0.8rem;
}

.display-podium {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
}

.podium-card,
.recent-run-card,
.officer-card {
  border-radius: 1.2rem;
  border: 1px solid rgba(42, 49, 57, 0.08);
}

.recent-run-card.is-empty,
.podium-card.is-empty {
  background: rgba(42, 49, 57, 0.05);
}

.recent-run-card.is-empty strong {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 1rem;
}

.recent-run-card.is-empty p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.45;
}

.podium-card {
  min-height: 12.5rem;
  padding: 1rem 0.95rem 1rem;
  display: grid;
  gap: 0.8rem;
  background: rgba(255, 255, 255, 0.76);
}

.podium-card.is-gold {
  background: linear-gradient(180deg, rgba(245, 213, 89, 0.36), rgba(255, 255, 255, 0.82));
  transform: translateY(-0.9rem);
}

.podium-card.is-silver {
  background: linear-gradient(180deg, rgba(183, 191, 202, 0.34), rgba(255, 255, 255, 0.82));
}

.podium-card.is-bronze {
  background: linear-gradient(180deg, rgba(189, 121, 75, 0.32), rgba(255, 255, 255, 0.82));
}

.podium-medal {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.podium-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 1.1rem;
}

.podium-medal-label,
.small-label,
.recent-run-meta,
.recent-run-number {
  font-size: 0.74rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.podium-copy {
  display: grid;
  gap: 0.28rem;
}

.podium-rank {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.podium-copy strong {
  font-size: 1.1rem;
}

.podium-copy p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.4;
}

.podium-time {
  margin-top: 0.25rem;
  font-size: 1.4rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.recent-run-list {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.recent-run-card,
.officer-card {
  padding: 0.95rem 1rem;
  background: rgba(42, 49, 57, 0.05);
}

.recent-run-card {
  display: grid;
  gap: 0.45rem;
}

.recent-run-topline,
.recent-run-bottomline,
.recent-run-tags {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: center;
  flex-wrap: wrap;
}

.recent-run-card strong {
  font-size: 1rem;
}

.recent-run-card p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.4;
}

.recent-run-time,
.recent-run-result {
  font-variant-numeric: tabular-nums;
}

.recent-run-time {
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.recent-run-result {
  font-size: 1.15rem;
  font-weight: 900;
}

.run-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: rgba(42, 49, 57, 0.08);
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.run-tag-warn {
  background: rgba(155, 98, 0, 0.14);
  color: var(--warning);
}

.display-officer-comparison {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.officer-card {
  padding: 0.95rem 1rem;
}

.officer-card h3 {
  margin: 0 0 0.25rem;
  font-size: 1.02rem;
}

.officer-card p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.45;
}

.officer-card strong {
  color: var(--accent-deep);
}

.table-shell {
  position: relative;
  border: 1px solid rgba(42, 49, 57, 0.1);
  border-radius: 1.3rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.7);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.fade-left,
.fade-right {
  pointer-events: none;
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18px;
  z-index: 6;
  opacity: 0;
  transition: opacity 160ms ease;
}

.fade-left {
  left: 0;
  background: linear-gradient(to right, rgba(255, 250, 242, 1), rgba(255, 250, 242, 0));
}

.fade-right {
  right: 0;
  background: linear-gradient(to left, rgba(255, 250, 242, 1), rgba(255, 250, 242, 0));
}

.table-shell.can-left .fade-left {
  opacity: 1;
}

.table-shell.can-right .fade-right {
  opacity: 1;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  padding: 0.85rem 0.8rem;
  text-align: center;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(243, 238, 229, 0.92);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.36);
}

tbody tr:hover td {
  background: rgba(214, 95, 33, 0.06);
}

td.pos,
th.pos,
td.best,
th.best {
  font-weight: 900;
}

td.best,
th.best,
td.run,
th.run {
  font-variant-numeric: tabular-nums;
}

th.pos,
td.pos {
  position: sticky;
  left: 0;
  background: inherit;
}

th.num,
td.num {
  position: sticky;
  left: var(--posw);
  background: inherit;
}

td.pos,
td.num {
  z-index: 4;
}

th.num {
  z-index: 7;
}

th.pos {
  z-index: 8;
}

th.pos,
td.pos,
th.num,
td.num {
  background: rgba(255, 250, 242, 0.84);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
}

th.pos,
th.num {
  background: rgba(243, 238, 229, 0.95);
}

.empty-row td {
  padding: 1.5rem 1rem;
  color: var(--ink-soft);
}

.class-header td {
  background: rgba(42, 49, 57, 0.08);
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 1080px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .recent-run-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100%, calc(100% - 1rem));
    padding-top: 1rem;
    padding-bottom: 6.5rem;
  }

  .topbar {
    flex-direction: column;
    gap: 0.55rem;
  }

  .display-status-stack {
    width: 100%;
  }

  .updated-pill {
    width: 100%;
    justify-content: flex-start;
    min-height: 2.15rem;
    padding: 0.55rem 0.8rem;
    font-size: 0.84rem;
  }

  .hero {
    gap: 0.7rem;
  }

  .event-badge-row {
    gap: 0.45rem;
  }

  .panel {
    padding: 0.9rem 0.85rem 1rem;
  }

  .section-heading {
    display: grid;
    gap: 0.35rem;
    align-items: start;
    margin-bottom: 0.7rem;
  }

  .section-heading h2 {
    font-size: 1.16rem;
  }

  .display-controls-panel {
    position: sticky;
    top: 0.55rem;
    z-index: 30;
    backdrop-filter: blur(18px);
    padding: 0.75rem;
  }

  .display-controls-panel .section-heading {
    display: none;
  }

  .bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }

  .seg,
  .class-wrap,
  .display-toggle,
  input {
    width: 100%;
  }

  .seg {
    grid-column: 1 / -1;
  }

  .seg button {
    flex: 1;
  }

  .class-wrap,
  .display-toggle {
    grid-column: 1 / -1;
  }

  #numberSearch {
    grid-column: 1 / -1;
  }

  #btnRefresh {
    position: fixed;
    right: 0.8rem;
    bottom: max(0.8rem, env(safe-area-inset-bottom));
    z-index: 45;
    width: auto;
    min-width: 7.5rem;
    padding-inline: 1.15rem;
    border-color: rgba(214, 95, 33, 0.42);
    background: linear-gradient(135deg, var(--accent), #ef8a2b);
    color: white;
    box-shadow: 0 18px 42px rgba(161, 58, 8, 0.28);
  }

  .display-officer-comparison {
    grid-template-columns: 1fr;
  }

  .display-podium,
  .recent-run-list {
    grid-template-columns: 1fr;
  }

  .podium-card.is-gold {
    transform: none;
  }

  .officer-card {
    padding: 0.85rem 0.9rem;
  }

  .table-shell {
    border-radius: 1rem;
  }

  th,
  td {
    padding: 0.75rem 0.7rem;
  }
}

@media (max-width: 520px) {
  .topbar h1 {
    font-size: clamp(1.75rem, 9vw, 2.45rem);
  }

  .subline,
  .hint {
    font-size: 0.84rem;
  }

  .eyebrow {
    margin-bottom: 0.2rem;
    font-size: 0.66rem;
  }

  .event-chip {
    padding: 0.36rem 0.65rem;
    font-size: 0.76rem;
  }

  .display-toggle {
    align-items: flex-start;
    border-radius: 1rem;
  }
}
