:root {
  --bg: #0a0612;
  --bg-elevated: #140c1f;
  --bg-panel: #161022;
  --bg-card: #1c142c;
  --border: #3a2a55;
  --border-strong: #5c3f88;
  --text: #f4ecff;
  --text-muted: #a892c4;
  --gold: #f0c14b;
  --gold-dim: rgba(240, 193, 75, 0.16);
  --gold-hover: #ffd76a;
  --accent: #c084fc;
  --accent-dim: rgba(192, 132, 252, 0.14);
  --success: #4ade80;
  --danger: #f87171;
  --felt: #1a3d2e;
  --felt-deep: #0f2419;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Playfair Display", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background:
    radial-gradient(900px 480px at 10% -10%, rgba(192, 132, 252, 0.14), transparent 55%),
    radial-gradient(700px 400px at 100% 0%, rgba(240, 193, 75, 0.08), transparent 50%),
    radial-gradient(600px 300px at 50% 100%, rgba(26, 61, 46, 0.35), transparent 55%),
    var(--bg);
  color: var(--text);
}

a {
  color: var(--gold);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.muted {
  color: var(--text-muted);
}

.tiny {
  font-size: 0.8rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: #1a0a2e;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-gold {
  background: linear-gradient(180deg, var(--gold-hover), var(--gold));
  color: #1a1200;
  border-color: #c9a227;
  box-shadow: 0 4px 16px rgba(240, 193, 75, 0.25);
}

.btn-gold:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.btn-danger {
  background: linear-gradient(180deg, #f87171, #dc2626);
  color: #fff;
  border-color: #fca5a5;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-danger-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
}

.btn-danger-ghost:hover {
  background: rgba(248, 113, 113, 0.1);
}

.test-tools {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
}

.test-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.6rem;
}

.test-row label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.test-row input {
  font: inherit;
  font-family: var(--mono);
  width: 110px;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.sound-toggle {
  margin-top: 0.65rem;
}

.player-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.form-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0.4rem 0 0;
}

.form-ok {
  color: var(--success);
  font-size: 0.9rem;
  margin: 0.4rem 0 0;
}

/* Password modal */
.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text);
  padding: 0;
  max-width: min(400px, 92vw);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(4, 2, 10, 0.72);
}

.modal form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem 1.35rem 1.35rem;
}

.modal h3 {
  font-family: var(--display);
  margin: 0 0 0.25rem;
  font-size: 1.2rem;
}

.modal label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal input,
.modal select {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.modal input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

/* ---------- Auth ---------- */
.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.4rem;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #3b1d63, #1a0f2e);
  border: 1px solid var(--border-strong);
  color: var(--gold);
  font-size: 1.4rem;
  font-weight: 700;
}

.brand h1 {
  font-family: var(--display);
  font-size: 1.55rem;
  margin: 0;
  letter-spacing: 0.02em;
}

.brand p {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.brand-sm {
  text-decoration: none;
  color: inherit;
  margin: 0;
}

.brand-sm:hover {
  text-decoration: none;
}

.brand-sm .brand-mark {
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
}

.brand-text {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.1rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.auth-form label,
.invite-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}

.auth-form input,
.invite-form input,
.copy-row input {
  font: inherit;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.auth-form input:focus,
.invite-form input:focus,
.copy-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.auth-footer {
  margin: 1.1rem 0 0;
  text-align: center;
  font-size: 0.88rem;
}

.invite-banner {
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.invite-banner.ok {
  border-color: rgba(74, 222, 128, 0.35);
  color: var(--success);
}

.invite-banner.bad {
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--danger);
}

/* ---------- Shell ---------- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 6, 18, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.92rem;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--bg-card);
  text-decoration: none;
}

.nav-links a.active {
  color: var(--gold);
  background: var(--gold-dim);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.balance-chip,
.debt-chip {
  display: flex;
  flex-direction: column;
  padding: 0.25rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  min-width: 72px;
}

.balance-chip {
  border-color: rgba(240, 193, 75, 0.35);
}

.debt-chip {
  border-color: rgba(248, 113, 113, 0.35);
}

.chip-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.chip-value {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.95rem;
}

.balance-chip .chip-value {
  color: var(--gold);
}

.debt-chip .chip-value {
  color: var(--danger);
}

.user-pill {
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Lobby ---------- */
.lobby-main,
.lb-main,
.admin-main {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.5rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.75rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--gold);
  margin: 0 0 0.4rem;
  font-weight: 600;
}

.hero-panel h1 {
  font-family: var(--display);
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin: 0 0 0.6rem;
}

.lede {
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 1.1rem;
  max-width: 42ch;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.advance-hint {
  font-size: 0.88rem;
}

.hero-stats {
  display: grid;
  gap: 0.75rem;
  align-content: start;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--gold);
}

.stat-card.debt .stat-value {
  color: var(--danger);
}

.stat-card.net .stat-value {
  color: var(--accent);
}

.games-section h2 {
  font-family: var(--display);
  margin: 0 0 0.9rem;
  font-size: 1.35rem;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.game-card {
  position: relative;
  display: block;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}

a.game-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  text-decoration: none;
}

.game-card.soon {
  opacity: 0.55;
}

.game-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.game-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.game-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.game-badge {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--gold-dim);
  color: var(--gold);
}

