:root {
  --bg: #f5f1ea;
  --card: #ffffff;
  --hairline: #e8e1d5;
  --ink: #1a1f2e;
  --ink-muted: #6b6f7c;
  --coral: #d4543a;
  --ink-blue: #2a6f97;
  --shadow-sm: 0 1px 2px rgba(26, 31, 46, 0.05);
  --shadow-md: 0 4px 18px rgba(26, 31, 46, 0.08);
  --shadow-lg: 0 12px 40px rgba(26, 31, 46, 0.18);
  --serif: Georgia, "Charter", "Iowan Old Style", "Source Serif Pro", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
}

/* ───── header ───── */
.page-header {
  text-align: center;
  margin-bottom: 3rem;
}

.masthead {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-muted);
  text-decoration: none;
  padding: 0 0.5rem 0.5rem;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 1.6rem;
  transition: color 140ms ease, border-color 140ms ease;
}

.masthead:hover {
  color: var(--ink);
  border-bottom-color: var(--coral);
}

/* ───── primary nav (under masthead) ───── */
.page-nav {
  display: flex;
  justify-content: center;
  gap: 1.4rem;
  margin: -0.6rem 0 1.4rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.page-nav a {
  color: var(--ink-muted);
  text-decoration: none;
  padding: 0.15rem 0;
  border-bottom: 1px solid transparent;
  transition: color 120ms ease, border-color 120ms ease;
}

.page-nav a:hover {
  color: var(--ink);
  border-bottom-color: var(--coral);
}

.page-header h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.01em;
  margin: 0 0 0.6rem;
}

.hint {
  color: var(--ink-muted);
  font-size: 0.85rem;
  font-family: var(--sans);
  margin: 0;
}

.hint kbd {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 1px 6px;
  border: 1px solid var(--hairline);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--card);
  color: var(--ink);
  margin: 0 1px;
}

/* ───── pair ───── */
.pair {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 1rem;
}

.vs {
  align-self: center;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ───── card ───── */
.card {
  position: relative;
  flex: 1 1 0;
  min-height: 220px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.75rem 1.5rem 2.25rem;
  transition: box-shadow 120ms ease, transform 120ms ease, border-color 120ms ease;
  user-select: none;
  overflow: hidden;
}

.card::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: var(--coral);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 140ms ease;
}

.card:hover:not(.is-busy) {
  box-shadow: var(--shadow-md);
  border-color: #d8d0bf;
}

.card:hover:not(.is-busy)::after {
  transform: scaleX(1);
}

.card:active:not(.is-busy) {
  transform: translateY(1px);
}

.card.is-busy {
  cursor: default;
  opacity: 0.55;
}

.card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
  width: 100%;
}

.thumb {
  width: 88px;
  height: 88px;
  border-radius: 6px;
  background: #f0eadd;
  border: 1px solid var(--hairline);
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 220ms ease;
}

.thumb.loaded {
  opacity: 1;
}

.thumb.empty {
  opacity: 0.55;
  background: repeating-linear-gradient(
    45deg,
    #f0eadd,
    #f0eadd 6px,
    #ebe4d4 6px,
    #ebe4d4 12px
  );
}

.label {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.25rem, 2.6vw, 1.55rem);
  letter-spacing: -0.005em;
  margin: 0;
  line-height: 1.3;
  transition: opacity 180ms ease;
}

.label.fading {
  opacity: 0;
}

/* ───── hotkey badge ───── */
.hotkey {
  position: absolute;
  bottom: 0.55rem;
  right: 0.7rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-muted);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 1px 5px;
  background: var(--bg);
  pointer-events: none;
}

/* ───── info button ───── */
.info-btn {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--card);
  color: var(--ink-blue);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}

.info-btn:hover {
  background: var(--ink-blue);
  color: #fff;
  transform: scale(1.08);
}

/* ───── skip link ─────
   Subdued by design — we don't want to encourage skipping over picking,
   but we do want a clear escape valve when the user genuinely has no
   opinion. Mono small-caps treatment matches the rest of the analytical
   chrome; coral on hover signals it's a real action. */
.skip-row {
  display: flex;
  justify-content: center;
  margin-top: 0.85rem;
}

.skip-btn {
  background: transparent;
  border: 0;
  padding: 0.35rem 0.6rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: color 120ms ease, background 120ms ease;
}

