/* ==========================================================================
   Paisa777 / Rocket — premium dark UI (layout modelled on bustabit's phone flow)
   Phone:   graph → past-rounds strip → bet card → one tall panel with
            vertical side tabs (Chat / Past rounds / Players) filling the rest
            of the screen. Chat input pinned to the bottom of that panel.
   Tablet:  graph + bet on the left, side-tabbed chat on the right,
            player list under the bet card.
   Desktop: bet + players | graph | chat — everything visible.
   ========================================================================== */

:root {
  --bg: #07070c;
  --bg-elevated: #0e0e16;
  --surface: rgba(18, 18, 28, 0.72);
  --surface-solid: #12121c;
  --surface-hover: #1a1a28;
  --border: rgba(255, 255, 255, 0.08);
  --border-bright: rgba(255, 255, 255, 0.14);

  --text: #f4f4f8;
  --muted: #8b8ba3;
  --dim: #5c5c72;

  --accent: #00e676;
  --accent-glow: rgba(0, 230, 118, 0.45);
  --accent-dim: #00c853;
  --gold: #ffc947;
  --gold-glow: rgba(255, 201, 71, 0.35);
  --danger: #ff4757;
  --danger-glow: rgba(255, 71, 87, 0.4);
  --cyan: #00d4ff;
  --purple: #a855f7;

  --font: "Outfit", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-full: 999px;

  --header-h: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --gutter: 12px;
  --page-max: 1500px;

  --glass: blur(20px) saturate(160%);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- animated background ---- */
.bg-mesh {
  position: fixed;
  inset: 0;
  /* Must sit BELOW in-flow content. At z-index 0 it painted over anything
     non-positioned (the past-rounds chips were invisible). */
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(0, 230, 118, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 50%, rgba(168, 85, 247, 0.08), transparent 50%),
    radial-gradient(ellipse 50% 30% at 0% 80%, rgba(0, 212, 255, 0.06), transparent 45%),
    var(--bg);
}

/* ---- page shell: phone = fixed-height app, the main area scrolls ---- */
.game-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* ---- header ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(var(--header-h) + var(--safe-t));
  padding: var(--safe-t) var(--gutter) 0;
  background: rgba(7, 7, 12, 0.85);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border-bottom: 1px solid var(--border);
}

/* ---- brand: gold coin mark + "Paisa777" wordmark ---- */
.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: block;
  filter: drop-shadow(0 0 8px rgba(247, 183, 51, 0.45));
}

.brand-text {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.01em;
  color: var(--text);
  line-height: 1;
}

.brand-777 { color: var(--gold); }

.header-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.nav-text {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.nav-text:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.header-status { flex: 1; min-width: 0; }

.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.conn-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.conn-pill.ok { color: var(--accent); }
.conn-pill.ok::before {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse-dot 1.5s ease infinite;
}

.conn-pill.bad { color: var(--danger); }
.conn-pill.bad::before { background: var(--danger); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.header-account {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-account .me-balance {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
  padding: 6px 10px;
  border-radius: var(--radius-full);
  background: rgba(0, 230, 118, 0.1);
  border: 1px solid rgba(0, 230, 118, 0.25);
  white-space: nowrap;
}

.header-account .me-name {
  display: none;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-account .nav-link,
.header-account .btn-ghost,
.header-account .btn-primary {
  font-size: 12px;
  padding: 7px 12px;
}

/* ==========================================================================
   Layout — phone first
   ========================================================================== */
.app-layout {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 10px var(--gutter) calc(12px + var(--safe-b));
}

.stage-col  { order: 1; flex-shrink: 0; display: flex; flex-direction: column; min-height: 0; }
.bet-dock   { order: 2; flex-shrink: 0; }
.social-col { order: 3; flex: 1 1 0; min-height: 360px; }
.players-col{ order: 4; }

.phone-only { display: inline-flex; }

/* ---- game stage (the hero) ---- */
.game-stage {
  position: relative;
  flex: none;
  height: clamp(200px, 30vh, 270px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-bright);
  background:
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(0, 230, 118, 0.08), transparent 60%),
    linear-gradient(180deg, rgba(14, 14, 22, 0.95) 0%, rgba(7, 7, 12, 0.98) 100%);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

@supports (height: 1dvh) {
  .game-stage { height: clamp(200px, 30dvh, 270px); }
}

.stage-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, black 60%, transparent);
  -webkit-mask-image: linear-gradient(180deg, black 60%, transparent);
}

.stage-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.45);
}

