/* Ramal — ASEAN prediction game POC. Mobile-first, warm, game-forward (not casino). */
:root {
  --bg:        #f6f1e9;
  --bg-2:      #efe7da;
  --surface:   #fffdf9;
  --ink:       #241f1a;
  --ink-soft:  #6b6157;
  --line:      #e7ddcd;
  --brand:     #c8512b;   /* warm terracotta */
  --brand-2:   #e2884f;
  --gold:      #d8a13a;
  --yes:       #2f8f6b;
  --yes-soft:  #e4f1ea;
  --no:        #c0533f;
  --no-soft:   #f6e6e1;
  --shadow:    0 1px 2px rgba(60,40,20,.06), 0 8px 24px rgba(60,40,20,.07);
  --shadow-lg: 0 6px 14px rgba(60,40,20,.10), 0 24px 48px rgba(60,40,20,.14);
  --radius:    18px;
  --maxw:      560px;
  font-synthesis: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
img.emoji { height: 1em; width: 1em; margin: 0 .04em 0 .08em; vertical-align: -0.12em; display: inline-block; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #fbf4e8 0%, var(--bg) 55%),
    var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(108px + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; }

.app { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(180deg, rgba(246,241,233,.96), rgba(246,241,233,.82));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: var(--maxw); margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 12px; }
.logo { display: flex; align-items: center; gap: 8px; font-family: 'Fraunces', serif; font-weight: 600; font-size: 19px; }
.logo .dot { width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--brand-2), var(--brand)); box-shadow: 0 4px 10px rgba(200,81,43,.35); font-size: 15px; }
.logo small { font-family: 'Inter', sans-serif; font-weight: 600; font-size: 9px; letter-spacing: .14em; color: var(--ink-soft); text-transform: uppercase; margin-top: 2px; }
.balance { margin-left: auto; text-align: right; }
.balance .amt { display: flex; align-items: center; gap: 5px; justify-content: flex-end; font-weight: 700; font-size: 16px; }
.balance .lbl { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.coin { color: var(--gold); }
.play-pill { font-size: 9px; font-weight: 700; letter-spacing: .1em; color: var(--yes); background: var(--yes-soft);
  padding: 2px 7px; border-radius: 999px; text-transform: uppercase; }

/* ---------- views ---------- */
.view { display: none; padding-top: 16px; animation: rise .28s ease both; }
.view.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { margin: 6px 2px 14px; }
.page-head h1 { font-size: 26px; }
.page-head p { margin: 4px 0 0; color: var(--ink-soft); font-size: 13.5px; }

/* ---------- category chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; padding: 7px 13px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--ink-soft); transition: .15s; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- market cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px; transition: transform .12s ease, box-shadow .12s ease; }
.card:active { transform: scale(.992); }
.card.tap { cursor: pointer; }
.card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cat { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; letter-spacing: .03em;
  padding: 3px 9px; border-radius: 999px; text-transform: uppercase; }
.flag { font-size: 20px; margin-left: auto; }
.q { font-family: 'Fraunces', serif; font-size: 17px; font-weight: 600; line-height: 1.25; }

.odds { margin-top: 14px; }
.odds-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; font-size: 13.5px; }
.odds-row .name { font-weight: 600; }
.odds-row .pct { font-weight: 800; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 999px; background: var(--bg-2); overflow: hidden; margin-bottom: 12px; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand-2), var(--brand)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.bar.yes > span { background: linear-gradient(90deg, #4bbd90, var(--yes)); }

.binary { display: flex; gap: 8px; margin-top: 4px; }
.binary button { flex: 1; border-radius: 13px; padding: 11px; font-weight: 700; font-size: 14px; border: 1.5px solid var(--line); background: var(--surface); transition: .12s; }
.binary .b-yes { color: var(--yes); border-color: #bfe3d2; background: var(--yes-soft); }
.binary .b-no  { color: var(--no);  border-color: #eccdc4; background: var(--no-soft); }
.binary button:active { transform: scale(.97); }
.binary button .p { display: block; font-size: 11px; font-weight: 700; opacity: .75; margin-top: 1px; }

.meta { display: flex; gap: 14px; margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-soft); }
.meta b { color: var(--ink); font-weight: 700; }
.trend.up { color: var(--yes); font-weight: 700; }
.trend.down { color: var(--no); font-weight: 700; }

/* ---------- detail ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink-soft); font-size: 13.5px; margin: 4px 0 12px; }
.detail-q { font-size: 22px; margin: 8px 0 6px; }
.detail-blurb { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 14px; }
.chart-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 12px 10px; box-shadow: var(--shadow); margin-bottom: 14px; }
.chart-head { display: flex; align-items: baseline; gap: 10px; padding: 0 4px 8px; }
.chart-head .big { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.chart-head .lbl { color: var(--ink-soft); font-size: 12px; font-weight: 600; }
svg.spark { display: block; width: 100%; height: 120px; }

.resolve-box { background: var(--bg-2); border-radius: 14px; padding: 13px 14px; font-size: 13px; margin-bottom: 14px; }
.resolve-box .row { display: flex; gap: 8px; margin-bottom: 6px; }
.resolve-box .row:last-child { margin-bottom: 0; }
.resolve-box .k { color: var(--ink-soft); min-width: 92px; }
.resolve-box .v { font-weight: 600; }

/* ---------- bet slip (sheet) ---------- */
.sheet-scrim { position: fixed; inset: 0; background: rgba(40,28,18,.42); z-index: 60; opacity: 0; pointer-events: none; transition: .22s; }
.sheet-scrim.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; background: var(--surface); border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg); padding: 18px 18px calc(20px + env(safe-area-inset-bottom)); transform: translateY(110%); transition: transform .28s cubic-bezier(.2,.85,.2,1); max-width: var(--maxw); margin: 0 auto; }
.sheet.open { transform: none; }
.sheet .grab { width: 40px; height: 4px; border-radius: 999px; background: var(--line); margin: -4px auto 14px; }
.sheet h3 { font-size: 18px; }
.sheet .sub { color: var(--ink-soft); font-size: 13px; margin: 2px 0 14px; }
.outcome-pick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.outcome-pick button { padding: 9px 13px; border-radius: 11px; border: 1.5px solid var(--line); font-weight: 700; font-size: 13.5px; }
.outcome-pick button.sel { border-color: var(--brand); background: #fbe9e0; color: var(--brand); }

.stake { margin-bottom: 14px; }
.stake label { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); }
.stake-input { display: flex; align-items: center; gap: 8px; background: var(--bg-2); border-radius: 13px; padding: 12px 14px; margin-top: 6px; }
.stake-input input { flex: 1; border: none; background: none; font-size: 22px; font-weight: 800; color: var(--ink); width: 100%; outline: none; font-variant-numeric: tabular-nums; }
.quick { display: flex; gap: 7px; margin-top: 9px; }
.quick button { flex: 1; padding: 8px; border-radius: 10px; background: var(--bg-2); font-weight: 700; font-size: 12.5px; color: var(--ink-soft); }
.payout { display: flex; justify-content: space-between; background: var(--yes-soft); border-radius: 13px; padding: 12px 14px; margin-bottom: 16px; }
.payout .k { color: var(--ink-soft); font-size: 13px; }
.payout .v { font-weight: 800; color: var(--yes); font-variant-numeric: tabular-nums; }
.confirm { width: 100%; padding: 15px; border-radius: 14px; background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: #fff; font-weight: 800; font-size: 15.5px; box-shadow: 0 8px 18px rgba(200,81,43,.32); transition: .12s; }
.confirm:active { transform: scale(.98); }
.confirm:disabled { opacity: .5; box-shadow: none; }

/* ---------- portfolio ---------- */
.stat-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 13px; box-shadow: var(--shadow); }
.stat .lbl { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.stat .val { font-size: 19px; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; }
.pos { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.pos:last-child { border-bottom: none; }
.pos .body { flex: 1; min-width: 0; }
.pos .body .pq { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.pos .body .pm { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }
.pos .tag { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 8px; }
.pos .tag.yes { background: var(--yes-soft); color: var(--yes); }
.pos .tag.no  { background: var(--no-soft); color: var(--no); }
.pos .val { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 14px; }
.pos .val small { display: block; font-weight: 700; font-size: 11px; }
.pl-up { color: var(--yes); } .pl-down { color: var(--no); }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty .em { font-size: 40px; } .empty p { margin: 10px 0 0; }

/* ---------- leaderboard ---------- */
.lb-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.lb-row:last-child { border-bottom: none; }
.lb-rank { width: 26px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.lb-rank.top { color: var(--gold); }
.lb-av { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; background: var(--bg-2); }
.lb-row .who { flex: 1; min-width: 0; }
.lb-row .who .h { font-weight: 700; font-size: 14px; }
.lb-row .who .c { font-size: 11.5px; color: var(--ink-soft); }
.lb-row .pts { font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-row.me { background: #fbe9e0; border-radius: 13px; padding-left: 8px; padding-right: 8px; border-bottom: none; }
.streak { font-size: 11px; color: var(--brand); font-weight: 700; }

/* ---------- create form ---------- */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field textarea, .field select { width: 100%; border: 1.5px solid var(--line); background: var(--surface); border-radius: 13px;
  padding: 12px 14px; font-size: 15px; font-family: inherit; color: var(--ink); outline: none; transition: .15s; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand-2); }
.field textarea { resize: vertical; min-height: 70px; }
.hint { font-size: 11.5px; color: var(--ink-soft); margin-top: 5px; }
.legal-note { display: flex; gap: 10px; background: var(--yes-soft); border-radius: 13px; padding: 12px 14px; font-size: 12.5px; color: #2c6650; margin-bottom: 16px; }
.legal-note .em { font-size: 18px; }

/* ---------- bottom nav ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: rgba(255,253,249,.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav-inner { max-width: var(--maxw); margin: 0 auto; display: flex; }
.nav button { flex: 1; padding: 10px 0 11px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink-soft); font-size: 10.5px; font-weight: 600; transition: color .15s; }
.nav button .ic { font-size: 20px; line-height: 1; }
.nav button.active { color: var(--brand); }
.nav .fab { flex: 0 0 auto; }
.nav .fab .ic { width: 46px; height: 46px; margin-top: -16px; border-radius: 16px; background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: #fff; display: grid; place-items: center; font-size: 26px; box-shadow: 0 8px 18px rgba(200,81,43,.4); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 104px; transform: translateX(-50%) translateY(20px); z-index: 80;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 13px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: .25s; display: flex; align-items: center; gap: 8px; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast .ok { color: #6ce0ad; }

@media (min-width: 480px) { body { font-size: 15.5px; } }

/* ---------- desktop / tablet: use the width instead of a frozen phone column ---------- */
@media (min-width: 760px) {
  :root { --maxw: 720px; }
  #market-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  #market-list .card { margin-bottom: 0; }
  .sheet { max-width: 480px; }              /* keep the bet slip a compact modal */
  .nav { background: transparent; border-top: none; }
  .nav-inner { background: rgba(255,253,249,.92); backdrop-filter: blur(12px); border: 1px solid var(--line);
    border-radius: 18px; box-shadow: var(--shadow-lg); margin-bottom: 14px; }
  .submit-clear { margin-bottom: 18px; }
}