.muted-badge {
  background: rgba(168, 146, 196, 0.12);
  color: var(--text-muted);
}

/* ---------- Slots ---------- */
.slots-main {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 1.25rem;
  align-items: start;
}

.machine {
  background:
    linear-gradient(180deg, #2a1838 0%, #1a0f24 40%, #120a1a 100%);
  border: 2px solid var(--border-strong);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.machine-header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.machine-header h1 {
  font-family: var(--display);
  margin: 0;
  color: var(--gold);
  font-size: 1.75rem;
}

.machine-header p {
  margin: 0.3rem 0 0;
}

.reels-frame {
  background: linear-gradient(180deg, var(--felt), var(--felt-deep));
  border: 3px solid #c9a227;
  border-radius: 16px;
  padding: 1.25rem;
  position: relative;
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.45),
    0 0 0 4px #3a2a12;
}

.reels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.reel {
  background: linear-gradient(180deg, #f8f4e8, #e8dfc8);
  border-radius: 12px;
  min-height: 140px;
  display: grid;
  place-items: center;
  border: 2px solid #2a2214;
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.reel .symbol {
  font-size: clamp(2.8rem, 8vw, 3.6rem);
  line-height: 1;
  user-select: none;
  transition: transform 0.08s;
}

.reel.spinning .symbol {
  animation: reel-blur 0.08s linear infinite;
}

@keyframes reel-blur {
  0% {
    transform: translateY(-8px);
    filter: blur(1px);
  }
  50% {
    transform: translateY(8px);
    filter: blur(2px);
  }
  100% {
    transform: translateY(-8px);
    filter: blur(1px);
  }
}

.reel.win {
  box-shadow:
    inset 0 4px 12px rgba(0, 0, 0, 0.15),
    0 0 0 3px var(--gold),
    0 0 24px rgba(240, 193, 75, 0.45);
}

.spin-message {
  text-align: center;
  min-height: 1.5em;
  margin: 1rem 0;
  font-weight: 600;
  font-size: 1.05rem;
}

.spin-message.win {
  color: var(--gold);
  text-shadow: 0 0 20px rgba(240, 193, 75, 0.35);
}

.spin-message.lose {
  color: var(--text-muted);
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.bet-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.control-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.bet-options {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.bet-opt {
  min-width: 52px;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-family: var(--mono);
  font-weight: 600;
  cursor: pointer;
}

.bet-opt:hover {
  border-color: var(--border-strong);
}

.bet-opt.active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold);
}

.btn-spin {
  min-width: 200px;
  padding: 1rem 2rem;
  font-size: 1.15rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff4d6d, #c9184a);
  color: #fff;
  border: 2px solid #ff8fa3;
  box-shadow: 0 8px 24px rgba(201, 24, 74, 0.4);
  flex-direction: column;
  gap: 0.1rem;
}

.btn-spin:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-spin:disabled {
  filter: grayscale(0.3);
}

.spin-label {
  letter-spacing: 0.15em;
  font-weight: 800;
}

.spin-bet {
  font-family: var(--mono);
  font-size: 0.85rem;
  opacity: 0.9;
}

.slots-side {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
}

.panel h2,
.panel h1 {
  font-family: var(--display);
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}

.paytable {
  list-style: none;
  margin: 0.75rem 0;
  padding: 0;
}

.paytable li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(58, 42, 85, 0.6);
  font-size: 0.92rem;
}

.paytable .sym {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.paytable .mult {
  font-family: var(--mono);
  font-weight: 600;
  display: flex;
  gap: 0.75rem;
}

.paytable .mult-two {
  color: var(--text-muted);
  min-width: 2.2rem;
  text-align: right;
}

.paytable .mult-three {
  color: var(--gold);
  min-width: 2.5rem;
  text-align: right;
}

.spin-history {
  list-style: none;
  margin: 0;
  padding: 0 0.55rem 0 0; /* room so scrollbar never covers amounts */
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #5c3f88 #120a1c;
}

.spin-history::-webkit-scrollbar {
  width: 10px;
}

.spin-history::-webkit-scrollbar-track {
  background: #120a1c;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.spin-history::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #6b4a96, #3a2a55);
  border-radius: 8px;
  border: 2px solid #120a1c;
}

.spin-history::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #8b5cf6, #5c3f88);
}

.spin-history li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.35rem 0.45rem 0;
  border-bottom: 1px solid rgba(58, 42, 85, 0.5);
  font-size: 0.88rem;
  font-family: var(--mono);
}

.spin-history li > span:last-child {
  flex-shrink: 0;
  min-width: 3.4rem;
  text-align: right;
  padding-right: 0.15rem;
}

.spin-history .win-amt {
  color: var(--success);
}

.spin-history .lose-amt {
  color: var(--danger);
}

/* ---------- Leaderboard / admin tables ---------- */
.lb-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.lb-header h1 {
  margin: 0;
  font-family: var(--display);
}

.table-wrap {
  overflow-x: auto;
}

.lb-table,
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.lb-table th,
.lb-table td,
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.lb-table th,
.admin-table th {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.lb-table .num,
.admin-table .num {
  text-align: right;
  font-family: var(--mono);
}

.lb-table tr.me {
  background: var(--gold-dim);
}

.lb-table tr.me td:first-child {
  color: var(--gold);
  font-weight: 700;
}

.rank-medal {
  font-weight: 700;
}

/* ---------- Admin ---------- */
.admin-main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.admin-main h1 {
  font-family: var(--display);
  margin: 0 0 0.35rem;
}

.invite-form {
  display: grid;
  grid-template-columns: 1fr 100px auto;
  gap: 0.75rem;
  align-items: end;
  margin: 1rem 0;
}

.created-link {
  margin: 0.75rem 0 1.25rem;
  padding: 0.9rem;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid rgba(240, 193, 75, 0.35);
}

.created-link label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.copy-row {
  display: flex;
  gap: 0.5rem;
}

.copy-row input {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.status-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.status-pill.active {
  background: rgba(74, 222, 128, 0.15);
  color: var(--success);
}

.status-pill.used,
.status-pill.revoked,
.status-pill.expired {
  background: rgba(168, 146, 196, 0.12);
  color: var(--text-muted);
}

.link-cell {
  font-family: var(--mono);
  font-size: 0.78rem;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero-panel,
  .slots-main {
    grid-template-columns: 1fr;
  }

  .invite-form {
    grid-template-columns: 1fr;
  }

  .nav-links {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .topbar {
    gap: 0.6rem;
  }
}

/* ---------- Social floor layout ---------- */
:root {
  --social-width: 320px;
}

.app-shell.has-social {
  padding-right: 0;
}

body.has-social-rail .app-shell.has-social {
  padding-right: var(--social-width);
}

body.has-social-rail .topbar {
  padding-right: calc(var(--social-width) + 1rem);
}

.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  font-size: 1.15rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
  padding: 0;
  transition: border-color 0.15s, transform 0.1s;
}

.avatar-btn:hover {
  border-color: var(--gold);
  transform: scale(1.05);
}

.social-rail {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--social-width);
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: rgba(14, 8, 24, 0.96);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

.social-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0.9rem 0.55rem;
  border-bottom: 1px solid var(--border);
}

.social-rail-head h2 {
  font-family: var(--display);
  font-size: 1rem;
  margin: 0;
}

.online-count-pill {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.12);
  color: var(--success);
}

.social-online {
  max-height: 34%;
  overflow-y: auto;
  padding: 0.5rem 0.55rem;
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: #5c3f88 #120a1c;
}

.social-online::-webkit-scrollbar {
  width: 8px;
}

.social-online::-webkit-scrollbar-thumb {
  background: #5c3f88;
  border-radius: 6px;
}

.online-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4rem 0.45rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.online-user:hover {
  background: var(--bg-card);
}

.online-user .av {
  font-size: 1.25rem;
  width: 1.6rem;
  text-align: center;
}

.online-user .meta {
  flex: 1;
  min-width: 0;
}

.online-user .name {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-user .bal {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--gold);
}

.dot-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.7);
  flex-shrink: 0;
}

