/*
 * Page layouts: home hero, WRs page, run page, player profile and error page.
 * See docs/design.md.
 */

/*
 * ── Home hero ────────────────────────────────────────────────────────────────
 * The one showpiece of the site: god rays, glow, temple, floating emblem, a shimmering gold
 * title and an entrance animation. Its effects stay scoped to .hero; the rest is flat.
 */
.hero {
  --hero-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
  isolation: isolate;
  margin: -1.5rem calc(50% - 50vw) 3.5rem;
  padding: clamp(3.5rem, 9vw, 7rem) 1rem clamp(3rem, 7vw, 5.5rem);
  overflow: hidden;
  text-align: center;
}

/* Decorative layers, faded out at the bottom so they melt into the page */
.hero-fx {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
}

.hero-rays {
  position: absolute;
  top: -55%;
  left: 50%;
  width: min(1500px, 200vw);
  aspect-ratio: 1;
  translate: -50% 0;
  background: repeating-conic-gradient(from 0deg, rgba(242, 201, 76, 0.11) 0deg 2.5deg, transparent 2.5deg 11deg);
  mask: radial-gradient(closest-side, #000 0%, rgba(0, 0, 0, 0.55) 35%, transparent 72%);
  animation: rays-spin 160s linear infinite;
}

.hero-glow {
  position: absolute;
  top: 8%;
  left: 50%;
  width: min(900px, 120vw);
  height: 420px;
  translate: -50% 0;
  background: radial-gradient(closest-side, rgba(242, 201, 76, 0.22), rgba(255, 122, 26, 0.08) 55%, transparent);
  filter: blur(10px);
}

.hero-temple {
  position: absolute;
  bottom: 2%;
  left: 50%;
  width: min(820px, 96vw);
  aspect-ratio: 600 / 320;
  translate: -50% 0;
  background: linear-gradient(180deg, #fff1bf, #b8862f);
  mask: url("/assets/img/temple.svg") center / contain no-repeat;
  opacity: 0.075;
}

.hero-emblem {
  display: block;
  width: clamp(5.5rem, 12vw, 8rem);
  height: auto;
  margin: 0 auto 1.5rem;
  filter: drop-shadow(0 0 30px rgba(242, 201, 76, 0.45));
  animation: hero-in 1s var(--hero-ease) both, float 6s ease-in-out 1s infinite;
}

.hero-title {
  margin: 0 0 1.25rem;
  font-family: var(--cs-font-display);
  font-size: clamp(2.6rem, 9vw, 6.4rem);
  font-weight: 900;
  line-height: 0.98;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  animation: hero-in 1.1s var(--hero-ease) 0.2s both;
}

.hero-title-crash {
  display: block;
  color: #fff;
  text-shadow: 0 0 50px rgba(255, 255, 255, 0.18);
}

.hero-title-gold {
  display: block;
  background: linear-gradient(110deg, #c08a2c 0%, #f2c94c 18%, #fff6d6 26%, #f2c94c 34%, #c08a2c 50%, #f2c94c 68%, #fff6d6 76%, #f2c94c 84%, #c08a2c 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 30px rgba(242, 201, 76, 0.3));
  animation: shimmer 7s linear infinite;
}

.hero-tagline {
  max-width: 36rem;
  margin: 0 auto 2.25rem;
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  color: var(--cs-muted);
  animation: hero-in 1.1s var(--hero-ease) 0.35s both;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  animation: hero-in 1.1s var(--hero-ease) 0.5s both;
}

.hero-actions .btn {
  --bs-btn-padding-x: 1.4rem;
  --bs-btn-padding-y: 0.7rem;
  --bs-btn-font-size: 1.02rem;
  --bs-btn-border-radius: 0.8rem;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.2s ease, transform 0.2s var(--hero-ease);
}

.hero-actions .btn-gold {
  --bs-btn-border-color: transparent;
  --bs-btn-hover-border-color: transparent;
  --bs-btn-active-border-color: transparent;
  background: linear-gradient(135deg, #fff1bf 0%, #f2c94c 38%, #c08a2c 72%, #f7d982 100%);
  box-shadow: 0 8px 24px -10px rgba(242, 201, 76, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.hero-actions .btn-gold:hover,
.hero-actions .btn-gold:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px -10px rgba(242, 201, 76, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.hero-actions .btn-ghost {
  backdrop-filter: blur(6px);
}

.hero-actions .btn-ghost:hover {
  transform: translateY(-1px);
}

.hero-games {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2.5rem;
  animation: hero-in 1.1s var(--hero-ease) 0.65s both;
}

.hero-games .chip {
  color: var(--cs-text);
  backdrop-filter: blur(6px);
}

.hero-games .chip:hover {
  border-color: color-mix(in srgb, var(--cs-accent) 60%, transparent);
  color: #fff;
}

.hero-games .game-dot {
  box-shadow: 0 0 10px color-mix(in srgb, var(--cs-accent) 45%, transparent);
}

@keyframes rays-spin {
  to { rotate: 360deg; }
}

@keyframes hero-in {
  from {
    opacity: 0;
    translate: 0 1.25rem;
    filter: blur(6px);
  }

  to {
    opacity: 1;
    translate: 0 0;
    filter: blur(0);
  }
}

@keyframes float {
  0%,
  100% { translate: 0 0; }
  50% { translate: 0 -8px; }
}

@keyframes shimmer {
  to { background-position: -200% center; }
}

@media (forced-colors: active) {
  .hero-title-gold {
    background: none;
    color: CanvasText;
    -webkit-text-fill-color: CanvasText;
  }
}

.home-section {
  margin-bottom: 3rem;
}

/* ── WRs page: one section per game, the record cards come from components.css ── */
.records-filters, .players-filters { margin-bottom: 2rem; }

/* Player picker: a select-looking toggle opening a searchable list of the holders */
.player-picker-toggle {
  display: flex;
  align-items: center;
  min-height: calc(1.5em + 0.75rem + 2px);
  text-align: start;
}
.player-picker-toggle.has-value { border-color: color-mix(in srgb, var(--cs-accent) 55%, var(--cs-border-strong)); }
.player-picker-current,
.player-picker-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.player-picker-current .bi,
.player-picker-option .bi { color: var(--cs-muted); }
.player-picker-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-picker-menu {
  width: max(100%, 18rem);
  padding: 0;
  overflow: hidden;
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.45);
}
.player-picker-search {
  position: relative;
  padding: 0.5rem;
  border-bottom: 1px solid var(--cs-border);
}
.player-picker-search .bi {
  position: absolute;
  top: 50%;
  left: 1.1rem;
  transform: translateY(-50%);
  color: var(--cs-faint);
  pointer-events: none;
}
.player-picker-search .form-control { padding-left: 2rem; }
.player-picker-list {
  max-height: 18rem;
  overflow-y: auto;
  padding: 0.25rem;
  overscroll-behavior: contain;
}
.player-picker-option {
  border-radius: var(--cs-radius-sm);
  padding: 0.4rem 0.6rem;
}
.player-picker-option[hidden] { display: none; }
.player-picker-option.active {
  background: color-mix(in srgb, var(--cs-accent) 22%, transparent);
  color: var(--cs-text);
}
.player-picker-count {
  margin-left: auto;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--cs-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.player-picker-option.active .player-picker-count { color: var(--cs-text); }
.player-picker-empty {
  margin: 0;
  padding: 0.75rem 1rem;
  color: var(--cs-muted);
  font-size: 0.875rem;
}
.records-game .section-title a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--cs-text);
  text-decoration: none;
}

.records-game .section-title a:hover {
  color: var(--game-accent, var(--cs-text));
}

.rules {
  color: var(--cs-muted);
}

.rules a {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.rules p:last-child,
.rules ul:last-child {
  margin-bottom: 0;
}

/* ── Run page ─────────────────────────────────────────────────────────────── */
.run-hero {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--cs-border);
}

.run-time {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem 1rem;
  margin: 0.4rem 0 0.6rem;
  font-family: var(--cs-font-mono);
  font-size: clamp(2.4rem, 7vw, 4.25rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  color: #fff;
}

.run-time-method {
  font-family: var(--cs-font-body);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cs-muted);
}

.run-by {
  font-size: 1.05rem;
  color: var(--cs-muted);
}

.run-badges {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
}

.run-badges .badge {
  font-size: 0.85rem;
}

.theater {
  overflow: hidden;
  border-radius: var(--cs-radius-lg);
  border: 1px solid var(--cs-border);
  background: #000;
}

.video-frame {
  display: block;
  aspect-ratio: 16 / 9;
  width: 100%;
  border: 0;
}

.video-links {
  margin: 0.9rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
  word-break: break-all;
}

.video-links .bi {
  margin-right: 0.35rem;
  color: var(--cs-muted);
}

.spec-list {
  margin: 0;
}

.spec-list > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--cs-border);
}

.spec-list > div:last-child {
  border-bottom: 0;
}

.spec-list dt {
  font-weight: 500;
  color: var(--cs-muted);
}

.spec-list dd {
  margin: 0;
  text-align: right;
}

/* ── Player profile ───────────────────────────────────────────────────────── */
.player-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem 1.75rem;
  margin-bottom: 2.5rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  border-radius: var(--cs-radius-lg);
  border: 1px solid var(--cs-border);
  background: var(--cs-surface);
}

.crest {
  display: grid;
  place-items: center;
  flex: none;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  border: 1px solid var(--cs-border-strong);
  background: var(--cs-surface-3);
  color: var(--cs-text);
  font-size: 1.9rem;
  font-weight: 700;
}

.player-name {
  margin: 0 0 0.35rem;
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  font-weight: 800;
}

.player-name .flag {
  font-size: 0.6em;
  vertical-align: 0.2em;
  margin-right: 0.6rem;
}

.player-sub {
  color: var(--cs-muted);
}

/* PB tables carry every run field: one line per cell, scrolled sideways when too wide */
.pb-filters { margin-bottom: 1rem; }
/* Each game folds away (<details>): name, speedrun / IL counts and a chevron */
.pb-game {
  border-bottom: 1px solid var(--cs-border);
}
.pb-game:first-of-type { border-top: 1px solid var(--cs-border); }
.pb-game[open] { padding-bottom: 1.5rem; }
.pb-game-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.85rem 0.25rem;
  cursor: pointer;
  list-style: none;
}
.pb-game-summary::-webkit-details-marker { display: none; }
.pb-game-summary:hover .pb-game-title { color: var(--cs-accent); }
.pb-game-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}
.pb-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.pb-count {
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--cs-border);
  border-radius: 999px;
  background: var(--cs-surface-2);
  color: var(--cs-muted);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.pb-count-value {
  font-family: var(--cs-font-mono);
  font-weight: 800;
  color: var(--cs-text);
}
.pb-game-chevron {
  color: var(--cs-muted);
  transition: transform 0.15s ease;
}
.pb-game[open] .pb-game-chevron { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) {
  .pb-game-chevron { transition: none; }
}
/* Inside a game: full-game speedruns, then individual levels */
.pb-block-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0 0.25rem;
  color: var(--cs-text);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pb-block-title::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--cs-border);
}
.pb-block:first-of-type .pb-block-title { margin-top: 0.25rem; }
.pb-category-title {
  margin: 1rem 0 0.5rem;
  color: var(--cs-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pb-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  min-height: 2.4rem;
}
.pb-toggles .form-check { margin: 0; }
.pb-table th, .pb-table td { white-space: nowrap; }
.pb-table td.pb-comment {
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Featured runs (partials/featured-run.tpl): up to three cards on top of the profile */
.featured-runs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: 1rem;
}
.featured-run {
  --tone: var(--cs-accent);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
  padding: 1.1rem 1.25rem 1rem;
  border-radius: var(--cs-radius-lg);
  border: 1px solid var(--cs-border);
  border-top: 3px solid var(--tone);
  background: var(--cs-surface);
}
.featured-run-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.featured-run-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.featured-run-values { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.featured-run-time {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--cs-text);
  text-decoration: none;
}
.featured-run-description {
  margin: 0;
  color: var(--cs-muted);
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.featured-run-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  margin-top: auto;
  color: var(--cs-faint);
  font-size: 0.85rem;
}
/* Above the card's stretched link */
.featured-run-video { position: relative; z-index: 2; margin-left: auto; }

/* Edit profile (pages/profile/*): sections in a sidebar, one form each */
.profile-settings {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  align-items: start;
  gap: 1.5rem;
}
.profile-settings-nav .bi { margin-right: 0.4rem; }
@media (max-width: 767.98px) {
  .profile-settings { grid-template-columns: minmax(0, 1fr); }
}

/* The custom game order only matters with "Custom" picked */
.profile-order:has(input[name="sort"][value="custom"]:not(:checked)) .custom-order { display: none; }
.custom-order-help { margin: 0; padding: 0 1rem 0.75rem; }
.sortable-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--cs-border);
}
.sortable-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--cs-border);
  background: var(--cs-surface);
}
.sortable-handle {
  color: var(--cs-faint);
  font-size: 1.15rem;
  cursor: grab;
  /* Touch drags the item instead of scrolling the page */
  touch-action: none;
}
.sortable-label { flex: 1; min-width: 0; }
.sortable-actions { display: flex; gap: 0.25rem; }
.sortable-list.is-sorting { user-select: none; }
.sortable-list.is-sorting .sortable-handle { cursor: grabbing; }
.sortable-item.is-dragging {
  position: relative;
  z-index: 1;
  background: var(--cs-surface-3);
  box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.4);
}

