/* ===== Monopoly Digital Bank — tema "ledger kas" ===== */
:root {
    --bg: #F3F0E3;
    --surface: #FFFFFF;
    --ink: #1B1B16;
    --muted: #746E5E;
    --line: #E3DDC9;
    --primary: #1B4332;
    --primary-dark: #10281B;
    --primary-tint: #E5EEE8;
    --gold: #A9821F;
    --gold-tint: #F6EED2;
    --danger: #9C3B2A;
    --danger-tint: #F5E4DE;
    --radius: 14px;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", Consolas, monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    padding-bottom: 90px;
    -webkit-tap-highlight-color: transparent;
}

.wrap { max-width: 560px; margin: 0 auto; padding: 16px; }
.wrap-narrow { max-width: 420px; padding-top: 40px; }

/* ---- Landing ---- */
.brand { text-align: center; margin-bottom: 24px; }
.brand-icon { font-size: 40px; line-height: 1; }
.brand h1 { font-size: 22px; margin: 8px 0 4px; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.divider {
    text-align: center; color: var(--muted); font-size: 12px;
    text-transform: uppercase; letter-spacing: .12em;
    margin: 18px 0; position: relative;
}
.divider::before, .divider::after {
    content: ""; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--line);
}
.divider::before { left: 0; } .divider::after { right: 0; }

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
}
.card h2 { font-size: 16px; margin: 0 0 12px; }
.card h3 { font-size: 14px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--primary); }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input, select {
    display: block; width: 100%; margin-top: 6px;
    padding: 12px 12px; font-size: 16px; font-family: var(--sans);
    border: 1px solid var(--line); border-radius: 10px; background: #FCFBF7; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.btn {
    appearance: none; border: none; cursor: pointer;
    padding: 13px 18px; font-size: 15px; font-weight: 600; letter-spacing: .01em;
    border-radius: 10px; font-family: var(--sans);
}
.btn-block { width: 100%; margin-top: 6px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-secondary { background: var(--gold-tint); color: #5C4718; }
.btn-secondary:active { background: #EFE2B7; }
.btn-danger { background: var(--danger-tint); color: var(--danger); }
.btn-danger:active { background: #ecd1c6; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 8px; }

.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
.alert-error { background: var(--danger-tint); color: var(--danger); }

/* ---- Top bar ---- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    background: var(--primary); color: #fff;
    padding: 12px 16px;
}
.topbar-title { display: flex; align-items: center; gap: 8px; font-family: var(--mono); }
.game-code { font-weight: 700; letter-spacing: .04em; }
.badge {
    background: var(--gold); color: #3A2C08; font-size: 11px; font-weight: 700;
    padding: 3px 7px; border-radius: 6px; letter-spacing: .05em;
}
.icon-btn {
    background: rgba(255,255,255,.15); border: none; color: #fff;
    width: 36px; height: 36px; border-radius: 9px; font-size: 16px; cursor: pointer;
}

/* ---- Balance hero: signature "banknote ledger" card ---- */
.balance-card {
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    padding: 20px 18px 18px;
    margin: 14px 0 16px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--primary-dark);
}
.balance-card::before {
    /* guilloche-esque fine ruled texture, restrained */
    content: "";
    position: absolute; inset: 0;
    background-image: repeating-linear-gradient(115deg, rgba(255,255,255,.05) 0 1px, transparent 1px 7px);
    pointer-events: none;
}
.balance-card::after {
    /* perforated ledger edge along the bottom */
    content: "";
    position: absolute; left: 0; right: 0; bottom: -1px; height: 8px;
    background-image: radial-gradient(circle, var(--bg) 2.2px, transparent 2.3px);
    background-size: 14px 14px;
    background-position: 4px -4px;
}
.balance-label { font-size: 13px; opacity: .85; text-transform: uppercase; letter-spacing: .08em; }
.balance-amount {
    font-family: var(--mono); font-size: 40px; font-weight: 700;
    font-variant-numeric: tabular-nums; margin: 4px 0 6px; letter-spacing: -0.01em;
}
.balance-sub { font-size: 13px; opacity: .85; }

.share-card { text-align: center; }
.share-code {
    font-family: var(--mono); font-size: 24px; font-weight: 700;
    letter-spacing: .08em; color: var(--primary); margin-top: 4px;
}

/* ---- Tabs ---- */
.tabs {
    display: flex; gap: 4px; overflow-x: auto; margin-bottom: 14px;
    scrollbar-width: none; -ms-overflow-style: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
    flex: 0 0 auto; background: var(--surface); border: 1px solid var(--line);
    color: var(--muted); padding: 9px 14px; font-size: 13.5px; font-weight: 600;
    border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.tab-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Lands grid ---- */
.lands-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.land-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    padding: 12px 14px; display: flex; align-items: center; gap: 12px;
}
.land-swatch { width: 8px; align-self: stretch; border-radius: 4px; flex-shrink: 0; }
.land-info { flex: 1; min-width: 0; }
.land-name { font-weight: 700; font-size: 14.5px; }
.land-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.land-owner { font-size: 12px; margin-top: 3px; font-weight: 600; }
.land-owner.mine { color: var(--primary); }
.land-owner.other { color: var(--muted); }
.land-owner.free { color: var(--gold); }
.land-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex-shrink: 0; }
.land-price { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.buildings-row { display: flex; gap: 3px; font-size: 13px; margin-top: 3px; }

/* ---- Players list ---- */
.player-row {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    padding: 12px 14px; margin-bottom: 8px;
}
.player-row .pname { font-weight: 700; font-size: 14.5px; }
.player-row .pname.host-tag::after { content: " · Host"; font-weight: 500; color: var(--gold); font-size: 11px; }
.player-row .pbal { font-family: var(--mono); font-weight: 700; font-size: 15px; color: var(--primary); }
.player-row .pbal.neg { color: var(--danger); }

/* ---- Debts ---- */
.debt-row {
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    padding: 12px 14px; margin-bottom: 8px;
}
.debt-top { display: flex; justify-content: space-between; align-items: baseline; }
.debt-parties { font-size: 13.5px; font-weight: 600; }
.debt-amount { font-family: var(--mono); font-weight: 700; color: var(--danger); }
.debt-bar { height: 5px; background: var(--line); border-radius: 3px; margin: 8px 0; overflow: hidden; }
.debt-bar-fill { height: 100%; background: var(--primary); }
.debt-sisa { font-size: 12px; color: var(--muted); }
.debt-actions { margin-top: 8px; display: flex; gap: 6px; }
.debt-actions input { flex: 1; margin: 0; padding: 8px 10px; font-size: 14px; }

/* ---- History ---- */
.history-list { max-height: 60vh; overflow-y: auto; }
.tx-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0; border-bottom: 1px solid var(--line); gap: 10px;
}
.tx-row:last-child { border-bottom: none; }
.tx-desc { font-size: 13.5px; }
.tx-desc .tx-note { color: var(--muted); font-size: 12px; display: block; margin-top: 1px; }
.tx-amount { font-family: var(--mono); font-weight: 700; white-space: nowrap; }

/* ---- Modal ---- */
.modal {
    display: none; position: fixed; inset: 0; background: rgba(20,18,10,.5);
    z-index: 50; align-items: flex-end;
}
.modal.open { display: flex; }
.modal-content {
    background: var(--bg); width: 100%; max-height: 82vh; overflow-y: auto;
    border-radius: 18px 18px 0 0; padding: 16px; margin: 0 auto; max-width: 560px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-header .icon-btn { background: var(--line); color: var(--ink); }

/* ---- Toast ---- */
.toast {
    position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
    background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px;
    font-size: 13.5px; opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 60;
    max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* ---- Buy land confirm ---- */
.buy-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.buy-row span { color: var(--muted); }
.buy-row b { font-family: var(--mono); font-size: 15px; }
.buy-row b.neg { color: var(--danger); }
.buy-row.buy-after { border-bottom: none; padding-top: 12px; }
.buy-row.buy-after b { font-size: 18px; color: var(--primary); }

/* ---- Empty state ---- */
.empty-state { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 13.5px; }

@media (min-width: 640px) {
    .lands-grid { grid-template-columns: 1fr 1fr; }
    .balance-amount { font-size: 44px; }
}
