:root {
  --bg: #f5f6f8; --card: #fff; --line: #e4e7ec; --text: #10151c; --dim: #667085; --field: #f0f2f5;
  --yes: #06a773; --yes-bg: #e3f6ef; --no: #d93f4c; --no-bg: #fde9eb;
  --accent: #06a773; --warn-bg: #fff4d6; --warn: #8a5a00; --shadow: 0 1px 2px rgba(16,21,28,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14; --card: #151b23; --line: #232b36; --text: #eef1f5; --dim: #8b96a5; --field: #1d2530;
    --yes: #0ac285; --yes-bg: #0d3229; --no: #f0616d; --no-bg: #3a1a1f;
    --accent: #0ac285; --warn-bg: #33290d; --warn: #f2c14e; --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.loading { text-align: center; color: var(--dim); padding: 80px 0; }

#app { max-width: 560px; margin: 0 auto; padding: 0 14px calc(92px + env(safe-area-inset-bottom)); }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 2px 10px; }
.brand { font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand b { color: var(--accent); }
.cash { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.cash small { color: var(--dim); font-weight: 500; margin-right: 4px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--dim); font-weight: 600; padding: 6px 8px 6px 0; }
h1.page { font-size: 24px; letter-spacing: -.02em; margin: 4px 2px 14px; }
h2.sec { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); margin: 22px 2px 8px; }

/* chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 14px; font-weight: 600; color: var(--dim); white-space: nowrap; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { opacity: .6; margin-left: 4px; font-weight: 500; }
.chips.wrap { flex-wrap: wrap; overflow: visible; padding-bottom: 2px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.card[data-href] { cursor: pointer; }
.card-top { display: flex; gap: 12px; align-items: flex-start; }
.q { flex: 1; font-weight: 650; font-size: 16.5px; line-height: 1.3; letter-spacing: -.01em; overflow-wrap: anywhere; }
.big { text-align: right; font-size: 26px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.big small { display: block; font-size: 11px; font-weight: 500; color: var(--dim); letter-spacing: 0; margin-top: 3px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--field); color: var(--dim); }
.tag.secret { background: var(--warn-bg); color: var(--warn); }
.tag.won { background: var(--yes-bg); color: var(--yes); }
.tag.lost { background: var(--no-bg); color: var(--no); }
.yn { display: flex; gap: 8px; margin-top: 12px; }
.btn { flex: 1; min-height: 46px; border-radius: 12px; font-weight: 700; font-size: 15px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform .05s; }
.btn:active { transform: scale(.98); }
.btn.yes { background: var(--yes-bg); color: var(--yes); }
.btn.no { background: var(--no-bg); color: var(--no); }
.btn.solid { background: var(--accent); color: #fff; }
.btn.solid.no { background: var(--no); }
.btn.plain { background: var(--field); color: var(--text); }
.btn.small { flex: none; min-height: 34px; font-size: 13px; border-radius: 10px; padding: 0 12px; }
.btn:disabled { opacity: .45; }
.btn span { font-weight: 500; opacity: .85; }
.rows { margin-top: 10px; display: grid; gap: 6px; }
.row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 10px; background: var(--field); overflow: hidden; font-weight: 600; font-size: 14.5px; width: 100%; text-align: left; }
.row i { position: absolute; inset: 0 auto 0 0; background: var(--c); opacity: .22; }
.row > span { position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row > b { position: relative; font-variant-numeric: tabular-nums; }
.row.win { outline: 2px solid var(--yes); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 10px; font-size: 12.5px; color: var(--dim); }
.more { font-size: 12.5px; color: var(--dim); padding: 2px 4px 0; }
.banner { background: var(--warn-bg); color: var(--warn); border-radius: 14px; padding: 12px 14px; font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.empty { text-align: center; color: var(--dim); padding: 44px 20px; }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }
.empty .btn { margin-top: 16px; flex: none; }

/* avatars */
.av { flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; background: hsl(var(--h) 55% 45%); }
.av.s { width: 18px; height: 18px; font-size: 10px; }
.av.l { width: 40px; height: 40px; font-size: 17px; }

/* market page */
.mq { font-size: 22px; font-weight: 750; letter-spacing: -.02em; line-height: 1.25; margin: 4px 2px 0; overflow-wrap: anywhere; }
.headline { display: flex; align-items: baseline; gap: 8px; margin: 14px 2px 2px; }
.headline b { font-size: 38px; font-weight: 800; letter-spacing: -.03em; color: var(--yes); line-height: 1; }
.headline span { color: var(--dim); font-size: 14px; }
svg.chart { width: 100%; height: auto; display: block; margin: 6px 0 4px; }
svg.chart text { fill: var(--dim); font-size: 9px; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
.details { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; color: var(--dim); }
.pos { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; }
.pos + .pos { border-top: 1px solid var(--line); }
.pos small { display: block; color: var(--dim); font-size: 12.5px; }
.pos .r { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.list > * { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.list > * + * { border-top: 1px solid var(--line); }
.list .grow { flex: 1; min-width: 0; }
.list small { color: var(--dim); font-size: 12.5px; display: block; }
.list .r { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.up { color: var(--yes); } .down { color: var(--no); }
.msg { display: flex; gap: 10px; padding: 8px 0; align-items: flex-start; }
.msg p { overflow-wrap: anywhere; white-space: pre-wrap; font-size: 15px; }
.msg small { color: var(--dim); font-size: 12px; }
.say { display: flex; gap: 8px; margin-top: 8px; }
.resolved { border-radius: 14px; padding: 12px 14px; background: var(--yes-bg); color: var(--yes); font-weight: 700; margin: 12px 0 0; }
.resolved.cancelled { background: var(--field); color: var(--dim); }
.resolved small { display: block; font-weight: 500; opacity: .9; }
.link { color: var(--dim); text-decoration: underline; font-size: 13px; padding: 8px 2px; }

/* forms */
label.f { display: block; font-size: 13px; font-weight: 650; color: var(--dim); margin: 16px 2px 6px; }
input.in, textarea.in { width: 100%; background: var(--field); border: 1.5px solid transparent; border-radius: 12px; padding: 12px 14px; font-size: 16px; outline: none; }
input.in:focus, textarea.in:focus { border-color: var(--accent); }
textarea.in { resize: none; min-height: 84px; display: block; }
.hint { font-size: 12.5px; color: var(--dim); margin: 6px 2px 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--field); border-radius: 12px; padding: 3px; }
.seg button { padding: 10px; border-radius: 10px; font-weight: 650; font-size: 14.5px; color: var(--dim); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.opt { display: flex; gap: 8px; margin-bottom: 8px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--warn-bg); color: var(--warn); padding: 12px 14px; border-radius: 12px; margin-top: 10px; font-size: 14px; font-weight: 600; width: 100%; text-align: left; }
.toggle small { display: block; font-weight: 500; opacity: .85; }
.toggle i { flex: none; width: 44px; height: 26px; border-radius: 999px; background: var(--dim); position: relative; transition: background .15s; }
.toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle.on i { background: var(--accent); }
.toggle.on i::after { transform: translateX(18px); }
.submit { margin-top: 22px; width: 100%; }
.err { color: var(--no); font-size: 14px; font-weight: 600; margin-top: 12px; min-height: 20px; }

/* auth */
.auth { padding-top: 12vh; }
.auth h1 { font-size: 32px; letter-spacing: -.03em; }
.auth h1 b { color: var(--accent); }
.auth > p { color: var(--dim); margin: 6px 0 22px; }

/* profile + ranks */
.hero { text-align: center; padding: 10px 0 6px; }
.hero .net { font-size: 42px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero p { color: var(--dim); font-size: 14px; }
.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 14px 0 4px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; text-align: center; font-weight: 750; font-variant-numeric: tabular-nums; }
.stats small { display: block; color: var(--dim); font-weight: 500; font-size: 12px; }
.rank { width: 22px; text-align: center; font-weight: 800; color: var(--dim); }
.me-row { background: var(--field); margin: 0 -14px; padding-left: 14px !important; padding-right: 14px !important; }

/* tab bar */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 6px max(8px, calc(50vw - 280px)) calc(6px + env(safe-area-inset-bottom)); }
#tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--dim); padding: 4px 0; }
#tabs a.on { color: var(--text); }
#tabs svg, .back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#tabs a.plus { justify-self: center; width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #fff; justify-content: center; }
#tabs a.plus svg { width: 26px; height: 26px; stroke-width: 2.6; }

/* bottom sheet */
#sheet { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; background: var(--card); border-radius: 22px 22px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .18s ease-out; max-height: 92vh; overflow-y: auto; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { font-size: 15px; font-weight: 600; color: var(--dim); overflow-wrap: anywhere; }
.sheet .pick { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 12px; }
.amount { display: flex; align-items: center; background: var(--field); border-radius: 14px; padding: 0 16px; font-size: 30px; font-weight: 800; }
.amount input { flex: 1; min-width: 0; background: none; border: 0; outline: none; padding: 12px 6px; font-weight: 800; font-variant-numeric: tabular-nums; }
.amount small { font-size: 13px; font-weight: 600; color: var(--dim); }
.sheet .chips { padding: 10px 0 4px; }
.sheet .chip { flex: 1; text-align: center; background: var(--field); border: 0; color: var(--text); }
.sum { margin: 10px 0 14px; font-size: 14.5px; }
.sum div { display: flex; justify-content: space-between; padding: 5px 0; color: var(--dim); }
.sum b { color: var(--text); font-variant-numeric: tabular-nums; }
.sum .payout b { color: var(--yes); font-size: 17px; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 14px 0 0; }

#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; max-width: 90vw; text-align: center; }