/* Search box over the featured run <select> (run-picker.js) */
.run-picker-box { position: relative; }
.run-picker-box .form-control { padding-right: 2.25rem; }
.run-picker-clear {
  position: absolute;
  top: 50%;
  right: 0.75rem;
  width: 0.6rem;
  height: 0.6rem;
  transform: translateY(-50%);
}
.run-picker-list {
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 20rem;
  margin-top: 0.25rem;
  overflow-y: auto;
}
.run-picker-list .dropdown-item {
  white-space: normal;
  cursor: pointer;
}
.run-picker-note {
  padding: 0.35rem 1rem;
  color: var(--cs-muted);
  font-size: 0.85rem;
}

/* Multiple select with a search box (admin forms, multi-select.js): chips, then the search input */
.multi-select {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-height: calc(1.5em + 0.75rem + 2px);
  cursor: text;
}
.multi-select:focus-within {
  border-color: var(--cs-border-strong);
  box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.08);
}
.multi-select-chips { display: contents; margin: 0; padding: 0; list-style: none; }
.multi-select-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.15rem 0.5rem 0.15rem 0.65rem;
  border: 1px solid var(--cs-border-strong);
  border-radius: 999px;
  background: var(--cs-surface-3);
  font-size: 0.85rem;
}
.multi-select-chip .btn-close { width: 0.5rem; height: 0.5rem; padding: 0.15rem; }
.multi-select-input {
  flex: 1 0 8rem;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
}
.multi-select-list {
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 16rem;
  margin-top: 0.25rem;
  overflow-y: auto;
}
.multi-select-list .dropdown-item { cursor: pointer; }
.multi-select-note {
  padding: 0.35rem 1rem;
  color: var(--cs-muted);
  font-size: 0.85rem;
}