#graph {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---- past rounds strip (directly under the graph) ---- */
.history-rail {
  padding: 8px 0 0;
  overflow: hidden;
  flex-shrink: 0;
}

.history-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.history-strip::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  scroll-snap-align: start;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(255, 71, 87, 0.12);
  color: var(--danger);
  border: 1px solid rgba(255, 71, 87, 0.25);
}

.chip.good {
  background: rgba(0, 230, 118, 0.12);
  color: var(--accent);
  border-color: rgba(0, 230, 118, 0.3);
}

.chip.great {
  background: rgba(255, 201, 71, 0.15);
  color: var(--gold);
  border-color: rgba(255, 201, 71, 0.35);
  box-shadow: 0 0 12px var(--gold-glow);
}

/* ---- glass panels ---- */
.panel-glass {
  background: var(--surface);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border: 1px solid var(--border);
}

/* ---- social panel: vertical side tabs + content ---- */
.social-col {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  border-radius: var(--radius);
  overflow: hidden;
}

.side-tabs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  border-right: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  overflow: hidden;
  min-height: 0;
}

/* Buttons don't take writing-mode reliably, so the label span is what's
   rotated: reads bottom-to-top like bustabit's CHAT / HISTORY / PLAYERS. */
.tab {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 34px;
  min-height: 44px;
  padding: 12px 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.tab-label {
  display: block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  line-height: 1;
  white-space: nowrap;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--gold);
  background: rgba(255, 201, 71, 0.1);
  text-shadow: 0 0 12px var(--gold-glow);
}

.tab-badge:not([hidden]) {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold-glow);
}

.tab-panels {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tab-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tab-panel.hidden { display: none !important; }

.history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* ---- chat ---- */
.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  font-size: 14px;
  line-height: 1.4;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  overflow-wrap: anywhere;
}

.chat-msg .who {
  color: var(--cyan);
  font-weight: 700;
  margin-right: 6px;
}

.chat-msg.bot .who { color: var(--purple); }

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--dim);
  font-size: 13px;
  padding: 24px 12px;
}

.bot-badge {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 6px;
  vertical-align: middle;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font: 15px var(--font);
}

.chat-form input:focus {
  outline: none;
  border-color: var(--purple);
}

.chat-form input:disabled { color: var(--dim); }

/* ---- who's playing ---- */
.players-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  flex-shrink: 0;
}

.section-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.pill-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  white-space: nowrap;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1.2s ease infinite;
}

.players-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }

th, td {
  padding: 9px 12px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--dim);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(18, 18, 28, 0.97);
}

td {
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
}

td:first-child { font-family: var(--font); font-weight: 500; }
.players td:first-child { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; }
.num { text-align: right; }
tr.won td { color: var(--accent); }
tr.lost td { color: var(--danger); }
tr.me td { background: rgba(0, 212, 255, 0.06); }
tr.me td:first-child { color: var(--cyan); font-weight: 700; }
td.empty { color: var(--muted); font-family: var(--font); white-space: normal; text-align: center; padding: 22px 12px; }

/* ---- bet card (in the flow, right under the past rounds) ---- */
.bet-dock {
  padding: 12px;
  border-radius: var(--radius);
}

.bet-dock.signed-out .bet-grid { display: none; }

.bet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font: 600 16px var(--mono);
  transition: border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
}

.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 230, 118, 0.15);
}

.chip-row { display: flex; gap: 4px; }

.chip-btn {
  flex: 1;
  min-height: 32px;
  padding: 0 6px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
}

.chip-btn:active { transform: scale(0.96); }
.chip-btn:hover { color: var(--text); border-color: var(--border-bright); }