.skip-btn:hover:not(:disabled),
.skip-btn:focus-visible {
  color: var(--coral);
  background: rgba(212, 84, 58, 0.06);
  outline: none;
}

.skip-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.skip-btn kbd {
  font-family: var(--mono);
  font-size: 0.65rem;
  padding: 0 4px;
  border: 1px solid var(--hairline);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--card);
  color: var(--ink-muted);
  margin-left: 0.4em;
  letter-spacing: 0;
  text-transform: lowercase;
}

/* ───── surprise card ───── */
.surprise-card {
  display: grid;
  grid-template-columns: 6px 1fr auto;
  margin-top: 1.75rem;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 140ms ease, transform 140ms ease, border-color 140ms ease;
  animation: surprise-rise 220ms ease both;
}

.surprise-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #d8d0bf;
}

.surprise-card:focus-visible {
  outline: 2px solid var(--ink-blue);
  outline-offset: 2px;
}

.surprise-bar {
  background: var(--surprise-color, var(--ink-muted));
  transition: background 220ms ease;
}

.surprise-main {
  padding: 1.05rem 1.3rem 1.1rem;
  background: var(--surprise-tint, transparent);
  transition: background 220ms ease;
  min-width: 0;
}

.surprise-headline {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.3rem;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.surprise-context {
  font-family: var(--sans);
  font-size: 0.84rem;
  color: var(--ink-muted);
  margin: 0 0 0.7rem;
  line-height: 1.4;
  word-wrap: break-word;
}

.surprise-context .winner {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink);
  font-size: 0.95rem;
}

.surprise-context .loser {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-muted);
  text-decoration: line-through;
  text-decoration-color: rgba(26, 31, 46, 0.35);
  font-size: 0.95rem;
}

.surprise-context .conn {
  font-family: var(--serif);
  font-style: italic;
  margin: 0 0.35em;
}

.meter {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
  max-width: 220px;
}

.meter span {
  height: 5px;
  border-radius: 1px;
  background: rgba(26, 31, 46, 0.08);
  transition: background 240ms ease;
}

.meter span.lit {
  background: var(--surprise-color, var(--ink-muted));
}

.surprise-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 1.05rem 1.3rem;
  border-left: 1px solid var(--hairline);
  background: var(--surprise-tint, transparent);
  min-width: 96px;
  transition: background 220ms ease;
}

.surprise-num {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--surprise-color, var(--ink));
  line-height: 1;
  transition: color 220ms ease;
}

.surprise-rerank {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  margin-top: 0.5rem;
  transition: color 140ms ease;
}

.surprise-card:hover .surprise-rerank {
  color: var(--coral);
}

@keyframes surprise-rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes surprise-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}

.surprise-num.pulse {
  animation: surprise-pulse 380ms ease;
}

/* ───── stats footer ───── */
.stats {
  margin-top: 1.4rem;
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.stat-block {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-key {
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.stat-val {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat-val.mono {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}

.stat-hint {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--ink);
  letter-spacing: 0;
}

.stat-hint .hint-num {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--coral);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.stat-hint .hint-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ───── report card modal ───── */
.report-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 31, 46, 0.45);
  z-index: 90;
  animation: fade 140ms ease both;
}

.report-card {
  position: fixed;
  z-index: 100;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(540px, calc(100% - 1.5rem));
  max-height: calc(100vh - 1.5rem);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 1.6rem 1.6rem 1.4rem;
  box-shadow: var(--shadow-lg);
  animation: rise 160ms ease both;
  text-align: center;
}

.report-masthead,
.report-foot {
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 0.55rem;
  margin-bottom: 1rem;
}

.report-foot {
  border-bottom: 0;
  border-top: 1px solid var(--hairline);
  padding-top: 0.6rem;
  padding-bottom: 0;
  margin-top: 1.2rem;
  margin-bottom: 0.4rem;
}

.report-wordmark {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.report-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1rem;
  color: var(--ink-muted);
  margin: 0 0 1rem;
}

.report-bignum {
  font-family: var(--mono);
  font-size: clamp(3.5rem, 10vw, 4.5rem);
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.report-bignum-label {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0.4rem 0 1.4rem;
}

.report-headline {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
  margin: 0 0 0.3rem;
}

.report-subline {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin: 0 0 1.2rem;
  font-variant-numeric: tabular-nums;
}

.report-pick {
  text-align: left;
  border-top: 1px dashed var(--hairline);
  padding: 0.85rem 0 0.4rem;
  margin: 0;
}

.report-pick-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.3rem;
}

.report-pick-body {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--ink);
  line-height: 1.4;
}