.social-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.social-chat-head {
  padding: 0.55rem 0.9rem 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 0.35rem 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  scrollbar-width: thin;
  scrollbar-color: #5c3f88 #120a1c;
}

.chat-log::-webkit-scrollbar {
  width: 8px;
}

.chat-log::-webkit-scrollbar-thumb {
  background: #5c3f88;
  border-radius: 6px;
}

.chat-msg {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 0.4rem;
  align-items: start;
}

.chat-msg .av {
  font-size: 1.1rem;
  line-height: 1.2;
}

.chat-msg .who {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.1rem;
}

.chat-msg .who strong {
  color: var(--text);
  font-weight: 600;
}

.chat-msg .who .admin-tag {
  color: var(--gold);
  font-weight: 700;
  margin-left: 0.25rem;
}

.chat-msg .body {
  font-size: 0.88rem;
  line-height: 1.35;
  word-break: break-word;
}

.chat-form {
  display: flex;
  gap: 0.4rem;
  padding: 0.65rem 0.7rem 0.85rem;
  border-top: 1px solid var(--border);
  background: rgba(10, 6, 18, 0.6);
}

.chat-form input {
  flex: 1;
  font: inherit;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}

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

.chat-form button {
  flex-shrink: 0;
}

/* Avatar picker */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.4rem;
  margin: 0.5rem 0 0.75rem;
}

