:root {
  --ink: #17130f;
  --paper: #f8f1e6;
  --paper-strong: #fffaf0;
  --clay: #b44825;
  --clay-dark: #743119;
  --moss: #31563f;
  --mint: #c8e4d3;
  --sky: #93c1c2;
  --sun: #f2c84b;
  --line: rgba(23, 19, 15, 0.16);
  --muted: rgba(23, 19, 15, 0.62);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(23, 19, 15, 0.48), rgba(23, 19, 15, 0.78)),
    url("./assets/track-hero.png") center top / cover fixed;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    radial-gradient(circle at 22% 10%, rgba(242, 200, 75, 0.24), transparent 30%),
    linear-gradient(90deg, rgba(49, 86, 63, 0.18), rgba(180, 72, 37, 0.14));
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

.site-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  color: var(--paper-strong);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border: 2px solid rgba(255, 250, 240, 0.82);
  border-radius: 8px;
  background: rgba(23, 19, 15, 0.36);
  font-weight: 900;
}

.brand-copy {
  display: grid;
  min-width: 0;
  line-height: 1.1;
}

.brand-copy strong,
.brand-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy strong {
  font-size: clamp(0.98rem, 2vw, 1.22rem);
}

.brand-copy small {
  color: rgba(255, 250, 240, 0.74);
  font-size: 0.78rem;
}

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

.nav-button,
.action-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  gap: 8px;
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease;
}

.nav-button {
  border: 1px solid rgba(255, 250, 240, 0.36);
  padding: 0 16px;
  color: var(--paper-strong);
  background: rgba(23, 19, 15, 0.38);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
}

.nav-button-secondary {
  color: var(--ink);
  border-color: rgba(242, 200, 75, 0.6);
  background: var(--sun);
}

.nav-button:hover,
.action-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
  transform: none;
}

.nav-button.is-active {
  color: var(--ink);
  border-color: var(--paper-strong);
  background: var(--paper-strong);
}

#view {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(26px, 5vw, 54px) 0 64px;
}

.hero-board {
  display: grid;
  min-height: calc(100vh - 102px);
  align-items: center;
}

.board-panel,
.form-panel {
  width: 100%;
  border: 1px solid rgba(255, 250, 240, 0.5);
  border-radius: 8px;
  background: rgba(248, 241, 230, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.board-panel {
  overflow: hidden;
}

.board-header,
.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(22px, 4vw, 34px);
  border-bottom: 1px solid var(--line);
}

.page-header {
  align-items: center;
  padding-left: 0;
  padding-right: 0;
  color: var(--paper-strong);
  border-bottom: 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--clay-dark);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.page-header .eyebrow {
  color: var(--sun);
}

h1,
h2 {
  margin: 0;
  line-height: 0.96;
}

h1 {
  max-width: 740px;
  font-size: clamp(3rem, 9vw, 7.6rem);
  text-transform: uppercase;
}

.page-header h1 {
  font-size: clamp(2.4rem, 8vw, 5.8rem);
}

.board-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(86px, 1fr));
  gap: 10px;
  min-width: 210px;
}

.board-controls {
  display: grid;
  min-width: 250px;
  gap: 10px;
}

.mode-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: rgba(255, 250, 240, 0.7);
}

.mode-button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 900;
}

.mode-button.is-active {
  color: var(--ink);
  background: var(--sun);
  box-shadow: 0 8px 18px rgba(116, 49, 25, 0.16);
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 250, 240, 0.78);
}

.metric strong {
  display: block;
  font-size: clamp(1.35rem, 3vw, 2.25rem);
  line-height: 1;
}

.metric span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.leaderboard-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

.detailed-table {
  min-width: 860px;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 17px clamp(16px, 3vw, 28px);
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

.leaderboard-table th {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.leaderboard-table tbody tr {
  background: rgba(255, 250, 240, 0.22);
}

.leaderboard-table tbody tr:nth-child(2n) {
  background: rgba(147, 193, 194, 0.16);
}

.leaderboard-table tbody tr:hover {
  background: rgba(200, 228, 211, 0.48);
}

.rank {
  width: 74px;
  color: var(--clay-dark);
  font-weight: 950;
}

.name-cell {
  font-size: clamp(1.04rem, 2vw, 1.32rem);
  font-weight: 900;
}

.time-cell {
  color: var(--clay-dark);
  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: clamp(1.08rem, 2.3vw, 1.58rem);
  font-weight: 900;
}

.date-cell {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 850;
  white-space: nowrap;
}

.bike-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 34px;
  border: 1px solid rgba(49, 86, 63, 0.28);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--moss);
  background: rgba(200, 228, 211, 0.7);
  font-size: 0.9rem;
  font-weight: 800;
}