.featured-slots { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--cs-border); }
.featured-slot {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--cs-border);
}
.featured-slot-number {
  padding-top: 2rem;
  text-align: right;
  color: var(--cs-muted);
  font-size: 1.1rem;
}

.stat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-left: auto;
}

.stat-chip {
  min-width: 6.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--cs-radius);
  border: 1px solid var(--cs-border);
  background: rgba(255, 255, 255, 0.03);
  text-align: center;
}

.stat-chip-value {
  display: block;
  font-family: var(--cs-font-mono);
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
  color: #fff;
}

.stat-chip-label {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cs-faint);
}

.stat-chip.is-gold {
  border-color: color-mix(in srgb, var(--cs-gold) 35%, var(--cs-border));
  background: color-mix(in srgb, var(--cs-gold) 6%, transparent);
}

.stat-chip.is-gold .stat-chip-value {
  color: var(--cs-gold);
}

/* ── Error page ───────────────────────────────────────────────────────────── */
.error-page {
  padding: clamp(3rem, 10vw, 6rem) 1rem;
  text-align: center;
}

.error-code {
  margin: 0;
  font-size: clamp(4.5rem, 16vw, 8rem);
  font-weight: 800;
  line-height: 1;
  color: var(--cs-faint);
}

.error-message {
  margin: 1.25rem auto 2rem;
  max-width: 32rem;
  font-size: 1.15rem;
  color: var(--cs-muted);
}

