:root {
  --felt: #0d3b26;
  --felt-2: #124d32;
  --felt-3: #1a6342;
  --card: #fbfaf6;
  --ink: #16201b;
  --muted: #6b7a72;
  --line: #e4e2da;
  --gold: #e3b341;
  --gold-ink: #3a2a00;
  --red: #c8102e;
  --green: #138a4b;
  --amber: #b26a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.08), 0 6px 18px rgba(0,0,0,.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(ellipse at top, var(--felt-3), var(--felt) 60%) fixed;
  color: var(--ink); min-height: 100vh; -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- header / nav ---------- */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(13,59,38,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand { color: #fff; text-decoration: none; font-weight: 800; letter-spacing: .12em; font-size: 17px; }
.suits-mini { margin-left: 6px; letter-spacing: .1em; opacity: .85; font-size: 14px; }
.suits-mini b { color: #ff6b7d; font-weight: 400; }
.sync { width: 9px; height: 9px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.2); }
.sync.off { background: #f87171; box-shadow: 0 0 0 3px rgba(248,113,113,.25); }
.sync.busy { background: var(--gold); }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; justify-content: space-around;
  background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabs a { flex: 1; text-align: center; text-decoration: none; font-size: 11px; color: var(--muted); padding: 4px 0; border-radius: 10px; font-weight: 600; }
.tabs a span { display: block; font-size: 20px; line-height: 1.2; filter: grayscale(1); opacity: .6; }
.tabs a.on { color: var(--felt); }
.tabs a.on span { filter: none; opacity: 1; }

/* ---------- layout ---------- */
main#app { max-width: 760px; margin: 0 auto; padding: 14px 12px 24px; }
.loading { color: #cfe9da; text-align: center; padding: 60px 0; }
h1.page { color: #fff; font-size: 22px; margin: 6px 4px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1.page small { font-size: 13px; font-weight: 500; color: #b6d8c5; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 15px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.empty { text-align: center; color: var(--muted); padding: 18px 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

/* ---------- buttons / inputs ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 14px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; white-space: nowrap; font-size: 15px; color: var(--ink);
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--felt-2); border-color: var(--felt-2); color: #fff; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.danger { color: var(--red); border-color: #f1c4cc; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.big { padding: 13px 18px; font-size: 16px; width: 100%; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=password], select, textarea {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; font-size: 16px; outline: none; color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--felt-3); box-shadow: 0 0 0 3px rgba(26,99,66,.15); }
label.f { display: block; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 10px 0 4px; }
.seg { display: inline-flex; background: #eeece5; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* ---------- stats tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tile { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 10px; color: #fff; }
.tile .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #b6d8c5; }
.tile .v { font-size: 20px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile.gold .v { color: var(--gold); }
.tile.light { background: #fff; color: var(--ink); border-color: var(--line); }
.tile.light .k { color: var(--muted); }

/* ---------- pot bar (live) ---------- */
.pot {
  background: linear-gradient(135deg, #1b1b1b, #2b2b2b); color: #fff; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.pot .big { font-size: 34px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.pot .split { display: flex; gap: 14px; font-size: 13px; color: #ccc; margin-top: 4px; flex-wrap: wrap; }
.pot .split b { color: #fff; }
.pot .split .warn b { color: #ffb4b4; }

/* ---------- player rows ---------- */
.prow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.prow:last-child { border-bottom: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; font-size: 14px; }
.pname { font-weight: 700; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.chip { font-size: 12px; border-radius: 999px; padding: 2px 8px; background: #eeece5; color: #444; border: 0; cursor: pointer; font-weight: 600; }
.chip.cash { background: #e3f4ea; color: #0f6b3a; }
.chip.transfer { background: #e3edfb; color: #1d4f9a; }
.chip.unpaid { background: #fde8e8; color: #a11; outline: 1px dashed #e99; }
.amt { font-weight: 800; font-variant-numeric: tabular-nums; }
.pos { color: var(--green); } .neg { color: var(--red); }

/* places */
.place-badge { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 999px; font-weight: 800; font-size: 13px; padding: 0 6px; }
.p1 { background: #f6d365; color: #4a3500; } .p2 { background: #d9dde3; color: #333; } .p3 { background: #e6b48a; color: #4a2600; } .pn { background: #eeece5; color: #555; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
td { padding: 9px 5px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th.sorted { color: var(--felt); }
.num { text-align: right; }

/* ledger list */
.gitem { display: block; text-decoration: none; background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow); }
.gitem .top-line { display: flex; justify-content: space-between; align-items: baseline; }
.gitem .date { font-weight: 800; }
.gitem .potv { font-weight: 800; color: var(--felt-2); font-variant-numeric: tabular-nums; }
.gitem .places { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: 14px; }
.gitem .places span { display: inline-flex; align-items: center; gap: 4px; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; text-transform: uppercase; letter-spacing: .04em; }
.tag.live { background: #fde8e8; color: var(--red); }
.tag.scheduled { background: #fff2cc; color: #7a5600; }
.tag.finished { background: #e3f4ea; color: #0f6b3a; }
.tag.legacy { background: #eeece5; color: #666; }

/* RSVP */
.rsvp .seg button.on.in { background: #e3f4ea; color: #0f6b3a; }
.rsvp .seg button.on.out { background: #fde8e8; color: #a11; }
.rsvp .seg button.on.maybe { background: #fff2cc; color: #7a5600; }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-card { background: var(--card); width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; animation: up .18s ease-out; }
.modal-card h3 { margin: 0 0 10px; font-size: 18px; }
@media (min-width: 600px) { .modal { align-items: center; } .modal-card { border-radius: 18px; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: #1b1b1b; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--red); }

.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; margin: 8px 0; }
.pick-list button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 8px; font-weight: 600; cursor: pointer; text-align: left; }
.pick-list button.on { background: var(--felt-2); color: #fff; border-color: var(--felt-2); }

.payout-row { display: grid; grid-template-columns: 34px 1fr 110px; gap: 8px; align-items: center; margin-bottom: 8px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 340px; text-align: center; }
.logo { color: #fff; font-size: 34px; font-weight: 900; letter-spacing: .16em; }
.suits { font-size: 30px; color: #fff; letter-spacing: .3em; margin: 6px 0 26px; }
.suits .red, .red { color: #ff6b7d; }
.login input { text-align: center; font-size: 18px; padding: 14px; margin-bottom: 10px; }
.err { color: #ffb4b4; min-height: 20px; font-weight: 600; }
body:has(.login) { padding-bottom: 0; }