.filters {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(170px, 240px) minmax(150px, 190px);
  gap: 12px;
  width: min(100%, 770px);
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: inherit;
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 250, 240, 0.32);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.94);
  outline: 0;
}

.board-panel .field input,
.board-panel .field select,
.form-panel .field input,
.form-panel .field select {
  border-color: var(--line);
}

.field input:focus,
.field select:focus {
  border-color: var(--sun);
  box-shadow: 0 0 0 3px rgba(242, 200, 75, 0.28);
}

.detail-grid {
  display: grid;
  gap: 20px;
}

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

.split-list span {
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--ink);
  background: rgba(147, 193, 194, 0.28);
  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 0.86rem;
  font-weight: 800;
}

.empty-state {
  padding: 26px;
  color: var(--muted);
  font-weight: 800;
}

.form-panel {
  max-width: 760px;
  padding: clamp(22px, 4vw, 34px);
}

.manual-panel {
  margin-top: 4px;
}

.manual-heading {
  margin-bottom: 18px;
}

.manual-heading h2 {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  text-transform: uppercase;
}

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

.form-grid .field-wide {
  grid-column: 1 / -1;
}

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

.timer-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(240px, 330px);
  gap: 18px;
  align-items: stretch;
  margin-top: 24px;
}

.timer-face {
  display: grid;
  align-content: center;
  min-height: 178px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(18px, 4vw, 28px);
  background:
    linear-gradient(135deg, rgba(49, 86, 63, 0.16), rgba(180, 72, 37, 0.12)),
    rgba(255, 250, 240, 0.78);
}

.timer-face span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.timer-face output {
  display: block;
  color: var(--clay-dark);
  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: clamp(2.4rem, 5vw, 3.55rem);
  font-weight: 950;
  line-height: 1;
}

.timer-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.timer-controls button {
  min-height: 84px;
}

.stop-button {
  color: var(--paper-strong);
  border-color: rgba(116, 49, 25, 0.4);
  background: var(--clay-dark);
}

.split-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.split-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 250, 240, 0.58);
}

.split-card.is-filled {
  border-color: rgba(49, 86, 63, 0.34);
  background: rgba(200, 228, 211, 0.58);
}

.split-card span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.split-card strong {
  color: var(--clay-dark);
  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: clamp(1.35rem, 3vw, 2.15rem);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 20px;
}

.action-button,
.ghost-button {
  border: 0;
  padding: 0 18px;
}

.action-button {
  color: var(--ink);
  background: var(--sun);
  box-shadow: 0 12px 24px rgba(116, 49, 25, 0.22);
}

.ghost-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 250, 240, 0.72);
}

.status {
  min-height: 22px;
  color: var(--moss);
  font-weight: 850;
}

.timer-status-row {
  margin-top: 14px;
}

.record-alert-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.record-alert-list[hidden] {
  display: none;
}

.record-alert {
  display: grid;
  gap: 5px;
  border: 1px solid rgba(49, 86, 63, 0.34);
  border-left: 6px solid var(--moss);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(200, 228, 211, 0.76);
  box-shadow: 0 12px 28px rgba(23, 19, 15, 0.13);
}

.record-alert-track {
  border-color: rgba(180, 72, 37, 0.36);
  border-left-color: var(--clay);
  background: rgba(242, 200, 75, 0.26);
}

.record-alert-bike {
  border-color: rgba(147, 193, 194, 0.58);
  border-left-color: var(--sky);
  background: rgba(147, 193, 194, 0.25);
}

.record-alert span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.record-alert strong {
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.05;
}

.record-alert p {
  margin: 0;
  color: var(--clay-dark);
  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 0.94rem;
  font-weight: 900;
}

.recent-list {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.recent-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 250, 240, 0.58);
}

.recent-row strong {
  display: block;
}

.recent-row span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.recent-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.delete-log-button {
  min-height: 34px;
  border: 1px solid rgba(180, 72, 37, 0.38);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--clay-dark);
  background: rgba(255, 250, 240, 0.8);
  font-size: 0.84rem;
  font-weight: 900;
  cursor: pointer;
}

.delete-log-button:hover {
  border-color: rgba(180, 72, 37, 0.7);
  background: rgba(242, 200, 75, 0.28);
}