.error-page pre {
  max-width: 100%;
  margin-top: 2rem;
  text-align: left;
}

/* ── Split timer (popup.tpl + pages/timer/show.tpl, timer.js) ────────────── */
/* Only classes of .timer-app and below: "Pin on top" moves it into another document */
.popup-body {
  min-height: 100vh;
}

.timer-host {
  max-width: 30rem;
  margin: 0 auto;
  padding: 0.75rem;
}

.timer-app {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.is-floating .timer-app {
  padding: 0.6rem;
}

/* In its window the timer fits the height: the split list shrinks (and scrolls) so the clock,
   the controls and the LiveSplit buttons stay in sight */
.popup-body .timer-host {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.popup-body .timer-app {
  flex: 1;
  min-height: 0;
}

.popup-body .split-list {
  flex: 0 1 auto;
  min-height: 8rem;
  max-height: none;
}

.timer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.timer-head .kicker {
  margin: 0;
  font-size: 0.7rem;
}

.timer-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.timer-attempts {
  flex-shrink: 0;
  font-family: var(--cs-font-mono);
  font-size: 0.8rem;
  color: var(--cs-muted);
}

.timer-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.86rem;
}

.timer-compare {
  display: inline-flex;
  gap: 0.15rem;
  padding: 0.2rem;
  border: 1px solid var(--cs-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.timer-compare button {
  padding: 0.15rem 0.7rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--cs-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.timer-compare button:hover:not(:disabled) {
  color: #fff;
}

.timer-compare button[aria-pressed="true"] {
  color: var(--cs-accent-contrast);
  background: var(--cs-accent);
}

.timer-compare button:disabled {
  opacity: 0.4;
}

.split-list {
  max-height: min(52vh, 30rem);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--cs-border);
  border-radius: var(--cs-radius);
  background: var(--cs-surface);
}

.split-row {
  padding: 0.4rem 0.65rem;
}

.split-row + .split-row {
  border-top: 1px solid var(--cs-border);
}

.split-row.is-current {
  background: color-mix(in srgb, var(--cs-accent) 14%, transparent);
  box-shadow: inset 3px 0 0 var(--cs-accent);
}

/* A group of splits (LiveSplit subsplits): a heading row, then its splits indented */
.split-group {
  padding: 0.3rem 0.65rem 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cs-muted);
  background: var(--cs-bg);
}

.split-row + .split-group {
  border-top: 1px solid var(--cs-border);
}

.split-row.is-subsplit .split-name {
  padding-left: 0.75rem;
}

.split-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.split-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.split-guide-btn {
  display: none;
  padding: 0 0.25rem;
  border: 0;
  background: none;
  color: var(--cs-faint);
  line-height: 1;
}

.guides-on .split-guide-btn {
  display: inline-block;
}

.split-guide-btn:hover,
.split-guide-btn[aria-expanded="true"] {
  color: var(--cs-accent);
}

.split-delta {
  min-width: 4.5rem;
  text-align: right;
  font-size: 0.82rem;
}

.split-time {
  min-width: 4.75rem;
  text-align: right;
}

.split-time.is-comparison {
  color: var(--cs-faint);
  font-weight: 500;
}

.delta-ahead {
  color: var(--cs-ahead);
}

.delta-behind {
  color: var(--cs-behind);
}

.delta-gold {
  color: var(--cs-gold);
}

.split-guide {
  margin: 0.4rem 0 0.15rem;
  padding: 0.45rem 0.65rem;
  border-left: 2px solid var(--cs-accent);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.84rem;
}

.split-guide ul {
  padding-left: 1.1rem;
}

.timer-clock {
  font-size: clamp(2.6rem, 15vw, 3.6rem);
  line-height: 1;
  text-align: right;
  letter-spacing: -0.02em;
}

.timer-clock.is-ahead {
  color: var(--cs-ahead);
}

.timer-clock.is-behind {
  color: var(--cs-behind);
}

.timer-clock.is-paused {
  opacity: 0.55;
}

.timer-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.15rem 1rem;
  margin: 0;
  font-size: 0.8rem;
}

.timer-stats > div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.timer-stats dt {
  font-weight: 500;
  color: var(--cs-muted);
}

.timer-stats dd {
  margin: 0;
}

.timer-finish {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--cs-border-strong);
  border-radius: var(--cs-radius);
  background: var(--cs-surface);
}