.avatar-opt {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 1.25rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.avatar-opt:hover,
.avatar-opt.active {
  border-color: var(--gold);
  background: var(--gold-dim);
}

/* Players page */
.players-main {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.players-table tbody tr {
  cursor: pointer;
}

.players-table tbody tr:hover {
  background: var(--gold-dim);
}

.players-table .av-cell {
  font-size: 1.25rem;
  width: 2rem;
}

.status-online {
  color: var(--success);
  font-weight: 600;
  font-size: 0.85rem;
}

.status-offline {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.player-detail-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.player-avatar-lg {
  font-size: 2.4rem;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.detail-stats {
  margin: 1rem 0;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.detail-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.detail-columns h3 {
  font-family: var(--display);
  font-size: 1.05rem;
  margin: 0 0 0.25rem;
}

.audit-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  max-height: 360px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #5c3f88 #120a1c;
}

.audit-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0.35rem;
  border-bottom: 1px solid rgba(58, 42, 85, 0.5);
  font-size: 0.82rem;
}

.audit-list .audit-main {
  min-width: 0;
}

.audit-list .audit-kind {
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.audit-list .audit-note {
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.audit-list .audit-amt {
  font-family: var(--mono);
  flex-shrink: 0;
  text-align: right;
}

.audit-list .pos {
  color: var(--success);
}

.audit-list .neg {
  color: var(--danger);
}

.social-toggle-mobile {
  display: none;
}

@media (max-width: 1100px) {
  :root {
    --social-width: 280px;
  }
}

@media (max-width: 860px) {
  body.has-social-rail .app-shell.has-social {
    padding-right: 0;
  }

  body.has-social-rail .topbar {
    padding-right: 1.25rem;
  }

  .social-rail {
    transform: translateX(100%);
    transition: transform 0.2s ease;
  }

  body.social-open .social-rail {
    transform: translateX(0);
  }

  .social-toggle-mobile {
    display: inline-flex;
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 50;
    border-radius: 999px;
    box-shadow: var(--shadow);
  }

  .detail-columns {
    grid-template-columns: 1fr;
  }
}

/* Admin sound check */
.sfx-check {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.75rem;
}

.sfx-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.sfx-label {
  min-width: 4.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.sfx-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex: 1;
}

.sfx-spin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.45rem;
  flex: 1;
  width: 100%;
}

.sfx-spin-pick-row {
  align-items: flex-start;
}

.sfx-spin-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.sfx-spin-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-card);
}

.sfx-spin-card.active {
  border-color: var(--gold);
  background: var(--gold-dim);
  box-shadow: 0 0 0 1px rgba(240, 193, 75, 0.25);
}

.sfx-spin-name {
  font-weight: 700;
  font-size: 0.88rem;
}

.sfx-spin-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.25;
}

/* ---------- Bar ---------- */
.bar-main {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.bar-hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
}

.bar-hero h1 {
  font-family: var(--display);
  margin: 0 0 0.5rem;
}

.drink-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: 0.85rem;
}