.report-pick-body em.winner {
  font-style: italic;
  font-weight: 600;
}

.report-pick-body em.loser {
  font-style: italic;
  color: var(--ink-muted);
  text-decoration: line-through;
  text-decoration-color: rgba(26, 31, 46, 0.3);
}

.report-pick-body .num {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  display: block;
  margin-top: 0.2rem;
}

.report-dismiss {
  display: block;
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.7rem 1rem;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.report-dismiss:hover {
  background: var(--bg);
  border-color: var(--coral);
  color: var(--coral);
}

/* ───── desktop tooltip (info hover) ───── */
.tooltip {
  position: fixed;
  z-index: 50;
  max-width: 280px;
  padding: 0.7rem 0.85rem;
  background: var(--ink);
  color: #f5f1ea;
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  font-size: 0.82rem;
  line-height: 1.45;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
}

.tooltip.visible {
  opacity: 1;
}

.tooltip .tt-title {
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #fff;
}

.tooltip .tt-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  background-color: rgba(255,255,255,0.08);
}

/* ───── mobile popover ───── */
.popover-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 31, 46, 0.45);
  z-index: 90;
  animation: fade 140ms ease both;
}

.popover {
  position: fixed;
  z-index: 100;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 2rem));
  background: var(--card);
  border-radius: 12px;
  padding: 1.5rem 1.5rem 1.4rem;
  box-shadow: var(--shadow-lg);
  animation: rise 160ms ease both;
}

.popover-close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  background: transparent;
  border: 0;
  font-size: 1.5rem;
  color: var(--ink-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem 0.5rem;
}

.popover-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background: #f0eadd;
  background-size: cover;
  background-position: center;
  margin-bottom: 1rem;
}

.popover-thumb.empty {
  background: repeating-linear-gradient(
    45deg,
    #f0eadd, #f0eadd 8px, #ebe4d4 8px, #ebe4d4 16px
  );
}

.popover-title {
  font-family: var(--serif);
  font-size: 1.35rem;
  margin: 0 0 0.6rem;
  color: var(--ink);
}

.popover-desc {
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink);
  margin: 0 0 0.9rem;
  max-height: 16rem;
  overflow-y: auto;
}

.popover-link {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-blue);
  text-decoration: none;
}

.popover-link:hover { text-decoration: underline; }

@keyframes fade {
  from { opacity: 0; } to { opacity: 1; }
}

