:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #1c1b19;
  --muted: #6d6a64;
  --line: #e4e1db;
  --accent: #fc5200;
  --accent-ink: #ffffff;
  --win: #1f8a4c;
  --win-bg: #e3f3e9;
  --loss: #c2372b;
  --loss-bg: #fbe6e3;
  --tie: #8a6d1f;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414;
    --card: #1e1e1d;
    --ink: #f1efe9;
    --muted: #9c988f;
    --line: #2f2e2b;
    --win: #5bd08b;
    --win-bg: #173323;
    --loss: #ff7d70;
    --loss-bg: #3a1b18;
    --tie: #e0c063;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; cursor: pointer; }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--card);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: clamp(19px, 4.6vw, 24px); letter-spacing: -0.01em; line-height: 1.1; text-decoration: none; color: var(--accent); }
.brand-mark { width: 1.6em; height: 1.6em; flex: none; display: block; margin: -0.2em 0; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; }

.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--line); flex: none; }
.avatar.lg { width: 56px; height: 56px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 999px; text-decoration: none;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.link { background: none; border: 0; color: var(--muted); padding: 0; text-decoration: underline; }

.hero { text-align: center; padding: 56px 0 32px; }
.hero h1 { font-size: clamp(28px, 6vw, 44px); line-height: 1.1; margin: 0 0 12px; }
.hero p { max-width: 520px; margin: 0 auto 24px; color: var(--muted); }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 32px 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.stack > * + * { margin-top: 16px; }

.status { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.status .stats { display: flex; gap: 20px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--line); }
.pill.syncing, .pill.queued { background: #fff1e6; color: #a23a00; }
.pill.rate_limited { background: #fff6d6; color: #7a5a00; }
.pill.error { background: var(--loss-bg); color: var(--loss); }
@media (prefers-color-scheme: dark) {
  .pill.syncing, .pill.queued { background: #3b2414; color: #ffb07f; }
  .pill.rate_limited { background: #3a3013; color: #f0d27a; }
}

.invite { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.invite input {
  flex: 1 1 240px; min-width: 0; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: 13px ui-monospace, monospace;
}

.tabs { display: flex; gap: 4px; margin: 24px 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  background: none; border: 0; padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--accent); font-weight: 600; }

.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: 28px 32px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 8px; border-bottom: 1px solid var(--line); text-decoration: none;
}
a.row:hover, button.row:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.row .rank { color: var(--muted); font-weight: 600; text-align: right; }
.row .name { font-weight: 600; }
.row .sub { font-size: 13px; color: var(--muted); }
.row.me { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.row .right { text-align: right; }

.record { font-weight: 700; }
.record .w { color: var(--win); }
.record .l { color: var(--loss); }
.record .t { color: var(--tie); }

.bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line); width: 120px; margin-top: 4px; margin-left: auto; }
.bar .w { background: var(--win); }
.bar .t { background: var(--tie); }
.bar .l { background: var(--loss); }

.seg { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 16px; padding: 12px 8px; border-bottom: 1px solid var(--line); align-items: center; }
.seg .name { font-weight: 600; grid-column: 1 / -1; }
.seg a.name { text-decoration: none; }
.seg a.name:hover { text-decoration: underline; }
.times { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.chip { padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.chip.win { background: var(--win-bg); color: var(--win); }
.chip.loss { background: var(--loss-bg); color: var(--loss); }
.chip.tie { background: var(--line); }
.delta { font-size: 13px; min-width: 64px; text-align: right; }
.delta.win { color: var(--win); }
.delta.loss { color: var(--loss); }

.h2h-head { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; text-align: center; margin: 16px 0; }
.h2h-head .side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.h2h-head .score { font-size: 36px; font-weight: 800; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.filters button { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 4px 12px; border-radius: 999px; font-size: 13px; }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.notice { padding: 12px 16px; border-radius: 10px; background: var(--win-bg); color: var(--win); margin-top: 16px; }
.notice.err { background: var(--loss-bg); color: var(--loss); }
.back { display: inline-block; margin: 16px 0 0; color: var(--muted); text-decoration: none; }

.foot { display: flex; justify-content: space-between; padding: 32px 16px; font-size: 13px; color: var(--muted); }

@media (max-width: 560px) {
  .row { grid-template-columns: 22px 32px 1fr auto; gap: 8px; }
  .bar { width: 80px; }
  .seg { grid-template-columns: 1fr auto; }
  .seg .delta { grid-column: 2; }
  .status .stats { gap: 14px; }
}

/* ---------- sync progress ---------- */
.progress { width: 100%; display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.progress-top { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; font-size: 14px; }
.progress .sub { font-size: 13px; color: var(--muted); min-height: 1.2em; overflow-wrap: anywhere; }
.meter { position: relative; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter > span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 4px; transition: width .6s ease; }
.meter.indeterminate > span { animation: meter-slide 1.4s ease-in-out infinite; }
@keyframes meter-slide { from { left: -30%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) {
  .meter > span { transition: none; }
  .meter.indeterminate > span { animation: none; left: 0; width: 100% !important; opacity: .4; }
}

/* ---------- Strava brand assets (official artwork, unmodified) ---------- */
.strava-connect { display: inline-block; line-height: 0; border-radius: 4px; }
.strava-connect img { height: 48px; width: auto; display: block; }
.strava-connect:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.powered-by { display: inline-block; line-height: 0; }
.powered-by img { height: 16px; width: auto; display: block; }
.powered-by .on-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .powered-by .on-light { display: none; }
  .powered-by .on-dark { display: block; }
}
/* Strava guidelines: "View on Strava" links are Strava orange and bold. */
a.view-on-strava { color: #fc5200; font-weight: 700; text-decoration: underline; }

.foot { flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.foot nav { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.foot a { color: var(--muted); }
.link.danger { color: var(--loss); }

/* ---------- privacy page ---------- */
.prose { max-width: 680px; padding-top: 24px; padding-bottom: 24px; }
.prose h1 { font-size: 28px; margin: 8px 0 4px; }
.prose h2 { font-size: 18px; margin: 28px 0 8px; }
.prose li + li { margin-top: 6px; }
.progress .eta { font-size: 14px; font-weight: 600; }
.progress .leave-note {
  margin: 6px 0 0; padding: 8px 12px; border-radius: 8px; font-size: 13px;
  background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--ink);
}

/* "What this is" intro, kept on the dashboard after connecting */
.about { text-align: center; padding: 28px 0 4px; }
.about h1 { font-size: clamp(22px, 4.5vw, 30px); line-height: 1.15; margin: 0 0 8px; }
.about > p { max-width: 520px; margin: 0 auto; color: var(--muted); }
.about .steps { margin: 20px 0; text-align: left; }

/* A rival who's still on their first sync */
.row .sub.rival-sync { color: #a23a00; }
.row .sub.rival-sync.error { color: var(--loss); }
@media (prefers-color-scheme: dark) { .row .sub.rival-sync { color: #ffb07f; } }
.notice.sync-notice { background: #fff1e6; color: #a23a00; }
@media (prefers-color-scheme: dark) { .notice.sync-notice { background: #3b2414; color: #ffb07f; } }

/* Phones: keep the bigger title on one line — drop the name beside the avatar. */
@media (max-width: 560px) {
  .who > span { display: none; }
  .brand, .who .link { white-space: nowrap; }
}

/* Tab explanations and Shared segments sections */
.tab-intro { margin: 4px 0 12px; font-size: 14px; color: var(--muted); }
.seg-section { margin: 20px 0 8px; }
.seg-section h3 { margin: 0; font-size: 16px; display: flex; gap: 8px; align-items: baseline; }
.seg-hint { margin: 2px 0 4px; font-size: 13px; }
.show-all { margin: 12px 8px 0; }
.pill.held { background: #fff6d6; color: #7a5a00; }
@media (prefers-color-scheme: dark) { .pill.held { background: #3a3013; color: #f0d27a; } }

/* ---------- find friends ---------- */
.add-friends { display: flex; justify-content: center; margin: 16px 0 4px; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.request-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-decoration: none; background: #fff1e6; color: #a23a00; }
@media (prefers-color-scheme: dark) { .request-banner { background: #3b2414; color: #ffb07f; } }
.friends-section { margin-top: 28px; }
.friends-section h3 { margin: 0 0 4px; font-size: 16px; }
.friends-section .hint { margin: 0 0 8px; font-size: 13px; }
.person { display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; align-items: center; padding: 12px 8px; border-bottom: 1px solid var(--line); }
.person .name { font-weight: 600; }
.person .sub { font-size: 13px; color: var(--muted); }
.person-actions { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.requested { font-size: 13px; }
.toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.toggle input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
@media (max-width: 560px) {
  .person { grid-template-columns: 32px 1fr; }
  .person-actions { grid-column: 2; }
}

/* Logo on the landing page */
.hero-mark { display: block; margin: 0 auto 20px; width: clamp(128px, 34vw, 176px); height: auto; }
.about .hero-mark { width: clamp(104px, 26vw, 136px); margin-bottom: 14px; }
/* The tagline's line break is for wide screens; on phones let it wrap naturally. */
@media (max-width: 560px) { .hero h1 br, .about h1 br { display: none; } }
.notice.crown-lost { background: var(--loss-bg); color: var(--loss); }
.notice.crown-lost a { color: inherit; font-weight: 600; }
.lanterne { cursor: help; }
.progress .quip { font-size: 13px; font-style: italic; color: var(--muted); }
.delta .nose { font-size: 11px; font-style: italic; opacity: .85; white-space: nowrap; }
/* Paused or waiting: a still, dimmed bar (no motion that suggests work is happening). */
.meter.paused { opacity: .55; }
.meter.paused > span { transition: none; }
.brag { cursor: help; }

/* Your photo at the start of your stats, so they read as yours, not a group total */
.status .stats { align-items: center; }
.stat-who { display: flex; align-items: center; }
.avatar.stat-avatar { width: 44px; height: 44px; }
@media (max-width: 560px) { .avatar.stat-avatar { width: 36px; height: 36px; } }