.drink-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.drink-card .drink-top {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.drink-card .drink-emoji {
  font-size: 1.75rem;
}

.drink-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.drink-card .price {
  font-family: var(--mono);
  color: var(--gold);
  font-weight: 700;
}

.drink-card .blurb {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.4;
  flex: 1;
  margin: 0;
}

.drink-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.active-drink-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(240, 193, 75, 0.35);
  background: var(--gold-dim);
}

.active-drink-emoji {
  font-size: 1.8rem;
}

/* Drink effect flair on body */
body.effect-champagne .user-pill,
body.effect-champagne #user-pill {
  color: var(--gold);
  text-shadow: 0 0 12px rgba(240, 193, 75, 0.45);
}

body.effect-absinthe {
  filter: hue-rotate(40deg) saturate(1.15);
}

body.effect-whiskey .spin-message.win {
  font-size: 1.2rem;
}

body.effect-lager .chat-msg .who strong::after {
  content: " 🍺";
}

body.effect-baller .brand-text::after {
  content: " · BALLER";
  color: var(--gold);
  font-size: 0.75rem;
}

.online-user .drink-badge {
  font-size: 0.9rem;
}

@media (max-width: 860px) {
  .bar-hero {
    grid-template-columns: 1fr;
  }
}

/* ---------- Liar's Table / Roulette ---------- */
.alpha-badge {
  background: rgba(251, 146, 60, 0.2);
  color: #fb923c;
  border: 1px solid rgba(251, 146, 60, 0.4);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.game-badge.alpha,
.alpha-badge {
  background: rgba(251, 146, 60, 0.18);
  color: #fb923c;
}

/* Fit under topbar; leave room for chat rail when present */
body.page-roulette .app-shell.roulette-shell {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

body.page-roulette {
  /* Avoid rubber-band scroll stealing touches from the table */
  overscroll-behavior: none;
  touch-action: manipulation;
}

body.page-roulette .app-shell.roulette-shell > .topbar {
  flex-shrink: 0;
}

.roulette-layout {
  display: grid;
  grid-template-columns: minmax(180px, 220px) 1fr;
  gap: 0.55rem;
  padding: 0.45rem 0.65rem 0.55rem;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: none;
  overflow: hidden;
}

.roulette-sidebar {
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  padding: 0.65rem 0.7rem !important;
  font-size: 0.88rem;
}

.roulette-sidebar h1 {
  font-family: var(--display);
  font-size: 1.05rem;
  margin: 0;
}

.roulette-sidebar .lb-header {
  margin-bottom: 0.45rem;
}

.roulette-sidebar .game-h4 {
  font-size: 0.82rem;
  margin: 0.55rem 0 0.25rem;
}

.roulette-sidebar .btn-block {
  width: 100%;
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
}

.roulette-sidebar .btn-sm {
  padding: 0.25rem 0.45rem;
  font-size: 0.75rem;
}

.roulette-stage {
  position: relative;
  min-height: 0;
  height: 100%;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stage-frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #3a2a55;
  background: #120a14;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
}

#rr-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.stage-overlay {
  position: absolute;
  left: 0;
  right: 0;
  top: 0.5rem;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}

.overlay-banner {
  background: rgba(10, 6, 18, 0.82);
  border: 1px solid var(--border-strong);
  color: var(--gold);
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  text-shadow: 0 0 12px rgba(240, 193, 75, 0.35);
}

/* In-scene gameplay HUD (actions live on the 3D side) */
.stage-hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  padding: 0.55rem 0.65rem 0.7rem;
}

.stage-hud-top,
.stage-hud-bottom {
  pointer-events: none;
}