@keyframes rise {
  from { opacity: 0; transform: translate(-50%, -46%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* ───── narrow screens ───── */
@media (max-width: 600px) {
  main {
    padding: 2rem 1rem 4rem;
  }
  .pair {
    flex-direction: column;
    gap: 0.6rem;
  }
  .vs {
    transform: rotate(0deg);
  }
  .card {
    min-height: 160px;
    padding: 1.25rem 1rem 1.75rem;
  }
  .thumb {
    width: 64px;
    height: 64px;
  }
  .tooltip { display: none; }

  .surprise-card {
    grid-template-columns: 6px 1fr auto;
    margin-top: 1.25rem;
  }
  .surprise-main {
    padding: 0.85rem 1rem 1rem;
  }
  .surprise-side {
    padding: 0.85rem 1rem;
    min-width: 84px;
  }
  .surprise-num {
    font-size: 1.25rem;
  }
  .meter {
    max-width: 160px;
  }
}

/* ───── stats page ───── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 132px;
}

.stat-card[hidden] { display: none; }

.stat-card--alarm {
  border-color: var(--coral);
  background: #fff5f3;
}

.stat-card--alarm .stat-label,
.stat-card--alarm .stat-value {
  color: var(--coral);
}

/* Wide audience grid lives below the main stat tiles. Page-views card
   stacks a per-path breakdown under the headline number; top-referrers
   card spans wider so the host names have room to breathe. */
.stats-grid--wide {
  grid-template-columns: minmax(220px, 1fr) minmax(320px, 2fr);
  margin-top: 1rem;
}

@media (max-width: 640px) {
  .stats-grid--wide {
    grid-template-columns: 1fr;
  }
}

.stat-card--span-2 {
  /* Reserved for the wider audience cards; on small screens auto-fit
     reflows. No-op here but documented as the intent. */
}

.stat-breakdown {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.stat-breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.stat-breakdown-key {
  color: var(--ink-muted);
}

.stat-breakdown-val {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat-rank-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.stat-rank-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--hairline);
}

.stat-rank-list li:last-child {
  border-bottom: none;
}

.stat-rank-key {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-rank-val {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.stat-rank-empty {
  justify-content: center;
  color: var(--ink-muted);
  border-bottom: none;
}

.stat-label {
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--ink-muted);
  letter-spacing: 0.005em;
}

.stat-value {
  font-family: var(--mono);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  color: var(--ink);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-value--split {
  display: flex;
  gap: 1.5rem;
  align-items: baseline;
}

.stat-value--split > span {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-sub {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.stats-cache-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin: -0.5rem 0 1.4rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-muted);
  flex-wrap: wrap;
}

.stats-refresh-btn {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid var(--hairline);
  padding: 0.18rem 0.55rem;
  border-radius: 2px;
  cursor: pointer;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

.stats-refresh-btn:hover:not(:disabled) {
  color: var(--coral);
  border-color: var(--coral);
}

.stats-refresh-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.stats-footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--hairline);
  text-align: center;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.stats-download {
  margin: 0.6rem 0 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.stats-download a {
  color: var(--ink-muted);
  text-decoration: underline;
  text-decoration-color: var(--hairline);
  text-underline-offset: 0.18em;
}

.stats-download a:hover {
  color: var(--coral);
  text-decoration-color: var(--coral);
}

/* ───── leaderboard page ───── */
.lb-section {
  margin-top: 2.4rem;
}

.lb-heading {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: -0.005em;
  margin: 0 0 0.9rem;
  color: var(--ink);
}

.lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.lb-empty {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-muted);
  font-style: italic;
  padding: 0.5rem 0.25rem;
}

/* Reuse `.card` look (background, border, shadow, hover lift) but lay
   out horizontally — thumbnail / label / mono meta / `i` button. */
.lb-item.card {
  flex: none;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  padding: 0.75rem 3rem 0.75rem 0.85rem;
  min-height: 0;
  gap: 0.95rem;
  cursor: default;
}

.lb-item.card:hover:not(.is-busy) {
  transform: none;
}

/* Don't show the coral underline animation on leaderboard rows — they
   aren't click targets, and the line implies "selectable". */
.lb-item.card::after { display: none; }

.lb-item .thumb {
  flex: none;
  width: 56px;
  height: 56px;
  margin: 0;
}

.lb-label-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.lb-item .label {
  font-size: clamp(1rem, 2vw, 1.15rem);
  text-align: left;
  margin: 0;
}

.lb-meta {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  font-variant-numeric: tabular-nums;
}

.lb-rank {
  font-family: var(--mono);
  font-size: 1.05rem;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.lb-rating {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.lb-games {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  opacity: 0.75;
}

/* The `i` button positions absolutely against the row's right edge,
   sized + colored same as the picker. */
.lb-info-btn {
  position: absolute;
  top: 50%;
  right: 0.7rem;
  transform: translateY(-50%);
}

.lb-info-btn:hover {
  transform: translateY(-50%) scale(1.08);
}

/* ───── search ───── */
.lb-search {
  position: relative;
  margin-top: 0.5rem;
}

.lb-search-input {
  width: 100%;
  padding: 0.85rem 1rem;
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.lb-search-input::placeholder {
  color: var(--ink-muted);
  font-style: italic;
}

.lb-search-input:focus {
  border-color: var(--ink-blue);
  box-shadow: 0 0 0 3px rgba(42, 111, 151, 0.12);
}

/* Search results panel — visually enclosed so a tall result list doesn't
   feel like it's running into the leaderboard sections below. The panel
   caps its own height; long lists scroll within instead of pushing the
   page around. */
.lb-results {
  margin-top: 0.6rem;
  padding: 0.45rem;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* `.lb-list`'s `display: flex` overrides the UA stylesheet's
   `[hidden] { display: none }`, so when there's no query the empty
   panel still rendered as a thin border + background. Restore the
   intended hidden behavior. */
.lb-results[hidden] {
  display: none;
}

/* Items inside the panel sit flush with the panel border, not with
   their own card shadow on top of the panel's shadow. */
.lb-results .lb-item.card {
  box-shadow: none;
  border-color: transparent;
  background: transparent;
}

.lb-results .lb-item.card:hover:not(.is-busy) {
  background: rgba(232, 225, 213, 0.35);
  border-color: var(--hairline);
}

.lb-search-empty {
  margin: 0.6rem 0 0;
  padding: 0.7rem 0.85rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-muted);
  font-style: italic;
  background: var(--card);
  border: 1px dashed var(--hairline);
  border-radius: 8px;
}

@media (max-width: 600px) {
  .lb-item.card {
    padding: 0.65rem 2.5rem 0.65rem 0.7rem;
    gap: 0.75rem;
  }
  .lb-item .thumb {
    width: 44px;
    height: 44px;
  }
  .lb-item .label {
    font-size: 0.98rem;
  }
  .lb-rank { font-size: 0.95rem; }
  .lb-rating { font-size: 0.72rem; }
  .lb-search-input {
    padding: 0.7rem 0.85rem;
    font-size: 1rem;
  }
}

/* ───── prose (about page) ───── */
.prose {
  max-width: 660px;
  margin: 0 auto;
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
}

.prose h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.55rem;
  letter-spacing: -0.005em;
  margin: 2.4rem 0 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--hairline);
}

.prose h2:first-child {
  margin-top: 0;
}

.prose p {
  margin: 0 0 1.1rem;
}

.prose a {
  color: var(--ink-blue);
  text-decoration: none;
  border-bottom: 1px dotted var(--hairline);
  transition: color 120ms ease, border-color 120ms ease;
}

.prose a:hover {
  color: var(--coral);
  border-bottom-color: var(--coral);
}

.prose-foot {
  max-width: 660px;
  margin: 3rem auto 0;
  padding-top: 1.4rem;
  border-top: 1px solid var(--hairline);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
}

.prose-foot a {
  color: var(--ink-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding: 0.15rem 0;
  transition: color 120ms ease, border-color 120ms ease;
}

.prose-foot a:hover {
  color: var(--ink);
  border-bottom-color: var(--coral);
}

@media (max-width: 600px) {
  .prose {
    font-size: 1rem;
  }
  .prose h2 {
    font-size: 1.35rem;
  }
}

/* ───── built-on cards (about page) ───── */
.built-on {
  margin: 2rem 0 2.4rem;
}

.built-on-intro {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  text-align: center;
  margin: 0 0 0.9rem;
}

.built-on-grid {
  display: flex;
  gap: 1rem;
}

.built-on-card {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 1.4rem 1.2rem 1rem;
  text-decoration: none;
  color: var(--ink);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 140ms ease, transform 140ms ease;
}

.built-on-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.built-on-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.built-on-card--railway .built-on-bar { background: #a855f7; }
.built-on-card--do      .built-on-bar { background: #0080ff; }

.built-on-brand {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.built-on-card--railway .built-on-brand { color: #a855f7; }
.built-on-card--do      .built-on-brand { color: #0080ff; }

.built-on-amount {
  font-family: var(--serif);
  font-size: 2.6rem;
  font-weight: 600;
  line-height: 1;
  margin: 0.4rem 0 0.45rem;
}

.built-on-card--railway .built-on-amount { color: #a855f7; }
.built-on-card--do      .built-on-amount { color: #0080ff; }

.built-on-caption {
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.4;
  margin-bottom: 0.9rem;
}

.built-on-cta {
  margin-top: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border-bottom: 1px solid transparent;
  padding-bottom: 0.1rem;
  transition: color 120ms ease, border-color 120ms ease;
}

.built-on-card:hover .built-on-cta {
  color: var(--coral);
  border-bottom-color: var(--coral);
}

/* Override the .prose a dotted-underline since built-on-card sits inside .prose. */
.prose a.built-on-card {
  border-bottom: 1px solid var(--hairline);
}
.prose a.built-on-card:hover {
  color: var(--ink);
  border-bottom-color: var(--hairline);
}

@media (max-width: 600px) {
  .built-on-grid {
    flex-direction: column;
  }
  .built-on-amount {
    font-size: 2.2rem;
  }
}