.timer-finish-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.badge-pb {
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--cs-gold);
  color: #2b1d03;
  font-size: 0.75rem;
  font-weight: 700;
}

.timer-finish-actions,
.timer-menu-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* The main button on its own row, then undo / skip / pause / reset */
.timer-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
}

.timer-main {
  grid-column: 1 / -1;
  padding-block: 0.6rem;
  font-weight: 700;
  white-space: nowrap;
}

.timer-main kbd {
  margin-left: 0.35rem;
  padding: 0.05rem 0.35rem;
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  font-size: 0.7rem;
  font-weight: 600;
}

.timer-reset {
  white-space: nowrap;
}

.timer-status {
  min-height: 1.2em;
  margin: 0;
  font-size: 0.82rem;
  color: var(--cs-muted);
  text-align: center;
}

/* Import / export of LiveSplit files, always in sight */
.timer-files {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}

.timer-files .btn {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timer-menu > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.84rem;
  color: var(--cs-muted);
  list-style: none;
  cursor: pointer;
}

.timer-menu > summary::-webkit-details-marker {
  display: none;
}

.timer-menu > summary:hover,
.timer-menu[open] > summary {
  color: var(--cs-text);
}

.timer-menu-body {
  margin-top: 0.5rem;
}

.timer-help {
  width: 100%;
  margin: 0;
  font-size: 0.78rem;
  color: var(--cs-muted);
}