.stage-hud .btn,
.stage-hud button {
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.stage-hud-tools {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  pointer-events: auto;
}

.stage-tool-btn {
  min-height: 36px;
  min-width: 3.25rem;
  background: rgba(10, 6, 18, 0.75) !important;
  border-color: rgba(92, 63, 136, 0.7) !important;
  font-size: 0.75rem;
}

.stage-log-drawer {
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  bottom: 0.5rem;
  top: auto;
  max-height: min(48%, 320px);
  z-index: 8;
  background: rgba(10, 6, 18, 0.94);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 0.45rem 0.55rem;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.stage-log-drawer[hidden] {
  display: none !important;
}

.stage-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  flex-shrink: 0;
}

.stage-log-head strong {
  font-size: 0.82rem;
  color: var(--gold);
}

#rr-log-stage.audit-list {
  margin: 0;
  max-height: none;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.stage-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin-top: 2.1rem; /* under overlay banner */
}

.stage-chip {
  background: rgba(10, 6, 18, 0.78);
  border: 1px solid rgba(92, 63, 136, 0.65);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  color: var(--text);
  backdrop-filter: blur(4px);
}

.stage-chip .muted {
  margin-right: 0.25rem;
  font-size: 0.68rem;
}

.stage-chip.pot-chip strong {
  color: var(--gold);
}

.stage-turn {
  text-align: center;
  margin: 0.45rem auto 0;
  max-width: 28rem;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--gold);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.85);
  background: rgba(10, 6, 18, 0.55);
  border: 1px solid rgba(240, 193, 75, 0.25);
  border-radius: 10px;
  padding: 0.35rem 0.75rem;
  pointer-events: none;
}

.stage-hud-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  pointer-events: auto;
  background: linear-gradient(
    180deg,
    rgba(10, 6, 18, 0) 0%,
    rgba(10, 6, 18, 0.72) 35%,
    rgba(10, 6, 18, 0.88) 100%
  );
  padding: 0.85rem 1rem 0.35rem;
  border-radius: 14px;
  width: min(100%, 34rem);
}

.btn-stage {
  min-width: 8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.btn-stage-pull {
  min-width: 12rem;
  font-size: 1rem !important;
  padding: 0.65rem 1.25rem !important;
  letter-spacing: 0.1em;
  border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.35), 0 8px 24px rgba(127, 29, 29, 0.45);
}

.btn-stage-leave {
  min-width: 6.5rem;
  opacity: 0.9;
}

.stage-feedback {
  margin: 0;
  text-align: center;
  font-size: 0.78rem;
  max-width: 28rem;
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

.rr-side-note {
  margin: 0.25rem 0 0.5rem;
}

.stage-hint {
  margin: 0.25rem 0 0;
  text-align: center;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.rr-table-list {
  list-style: none;
  margin: 0.35rem 0;
  padding: 0;
  max-height: 140px;
  overflow-y: auto;
}

.rr-table-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(58, 42, 85, 0.5);
  font-size: 0.8rem;
}

.rr-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  margin: 0.45rem 0;
  font-size: 0.78rem;
}

.rr-turn {
  font-weight: 700;
  color: var(--gold);
  min-height: 1.2em;
  font-size: 0.82rem;
  margin: 0.25rem 0;
}

.rr-actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.45rem 0;
}

.btn-pull {
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  padding: 0.45rem 0.6rem;
  animation: pull-pulse 1.4s ease-in-out infinite;
}

.btn-stage-pull.btn-pull {
  font-size: 1rem;
  padding: 0.65rem 1.25rem;
}

@keyframes pull-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.35); }
  50% { box-shadow: 0 0 14px 1px rgba(248, 113, 113, 0.4); }
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.field-label input {
  font: inherit;
  font-family: var(--mono);
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

/* Chat rail still visible but stage uses remaining width */
body.page-roulette.has-social-rail .roulette-layout {
  padding-right: 0.35rem;
}

body.page-roulette.has-social-rail .app-shell.roulette-shell {
  /* social rail is fixed; keep layout from overflowing under it */
  padding-right: var(--social-width, 320px);
}

body.page-roulette.has-social-rail .topbar {
  padding-right: calc(var(--social-width, 320px) + 0.75rem);
}

#rr-log.audit-list {
  max-height: 220px;
}

