:root {
  --bg: #0b0f14;
  --panel: #131a22;
  --panel-2: #1a232e;
  --line: #253141;
  --text: #e8eef5;
  --muted: #8ea0b5;
  --brand: #fc4c02;   /* Strava orange */
  --gold: #ffd54a;
  --silver: #c9d3de;
  --bronze: #d99058;
  --swim: #38bdf8;
  --bike: #34d399;
  --run: #f472b6;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(11,15,20,0.9);
  backdrop-filter: blur(8px); z-index: 10;
}
.brand { color: var(--text); font-weight: 800; letter-spacing: 0.5px; text-decoration: none; font-size: 1.1rem; }
.user-slot { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; color: var(--muted); }
.user-slot img { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); }

.app { max-width: 760px; margin: 0 auto; padding: 20px 16px 60px; }

/* ---- generic ---- */
h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 26px 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.row { display: flex; gap: 12px; align-items: center; }
.spread { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 11px 16px; border-radius: 10px; font-weight: 600; font-size: 0.95rem;
  cursor: pointer; text-decoration: none; transition: transform .05s ease, filter .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.strava { background: var(--brand); border-color: var(--brand); color: #fff; font-size: 1.05rem; padding: 14px 22px; }
.btn.ghost { background: transparent; }
.btn:hover { filter: brightness(1.08); }
.btn.block { width: 100%; }

/* ---- forms ---- */
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 14px 0 6px; }
input, select {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-size: 1rem;
}
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.hint { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

/* ---- countdown ---- */
.countdown { display: flex; gap: 10px; justify-content: center; margin: 10px 0 4px; }
.cd-unit { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 70px; text-align: center; }
.cd-num { font-size: 1.8rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cd-label { font-size: 0.7rem; text-transform: uppercase; color: var(--muted); letter-spacing: 1px; }

/* ---- leaderboard ---- */
.lb-row {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center;
  gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 8px; background: var(--panel-2);
}
.lb-rank { font-size: 1.2rem; font-weight: 800; text-align: center; }
.lb-name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.lb-name img { width: 26px; height: 26px; border-radius: 50%; }
.lb-score { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-sub { font-size: 0.78rem; color: var(--muted); margin-top: 3px; }
.rank-1 { border-color: var(--gold); }
.rank-2 { border-color: var(--silver); }
.rank-3 { border-color: var(--bronze); }
.dunce { border-color: #5a4020; }

.pill { display: inline-block; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.swim { color: var(--swim); } .bike { color: var(--bike); } .run { color: var(--run); } .weight { color: #f59e0b; }

/* ---- day breakdown ---- */
.day { border-top: 1px solid var(--line); padding: 10px 0; }
.day-date { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.day-entries { display: flex; flex-wrap: wrap; gap: 8px; }
.day-chip { font-size: 0.82rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.day-chip.zero { opacity: 0.45; }

/* ---- invite box ---- */
.invite { display: flex; gap: 8px; }
.invite input { font-size: 0.85rem; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px;
  border-radius: 10px; font-size: 0.9rem; opacity: 0; transition: opacity .2s; z-index: 50;
}
.toast.show { opacity: 1; }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.spinner { text-align: center; padding: 40px; color: var(--muted); }
a.link { color: var(--swim); }

@media (max-width: 480px) {
  .grid-3 { grid-template-columns: 1fr; }
  .cd-unit { min-width: 60px; padding: 10px; }
  .cd-num { font-size: 1.5rem; }
}
