:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-elev-2: #1f232c;
  --line: #2a2f3a;
  --text: #eef0f4;
  --text-dim: #9aa3b2;
  --text-faint: #6b7385;
  --accent: #f5b83d;
  --accent-ink: #1b1405;
  --accent-soft: rgba(245, 184, 61, .14);
  --good: #4cc38a;
  --bad: #ef5b5b;
  --radius: 16px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }

/* layout */
.app { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 24px); }
.app.no-nav { padding-bottom: 32px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 18px; }
.topbar .sub { color: var(--text-dim); font-size: .9rem; margin-top: 2px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 26px 0 10px; }
.section-title h2 { font-size: 1rem; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

/* cards */
.card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.tight { padding: 12px 14px; }
.hero {
  background: radial-gradient(120% 140% at 0% 0%, rgba(245,184,61,.22), transparent 55%), var(--bg-elev);
  border: 1px solid var(--line); border-radius: 20px; padding: 20px;
}
.hero .big { font-size: 3rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.hero .unit { font-size: 1rem; color: var(--text-dim); font-weight: 500; margin-left: 6px; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat { background: rgba(255,255,255,.03); border-radius: var(--radius-sm); padding: 10px; }
.stat .v { font-size: 1.15rem; font-weight: 700; }
.stat .l { font-size: .75rem; color: var(--text-dim); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--bg-elev-2); color: var(--text);
  font: inherit; font-weight: 600; border-radius: 12px; padding: 12px 16px; min-height: 46px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  text-align: center; transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { background: transparent; color: var(--bad); border-color: rgba(239,91,91,.4); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { background: none; border: none; color: var(--text-dim); font-size: 1.1rem; padding: 8px; cursor: pointer; border-radius: 10px; min-width: 40px; min-height: 40px; }
.icon-btn:active { background: var(--bg-elev-2); }

/* forms */
label { display: block; font-size: .85rem; color: var(--text-dim); margin-bottom: 6px; }
.field + .field { margin-top: 14px; }
input[type=text], input[type=number], input[type=email], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 12px;
  padding: 12px 14px; font: inherit; font-size: 16px; min-height: 46px;
}
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.check { display: flex; align-items: center; gap: 12px; padding: 10px 0; color: var(--text); font-size: 1rem; margin: 0; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.hint { font-size: .8rem; color: var(--text-faint); margin-top: 6px; }

/* chips / segmented */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--bg-elev); color: var(--text-dim);
  border-radius: 999px; padding: 8px 14px; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; min-height: 38px;
}
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented button { border: none; background: transparent; color: var(--text-dim); font: inherit; font-weight: 600; padding: 9px 4px; border-radius: 9px; cursor: pointer; font-size: .9rem; }
.segmented button.active { background: var(--bg-elev-2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.04) inset; }

/* category tiles */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; color: var(--text);
  font: inherit; font-weight: 600; font-size: .9rem; min-height: 92px; justify-content: center;
}
.tile .emoji { font-size: 1.9rem; line-height: 1; }
.tile:active { transform: scale(.97); background: var(--bg-elev-2); }

/* lists */
.list { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: none; }
.list-item .emoji { font-size: 1.5rem; width: 34px; text-align: center; flex: none; }
.list-item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .meta { font-size: .82rem; color: var(--text-dim); }
.list-item.me { background: var(--accent-soft); }
a.list-item { color: inherit; }
.empty { text-align: center; padding: 28px 16px; color: var(--text-dim); }
.empty .emoji { font-size: 2.2rem; display: block; margin-bottom: 8px; }

/* leaderboard */
/* minmax(0, …) lets columns shrink below their content, so long names get an ellipsis instead of overflowing */
.podium { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr); align-items: end; gap: 8px; margin: 8px 0 16px; }
.podium .p { text-align: center; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.podium .bar {
  width: 100%; box-sizing: border-box; border-radius: 14px 14px 6px 6px; background: var(--bg-elev); border: 1px solid var(--line);
  padding: 8px 6px 10px; margin-top: 8px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px;
}
/* min-height (not height) so the content always fits; the difference just shows the podium steps */
.podium .p1 .bar { min-height: 112px; background: linear-gradient(180deg, rgba(245,184,61,.30), var(--bg-elev)); border-color: rgba(245,184,61,.5); }
.podium .p2 .bar { min-height: 92px; }
.podium .p3 .bar { min-height: 78px; }
.podium .medal { font-size: 1.3rem; line-height: 1.1; }
.podium .name { font-weight: 700; font-size: .85rem; line-height: 1.25; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.podium .val { font-size: .82rem; color: var(--text-dim); white-space: nowrap; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-elev-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; overflow: hidden; flex: none; color: var(--text-dim); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.podium .avatar { width: 52px; height: 52px; margin: 0 auto; }
.rank { width: 26px; text-align: center; color: var(--text-dim); font-weight: 700; flex: none; }
.value { font-weight: 700; text-align: right; }
.titles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.title-card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: .85rem; }
.title-card b { display: block; font-size: .95rem; }

/* badges */
.badge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.badge { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.badge .icon { font-size: 2rem; line-height: 1; }
.badge .name { font-weight: 700; }
.badge .desc { font-size: .82rem; color: var(--text-dim); }
.badge.locked .icon { filter: grayscale(1); opacity: .45; }
.badge.locked .name { color: var(--text-dim); }
.badge.earned { border-color: rgba(245,184,61,.45); background: linear-gradient(180deg, rgba(245,184,61,.10), var(--bg-elev) 60%); }
.progress { height: 6px; background: var(--bg-elev-2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.pill { display: inline-block; font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--bg-elev-2); color: var(--text-dim); }
.pill.good { background: rgba(76,195,138,.15); color: var(--good); }
.pill.bad { background: rgba(239,91,91,.15); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* bottom nav */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(15,17,21,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.bottom-nav .inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--nav-h); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-faint); font-size: .7rem; font-weight: 600; }
.bottom-nav a .i { font-size: 1.3rem; line-height: 1; filter: grayscale(1); opacity: .8; }
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a.active .i { filter: none; opacity: 1; }

/* sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-width: 560px; margin: 0 auto;
  background: var(--bg-elev); border-radius: 22px 22px 0 0; border: 1px solid var(--line); border-bottom: none;
  padding: 10px 16px calc(16px + var(--safe-b)); transform: translateY(105%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
  max-height: 88dvh; overflow-y: auto;
}
.sheet.open { transform: translateY(0); }
.sheet .grabber { width: 40px; height: 5px; background: var(--line); border-radius: 99px; margin: 0 auto 12px; }
.drink-options { display: flex; flex-direction: column; gap: 8px; }
.drink-option { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); cursor: pointer; color: var(--text); font: inherit; text-align: left; }
.drink-option.active { border-color: var(--accent); background: var(--accent-soft); }
.drink-option .emoji { font-size: 1.4rem; }
.stepper { display: flex; align-items: center; justify-content: space-between; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.stepper button { width: 46px; height: 42px; border-radius: 10px; border: none; background: var(--bg-elev-2); color: var(--text); font-size: 1.3rem; font-weight: 700; cursor: pointer; }
.stepper .val { font-size: 1.2rem; font-weight: 700; }

/* toast / flash */
.toast-wrap { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top, 0px) + 12px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: #232833; border: 1px solid #3a4150; color: var(--text); padding: 12px 16px; border-radius: 14px; box-shadow: 0 12px 32px rgba(0,0,0,.6); font-weight: 600; max-width: 520px; width: 100%; animation: toast-in .25s ease; opacity: 1; }
.toast .faint { color: #c3cad6; font-weight: 500; }
.toast.error { border-color: rgba(239,91,91,.5); }
.toast.success { border-color: rgba(76,195,138,.45); }
.toast.badge-toast { border: 1px solid var(--accent); background: #2e2614; box-shadow: 0 12px 32px rgba(0,0,0,.6), 0 0 0 1px rgba(245,184,61,.25); }
@keyframes toast-in { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; border: 1px solid var(--line); background: var(--bg-elev); font-weight: 500; }
.flash.error { border-color: rgba(239,91,91,.5); }
.flash.success { border-color: rgba(76,195,138,.45); }

/* misc */
.staging-ribbon { background: repeating-linear-gradient(45deg, #5a3d00, #5a3d00 10px, #6b4800 10px, #6b4800 20px); color: #ffd98a; text-align: center; font-size: .72rem; font-weight: 800; letter-spacing: .12em; padding: 3px; }
.login-wrap { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; max-width: 420px; margin: 0 auto; }
.brand { font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; }
.brand span { color: var(--accent); }
.google-btn { background: #fff; color: #1f1f1f; border-color: #fff; }
.google-btn svg { width: 20px; height: 20px; }
.footer-note { text-align: center; font-size: .75rem; color: var(--text-faint); margin-top: 28px; }
.chart-box { position: relative; height: 260px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th, table.data td { padding: 10px 8px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { color: var(--text-dim); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; border-top: none; }
.table-wrap { overflow-x: auto; }
details.card summary { cursor: pointer; font-weight: 600; list-style: none; }
details.card summary::-webkit-details-marker { display: none; }
details.card[open] summary { margin-bottom: 12px; }
.admin-nav { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 16px; scrollbar-width: none; }
.admin-nav::-webkit-scrollbar { display: none; }
pre.json { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px; font-size: .75rem; white-space: pre-wrap; word-break: break-all; max-height: 200px; overflow: auto; margin: 6px 0 0; }
.hidden { display: none !important; }
@media (min-width: 560px) { .badge-grid { grid-template-columns: repeat(3, 1fr); } }

/* drive-home check */
.ride-sheet { z-index: 55; text-align: center; padding-top: 10px; }
#ride-backdrop { z-index: 54; }
.ride-sheet h2 { font-size: 1.35rem; }
.ride-emoji { font-size: 2.6rem; line-height: 1; margin: 4px 0 10px; }
.ride-main { margin-top: 20px; min-height: 72px; font-size: 1.05rem; text-align: left; justify-content: flex-start; gap: 14px;
  box-shadow: 0 8px 28px rgba(245,184,61,.35); animation: ride-pulse 2.2s ease-in-out infinite; }
.ride-main .ride-icon { font-size: 2rem; }
.ride-main .ride-sub { font-weight: 500; font-size: .85rem; opacity: .8; }
@keyframes ride-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.02); } }
.ride-sheet.ride-danger { border-top: 4px solid var(--bad); background: #1d1214; }
.ride-sheet.ride-danger h2 { color: #ff8080; }
.ride-sheet.ride-warn { border-top: 4px solid var(--accent); }
#ride-result p { text-align: left; }
@media (prefers-reduced-motion: reduce) { .ride-main { animation: none; } }

/* legal pages (privacy policy, terms) */
.legal { line-height: 1.55; }
.legal h2 { font-size: 1.05rem; margin: 22px 0 8px; }
.legal h2:first-child { margin-top: 0; }
.legal p, .legal ul { margin: 0 0 10px; color: var(--text-dim); }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 4px; }
.legal b { color: var(--text); }
.legal a, .footer-note a { color: var(--accent); }

/* group emoji picker */
.emoji-chips { flex-wrap: wrap; margin: 4px 0 8px; }
.emoji-chips .chip { font-size: 1.15rem; padding: 4px 9px; }
.emoji-input { width: 5.5em; text-align: center; font-size: 1.2rem; }
