:root {
  --bg: #0b0f1a;
  --surface: #141a2b;
  --surface-2: #1b2338;
  --border: #232b40;
  --text: #e7ecf5;
  --muted: #9aa6bd;
  --accent: #22c55e;
  --accent-ink: #05130a;
  --amber: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: calc(58px + var(--safe-b));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb; --surface: #ffffff; --surface-2: #eef2f9; --border: #dde3ef;
    --text: #101828; --muted: #5a6478; --accent-ink: #05130a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }

/* ── top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  justify-content: space-between; padding: 12px 16px calc(12px);
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.mark {
  display: inline-grid; place-items: center; width: 26px; height: 26px;
  background: var(--accent); color: var(--accent-ink); border-radius: 8px; font-weight: 800;
}

/* ── layout ── */
.view { padding: 16px 16px calc(var(--tabbar-h) + 20px); max-width: 640px; margin: 0 auto; }
.loading { color: var(--muted); text-align: center; padding: 40px 0; }
h2.screen-title { font-size: 22px; margin: 4px 0 4px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

/* ── chips ── */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.chip-fresh { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.chip-stale { background: color-mix(in srgb, var(--amber) 20%, transparent); color: var(--amber); }
.chip-dead { background: color-mix(in srgb, var(--red) 20%, transparent); color: var(--red); }
.chip-info { background: color-mix(in srgb, var(--blue) 22%, transparent); color: var(--blue); }
.chip-muted { background: var(--surface-2); color: var(--muted); }

/* ── cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.card.tappable { cursor: pointer; transition: transform .08s ease, border-color .15s; }
.card.tappable:active { transform: scale(.99); border-color: var(--accent); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.match { font-weight: 700; font-size: 16px; line-height: 1.25; }
.meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.stat-row { display: flex; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-weight: 700; font-size: 18px; }
.v.pos { color: var(--accent); }

/* ── stake sheet / table ── */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.legs { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 340px; }
table.legs th, table.legs td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
table.legs th { color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 600; }
table.legs td.num { font-variant-numeric: tabular-nums; }

/* ── buttons ── */
.btn {
  appearance: none; border: 0; border-radius: 12px; background: var(--accent);
  color: var(--accent-ink); font-weight: 700; font-size: 15px; padding: 13px 16px;
  width: 100%; cursor: pointer;
}
.btn:active { filter: brightness(.94); }
.btn.btn-sm { width: auto; padding: 8px 14px; font-size: 13px; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.launch { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); text-align: left; }
.btn-ghost { background: transparent; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }

.disclaimer {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: 12.5px;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); line-height: 1.45;
}
.back { background: none; border: 0; color: var(--accent); font-size: 15px; padding: 4px 0; cursor: pointer; margin-bottom: 6px; }
.empty { text-align: center; color: var(--muted); padding: 44px 12px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ── big track-record hero ── */
.hero {
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; text-align: center; margin-bottom: 14px;
}
.hero .num { font-size: 46px; font-weight: 800; color: var(--accent); line-height: 1; }
.hero .lbl { color: var(--muted); font-size: 13px; margin-top: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.mini .k { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.mini .v { font-size: 22px; font-weight: 700; margin-top: 4px; }

/* ── forms ── */
label.field { display: block; margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
input.inp, select.inp {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 15px;
}
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ── tab bar ── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; height: var(--tabbar-h);
  padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tab {
  background: none; border: 0; color: var(--muted); font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer;
}
.tab span { font-size: 20px; }
.tab.active { color: var(--accent); }

/* ── toast + install ── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 14px);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 11px 16px; border-radius: 12px; font-size: 13px; z-index: 40; max-width: 90%;
}
.install-banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + 10px); z-index: 30;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.install-banner span { flex: 1; }
.countdown { font-variant-numeric: tabular-nums; }
