:root {
  --pine: #0F3D2E;
  --pine-text: #DCEBE2;
  --cream: #FBF6EC;
  --sand: #EDE5D3;
  --red: #B3102A;
  --gold: #F2C14E;
  --gold-dark: #3D2A05;
  --silver: #C9D1D6;
  --bronze: #C98A4B;
  --green: #2E8B57;
  --ink: #1B1B1B;
  --muted: #4A4A4A;
  --strava: #FC5200;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--pine); }
body {
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
h1, h2, .display { font-family: 'Fredoka', 'Nunito', sans-serif; }
button { font: inherit; cursor: pointer; }
a { color: inherit; }
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; overflow-x: hidden; }

.snow { position: absolute; inset: 0 0 auto 0; height: 300px; pointer-events: none; opacity: .18; }

/* ---------- welcome ---------- */
.welcome { min-height: 100vh; display: flex; flex-direction: column; position: relative; }
.welcome .top { padding: calc(64px + env(safe-area-inset-top)) 28px 80px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; position: relative; }
.eyebrow { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 14px; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); }
.welcome h1 { margin: 0; font-weight: 700; font-size: 40px; line-height: 1.02; color: #fff; }
.welcome .lead { margin: 0; font-size: 17px; color: var(--pine-text); max-width: 300px; }
.welcome .bottom { flex: 1; background: var(--cream); border-radius: 36px 36px 0 0; padding: 32px 24px 40px; display: flex; flex-direction: column; gap: 18px; }
.steps { display: flex; flex-direction: column; gap: 12px; }
.step { display: flex; gap: 12px; align-items: center; font-size: 15px; }
.step b.num { width: 32px; height: 32px; border-radius: 50%; background: var(--pine); color: #fff; font-family: 'Fredoka', sans-serif; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.btn { height: 56px; border-radius: 16px; font-weight: 800; font-size: 17px; text-decoration: none; display: flex; align-items: center; justify-content: center; border: 0; width: 100%; }
.btn.strava { background: var(--strava); color: #fff; }
.btn.outline { background: #fff; border: 2px solid var(--pine); color: var(--pine); height: 52px; font-size: 16px; }

/* ---------- pick ---------- */
.page { background: var(--cream); min-height: 100vh; padding: calc(20px + env(safe-area-inset-top)) 20px calc(32px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; }
.page h1 { margin: 0; font-weight: 700; font-size: 32px; color: var(--pine); }
.page p.sub { margin: 4px 0 0; font-size: 15px; color: var(--muted); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.pick { background: #fff; border: 3px solid transparent; border-radius: 18px; padding: 14px 6px; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--ink); }
.pick.me { background: #FFF4D6; border-color: var(--gold); }
.pick span.n { font-weight: 800; font-size: 14px; text-align: center; }
.note { background: #fff; border-radius: 16px; padding: 14px 16px; font-size: 14px; color: var(--muted); }
.link { background: none; border: 0; color: var(--pine); font-weight: 800; text-decoration: underline; padding: 12px 0; min-height: 44px; }

.avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: 'Fredoka', sans-serif; font-weight: 600; color: var(--ink); flex-shrink: 0; }

/* ---------- board ---------- */
.board-top { padding: calc(24px + env(safe-area-inset-top)) 20px 0; position: relative; display: flex; flex-direction: column; gap: 6px; }
.board-top .row { display: flex; justify-content: space-between; align-items: center; }
.pill { font-size: 13px; font-weight: 700; color: var(--pine-text); background: rgba(255,255,255,.12); padding: 6px 12px; border-radius: 999px; border: 0; min-height: 32px; }
.board-top h1 { margin: 0; font-weight: 700; font-size: 34px; line-height: 1.05; color: #fff; }
.board-top p { margin: 0; font-size: 15px; color: var(--pine-text); }
.board-top p strong { color: #fff; }

.podium { padding: 28px 16px 0; display: flex; align-items: flex-end; justify-content: center; gap: 8px; position: relative; }
.spot { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; background: none; border: 0; padding: 0; color: #fff; min-width: 0; }
.spot.first { flex: 1.15; }
.spot .who { text-align: center; }
.spot .nm { font-weight: 800; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
.spot.first .nm { font-size: 17px; }
.spot .km { font-size: 13px; color: var(--pine-text); }
.spot .km.done { color: var(--gold); font-weight: 700; }
.plinth { width: 100%; border-radius: 14px 14px 0 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.plinth .r { font-family: 'Fredoka', sans-serif; font-weight: 700; }
.plinth .pz { font-size: 12px; font-weight: 800; }
.spot.first .plinth { height: 132px; background: var(--gold); color: var(--gold-dark); }
.spot.first .plinth .r { font-size: 44px; }
.spot.second .plinth { height: 96px; background: var(--silver); color: #22313A; }
.spot.second .plinth .r { font-size: 32px; }
.spot.third .plinth { height: 76px; background: var(--bronze); color: #2E1907; }
.spot.third .plinth .r { font-size: 28px; }

.boardpage { min-height: 100vh; display: flex; flex-direction: column; position: relative; }
.sheet { background: var(--cream); border-radius: 28px 28px 0 0; margin-top: -4px; padding: 24px 16px calc(110px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; flex: 1; position: relative; }
.gift { background: #fff; border: 2px dashed var(--red); border-radius: 18px; padding: 14px 16px; display: flex; gap: 12px; align-items: center; }
.gift b { display: block; font-size: 15px; }
.gift span { font-size: 13px; color: var(--muted); }
.sheet h2 { margin: 8px 0 0; font-weight: 600; font-size: 20px; color: var(--pine); }
.row-card { background: #fff; border-radius: 16px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; box-shadow: 0 1px 0 rgba(15,61,46,.08); border: 0; width: 100%; text-align: left; color: var(--ink); }
.row-card.me { outline: 3px solid var(--gold); }
.row-card .rk { width: 22px; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 17px; color: #5B6B63; text-align: center; }
.row-card .body { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.row-card .line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 800; font-size: 15px; }
.row-card .line .k { color: var(--pine); white-space: nowrap; }
.bar { height: 10px; background: var(--sand); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 10px; background: var(--green); border-radius: 999px; }
.bar i.gold { background: var(--gold); }
.row-card small { font-size: 12px; color: #5B5B5B; }
.empty { text-align: center; color: var(--muted); padding: 24px; }

.mebar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); width: calc(100% - 32px); max-width: 448px; background: var(--red); color: #fff; border-radius: 18px; padding: 8px; display: flex; align-items: center; gap: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 4; }
.mebtn { flex: 1; display: flex; align-items: center; gap: 12px; background: none; border: 0; color: #fff; text-align: left; padding: 4px 8px; min-height: 48px; text-decoration: none; min-width: 0; }
.mebar .t { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mebar .t b { font-size: 15px; }
.mebar .t span { font-size: 13px; color: #FFE3A3; }
.logbtn { display: flex; align-items: center; gap: 4px; background: var(--gold); color: var(--gold-dark); font-weight: 800; font-size: 16px; text-decoration: none; border-radius: 14px; padding: 0 16px; height: 52px; flex-shrink: 0; }
.toast { position: fixed; top: calc(16px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); background: var(--gold); color: var(--gold-dark); font-weight: 800; padding: 12px 18px; border-radius: 999px; box-shadow: 0 6px 18px rgba(0,0,0,.25); z-index: 6; animation: pop 3.2s ease forwards; white-space: nowrap; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -10px); } 8% { opacity: 1; transform: translate(-50%, 0); } 85% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------- forms ---------- */
.btn.primary { background: var(--red); color: #fff; gap: 6px; }
.btn.strava { gap: 6px; }
.back.dark { color: var(--pine); align-self: flex-start; }
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 14px; color: var(--pine); }
.field input { font: inherit; font-weight: 600; font-size: 17px; padding: 14px; border-radius: 14px; border: 2px solid #D9CFB8; background: #fff; color: var(--ink); min-height: 52px; width: 100%; }
.field input:focus, select:focus { outline: 3px solid var(--gold); border-color: var(--pine); }
.kmwrap { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid #D9CFB8; border-radius: 18px; padding: 6px 16px; }
.kmwrap:focus-within { outline: 3px solid var(--gold); border-color: var(--pine); }
.kmwrap input { border: 0; outline: 0; font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 48px; padding: 4px 0; min-height: 0; color: var(--pine); }
.kmwrap input:focus { outline: 0; }
.kmwrap b { font-family: 'Fredoka', sans-serif; font-size: 24px; color: var(--muted); }
.chips { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips legend { font-weight: 800; font-size: 14px; color: var(--pine); margin-bottom: 8px; padding: 0; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; background: #fff; border: 2px solid #D9CFB8; font-weight: 800; font-size: 15px; color: var(--ink); }
.chip input:checked + span { background: var(--pine); border-color: var(--pine); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid var(--gold); }
.chips select { font: inherit; font-weight: 700; min-height: 44px; border-radius: 12px; border: 2px solid #D9CFB8; background: #fff; padding: 0 10px; color: var(--ink); }
.err { margin: 0; color: #8A0C20; font-weight: 700; min-height: 1em; }
.err:empty { display: none; }
.id-row { display: flex; gap: 14px; align-items: center; }
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.log li { background: #fff; border-radius: 14px; padding: 10px 12px; display: flex; gap: 12px; align-items: center; }
.log .when { font-family: 'Fredoka', sans-serif; font-weight: 600; color: var(--pine); width: 52px; flex-shrink: 0; }
.log .what { flex: 1; display: flex; flex-direction: column; font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.log small { color: #5B5B5B; font-size: 12px; }
.mini { background: none; border: 2px solid #D9CFB8; border-radius: 10px; font-weight: 800; font-size: 13px; color: #8A0C20; min-height: 40px; padding: 0 10px; }
.actions { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

/* ---------- person ---------- */
.person { background: var(--cream); min-height: 100vh; }
.person .head { background: var(--red); padding: calc(16px + env(safe-area-inset-top)) 20px 28px; display: flex; flex-direction: column; gap: 16px; border-radius: 0 0 28px 28px; color: #fff; }
.back { color: #fff; font-weight: 800; font-size: 15px; background: none; border: 0; display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0; }
.person .id { display: flex; gap: 16px; align-items: center; }
.person .id .nm { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 28px; }
.person .id .st { font-size: 14px; font-weight: 700; color: #FFE3A3; }
.total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.total .big { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 40px; }
.total .big small { font-size: 18px; }
.total .to { font-size: 14px; font-weight: 700; text-align: right; }
.track { height: 14px; background: rgba(255,255,255,.25); border-radius: 999px; position: relative; }
.track i { display: block; height: 14px; background: var(--gold); border-radius: 999px; }
.track .mark { position: absolute; left: 50%; top: -4px; width: 3px; height: 22px; background: #fff; border-radius: 2px; }
.scale { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: #FFE3A3; }
.cal { padding: 24px 20px 40px; display: flex; flex-direction: column; gap: 14px; }
.cal .hd { display: flex; justify-content: space-between; align-items: baseline; }
.cal h2 { margin: 0; font-weight: 600; font-size: 22px; color: var(--pine); }
.cal .hd span { font-size: 13px; color: var(--muted); }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tile { height: 88px; border-radius: 16px; padding: 8px; display: flex; flex-direction: column; justify-content: space-between; background: #EFE8D8; color: #5B5B5B; border: 2px solid transparent; }
.tile .d { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 20px; }
.tile .l { font-size: 13px; font-weight: 800; }
.tile.ran { background: var(--green); color: #fff; }
.tile.rest { background: #fff; }
.tile.today { background: #FFF4D6; color: var(--gold-dark); border-color: #E0A82E; }
.tile.today.ran { background: var(--green); color: #fff; border-color: var(--gold); }
.tile.finish { background: var(--red); color: #fff; }
.cal p { margin: 0; font-size: 13px; color: var(--muted); }
.demo { position: fixed; top: calc(8px + env(safe-area-inset-top)); right: 8px; background: var(--gold); color: var(--gold-dark); font-weight: 800; font-size: 12px; padding: 4px 10px; border-radius: 999px; z-index: 5; }
.sub.center { text-align: center; margin: 0; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 700; }
.or::before, .or::after { content: ""; flex: 1; height: 2px; background: #E3D9C3; }

/* ---------- pull to refresh ---------- */
html, body { overscroll-behavior-y: contain; }
.ptr { position: fixed; left: 50%; top: calc(8px + env(safe-area-inset-top)); width: 40px; height: 40px; margin-left: -20px; border-radius: 50%; background: var(--gold); color: var(--gold-dark); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(0,0,0,.25); z-index: 7; opacity: 0; transform: translateY(-60px); pointer-events: none; }
.ptr.go svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ptr.go svg { animation: none; } }

/* ---------- welcome fits one screen on shorter phones ---------- */
.welcome { min-height: 100vh; min-height: 100dvh; }
.welcome .top { padding: calc(clamp(16px, 5dvh, 64px) + env(safe-area-inset-top)) 24px clamp(24px, 6dvh, 80px); gap: clamp(6px, 1.4dvh, 14px); }
.welcome .top > svg { width: clamp(56px, 10dvh, 92px); height: clamp(56px, 10dvh, 92px); }
.welcome h1 { font-size: clamp(28px, 4.8dvh, 40px); }
.welcome .lead { font-size: clamp(15px, 2.1dvh, 17px); }
.welcome .bottom { padding: clamp(18px, 3.4dvh, 32px) 24px calc(clamp(16px, 3.5dvh, 40px) + env(safe-area-inset-bottom)); gap: clamp(10px, 1.9dvh, 18px); }
.welcome .steps { gap: clamp(6px, 1.3dvh, 12px); }
.welcome .btn { height: clamp(48px, 6.5dvh, 56px); }
.welcome .link { padding: 6px 0; }
.welcome .logo { width: auto; height: clamp(150px, 28dvh, 320px); max-width: 88%; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0,0,0,.25)); }
.welcome h1 { font-size: clamp(24px, 3.9dvh, 34px); }
.welcome .top { padding-bottom: clamp(20px, 4.5dvh, 64px); }
@media (max-height: 680px) {
  .welcome .logo { height: 150px; }
  .welcome h1 { font-size: 22px; }
  .welcome .step { font-size: 14px; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