@media (max-width: 760px) {
  body {
    background-attachment: scroll;
    background-position: center top;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    width: min(100% - 20px, 420px);
    padding: 10px 0;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .brand-copy strong {
    font-size: 1rem;
  }

  .brand-copy small {
    font-size: 0.72rem;
  }

  .nav-actions {
    width: 100%;
    gap: 8px;
  }

  .nav-button {
    flex: 1 1 0;
    min-height: 50px;
    padding-left: 10px;
    padding-right: 10px;
    font-size: 0.96rem;
  }

  #view {
    width: min(100% - 20px, 420px);
    padding: 10px 0 42px;
  }

  .hero-board {
    min-height: auto;
    align-items: start;
  }

  .board-panel,
  .form-panel {
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.26);
  }

  .form-panel {
    padding: 14px;
  }

  .board-header,
  .page-header {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .board-header {
    padding: 18px;
  }

  .page-header {
    padding-top: 8px;
    padding-bottom: 0;
  }

  .page-header .eyebrow {
    margin-bottom: 6px;
  }

  .board-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
  }

  .board-controls {
    min-width: 0;
    width: 100%;
  }

  .mode-button {
    min-height: 42px;
  }

  .filters,
  .form-grid,
  .timer-panel {
    grid-template-columns: 1fr;
  }

  .field {
    gap: 6px;
  }

  .field input,
  .field select {
    min-height: 50px;
    padding: 0 13px;
    font-size: 16px;
  }

  .timer-panel {
    gap: 12px;
    margin-top: 16px;
  }

  .timer-face {
    min-height: 128px;
    padding: 16px;
  }

  .timer-face output {
    font-size: clamp(2.65rem, 14vw, 3.3rem);
  }

  .timer-controls {
    gap: 8px;
  }

  .timer-controls button {
    min-height: 62px;
    font-size: 1rem;
  }

  .split-board,
  .split-inputs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .split-card {
    min-height: 78px;
    padding: 10px 8px;
  }

  .split-card strong {
    font-size: 1.03rem;
  }

  .split-inputs input {
    min-width: 0;
    padding-left: 8px;
    padding-right: 8px;
    text-align: center;
  }

  .form-actions,
  .recent-row {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .recent-row-actions {
    justify-content: space-between;
  }

  .delete-log-button {
    min-width: 88px;
  }

  .leaderboard-table,
  .detailed-table,
  .all-time-table {
    display: block;
    min-width: 0;
  }

  .leaderboard-table thead {
    display: none;
  }

  .leaderboard-table tbody {
    display: grid;
    gap: 10px;
    padding: 10px;
  }

  .leaderboard-table tr {
    display: grid;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: rgba(255, 250, 240, 0.62);
  }

  .leaderboard-table tbody tr:nth-child(2n) {
    background: rgba(200, 228, 211, 0.46);
  }

  .leaderboard-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 0;
    padding: 0;
    text-align: right;
  }

  .leaderboard-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 950;
    text-align: left;
    text-transform: uppercase;
  }

  .leaderboard-table td:not([data-label]) {
    display: block;
    text-align: left;
  }

  .leaderboard-table td:not([data-label])::before {
    content: none;
  }

  .leaderboard-table .name-cell {
    align-items: start;
    flex-direction: column;
    gap: 3px;
    text-align: left;
  }

  .leaderboard-table .name-cell,
  .leaderboard-table .time-cell {
    font-size: 1.02rem;
  }

  .leaderboard-table .date-cell {
    font-size: 0.84rem;
    white-space: normal;
  }

  .leaderboard-table .bike-pill {
    min-height: 30px;
    padding: 5px 7px;
    overflow-wrap: anywhere;
    font-size: 0.8rem;
    line-height: 1.15;
    text-align: left;
  }

  h1,
  .page-header h1 {
    font-size: clamp(2.35rem, 12vw, 3.2rem);
  }

  .page-header h1 {
    font-size: clamp(2rem, 10vw, 2.75rem);
  }
}

@media (max-width: 380px) {
  .topbar {
    gap: 8px;
    padding: 8px 0;
  }

  .brand-copy strong {
    font-size: 0.92rem;
  }

  .nav-button {
    min-height: 44px;
    font-size: 0.9rem;
  }

  #view {
    padding-top: 8px;
  }

  .page-header h1 {
    font-size: 1.9rem;
  }

  .page-header .eyebrow {
    font-size: 0.68rem;
  }

  .form-panel {
    padding: 12px;
  }

  .form-grid {
    gap: 10px;
  }

  .field input,
  .field select {
    min-height: 46px;
  }

  .timer-panel {
    margin-top: 12px;
  }

  .timer-face {
    min-height: 112px;
    padding: 14px;
  }

  .timer-face output {
    font-size: 2.55rem;
  }

  .timer-controls button {
    min-height: 56px;
  }

  .split-card {
    min-height: 70px;
    padding: 8px 6px;
  }

  .split-card strong {
    font-size: 0.95rem;
  }
}