/* ---- main CTA ---- */
.bet-cta {
  width: 100%;
  min-height: 54px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #041208;
  background: linear-gradient(135deg, #00e676 0%, #00c853 50%, #69f0ae 100%);
  box-shadow: 0 4px 20px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.3);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
  padding: 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bet-cta:hover:not(:disabled) { filter: brightness(1.05); }
.bet-cta:active:not(:disabled) { transform: scale(0.98); }
.bet-cta:disabled {
  background: var(--surface-hover);
  color: var(--dim);
  box-shadow: none;
  cursor: default;
}

.bet-cta.cashout {
  color: #1a1000;
  background: linear-gradient(135deg, #ffc947 0%, #ff9800 50%, #ffe082 100%);
  box-shadow: 0 4px 24px var(--gold-glow);
  animation: cashout-pulse 1s ease infinite;
}

@keyframes cashout-pulse {
  0%, 100% { box-shadow: 0 4px 24px var(--gold-glow); }
  50% { box-shadow: 0 4px 36px rgba(255, 201, 71, 0.6); }
}

.bet-cta.queued {
  background: linear-gradient(135deg, #4c8dff, #00d4ff);
  color: #fff;
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.35);
}

.bet-cta.login {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
}

.bet-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}

.bet-hint:empty { display: none; }

/* ---- buttons ---- */
.btn-primary, .btn-ghost, .nav-link, .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.12s;
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #041208;
  padding: 10px 16px;
}

.btn-primary.sm { padding: 10px 14px; font-size: 13px; min-height: 44px; }
.btn-primary:disabled { opacity: 0.45; cursor: default; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
}

.btn-ghost.sm { padding: 7px 12px; font-size: 12px; }
.btn-ghost:hover { border-color: var(--border-bright); background: rgba(255, 255, 255, 0.04); }

.nav-link {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  font-size: 12px;
}

.nav-link.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border: none;
  color: #041208;
}

.icon-btn {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 16px;
}

.icon-btn:hover { color: var(--text); }

.hidden { display: none !important; }

/* ---- toasts ---- */
.toasts {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-t) + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 28px), 420px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--danger);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}

.toast.info {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  color: var(--text);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.95); }
  to { opacity: 1; transform: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==========================================================================
   Scrollbars — none on phones (like bustabit), thin and subtle on bigger
   screens so mouse users still see that a list scrolls.
   ========================================================================== */
.game-page, .app-layout, .chat-log, .players-scroll, .history-list, .history-strip, .table-scroll {
  scrollbar-width: none;
}

.game-page::-webkit-scrollbar,
.app-layout::-webkit-scrollbar,
.chat-log::-webkit-scrollbar,
.players-scroll::-webkit-scrollbar,
.history-list::-webkit-scrollbar,
.history-strip::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar { display: none; width: 0; height: 0; }

@media (min-width: 720px) {
  .chat-log, .players-scroll, .history-list, .table-scroll {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
  }

  .chat-log::-webkit-scrollbar,
  .players-scroll::-webkit-scrollbar,
  .history-list::-webkit-scrollbar,
  .table-scroll::-webkit-scrollbar { display: block; width: 6px; height: 6px; }

  .chat-log::-webkit-scrollbar-track,
  .players-scroll::-webkit-scrollbar-track,
  .history-list::-webkit-scrollbar-track,
  .table-scroll::-webkit-scrollbar-track { background: transparent; }

  .chat-log::-webkit-scrollbar-thumb,
  .players-scroll::-webkit-scrollbar-thumb,
  .history-list::-webkit-scrollbar-thumb,
  .table-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 3px;
  }
}

/* ==========================================================================
   Layout — phone only (< 720px): player list lives inside the tab panel
   ========================================================================== */
