/* Callkit engine UI: dark, big one-thumb targets. Each app sets its brand color, fonts and
   background in css/theme.css (generated from brand.js). Phase tones color the calls:
   green = racing/in the match, yellow = caution, red = big moments, white = everything else. */
:root {
  --bg: #0b0c0f;
  --surface: #15171c;
  --surface-2: #1d2027;
  --surface-3: #262a33;
  --line: #2c313b;
  --text: #f3f4f6;
  --muted: #a1a8b3;
  --dim: #6f7682;
  --brand: #ffd23f;        /* overridden by theme.css */
  --brand-ink: #1a1400;
  --caution: #ffd23f;
  --green: #22c55e;
  --green-ink: #03140a;
  --red: #ff5a5a;
  --blue: #5aa9ff;
  --radius: 16px;
  --radius-sm: 10px;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 var(--body); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- type ---------- */
.display { font-family: var(--display); font-weight: 800; letter-spacing: .01em; line-height: .95; text-transform: uppercase; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; text-transform: uppercase; letter-spacing: .01em; line-height: 1; margin: 0 0 .4em; }
h1 { font-size: 40px; }
h2 { font-size: 26px; }
h3 { font-size: 19px; }
.eyebrow { font: 700 13px/1 var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.num { font-family: var(--display); font-weight: 800; font-variant-numeric: tabular-nums; }
.accent { color: var(--brand); }
.green { color: var(--green); }
.red { color: var(--red); }

/* ---------- layout ---------- */
.wrap { max-width: 520px; margin: 0 auto; padding: 0 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.mt0 { margin-top: 0 !important; }
.mt { margin-top: 16px; }
.mt2 { margin-top: 28px; }
.mb0 { margin-bottom: 0 !important; }

/* checkered strip */
.checker {
  height: 10px;
  background: repeating-conic-gradient(#f3f4f6 0 25%, #0b0c0f 0 50%) 0 0 / 10px 10px;
  opacity: .9;
}

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.tight { padding: 12px 14px; }
.card.flat { background: transparent; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); font: 700 13px/1.2 var(--display);
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
.chip.live { color: var(--green-ink); background: var(--green); border-color: var(--green); }
.chip.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green-ink); animation: blink 1.2s infinite; }
.chip.accent { color: var(--brand-ink); background: var(--brand); border-color: var(--brand); }
.chip.tone-yellow { color: #1a1400; background: var(--caution); border-color: var(--caution); }
.chip.tone-red { color: #fff; background: var(--red); border-color: var(--red); }
.chip.tone-green { color: var(--green); border-color: rgba(34, 197, 94, .45); }
.chip.sponsor { text-transform: none; letter-spacing: 0; font: 500 12px/1.2 var(--body); }
@keyframes blink { 50% { opacity: .25; } }

.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 20px;
  border-radius: 14px; border: 0; background: var(--brand); color: var(--brand-ink); cursor: pointer;
  font: 800 20px/1 var(--display); letter-spacing: .04em; text-transform: uppercase; text-decoration: none;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.green { background: var(--green); color: var(--green-ink); }
.btn.red { background: transparent; color: var(--red); border: 1px solid #5a2a2a; }
.btn.sm { min-height: 40px; font-size: 16px; padding: 0 14px; border-radius: 10px; }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; text-decoration: underline; font: inherit; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2);
  display: inline-grid; place-items: center; cursor: pointer; color: var(--text); font-size: 18px;
}

/* ---------- forms ---------- */
label.field { display: block; }
label.field > span { display: block; margin-bottom: 6px; font: 700 14px/1 var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); outline: none; font-size: 17px;
}
.input:focus { border-color: var(--brand); }
textarea.input { min-height: 80px; resize: vertical; }
.err { color: var(--red); font-size: 14px; min-height: 1em; }

/* segmented control */
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button {
  flex: 1; min-height: 40px; border: 0; background: transparent; border-radius: 9px; cursor: pointer; color: var(--muted);
  font: 700 15px/1 var(--display); letter-spacing: .06em; text-transform: uppercase;
}
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }

/* ---------- app shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(11, 12, 15, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 10px; height: 56px; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.logo b { font: 800 24px/1 var(--display); letter-spacing: .02em; text-transform: uppercase; }
.logo svg { width: 28px; height: 28px; }
.score-pill { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.score-pill .num { font-size: 22px; color: var(--brand); }

main.app { padding: 16px 0 calc(96px + var(--safe-b)); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(15, 16, 20, .96);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b); backdrop-filter: blur(10px);
}
.tabbar .wrap { display: flex; padding: 0 4px; }
.tabbar button {
  flex: 1; min-height: 62px; border: 0; background: none; color: var(--dim); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font: 700 12px/1 var(--display); letter-spacing: .08em; text-transform: uppercase;
}
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button[aria-current="page"] { color: var(--brand); }

/* ---------- race header ---------- */
.racehead { padding: 16px; border-radius: var(--radius); background:
  linear-gradient(160deg, color-mix(in srgb, var(--brand) 10%, transparent), transparent 55%), var(--surface); border: 1px solid var(--line); }
.racehead h2 { font-size: 30px; margin: 6px 0 2px; }
.racehead .meta { color: var(--muted); font-size: 15px; }
.countdown { display: flex; gap: 10px; margin-top: 14px; }
.countdown div { flex: 1; text-align: center; background: var(--surface-2); border-radius: 12px; padding: 10px 4px; }
.countdown .num { font-size: 32px; display: block; }
.countdown small { font: 700 11px/1 var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }

/* ---------- calls ---------- */
.call { position: relative; border-radius: 20px; padding: 18px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.call.open { border-color: var(--green); box-shadow: 0 0 0 1px var(--green), 0 10px 40px rgba(34, 197, 94, .12); }
.call.tone-yellow.open { border-color: var(--caution); box-shadow: 0 0 0 1px var(--caution), 0 10px 40px rgba(255, 210, 63, .12); }
.call.tone-red.open { border-color: var(--red); box-shadow: 0 0 0 1px var(--red), 0 10px 40px rgba(255, 90, 90, .14); }
.call .top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.call .q { font: 800 30px/1.02 var(--display); text-transform: uppercase; margin: 0 0 14px; letter-spacing: .005em; }
.call.compact .q { font-size: 21px; margin-bottom: 8px; }
.call .tip { margin-top: 12px; font-size: 14px; color: var(--muted); border-left: 3px solid var(--brand); padding-left: 10px; }
.opts { display: grid; gap: 10px; }
.opt {
  position: relative; width: 100%; min-height: 58px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface-2);
  color: var(--text); cursor: pointer; text-align: left; padding: 12px 16px; overflow: hidden;
  font: 800 21px/1.05 var(--display); text-transform: uppercase; letter-spacing: .02em;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.opt:active { transform: scale(.99); }
.opt[disabled] { cursor: default; }
.opt .fill { position: absolute; inset: 0 auto 0 0; background: rgba(255, 255, 255, .07); width: 0; transition: width .6s ease; z-index: 0; }
.opt > span { position: relative; z-index: 1; }
.opt .pct { font-size: 18px; color: var(--muted); }
.opt.mine { border-color: var(--brand); }
.opt.mine .fill { background: color-mix(in srgb, var(--brand) 18%, transparent); }
.opt.right { border-color: var(--green); }
.opt.right .fill { background: rgba(34, 197, 94, .22); }
.opt.wrong.mine { border-color: var(--red); }
.opt.wrong.mine .fill { background: rgba(255, 90, 90, .16); }
.opt .tag { font: 700 12px/1 var(--display); letter-spacing: .1em; padding: 4px 6px; border-radius: 6px; background: var(--brand); color: var(--brand-ink); margin-left: 8px; vertical-align: middle; }

.ring { width: 54px; height: 54px; margin-left: auto; position: relative; flex: none; }
.ring svg { width: 54px; height: 54px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring .bg { stroke: var(--surface-3); }
.ring .fg { stroke: var(--green); stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke .3s; }
.ring.hurry .fg { stroke: var(--red); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 800 20px/1 var(--display); }

.result { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.result .num { font-size: 26px; }
.result.win { background: rgba(34, 197, 94, .12); }
.result.calledit { background: linear-gradient(90deg, color-mix(in srgb, var(--brand) 25%, transparent), color-mix(in srgb, var(--brand) 5%, transparent)); }

.feed { font-size: 15px; }
.feed li { padding: 8px 0; border-bottom: 1px solid var(--line); list-style: none; display: flex; gap: 10px; }
.feed ul { margin: 0; padding: 0; }
.feed .lap { font: 800 15px/1.4 var(--display); color: var(--brand); min-width: 64px; }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .big { font: 800 28px/1 var(--display); text-transform: uppercase; color: var(--text); margin-bottom: 8px; }

/* ---------- lists / boards ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); min-height: 56px; }
.li:first-child { border-top: 0; }
.li.me { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.li .rank { width: 30px; text-align: center; font: 800 20px/1 var(--display); color: var(--dim); }
.li .rank.top { color: var(--brand); }
.li .name { font-weight: 600; }
.li .sub { font-size: 13px; color: var(--dim); }
.li .pts { margin-left: auto; text-align: right; font: 800 22px/1 var(--display); }
.li button.rowbtn { all: unset; display: contents; cursor: pointer; }
.ebadge {
  min-width: 38px; height: 30px; padding: 0 6px; border-radius: 8px; display: inline-grid; place-items: center;
  background: var(--surface-3); font: 800 18px/1 var(--display); font-style: italic; color: var(--text);
}
.ebadge.lg { min-width: 54px; height: 44px; font-size: 26px; border-radius: 10px; }

/* driver picker */
.drivers { display: grid; gap: 8px; max-height: 46vh; overflow: auto; padding-right: 2px; }
.driver {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--surface-2); cursor: pointer; text-align: left; color: var(--text); width: 100%;
}
.driver[aria-pressed="true"] { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, transparent); }
.driver .meta { font-size: 13px; color: var(--dim); }

/* ---------- bottom sheet ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(20px + var(--safe-b)); animation: up .22s ease;
}
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 0 auto 14px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; max-width: 90vw;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .4); animation: up .2s ease;
}

/* onboarding */
.onboard { min-height: 100vh; display: flex; flex-direction: column; padding: 24px 0 calc(24px + var(--safe-b)); }
.onboard .wrap { flex: 1; display: flex; flex-direction: column; width: 100%; }
.onboard .foot { margin-top: auto; padding-top: 20px; }
.steps { display: flex; gap: 6px; margin-bottom: 22px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); }
.steps i.on { background: var(--brand); }
.how { display: grid; gap: 12px; margin: 18px 0; }
.how div { display: flex; gap: 14px; align-items: flex-start; }
.how .n { flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font: 800 20px/1 var(--display); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: var(--surface-2); border-radius: 12px; padding: 12px 6px; text-align: center; }
.stats .num { font-size: 28px; display: block; }
.stats small { font: 700 11px/1 var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }

.gloss dt { font: 800 18px/1.2 var(--display); text-transform: uppercase; margin-top: 14px; }
.gloss dd { margin: 4px 0 0; color: var(--muted); }

/* points burst */
.burst { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; pointer-events: none; }
.burst div { font: 800 64px/1 var(--display); color: var(--brand); text-shadow: 0 6px 30px rgba(0, 0, 0, .6); animation: pop 1.4s ease forwards; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 20% { transform: scale(1.1); opacity: 1; } 70% { opacity: 1; } 100% { transform: translateY(-80px) scale(.9); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- web pages (landing, legal) ---------- */
.site-nav { display: flex; align-items: center; gap: 12px; height: 64px; }
.site-nav .sp { flex: 1; }
.hero { padding: 36px 0 28px; }
.hero h1 { font-size: clamp(46px, 13vw, 84px); line-height: .9; }
.hero p.lede { font-size: 19px; color: var(--muted); max-width: 34em; }
.prose { max-width: 720px; }
.prose h2 { margin-top: 1.6em; }
.prose p, .prose li { color: #d7dbe1; }
.foot-legal { color: var(--dim); font-size: 13px; padding: 28px 0 40px; border-top: 1px solid var(--line); margin-top: 40px; }
.foot-legal a { color: var(--muted); }

/* ---------- race control ---------- */
.rc-grid { display: grid; gap: 20px; }
@media (min-width: 900px) { .rc-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.rc-grid .call .q { font-size: 22px; }
.chip.red { color: var(--red); border-color: #5a2a2a; }
details.tip summary { cursor: pointer; color: var(--brand); font-weight: 600; }

/* ---------- landing page ---------- */
.lp section { padding: 34px 0; }
.lp .grid3 { display: grid; gap: 12px; }
@media (min-width: 760px) {
  .lp .wrap { max-width: 1040px; }
  .lp .grid3 { grid-template-columns: repeat(3, 1fr); }
  .lp .split { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; }
}
.phone { max-width: 360px; margin: 0 auto; border: 1px solid var(--line); border-radius: 32px; padding: 14px; background: #08090b; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.feature .n { font: 800 44px/1 var(--display); color: var(--brand); }
.picks { display: grid; gap: 8px; }
.picks label { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 8px; }
.picks b { font: 800 24px/1 var(--display); color: var(--brand); text-align: center; }
#sample img { width: 100%; max-width: 380px; border-radius: 18px; margin: 0 auto; border: 1px solid var(--line); }
.faq dt { font: 800 20px/1.2 var(--display); text-transform: uppercase; margin-top: 18px; }
.faq dd { margin: 6px 0 0; color: var(--muted); }