.timer-pip-note {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--cs-muted);
}

/* "Start timer" menu on a board */
.timer-option small {
  margin-left: 0.35rem;
  color: var(--cs-muted);
}

/* Admin forms (admin/crud/form.tpl): one card per section, jump links above, Save always in reach */
.admin-form-nav .chip:hover {
  border-color: var(--cs-border-strong);
  color: var(--cs-text);
}

/* Rows of the edited one (a variable's values), after the form and its Save bar */
.admin-children {
  margin-top: 1.5rem;
}

.admin-section + .admin-section {
  margin-top: 1rem;
}

.admin-form-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--cs-border);
  background: var(--cs-bg);
}

/* Admin split editor (admin/timer-splits.tpl, split-editor.js) */
.split-editor {
  margin: 0;
  padding: 0;
  list-style: none;
}

.split-editor-row {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--cs-border);
}

.split-editor-number {
  padding-top: 0.45rem;
  text-align: right;
  color: var(--cs-muted);
}

.split-editor-fields {
  display: grid;
  gap: 0.4rem;
}

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

.split-editor-import {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--cs-border);
}

.split-editor-actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* ── Small screens ────────────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .hero {
    margin-bottom: 2.5rem;
  }

  .stat-chips {
    margin-left: 0;
    width: 100%;
  }

  .stat-chip {
    flex: 1;
    min-width: 0;
  }
}
/* Game directory */
.directory-header { margin-bottom: 1.5rem; }
.directory-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--cs-border);
  border-radius: var(--cs-radius-lg);
  background: var(--cs-bg-deep);
}
.directory-filters > div { flex: 1 1 12rem; }
.directory-count { margin: 1.25rem 0; }
.directory-section { margin: 2.5rem 0; }
.games-directory .game-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); }
.home-catalog { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.5rem; }
.home-catalog > div { flex: 1 1 24rem; }
.home-catalog p { margin-bottom: 0; }
@media (max-width: 575.98px) {
  .directory-filters > div { flex-basis: 100%; }
  .directory-filters > .btn { flex: 1; }
}

/* Site rankings (/rankings) */
.rankings-excluded { display: flex; gap: 0.75rem; align-items: flex-start; }
.rankings-excluded > .bi { font-size: 1.25rem; line-height: 1.2; }
.rankings-excluded-list { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0.35rem 0 0; padding: 0; list-style: none; }
.rankings-games { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 1rem 0; }
.rankings-game {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--cs-border);
  border-radius: 999px;
  color: var(--cs-text);
  font-size: 0.875rem;
  text-decoration: none;
}
.rankings-game:hover { border-color: var(--cs-accent); }

/*
 * The table is two tables with the same columns (table-layout: fixed, widths from the header
 * cells): the header strip sticks under the navbar with the sideways scrollbar right below it,
 * only as wide as the game columns; head, body and bar scroll together (scroll-sync.js). #, the
 * player and the value stay anchored on the left, the games count on the right.
 * On phones the game columns are hidden: one plain table with a sticky header.
 */
.rankings-board {
  --rk-place: 3.25rem;
  --rk-player: 13rem;
  --rk-value: 6.5rem;
  --rk-done: 5.25rem;
}

.rankings-strip {
  position: sticky;
  top: var(--cs-nav-height);
  z-index: 3;
  border-bottom: 1px solid var(--cs-border-strong);
  border-radius: var(--cs-radius) var(--cs-radius) 0 0;
  background: var(--cs-surface);
  box-shadow: 0 8px 14px -10px rgba(0, 0, 0, 0.7);
}