@media (max-width: 719.98px) {
  .tab-panels > .players-col {
    flex: 1;
    min-height: 0;
    background: none;
    border: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ==========================================================================
   Layout — tablet (720px+): graph + bet on the left, chat on the right
   ========================================================================== */
@media (min-width: 720px) {
  :root { --gutter: 16px; }

  .phone-only { display: none !important; }

  /* The shell stays viewport-height so panels scroll inside themselves.
     If the window is shorter than the grid's minimum, the shell scrolls. */
  .game-page { overflow-y: auto; }

  .app-layout {
    overflow: visible;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "stage   social"
      "dock    social"
      "players social";
    gap: 12px;
    padding-bottom: 12px;
    min-height: 640px;
  }

  .stage-col   { grid-area: stage; }
  .bet-dock    { grid-area: dock; }
  .social-col  { grid-area: social; min-height: 0; }
  .players-col { grid-area: players; border-radius: var(--radius); overflow: hidden; }

  .game-stage { height: clamp(260px, 38vh, 420px); }

  .bet-dock { padding: 14px; }
  .players td:first-child { max-width: 160px; }
}

/* ==========================================================================
   Layout — desktop (1024px+): bet + players | graph | chat
   ========================================================================== */
@media (min-width: 1024px) {
  :root { --gutter: 20px; }

  .header-account .me-name { display: inline-block; }

  .app-layout {
    grid-template-columns: 300px minmax(0, 1fr) 340px;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "dock    stage social"
      "players stage social";
    gap: 14px;
    min-height: 560px;
  }

  .game-stage {
    flex: 1 1 0;
    height: auto;
    min-height: 320px;
  }

  .bet-grid { grid-template-columns: 1fr; gap: 12px; }
  .players td:first-child { max-width: 130px; }
}

@media (min-width: 1280px) {
  .app-layout { grid-template-columns: 320px minmax(0, 1fr) 380px; }
  .bet-grid { grid-template-columns: 1fr 1fr; }
  .players td:first-child { max-width: 150px; }
}

/* ==========================================================================
   Auth & wallet pages
   ========================================================================== */
.auth-page, body:not(.game-page) {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}

.auth-page .app-header { position: relative; }

/* ==========================================================================
   Home page
   ========================================================================== */
.home {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px var(--gutter) 48px;
  display: flex;
  flex-direction: column;
  gap: 44px;
}

.hero {
  display: grid;
  gap: 24px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
}

.hero h1 {
  margin: 0;
  font-size: clamp(32px, 8vw, 58px);
  line-height: 1.04;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.lead {
  margin: 16px 0 0;
  font-size: 17px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 46ch;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.cta-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 0 28px;
  text-decoration: none;
}

.btn-ghost.lg {
  min-height: 54px;
  padding: 0 22px;
  border-radius: var(--radius);
  font-size: 15px;
}

.hero-note {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--dim);
}

.hero-art {
  border-radius: var(--radius-lg);
  padding: 14px;
  max-width: 100%;
}

.hero-art svg {
  display: block;
  width: 100%;
  height: auto;
}

.section-title {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.steps-grid {
  display: grid;
  gap: 12px;
}

.step {
  padding: 20px;
  border-radius: var(--radius);
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 201, 71, 0.14);
  color: var(--gold);
  font-family: var(--mono);
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 12px;
}

.step h3 { margin: 0 0 6px; font-size: 17px; font-weight: 700; }
.step p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }

.perks-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.perks-list li {
  position: relative;
  padding-left: 26px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}

.perks-list li strong { color: var(--text); }

.perks-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.cta-band {
  text-align: center;
  padding: 32px 20px;
  border-radius: var(--radius-lg);
}

.cta-band h2 { margin: 0 0 6px; font-size: 24px; font-weight: 800; }
.cta-band p { margin: 0 0 18px; color: var(--muted); }

/* ---- footer (home + docs) ---- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 20px;
  padding: 20px var(--gutter) calc(20px + var(--safe-b));
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.site-footer a { color: var(--muted); text-decoration: none; font-weight: 600; }
.site-footer a:hover { color: var(--text); }
.footer-brand { font-weight: 800; color: var(--text); }
.footer-note { flex-basis: 100%; text-align: center; color: var(--dim); font-size: 12px; }

/* ---- simple document pages (help, terms, privacy) ---- */
.doc {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 28px var(--gutter) 48px;
}

.doc h1 { margin: 0 0 6px; font-size: 32px; font-weight: 800; }
.doc-updated { margin: 0 0 18px; font-size: 13px; color: var(--dim); }
.doc h2 { margin: 30px 0 10px; font-size: 18px; font-weight: 700; }
.doc p, .doc li { font-size: 15px; line-height: 1.6; color: #c9c9d8; }
.doc p { margin: 0 0 12px; }
.doc ul, .doc ol { margin: 0 0 12px; padding-left: 22px; }
.doc li { margin-bottom: 6px; }
.doc a { color: var(--cyan); }

@media (min-width: 720px) {
  .home { padding: 40px var(--gutter) 64px; }
  .steps-grid { grid-template-columns: repeat(3, 1fr); }
  .perks-list { grid-template-columns: repeat(3, 1fr); gap: 20px; }
}

@media (min-width: 900px) {
  .hero { grid-template-columns: 1.1fr 1fr; gap: 40px; }
}

.auth-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + var(--safe-b));
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 28px 22px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-card h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-card label, .wallet-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.auth-card label small, .wallet-card label small {
  text-transform: none;
  font-weight: 400;
  letter-spacing: 0;
}

.auth-card input, .wallet-card input {
  min-height: 48px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 14px;
  font: 16px var(--font);
}

.auth-card input:focus, .wallet-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 230, 118, 0.12);
}

