:root {
  color-scheme: dark;
  --bg: #0a0f0d;
  --surface: #111915;
  --surface-2: #17211c;
  --surface-3: #1e2a24;
  --line: #233129;
  --line-2: #2e3f35;
  --ink: #edf3ef;
  --ink-2: #a3b3aa;
  --ink-3: #6c7e74;
  --felt: #1d9a68;
  --felt-deep: #0e4d35;
  --gold: #e9b95c;
  --win: #4fd98b;
  --loss: #ff7a72;
  --blue: #8fb4ff;
  --r: 16px;
  --display: "Fraunces", Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -200px, rgb(29 154 104 / 0.16), transparent 70%), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-family: var(--display); font-size: 30px; line-height: 1.1; }
h2 { font-family: var(--display); font-size: 20px; }
h3 { font-size: 15px; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.win { color: var(--win); }
.loss { color: var(--loss); }
.flat { color: var(--ink-2); }
.gold { color: var(--gold); }
.label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { max-width: 980px; margin: 0 auto; padding: 16px 16px 110px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  background: rgb(10 15 13 / 0.78);
  border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: 980px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 600; font-size: 18px; white-space: nowrap; }
.brand .spade { color: var(--felt); font-size: 22px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { padding: 7px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; font-size: 14px; }
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-3); }
.nav .ico { display: none; }
@media (max-width: 720px) {
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 30;
    justify-content: space-around; gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgb(13 19 16 / 0.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .nav a { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 11px; padding: 6px 10px; flex: 1; }
  .nav .ico { display: block; font-size: 19px; line-height: 1.1; }
  .nav a[aria-current="page"] { background: transparent; color: var(--felt); }
  .topbar .me-chip { margin-left: auto; }
}
.me-chip { display: flex; align-items: center; gap: 8px; }

.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 28px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 720px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .g2.collapse { grid-template-columns: 1fr; } }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.pad { padding: 16px; }
.card.felt {
  background: radial-gradient(120% 140% at 0% 0%, rgb(29 154 104 / 0.28), transparent 60%), var(--surface);
  border-color: rgb(29 154 104 / 0.35);
}
.divide > * + * { border-top: 1px solid var(--line); }
.tile { padding: 14px; }
.tile .v { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
a.list-item:hover { background: var(--surface-2); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--surface-2); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, transform 0.08s, border-color 0.15s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--felt); border-color: var(--felt); color: #04150d; }
.btn.primary:hover { background: #22b077; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #261a03; }
.btn.danger { color: var(--loss); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.icon { width: 40px; padding: 0; }
.btn.sm.icon { width: 32px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.input {
  width: 100%; height: 44px; padding: 0 13px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--bg); outline: none; font-size: 16px;
}
.input:focus { border-color: var(--felt); box-shadow: 0 0 0 3px rgb(29 154 104 / 0.22); }
.input.big { height: 56px; font-size: 26px; font-weight: 650; text-align: center; font-variant-numeric: tabular-nums; }
.hint { font-size: 12px; color: var(--ink-3); }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { border: 0; background: transparent; padding: 6px 11px; border-radius: 9px; color: var(--ink-2); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.pill.live { background: rgb(79 217 139 / 0.12); color: var(--win); }
.pill.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--win); animation: pulse 1.8s ease-in-out infinite; }
.pill.money { background: rgb(233 185 92 / 0.12); color: var(--gold); }
.pill.fun { background: rgb(143 180 255 / 0.12); color: var(--blue); }
.pill.link { background: rgb(29 154 104 / 0.15); color: var(--felt); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgb(79 217 139 / 0.55); } 50% { box-shadow: 0 0 0 6px rgb(79 217 139 / 0); } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-toggle {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface-2); cursor: pointer; font-weight: 500; font-size: 14px;
}
.chip-toggle[aria-pressed="true"] { border-color: var(--felt); background: rgb(29 154 104 / 0.16); }
.chip-toggle .x { color: var(--ink-3); margin-left: 2px; }

.avatar {
  flex: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  font-weight: 700; font-size: 13px; color: #06130d; letter-spacing: 0.02em;
}
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
th.r, td.r { text-align: right; }
tr.me td { background: rgb(29 154 104 / 0.08); }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--surface-2); }
.dim td { opacity: 0.55; }

.form-dots { display: inline-flex; gap: 3px; }
.form-dots i { width: 8px; height: 8px; border-radius: 2px; background: var(--ink-3); }
.form-dots i.win { background: var(--win); }
.form-dots i.loss { background: var(--loss); }

/* ---------- game seats ---------- */
.seat { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.seat.out { background: rgb(255 255 255 / 0.015); }
.seat .meta { font-size: 12.5px; color: var(--ink-3); }
.seat-actions { display: flex; gap: 6px; flex: none; }
@media (max-width: 480px) {
  .seat { flex-wrap: wrap; }
  .seat-actions { width: 100%; padding-left: 48px; }
  .seat-actions .btn:not(.icon) { flex: 1; }
}

.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 10px; align-items: end; }
.podium .p { text-align: center; padding: 14px 8px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.podium .p.first { padding-top: 22px; border-color: rgb(233 185 92 / 0.45); background: radial-gradient(100% 100% at 50% 0%, rgb(233 185 92 / 0.16), transparent 70%), var(--surface); }
.podium .medal { font-size: 22px; }
.podium .avatar { margin: 6px auto; }

.banner { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface-2); font-size: 14px; }
.banner.warn { border-color: rgb(255 122 114 / 0.4); background: rgb(255 122 114 / 0.08); }
.banner.ok { border-color: rgb(79 217 139 / 0.35); background: rgb(79 217 139 / 0.07); }
.banner.info { border-color: rgb(233 185 92 / 0.35); background: rgb(233 185 92 / 0.07); }

.empty { text-align: center; padding: 36px 16px; color: var(--ink-2); }
.empty .big { font-size: 34px; margin-bottom: 6px; }

.chart { width: 100%; height: 150px; display: block; }
.chart text { fill: var(--ink-3); font-size: 10px; font-family: var(--sans); }

/* ---------- auth screens ---------- */
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; padding: 28px 22px; text-align: center; }
.auth-card .spade { font-size: 44px; color: var(--felt); line-height: 1; }
.or { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 12px; margin: 18px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot .spade { font-size: 40px; color: var(--felt); animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.35; transform: scale(0.92); } }

/* ---------- modal & toast ---------- */
dialog {
  width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 40px); padding: 0;
  border: 1px solid var(--line-2); border-radius: 20px; background: var(--surface); color: var(--ink);
  box-shadow: 0 30px 80px rgb(0 0 0 / 0.6);
}
dialog::backdrop { background: rgb(0 0 0 / 0.6); backdrop-filter: blur(3px); }
dialog[open] { animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.modal-body { padding: 20px; }
.modal-body h2 { margin-bottom: 4px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.menu-list { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.menu-list .btn { justify-content: flex-start; height: 46px; }
@keyframes pop { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--surface-3); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 12px;
  font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: 0.2s; z-index: 100; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: rgb(255 122 114 / 0.5); color: var(--loss); }
@media (min-width: 721px) { #toast { bottom: 24px; } }

.rise { animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