.rankings-strip-head,
.rankings-body {
  overflow-x: auto;
  scrollbar-width: none;
}

.rankings-strip-head::-webkit-scrollbar,
.rankings-body::-webkit-scrollbar {
  display: none;
}

/* The scrollbar spans the game columns only (its spacer is sized by scroll-sync.js) */
.rankings-scrollbar {
  margin-left: calc(var(--rk-place) + var(--rk-player) + var(--rk-value));
  margin-right: var(--rk-done);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--cs-faint) var(--cs-surface-2);
}

.rankings-scrollbar > [data-scroll-spacer] {
  height: 1px;
}

.rankings-table {
  table-layout: fixed;
}

.rankings-table > :not(caption) > * > * {
  padding: 0.45rem 0.5rem;
}

.rankings-table thead th {
  color: var(--cs-muted);
  vertical-align: bottom;
}

.rankings-table .rk-place { width: var(--rk-place); }
.rankings-table .rk-player { width: var(--rk-player); }
.rankings-table .rk-value { width: var(--rk-value); }
.rankings-table .rk-game.rk-s { width: 6.5rem; }
.rankings-table .rk-game.rk-cs { width: 8rem; }
.rankings-table .rk-game.rk-ms { width: 8.5rem; }
.rankings-table .rk-done { width: var(--rk-done); }

.rankings-table .rk-player {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Anchored columns: opaque (the record row's tint goes on top), with an edge towards the games */
.rankings-table .rk-sticky,
.rankings-table .rk-sticky-end {
  position: sticky;
  z-index: 1;
  background-color: var(--cs-surface);
}

.rankings-table .rk-sticky {
  left: 0;
}

.rankings-table .rk-sticky.rk-player {
  left: var(--rk-place);
}

.rankings-table .rk-sticky.rk-value {
  left: calc(var(--rk-place) + var(--rk-player));
}

.rankings-table .rk-sticky-end {
  right: 0;
}

.rankings-table .rk-value::after,
.rankings-table .rk-done::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--cs-border-strong);
}

.rankings-table .rk-value::after {
  right: 0;
}

.rankings-table .rk-done::before {
  left: 0;
}

.rankings-table tr.is-record > .rk-sticky,
.rankings-table tr.is-record > .rk-sticky-end {
  background-image: linear-gradient(color-mix(in srgb, var(--cs-gold) 7%, transparent), color-mix(in srgb, var(--cs-gold) 7%, transparent));
}

/* Game columns: the game's name in its own colour, with a bar of it on top */
.rankings-table th.rk-game {
  padding-top: 0.6rem;
  font-size: 0.78rem;
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
  box-shadow: inset 0 3px 0 var(--cs-accent);
}

.rankings-table th.rk-game a {
  color: color-mix(in srgb, var(--cs-accent) 50%, #fff);
  text-decoration: none;
}

.rankings-table th.rk-game a:hover {
  color: #fff;
}

/* A game's PB: small medallion with the place, the time right next to it */
.rankings-pb {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.rankings-cell .rank {
  flex: none;
  width: auto;
  min-width: 1.45rem;
  height: 1.45rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  font-size: 0.66rem;
}

.rankings-cell .rank-1::before {
  display: none;
}

.rankings-time {
  color: var(--cs-text);
  font-family: var(--cs-font-mono);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rankings-none {
  color: var(--cs-faint);
}

/* The body's own header: only the column widths (and screen readers) on wide screens */
@media (min-width: 576px) {
  .rankings-table .rankings-head-sr th {
    height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border: 0;
    box-shadow: none;
    font-size: 0;
    line-height: 0;
  }
}

@media (max-width: 575.98px) {
  .rankings-strip {
    display: none;
  }

  .rankings-body {
    overflow: visible;
  }

  .rankings-table {
    table-layout: auto;
  }

  .rankings-table .rk-player {
    width: auto;
    white-space: normal;
  }

  .rankings-table .rk-sticky,
  .rankings-table .rk-sticky-end {
    position: static;
  }

  .rankings-table .rk-value::after,
  .rankings-table .rk-done::before {
    display: none;
  }

  .rankings-table .rankings-head-sr th {
    position: sticky;
    top: var(--cs-nav-height);
    z-index: 2;
    background: var(--cs-surface);
  }
}