.form-error { color: var(--danger); font-size: 13px; min-height: 18px; line-height: 1.4; }
.form-error:empty { min-height: 0; }

.auth-alt {
  margin: 0;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.auth-sub {
  margin: -8px 0 8px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-alt a { color: var(--cyan); font-weight: 600; }

/* ---- wallet ---- */
.wallet-wrap {
  flex: 1;
  padding: 16px 16px calc(24px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.wallet-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 20px;
  border-radius: var(--radius);
}

.wallet-hero .who { margin: 0; font-size: 14px; color: var(--muted); }
.wallet-hero .who strong { color: var(--text); font-size: 16px; }

.wallet-hero .big-balance {
  margin: 0;
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
}

.wallet-hero .big-balance small {
  display: block;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.wallet-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }

.wallet-card {
  padding: 18px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.wallet-card h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.card-sub {
  margin: -6px 0 4px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

.quick-amounts { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-amounts .chip-btn { flex: 1 1 auto; min-height: 36px; font-size: 12px; }

.withdraw-btn {
  background: linear-gradient(135deg, #ffc947, #ff9800) !important;
  color: #1a1000 !important;
  box-shadow: 0 4px 20px var(--gold-glow) !important;
}

.wallet-card .hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -18px; padding: 0 18px; }

.status-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-pill.ok { color: var(--accent); }
.status-pill.warn { color: var(--gold); }
.status-pill.bad { color: var(--danger); }
.status-pill.muted { color: var(--muted); }

td.pos { color: var(--accent); }
td.neg { color: var(--danger); }
td.muted, .muted { color: var(--muted); }

/* Phone: wallet tables become stacked cards so nothing scrolls sideways. */
@media (max-width: 599.98px) {
  .stack-table thead { display: none; }
  .stack-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
  }
  .stack-table td {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0;
    border: none;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .stack-table td.num { text-align: left; }
  .stack-table td:empty { display: none; }
  .stack-table td[data-label]::before {
    content: attr(data-label);
    font-family: var(--font);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--dim);
  }
  .stack-table td.grow { flex: 1 1 100%; }
  .stack-table td.empty { width: 100%; text-align: center; padding: 20px 0; }
}

@media (min-width: 720px) {
  .wallet-wrap { padding: 20px var(--gutter) 32px; }
  .wallet-grid { grid-template-columns: 1fr 1fr; }
  .wallet-card { padding: 22px; }
  .table-scroll { margin: 0 -22px; padding: 0 22px; }
  .wallet-hero .big-balance { font-size: 32px; }
}