/* ---------- Liar's Table mobile / narrow ---------- */
@media (max-width: 960px) {
  body.page-roulette.has-social-rail .app-shell.roulette-shell {
    padding-right: 0;
  }

  body.page-roulette.has-social-rail .topbar {
    padding-right: 0.65rem;
  }

  /* Compact topbar so the stage gets height */
  body.page-roulette .topbar {
    padding: 0.4rem 0.55rem;
    gap: 0.35rem;
  }

  body.page-roulette .nav-links {
    display: none;
  }

  body.page-roulette .brand-text {
    font-size: 0.85rem;
  }

  body.page-roulette .alpha-badge {
    display: none;
  }

  body.page-roulette .user-pill {
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.75rem;
  }

  body.page-roulette .balance-chip,
  body.page-roulette .debt-chip {
    min-width: 0;
    padding: 0.15rem 0.45rem;
  }

  body.page-roulette .chip-label {
    font-size: 0.58rem;
  }

  body.page-roulette .chip-value {
    font-size: 0.78rem;
  }

  body.page-roulette #logout-btn {
    padding: 0.3rem 0.45rem;
    font-size: 0.72rem;
  }

  .roulette-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.35rem;
    padding: 0.3rem 0.35rem 0.35rem;
  }

  /* Lobby: usable join list + preview of stage */
  body.page-roulette:not(.rr-at-table) .roulette-sidebar {
    max-height: min(46vh, 360px);
    -webkit-overflow-scrolling: touch;
  }

  body.page-roulette:not(.rr-at-table) .roulette-stage {
    min-height: 0;
  }

  body.page-roulette:not(.rr-at-table) .stage-frame {
    min-height: 200px;
  }

  /* In-game: full-bleed stage — sidebar out of the way */
  body.page-roulette.rr-at-table .roulette-layout {
    grid-template-rows: 1fr;
    padding: 0.2rem 0.25rem 0.25rem;
    gap: 0;
  }

  body.page-roulette.rr-at-table .roulette-sidebar {
    display: none;
  }

  body.page-roulette.rr-at-table .roulette-stage {
    padding: 0.15rem;
    border-radius: 10px;
  }

  body.page-roulette.rr-at-table .stage-frame {
    min-height: 0;
    border-radius: 10px;
  }

  body.page-roulette.rr-at-table .stage-hint {
    display: none;
  }

  .roulette-sidebar .btn-block,
  .roulette-sidebar .btn {
    min-height: 44px;
    touch-action: manipulation;
  }

  .rr-table-list {
    max-height: none;
  }

  .rr-table-item {
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.5rem 0;
  }

  .rr-table-item .btn {
    min-height: 40px;
    min-width: 4.5rem;
    flex-shrink: 0;
  }

  .field-label input {
    min-height: 44px;
    font-size: 16px; /* prevent iOS focus zoom */
  }

  .stage-hud {
    padding: 0.4rem 0.4rem max(0.45rem, env(safe-area-inset-bottom, 0px));
  }

  .stage-meta {
    margin-top: 1.7rem;
    gap: 0.25rem;
  }

  .stage-chip {
    padding: 0.18rem 0.45rem;
    font-size: 0.7rem;
  }

  .stage-turn {
    font-size: 0.8rem;
    padding: 0.3rem 0.55rem;
    margin-top: 0.35rem;
    max-width: 100%;
  }

  .overlay-banner {
    font-size: 0.72rem;
    padding: 0.25rem 0.55rem;
    max-width: calc(100% - 1rem);
    text-align: center;
  }

  .stage-actions {
    width: 100%;
    max-width: 100%;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.55rem 0.45rem 0.15rem;
    border-radius: 12px 12px 0 0;
  }

  .btn-stage,
  .btn-stage-leave,
  .btn-stage-pull {
    width: 100%;
    min-width: 0;
    min-height: 48px;
  }

  .btn-stage-pull {
    font-size: 1.05rem !important;
    padding: 0.75rem 1rem !important;
    letter-spacing: 0.08em;
    order: -1; /* pull first when visible */
  }

  .btn-stage-leave {
    min-height: 42px;
    opacity: 1;
  }

  /* Keep chat FAB clear of PULL / Leave */
  body.page-roulette .social-toggle-mobile {
    bottom: calc(7.25rem + env(safe-area-inset-bottom, 0px));
    right: 0.65rem;
    min-height: 44px;
    padding: 0.55rem 0.85rem;
  }

  body.page-roulette.rr-at-table .social-toggle-mobile {
    bottom: calc(9.5rem + env(safe-area-inset-bottom, 0px));
  }

  body.page-roulette.social-open .social-toggle-mobile {
    bottom: 1rem;
  }

  .stage-log-drawer {
    left: 0.35rem;
    right: 0.35rem;
    bottom: calc(5.75rem + env(safe-area-inset-bottom, 0px));
    max-height: min(42%, 280px);
  }

  body.page-roulette.rr-at-table .stage-tool-btn {
    min-height: 40px;
  }
}

