/* Compound Interests ledger. Clear Ledger style (A-074): navy and gold, Manrope / Inter. */
:root {
  --font-display: "Manrope", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --navy: #1c3557; --ink: #142033; --muted: #56616f; --line: #d6dce3;
  --paper: #ffffff; --bg: #f3f5f8; --gold: #c9a227; --gold-soft: #f6efd6;
  --weak: #b3372b; --normal: #4f5d6b; --strong: #23794a;
  --c-small: #2e7d4f; --c-big: #1f5fa8; --c-life: #b4531b; --c-splurge: #9c2f6e;
  --c-mhouse: #6a4a3a; --c-mbiz: #3e5563; --c-msec: #5a3fa0; --c-house: #17706b;
  --radius: 14px; --shadow: 0 1px 2px rgba(20,32,51,.06), 0 4px 14px rgba(20,32,51,.06);
  --nav-h: 64px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--font-body); -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.neg { color: var(--weak); }
.pos { color: var(--strong); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--navy); color: #fff;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 0;
}
.topbar-row { display: flex; align-items: center; gap: 10px; max-width: 560px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.brand img { height: 34px; width: auto; flex: none; margin: -4px 0; }
.brand-name { font: 800 16px var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.round-pill {
  background: rgba(255,255,255,.12); border-radius: 999px; padding: 4px 10px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.icon-btn {
  background: transparent; border: 0; color: inherit; width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; font-size: 20px;
}
.icon-btn:active { background: rgba(255,255,255,.15); }
.players { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 10px; max-width: 560px; margin: 0 auto; scrollbar-width: none; }
.players::-webkit-scrollbar { display: none; }
.pchip {
  flex: none; display: flex; align-items: center; gap: 6px; border: 0; border-radius: 999px;
  padding: 6px 12px 6px 8px; background: rgba(255,255,255,.1); color: #fff; font-weight: 600; font-size: 14px;
}
.pchip .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.7); }
.pchip.on { background: #fff; color: var(--navy); }
.pchip.on .dot { border-color: var(--navy); }
.pchip.add { padding: 6px 12px; }

/* ---------- layout ---------- */
main { max-width: 560px; margin: 0 auto; padding: 14px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }
.card {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.card h2 { font-size: 17px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card h2 .tag { margin-left: auto; }
.section-title { font: 700 13px var(--font-display); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 4px 8px; }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: end; }
.hero .label { font-size: 13px; color: var(--muted); font-weight: 600; }
.hero .cash { font: 800 34px/1.1 var(--font-display); }
.hero .flow { font-size: 14px; color: var(--muted); }
.btn {
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; background: var(--navy); color: #fff;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn.gold { background: var(--gold); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--line); }
.btn.danger { background: var(--weak); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; }
.btn.done { background: #e7ece9; color: var(--strong); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 140px; }

/* ---------- freedom ---------- */
.freedom-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.freedom-head b { font: 800 20px var(--font-display); }
.bar { height: 12px; border-radius: 999px; background: #e6e9ee; overflow: hidden; margin: 8px 0 4px; position: relative; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #e0be4a); border-radius: inherit; }
.bar.full > i { background: linear-gradient(90deg, var(--strong), #39a56a); }
.checks { display: grid; gap: 6px; margin-top: 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.check .mark { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: #e6e9ee; color: var(--muted); }
.check.ok .mark { background: var(--strong); color: #fff; }
.win-banner {
  background: linear-gradient(135deg, var(--navy), #2a4d7c); color: #fff; border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center;
}
.win-banner svg { width: 34px; height: 34px; color: var(--gold); flex: none; }
.win-banner b { font: 800 18px var(--font-display); display: block; }

.hourglasses { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px; margin-top: 12px; }
.hg { aspect-ratio: 1; display: grid; place-items: center; }
.hg svg { width: 100%; height: 100%; }
.hg.job { color: var(--navy); }
.hg.asset { color: var(--c-small); }
.hg.lost { color: var(--c-life); }
.hg.free { color: #c8ced6; }
.hg.over { color: var(--weak); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; background: var(--c); }

/* ---------- rows ---------- */
.rows { display: grid; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { font-size: 12.5px; color: var(--muted); }
.row .amt { font-weight: 700; text-align: right; white-space: nowrap; }
.row.total { font-weight: 800; border-top: 2px solid var(--ink); }
.row .mini { padding: 6px 10px; min-height: 34px; font-size: 13px; border-radius: 9px; }
.tag {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: #eef1f5; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; vertical-align: 1px;
}
.tag.passive { background: #e3f1e8; color: var(--strong); }
.tag.active { background: #fbeee4; color: var(--c-life); }
.tag.W { background: #f8e3e1; color: var(--weak); }
.tag.N { background: #e8ebef; color: var(--normal); }
.tag.S { background: #e3f1e8; color: var(--strong); }
.tag.small { background: #e3f1e8; color: var(--c-small); }
.tag.big { background: #e2ebf7; color: var(--c-big); }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

/* ---------- actions grid ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action {
  background: var(--paper); border: 0; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; text-align: left; display: grid; gap: 4px; min-height: 92px; border-left: 5px solid var(--c, var(--navy));
}
.action b { font: 700 15px var(--font-display); }
.action span { font-size: 12.5px; color: var(--muted); }
.action:active { transform: translateY(1px); }

/* ---------- market ---------- */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 9px 4px; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg button + button { border-left: 1.5px solid var(--line); }
.seg button.on.W { background: var(--weak); color: #fff; }
.seg button.on.N { background: var(--normal); color: #fff; }
.seg button.on.S { background: var(--strong); color: #fff; }
.mrow { display: grid; grid-template-columns: 1fr 168px; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.mrow:first-of-type { border-top: 0; }
.mrow .sub { font-size: 12px; color: var(--muted); }
.price-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 14px;
}
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.stripe { height: 5px; border-radius: 5px 5px 0 0; margin: -16px -16px 12px; background: var(--c); }
.notice { background: var(--gold-soft); border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; }
.notice .btn { margin-left: auto; padding: 8px 12px; min-height: 36px; }
.notice.warn { background: #fbe9e7; }

/* ---------- forms ---------- */
label.field { display: grid; gap: 6px; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
input[type=text], input[type=number], input[type=search], select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff; font-size: 16px;
}
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }
.colors { display: flex; flex-wrap: wrap; gap: 10px; }
.colors button { width: 38px; height: 38px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--line); }
.colors button.on { box-shadow: 0 0 0 3px var(--ink); }
.colors button:disabled { opacity: .25; }
.pick { display: grid; gap: 8px; }
.pick button {
  text-align: left; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 2px;
}
.pick button.on { border-color: var(--navy); box-shadow: inset 0 0 0 1.5px var(--navy); background: #f5f8fc; }
.pick button b { font-weight: 700; }
.pick button span { font-size: 13px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; text-align: right; }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); height: var(--nav-h); }
.nav button { border: 0; background: none; display: grid; place-items: center; align-content: center; gap: 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
.nav button svg { width: 24px; height: 24px; }
.nav button.on { color: var(--navy); }
.nav button.on svg { color: var(--gold); }

/* ---------- sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(20,32,51,.45); z-index: 30; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column; animation: up .2s ease-out;
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); background: #fff; border-radius: 18px 18px 0 0; }
.sheet-head h3 { font-size: 18px; flex: 1; }
.sheet-head .icon-btn { color: var(--muted); }
.sheet-body { overflow-y: auto; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

.opp { background: #fff; border-radius: 12px; padding: 12px; margin-bottom: 8px; border: 1.5px solid var(--line); text-align: left; width: 100%; display: grid; gap: 4px; }
.opp-top { display: flex; gap: 8px; align-items: center; }
.opp-top b { flex: 1; }
.cf3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; font-size: 13px; text-align: center; }
.cf3 div { background: #f4f6f9; border-radius: 8px; padding: 4px; }
.cf3 div.cur { outline: 2px solid var(--gold); background: var(--gold-soft); font-weight: 700; }
.cf3 small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.dice { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 10px 0; }
.dice button { aspect-ratio: 1; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; font: 800 20px var(--font-display); }
.dice button.win { border-color: var(--strong); color: var(--strong); background: #eef7f1; }
.result { border-radius: 12px; padding: 14px; font-weight: 600; margin: 10px 0; }
.result.ok { background: #e3f1e8; color: var(--strong); }
.result.no { background: #f8e3e1; color: var(--weak); }
.filters { display: flex; gap: 6px; margin-bottom: 10px; }
.qty { display: flex; gap: 8px; align-items: center; }
.qty input { text-align: center; }
.qty .btn { min-width: 44px; padding: 0 12px; }

/* ---------- history ---------- */
.log-item { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.log-item:first-child { border-top: 0; }
.log-item .r { font: 700 12px var(--font-display); color: var(--muted); background: #eef1f5; border-radius: 8px; text-align: center; padding: 3px 0; height: fit-content; }

/* ---------- welcome ---------- */
.welcome { text-align: center; padding: 28px 8px 8px; }
.welcome .mascot { display: block; height: 180px; width: auto; margin: 0 auto 8px; }
.welcome h1 { font-size: 26px; }
.welcome p { color: var(--muted); max-width: 360px; margin: 8px auto 20px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 40; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
