:root {
  color-scheme: dark;
  --bg: #0a0d12;
  --bg-2: #11161e;
  --surface: #151b24;
  --surface-2: #1c2430;
  --line: #273140;
  --text: #edf1f6;
  --text-2: #a7b2c1;
  --muted: #7a8596;
  --accent: #e2b04a;
  --accent-2: #f4d27f;
  --green: #2fa36b;
  --red: #e5484d;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
/* The product is dark by design: both theme stamps resolve to the same palette. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }
:root[data-theme="dark"], :root[data-theme="light"] { color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
a { color: inherit; }
kbd {
  font: 600 10px/1 var(--font); padding: 3px 5px; border-radius: 4px; margin-left: 6px;
  background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.18); opacity: .75; vertical-align: 2px;
}

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); padding: 10px 16px; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center; white-space: nowrap;
  transition: transform .08s, background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: #3a4657; background: #222b38; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.icon { padding: 7px 9px; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(255,255,255,.04); }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #231904; border-color: #c39628; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: #3a1517; border-color: #6b2226; color: #ffb4b6; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px;
  height: 58px; padding: 0 18px; background: rgba(10, 13, 18, .86); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 17px; letter-spacing: .2px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.brand b { color: var(--accent); }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 16px;
  background: linear-gradient(145deg, var(--accent-2), var(--accent)); color: #1d1404;
}
.wallet {
  display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 14px; border-radius: 999px;
  background: linear-gradient(180deg, #1c232e, #141a22); border: 1px solid var(--line);
}
.wallet-label { color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; }
.wallet #walletBalance { font-weight: 800; color: var(--accent-2); font-size: 16px; }
.play-tag { font-size: 11px; font-weight: 600; color: #9be4bd; background: #113124; border: 1px solid #1f5a3d; padding: 3px 9px; border-radius: 999px; }
.top-actions { margin-left: auto; display: flex; gap: 4px; }

/* ---------- modal ---------- */
.modal { border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--surface); color: var(--text); width: min(620px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 30px 80px rgba(0,0,0,.7); }
.modal::backdrop { background: rgba(4,7,10,.72); backdrop-filter: blur(5px); }
.modal-body { padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { margin: 0; font-size: 22px; letter-spacing: -.2px; }
.modal p { margin: 0; }
.buyin { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.buyin label { color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; }
.buyin-val { font-size: 30px; font-weight: 800; color: var(--accent-2); text-align: center; }
.buyin input[type=range] { accent-color: var(--accent); width: 100%; }
.games { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.game-tab {
  font: inherit; cursor: pointer; text-align: left; padding: 10px 12px; border-radius: 12px; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; transition: border-color .15s, background .15s;
}
.game-tab b { font-size: 17px; letter-spacing: .3px; }
.game-tab span { font-size: 12px; color: var(--text-2); }
.game-tab small { font-size: 11px; color: var(--muted); }
.game-tab:hover { border-color: #3a4657; }
.game-tab.active { border-color: var(--accent); background: linear-gradient(180deg, rgba(226,176,74,.16), rgba(226,176,74,.04)); }
.game-tab.active b { color: var(--accent-2); }
.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mode-tabs { display: flex; padding: 3px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); }
.mode-tabs button { font: inherit; font-size: 12.5px; font-weight: 700; border: 0; cursor: pointer; padding: 6px 12px; border-radius: 999px; background: transparent; color: var(--text-2); }
.mode-tabs button.active { background: var(--accent); color: #231904; }
.server-note { font-size: 13px; color: #ffcf8a; background: #2e2210; border: 1px solid #5a4317; padding: 8px 12px; border-radius: 10px; }
.name-field { display: flex; align-items: center; gap: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-2); }
.name-field input { flex: 1; font: inherit; font-size: 15px; text-transform: none; letter-spacing: 0; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); }
.stake { position: relative; }
.stake .people { position: absolute; top: -7px; right: -5px; font-size: 10.5px; padding: 1px 6px; border-radius: 999px; background: #1d6b44; color: #fff; border: 1px solid #4ad08a; }
.lobby-label { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-2); margin-bottom: -6px; }
.stakes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.stake {
  font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; padding: 9px 4px; border-radius: 10px; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line); font-variant-numeric: tabular-nums;
}
.stake:hover:not(:disabled) { border-color: #3a4657; }
.stake.active { border-color: var(--accent); color: #231904; background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.stake:disabled { opacity: .35; cursor: not-allowed; }
@media (max-width: 560px) {
  .games { grid-template-columns: repeat(2, 1fr); }
  .stakes { grid-template-columns: repeat(3, 1fr); }
  .modal-body { padding: 18px; gap: 12px; }
}
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1; padding: 12px; }
.disclaimer { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }

.toast {
  position: fixed; bottom: 120px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 50;
  background: #1f2834; border: 1px solid var(--line); padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow);
  transition: opacity .2s, transform .2s; font-size: 14px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .brand { font-size: 15px; }
  .play-tag { display: none; }
  .top-actions { width: 100%; margin: 0; overflow-x: auto; scrollbar-width: none; }
}