/* Very narrow phones */
@media (max-width: 400px) {
  body.page-roulette .brand-text {
    display: none;
  }

  .stage-chip .muted {
    display: none;
  }

  .btn-stage-pull {
    font-size: 0.95rem !important;
    letter-spacing: 0.05em;
  }
}

/* Landscape phones — maximize horizontal stage */
@media (max-width: 960px) and (max-height: 480px) and (orientation: landscape) {
  body.page-roulette .topbar {
    padding: 0.2rem 0.4rem;
  }

  body.page-roulette .balance-chip .chip-label,
  body.page-roulette .debt-chip,
  body.page-roulette #logout-btn {
    display: none;
  }

  body.page-roulette:not(.rr-at-table) .roulette-layout {
    grid-template-columns: minmax(160px, 38%) 1fr;
    grid-template-rows: 1fr;
  }

  body.page-roulette:not(.rr-at-table) .roulette-sidebar {
    max-height: none;
  }

  body.page-roulette.rr-at-table .stage-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  body.page-roulette.rr-at-table .btn-stage-pull {
    width: auto;
    min-width: 11rem;
    flex: 1 1 auto;
  }

  body.page-roulette.rr-at-table .btn-stage,
  body.page-roulette.rr-at-table .btn-stage-leave {
    width: auto;
    flex: 0 1 auto;
  }

  body.page-roulette .social-toggle-mobile,
  body.page-roulette.rr-at-table .social-toggle-mobile {
    bottom: 0.5rem;
    right: 0.5rem;
  }

  .stage-meta {
    margin-top: 1.35rem;
  }

  .stage-turn {
    font-size: 0.72rem;
    padding: 0.2rem 0.45rem;
  }

  .stage-log-drawer {
    bottom: 3.5rem;
    max-height: 55%;
  }
}

/* Blood / bang FX on roulette stage */
.blood-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  overflow: hidden;
  opacity: 0;
}

.blood-layer.active {
  opacity: 1;
  animation: blood-fade 2.8s ease-out forwards;
}

.blood-splat {
  position: absolute;
  border-radius: 50% 40% 55% 45%;
  background: radial-gradient(circle at 30% 30%, #e11d48, #7f1d1d 55%, #450a0a 100%);
  box-shadow:
    0 0 12px rgba(127, 29, 29, 0.6),
    inset -4px -6px 10px rgba(0, 0, 0, 0.35);
  transform: scale(0);
  animation: splat-pop 0.55s cubic-bezier(0.2, 1.4, 0.3, 1) forwards;
}

.blood-drip {
  position: absolute;
  width: 6px;
  background: linear-gradient(180deg, #9f1239, #7f1d1d);
  border-radius: 0 0 4px 4px;
  animation: drip-down 1.4s ease-in forwards;
  opacity: 0.9;
}

.bang-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: radial-gradient(circle at 50% 45%, rgba(255, 80, 60, 0.55), transparent 55%);
  opacity: 0;
}

.bang-flash.active {
  animation: bang-flash 0.45s ease-out forwards;
}

.stage-frame.shake {
  animation: stage-shake 0.45s ease-out;
}

@keyframes splat-pop {
  0% { transform: scale(0) rotate(0deg); opacity: 0; }
  40% { transform: scale(1.15) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(-4deg); opacity: 0.92; }
}

@keyframes drip-down {
  0% { height: 0; opacity: 0; }
  20% { opacity: 0.95; }
  100% { height: 70px; opacity: 0.35; }
}

@keyframes blood-fade {
  0%, 55% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes bang-flash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes stage-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -4px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(3px, 2px); }
}
