:root {
  --bg: #090c0b;
  --bg-2: #0f1513;
  --panel: rgba(14, 19, 17, 0.88);
  --panel-solid: #121816;
  --line: rgba(216, 180, 90, 0.18);
  --line-strong: rgba(216, 180, 90, 0.45);
  --gold: #d8b45a;
  --gold-2: #f3dd9b;
  --gold-3: #a07a2a;
  --red: #b3232b;
  --red-2: #e0434b;
  --black: #151617;
  --green: #12804a;
  --felt: #0f5638;
  --felt-dark: #082d1e;
  --text: #f1ede2;
  --muted: #9aa59f;
  --ok: #5fd39a;
  --danger: #e2575e;
  --radius: 14px;
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --felt-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(40, 90, 64, 0.35), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(120, 70, 20, 0.12), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
kbd {
  font-family: var(--sans); font-size: 11px; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--line-strong); background: rgba(255,255,255,.05);
}

/* ------------------------------------------------------------------ buttons */
.btn {
  --b: rgba(255,255,255,.06);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--b); font-weight: 600; letter-spacing: .02em;
  transition: transform .12s ease, background .2s, box-shadow .2s, opacity .2s, border-color .2s;
  user-select: none; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: rgba(255,255,255,.1); border-color: var(--gold); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 14px 22px; font-size: 16px; }
.btn.wide { width: 100%; }
.btn-gold {
  color: #241703; border-color: #f6e2a4;
  background: linear-gradient(180deg, #f7e3a3 0%, #d8b45a 48%, #b48a34 100%);
  box-shadow: 0 6px 20px -8px rgba(216,180,90,.7), inset 0 1px 0 rgba(255,255,255,.6);
}
.btn-gold:hover:not(:disabled) { background: linear-gradient(180deg, #fff0bd 0%, #e2c06a 48%, #c0953d 100%); }
.btn-gold.active { background: linear-gradient(180deg, #8ff0bd, #3fbf7c 55%, #2a8f5a); border-color: #b8ffd8; color: #032112; }
.btn-red {
  color: #fff; border-color: #ff8a8f;
  background: linear-gradient(180deg, #e54a52 0%, #b3232b 55%, #861319 100%);
  box-shadow: 0 6px 20px -8px rgba(227, 67, 75, .8), inset 0 1px 0 rgba(255,255,255,.35);
}
.btn-red:hover:not(:disabled) { background: linear-gradient(180deg, #f2616a 0%, #c42d35 55%, #93161d 100%); }
.btn-ghost { background: rgba(255,255,255,.04); }
.btn-danger { border-color: rgba(226,87,94,.6); color: #ffb3b7; background: rgba(226,87,94,.08); }
.btn-danger:hover:not(:disabled) { background: rgba(226,87,94,.18); border-color: var(--danger); }

.icon-btn {
  position: relative;
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--gold-2);
  font-weight: 700; transition: background .2s, border-color .2s;
}
.icon-btn:hover { background: rgba(255,255,255,.09); border-color: var(--gold); }
.badge {
  position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--red-2); color: #fff; font-size: 10px; font-style: normal;
  display: grid; place-items: center; font-weight: 700;
}
.tab .badge { position: static; display: inline-grid; margin-left: 4px; }

/* ------------------------------------------------------------------ forms */
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field > span { font-weight: 600; letter-spacing: .02em; }
.field small { font-size: 11.5px; color: var(--muted); opacity: .8; }
.field em { font-style: normal; opacity: .7; font-weight: 400; }
input, select {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: rgba(0,0,0,.35); color: var(--text);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(216,180,90,.18); }
select option { background: var(--panel-solid); }
.form-error { min-height: 18px; margin: 0; color: #ff9aa0; font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; min-width: 0; }
.dialog-row { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--line); padding-top: 14px; }
.grow { flex: 1; }

/* ------------------------------------------------------------------ landing */
.landing { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.landing-glow {
  position: absolute; inset: -20%;
  background:
    radial-gradient(500px 300px at 50% 35%, rgba(216,180,90,.13), transparent 70%),
    radial-gradient(700px 500px at 50% 60%, rgba(18,128,74,.22), transparent 70%);
  pointer-events: none;
}
.landing-card {
  position: relative; width: min(440px, 100%);
  padding: 36px 32px 26px; border-radius: 24px;
  background: linear-gradient(180deg, rgba(20,28,25,.92), rgba(10,14,12,.95));
  border: 1px solid var(--line-strong);
  box-shadow: 0 40px 120px -30px rgba(0,0,0,.9), inset 0 1px 0 rgba(255,255,255,.05);
}
.landing-card::before {
  content: ''; position: absolute; inset: 8px; border-radius: 18px; pointer-events: none;
  border: 1px solid rgba(216,180,90,.12);
}
.brand { text-align: center; margin-bottom: 26px; }
.brand-mark { width: 84px; height: 84px; margin: 0 auto 14px; filter: drop-shadow(0 10px 24px rgba(0,0,0,.6)); }
.brand-mark svg { width: 100%; height: 100%; animation: spin 18s linear infinite; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .32em; font-size: 11px; color: var(--gold); }
.brand h1 {
  margin: 6px 0 6px; font-family: var(--serif); font-weight: 800; font-size: 40px; letter-spacing: .01em;
  background: linear-gradient(180deg, #fff6d6, #d8b45a 60%, #a07a2a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { margin: 0; color: var(--muted); }
.landing-form { display: grid; gap: 14px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .18em; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; text-align: center; }
.fineprint { margin: 18px 0 0; text-align: center; font-size: 12px; color: var(--muted); opacity: .8; }

/* ------------------------------------------------------------------ game shell */
.game { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(10,14,12,.95), rgba(10,14,12,.8));
  backdrop-filter: blur(8px); z-index: 5;
}
.brand-small {
  font-family: var(--serif); font-weight: 800; font-size: 20px; white-space: nowrap;
  background: linear-gradient(180deg, #fff2c8, #d8b45a 70%); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.code-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(0,0,0,.3);
}
.code-pill b { font-size: 15px; letter-spacing: .28em; color: var(--gold-2); }
.code-label { font-size: 11px; text-transform: uppercase; letter-spacing: .15em; color: var(--muted); }
.code-copy { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(216,180,90,.14); color: var(--gold-2); }
.code-pill:hover .code-copy { background: rgba(216,180,90,.28); }

.phase { flex: 1; max-width: 420px; margin: 0 auto; display: grid; gap: 6px; text-align: center; }
.phase-text { display: flex; justify-content: center; gap: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 13px; color: var(--gold-2); }
#phaseTimer { font-variant-numeric: tabular-nums; color: #fff; min-width: 2.5ch; }
.phase-bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; }
.phase-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-3), var(--gold-2)); border-radius: 4px; transition: width .25s linear; }
.phase.spinning .phase-text { color: #ff9aa0; }
.phase.spinning .phase-bar i { background: linear-gradient(90deg, #861319, #f2616a); }
.phase.results .phase-text { color: var(--ok); }
.phase.results .phase-bar i { background: linear-gradient(90deg, #1d6b45, #5fd39a); }
.phase.urgent #phaseTimer { color: #ff8a8f; animation: blink .5s steps(2) infinite; }
.top-actions { display: flex; gap: 8px; }
.panel-toggle { display: none; }

.layout { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: 0; }
.table-area { display: flex; flex-direction: column; gap: 12px; padding: 16px; min-height: 0; overflow: auto; }

/* ------------------------------------------------------------------ table */
.rail {
  position: relative; padding: 14px; border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.12), rgba(0,0,0,.25)),
    repeating-linear-gradient(95deg, #3b1d0c 0 7px, #4a2511 7px 11px, #351a0a 11px 19px),
    #3b1d0c;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.95), inset 0 2px 0 rgba(255,255,255,.12), inset 0 -3px 8px rgba(0,0,0,.5);
}
.rail::after {
  content: ''; position: absolute; inset: 10px; border-radius: 20px; pointer-events: none;
  box-shadow: 0 0 0 1px rgba(216,180,90,.55), 0 0 0 3px rgba(0,0,0,.4);
}
.rail { container-type: inline-size; container-name: table; }
.felt {
  position: relative; border-radius: 18px; padding: 18px 22px;
  display: grid; grid-template-columns: minmax(200px, 30%) minmax(0, 1fr); gap: 22px; align-items: center;
  background:
    var(--felt-noise),
    radial-gradient(120% 90% at 50% 30%, #17714a 0%, #0f5638 45%, #08321f 100%);
  background-blend-mode: overlay, normal;
  box-shadow: inset 0 0 80px rgba(0,0,0,.55), inset 0 0 0 1px rgba(0,0,0,.6);
  overflow: hidden;
}
.felt::before {
  content: 'THE BACK ROOM'; position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%);
  font-family: var(--serif); font-weight: 800; letter-spacing: .6em; font-size: 11px; color: rgba(243,221,155,.16); pointer-events: none; white-space: nowrap;
}
.wheel-zone { display: grid; gap: 14px; justify-items: center; }
.wheel-wrap { position: relative; width: 100%; max-width: 340px; aspect-ratio: 1; filter: drop-shadow(0 22px 30px rgba(0,0,0,.6)); }
.wheel-wrap canvas { width: 100%; height: 100%; display: block; }
.history-zone { width: 100%; max-width: 340px; }
.mini-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .22em; color: rgba(243,221,155,.7); margin-bottom: 8px; }
.history { display: flex; flex-wrap: wrap; gap: 5px; min-height: 28px; }
.hnum {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 700; font-size: 13px; color: #fff; font-variant-numeric: lining-nums;
  border: 1px solid rgba(255,255,255,.25); box-shadow: inset 0 -2px 4px rgba(0,0,0,.35);
}
.hnum.red { background: radial-gradient(circle at 35% 30%, #e0434b, #8f161d); }
.hnum.black { background: radial-gradient(circle at 35% 30%, #3a3b40, #0b0b0c); }
.hnum.green { background: radial-gradient(circle at 35% 30%, #22b56a, #0a5430); }
.hnum:first-child { width: 36px; height: 36px; font-size: 16px; border-color: var(--gold-2); box-shadow: 0 0 0 2px rgba(216,180,90,.35), inset 0 -2px 4px rgba(0,0,0,.35); }
.hnum.fresh { animation: pop .5s cubic-bezier(.2,1.6,.4,1); }
.stats { margin-top: 10px; display: grid; gap: 6px; }
.stat-bar { display: flex; height: 6px; border-radius: 6px; overflow: hidden; background: rgba(0,0,0,.3); }
.stat-bar i { display: block; height: 100%; transition: width .4s; }
.stat-legend { display: flex; justify-content: space-between; font-size: 11px; color: rgba(241,237,226,.7); font-variant-numeric: tabular-nums; }

.result-badge {
  position: absolute; left: 50%; top: 50%; width: 38%; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%) scale(.3); opacity: 0; pointer-events: none;
  display: grid; place-items: center; align-content: center;
  font-family: var(--serif); color: #fff; text-align: center; font-variant-numeric: lining-nums;
  border: 3px solid var(--gold-2);
  box-shadow: 0 0 0 6px rgba(0,0,0,.35), 0 0 40px rgba(243,221,155,.55), inset 0 -8px 16px rgba(0,0,0,.35);
  transition: transform .45s cubic-bezier(.2,1.5,.4,1), opacity .25s;
}
.result-badge.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.result-badge.red { background: radial-gradient(circle at 35% 30%, #ea535b, #8f161d); }
.result-badge.black { background: radial-gradient(circle at 35% 30%, #45464c, #0b0b0c); }
.result-badge.green { background: radial-gradient(circle at 35% 30%, #2ac477, #0a5430); }
.result-badge b { font-size: clamp(28px, 9cqw, 64px); line-height: 1; }
.wheel-wrap { container-type: inline-size; }
.result-badge b { font-size: 15cqw; }
.result-badge small { font-family: var(--sans); font-weight: 600; font-size: 3cqw; letter-spacing: .14em; text-transform: uppercase; opacity: .92; line-height: 1.35; }
.result-badge small:first-of-type { margin-top: 1cqw; font-weight: 800; }

.board-zone { min-width: 0; display: grid; gap: 8px; }
.board { width: 100%; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.board-svg { width: 100%; height: auto; display: block; overflow: visible; }
.hover-info { min-height: 20px; text-align: center; font-size: 13px; color: rgba(243,221,155,.8); letter-spacing: .02em; }
.hover-info b { color: #fff; }

/* SVG board styling */
.board-bg { fill: rgba(0,0,0,.12); }
.cell { fill: rgba(0,0,0,0); transition: fill .15s; }
.cell.n-green { fill: rgba(18,128,74,.55); }
.grid-lines { fill: none; stroke: rgba(243,221,155,.62); stroke-width: 1.6; stroke-linecap: square; }
.cell.n-green, path.cell { stroke: rgba(243,221,155,.62); stroke-width: 1.6; }
.num-bg { stroke: rgba(243,221,155,.45); stroke-width: 1; transition: filter .15s; }
.num-bg.n-red { fill: #a71f27; }
.num-bg.n-black { fill: #141516; }
.num { font-variant-numeric: lining-nums; fill: #f5efdd; font-family: var(--serif); font-weight: 700; font-size: 22px; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.board-svg.vertical .num { font-size: 20px; }
.lbl { fill: #f3dd9b; font-family: var(--sans); font-weight: 600; font-size: 15px; letter-spacing: .08em; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.lbl.small { font-size: 12.5px; letter-spacing: .04em; }
.diamond { stroke: rgba(243,221,155,.7); stroke-width: 1.2; }
.d-red { fill: #b3232b; }
.d-black { fill: #101112; }
.cell.lit { fill: rgba(255, 233, 160, .22); }
.cell.n-green.lit { fill: rgba(60, 200, 130, .75); }
.board:not(.locked) .hs { cursor: pointer; }
.hs { fill: transparent; }
.board:not(.locked) .hs:hover { fill: rgba(255, 236, 170, .08); }
.board:not(.locked) .hs.corner:hover { fill: rgba(255, 236, 170, .35); }
.board.locked .hs { cursor: default; }
.num-bg.lit { filter: brightness(1.35); }
.num-bg.winner { stroke: #ffe9a6; stroke-width: 3; filter: drop-shadow(0 0 6px rgba(255,220,120,.9)); }
.cell.winner { animation: winnerPulse 1s ease-in-out infinite alternate; }
.cell.n-green.winner { animation: winnerPulseGreen 1s ease-in-out infinite alternate; }
@keyframes winnerPulse { from { fill: rgba(255, 220, 120, .1); } to { fill: rgba(255, 220, 120, .48); } }
@keyframes winnerPulseGreen { from { fill: rgba(18,128,74,.55); } to { fill: rgba(120, 255, 180, .8); } }

.chip { transition: opacity .3s; }
.chip-label { font-family: var(--sans); font-weight: 800; letter-spacing: -.02em; pointer-events: none; }
.chips { pointer-events: none; }
.chip.theirs { opacity: .95; }
.chip { transform-box: fill-box; transform-origin: center; }
.chip.lost { animation: chipLost 1.3s .6s ease-in forwards; }
.chip.won { animation: chipWon .9s ease-in-out infinite alternate; }
@keyframes chipLost { 40% { opacity: .8; } to { opacity: 0; transform: scale(.4); } }
@keyframes chipWon { from { filter: drop-shadow(0 0 0 rgba(255,220,120,0)); } to { filter: drop-shadow(0 0 7px rgba(255,220,120,.95)); } }
.float { fill: var(--gold-2); font-family: var(--sans); font-weight: 800; font-size: 20px; text-anchor: middle; paint-order: stroke; stroke: rgba(0,0,0,.65); stroke-width: 4px; animation: floatUp 2.4s ease-out forwards; pointer-events: none; }
.float.big { font-size: 26px; fill: #fff3c4; }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(8px); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateY(-34px); } }
.ping { fill: none; stroke-width: 3; animation: ping .7s ease-out forwards; transform-box: fill-box; transform-origin: center; pointer-events: none; }
@keyframes ping { from { opacity: .9; transform: scale(.6); } to { opacity: 0; transform: scale(2.4); } }

/* ------------------------------------------------------------------ controls */
.controls {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 20px 50px -30px rgba(0,0,0,.9);
}
.money { display: flex; gap: 18px; }
.money-item { display: grid; }
.money-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); }
.money-value { font-variant-numeric: lining-nums tabular-nums; font-family: var(--serif); font-weight: 700; font-size: 24px; color: var(--gold-2); font-variant-numeric: tabular-nums; }
.money-value.dim { color: var(--text); opacity: .85; }
.money-value.bump { animation: bump .6s ease; }
.money-value.down { animation: bumpDown .6s ease; }
.chip-tray { flex: 1; display: flex; justify-content: center; gap: 6px; padding: 6px 0; min-width: 0; }
.tray-chip {
  border: none; background: none; padding: 0; border-radius: 50%;
  transition: transform .18s cubic-bezier(.2,1.4,.4,1), filter .2s, opacity .2s;
  filter: drop-shadow(0 4px 5px rgba(0,0,0,.5));
}
.tray-chip svg { display: block; }
.tray-chip:hover { transform: translateY(-3px); }
.tray-chip.selected { transform: translateY(-8px) scale(1.06); filter: drop-shadow(0 0 10px rgba(243,221,155,.85)) drop-shadow(0 6px 6px rgba(0,0,0,.5)); }
.tray-chip.cant { opacity: .3; filter: grayscale(.8); }
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.main-actions { display: flex; gap: 6px; align-items: center; }

/* ------------------------------------------------------------------ side panel */
.side-panel {
  display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--line); background: rgba(10,14,12,.78);
}
.tabs { display: flex; padding: 10px 10px 0; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; padding: 10px 8px; border: none; background: none; color: var(--muted); font-weight: 600; font-size: 13px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--gold-2); border-bottom-color: var(--gold); }
.tab-body { display: none; flex: 1; min-height: 0; flex-direction: column; }
.tab-body.active { display: flex; }
.players { list-style: none; margin: 0; padding: 8px; overflow: auto; flex: 1; }
.player {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  padding: 10px; border-radius: 12px; border: 1px solid transparent; transition: background .2s, border-color .2s;
}
.player + .player { margin-top: 4px; }
.player.me { background: rgba(216,180,90,.07); border-color: rgba(216,180,90,.22); }
.player.clickable { cursor: pointer; }
.player.clickable:hover { background: rgba(255,255,255,.05); border-color: var(--line-strong); }
.player.offline { opacity: .5; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px;
  color: #111; position: relative; box-shadow: inset 0 -3px 6px rgba(0,0,0,.25);
}
.avatar::after {
  content: ''; position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%;
  background: #6b7570; border: 2px solid var(--panel-solid);
}
.player.online .avatar::after { background: var(--ok); }
.pname { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.pname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crown { color: var(--gold); font-size: 13px; }
.tag { font-size: 10px; padding: 2px 6px; border-radius: 6px; background: rgba(95,211,154,.15); color: var(--ok); font-weight: 700; letter-spacing: .05em; }
.tag.you { background: rgba(216,180,90,.15); color: var(--gold-2); }
.psub { font-size: 12px; color: var(--muted); display: flex; gap: 8px; }
.psub .up { color: var(--ok); }
.psub .downv { color: #ff9aa0; }
.pchips { font-variant-numeric: lining-nums tabular-nums; text-align: right; font-family: var(--serif); font-weight: 700; color: var(--gold-2); font-variant-numeric: tabular-nums; }
.pchips small { display: block; font-family: var(--sans); font-weight: 500; font-size: 11px; color: var(--muted); }
.panel-foot { padding: 10px; border-top: 1px solid var(--line); }
.requests { padding: 8px 8px 0; display: grid; gap: 6px; }
.request {
  display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 12px;
  background: rgba(216,180,90,.1); border: 1px solid var(--line-strong); font-size: 13px;
}
.request span { flex: 1; }
.request .btn { padding: 5px 10px; font-size: 12px; }

.chat-list, .log-list { list-style: none; margin: 0; padding: 10px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { font-size: 13.5px; line-height: 1.4; word-wrap: break-word; }
.chat-msg b { margin-right: 6px; }
.chat-msg time, .log-item time { font-size: 10.5px; color: var(--muted); margin-left: 6px; }
.quick-reacts { display: flex; gap: 4px; padding: 0 10px 6px; flex-wrap: wrap; }
.quick-reacts button { border: 1px solid var(--line); background: rgba(255,255,255,.04); border-radius: 999px; padding: 3px 9px; font-size: 13px; }
.quick-reacts button:hover { border-color: var(--gold); }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form input { padding: 8px 12px; }
.log-item { font-size: 12.5px; color: rgba(241,237,226,.85); padding-left: 10px; border-left: 2px solid var(--line); }
.log-item.bank { border-left-color: var(--gold); }

/* ------------------------------------------------------------------ dialogs */
.dialog {
  border: 1px solid var(--line-strong); border-radius: 20px; padding: 0; width: min(520px, calc(100vw - 24px));
  background: linear-gradient(180deg, #151d1a, #0d1210); color: var(--text);
  box-shadow: 0 40px 120px -20px rgba(0,0,0,.9);
}
.dialog.small { width: min(420px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(3,5,4,.65); backdrop-filter: blur(4px); }
.dialog[open] { animation: dialogIn .25s cubic-bezier(.2,1.2,.4,1); }
.dialog-inner { padding: 22px; display: grid; gap: 16px; }
.dialog-head { display: flex; align-items: flex-start; gap: 12px; }
.dialog-head > div { flex: 1; }
.dialog-head h2 { margin: 0; font-family: var(--serif); font-size: 24px; color: var(--gold-2); }
.dialog-head p { margin: 4px 0 0; font-size: 13px; }
.dialog-head .dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 8px; }
.dialog-section { display: grid; gap: 8px; }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); }
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick-grid .btn { padding: 10px 6px; }
.settings-grid { display: grid; gap: 14px; }
.dialog-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.switch { flex: none; width: 40px; height: 23px; border-radius: 999px; background: rgba(255,255,255,.12); position: relative; transition: background .2s; margin-top: 2px; border: 1px solid var(--line); }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #ddd; transition: transform .2s; }
.toggle input:checked + .switch { background: var(--gold-3); }
.toggle input:checked + .switch::after { transform: translateX(17px); background: #fff3c4; }
.toggle input:focus-visible + .switch { box-shadow: 0 0 0 3px rgba(216,180,90,.3); }
.howto { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 14px; line-height: 1.5; }
.payouts { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.payouts th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.payouts td { padding: 8px; border-bottom: 1px solid rgba(255,255,255,.05); }
.payouts td:last-child { font-variant-numeric: lining-nums; font-family: var(--serif); font-weight: 700; color: var(--gold-2); white-space: nowrap; }

/* ------------------------------------------------------------------ toasts & celebration */
.toasts { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; gap: 10px; align-items: center;
  padding: 12px 16px; border-radius: 14px; font-size: 14px;
  background: rgba(18,24,22,.96); border: 1px solid var(--line-strong);
  box-shadow: 0 20px 50px -20px rgba(0,0,0,.9);
  animation: toastIn .3s cubic-bezier(.2,1.3,.4,1);
}
.toast.err { border-color: rgba(226,87,94,.6); }
.toast.good { border-color: rgba(95,211,154,.6); }
.toast.leaving { animation: toastOut .3s ease forwards; }
.toast .btn { padding: 4px 10px; font-size: 12px; }
.toast span { flex: 1; }

.celebrate { position: fixed; inset: 0; pointer-events: none; z-index: 40; display: grid; place-items: center; overflow: hidden; }
.celebrate .win-text {
  font-variant-numeric: lining-nums; font-family: var(--serif); font-weight: 800; font-size: clamp(48px, 10vw, 110px);
  background: linear-gradient(180deg, #fffbe8, #f3dd9b 40%, #c9963a); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 8px 30px rgba(0,0,0,.8)) drop-shadow(0 0 30px rgba(243,221,155,.35));
  animation: winText 2.6s cubic-bezier(.2,1.2,.4,1) forwards;
  text-align: center; line-height: 1;
}
.celebrate .win-text small { display: block; font-family: var(--sans); font-size: .2em; letter-spacing: .3em; text-transform: uppercase; -webkit-text-fill-color: #f3dd9b; margin-bottom: 8px; }
.flying-chip { position: absolute; left: 50%; top: 60%; animation: flyChip var(--dur, 1.6s) cubic-bezier(.15,.7,.3,1) forwards; }

.scrim { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes pop { 0% { transform: scale(.2); } 100% { transform: scale(1); } }
@keyframes bump { 30% { transform: scale(1.18); color: #fff7d6; } }
@keyframes bumpDown { 30% { transform: translateY(2px); color: #ff9aa0; } }
@keyframes dialogIn { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }
@keyframes winText { 0% { opacity: 0; transform: scale(.4); } 18% { opacity: 1; transform: scale(1.06); } 30% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1.02) translateY(-20px); } }
@keyframes flyChip {
  0% { transform: translate(-50%, 0) rotate(0) scale(.6); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), var(--dy)) rotate(var(--rot)) scale(1); opacity: 0; }
}

/* ------------------------------------------------------------------ responsive */
@media (min-width: 761px) {
  .rail { flex: 1 0 auto; display: flex; }
  .felt { flex: 1; align-content: center; }
  .wheel-wrap { max-width: min(400px, 46vh); }
  .history-zone { max-width: min(400px, 46vh); }
}

@container table (max-width: 980px) {
  .felt { grid-template-columns: 1fr; align-content: start; }
  .wheel-zone { grid-template-columns: minmax(140px, 46%) 1fr; align-items: center; justify-items: stretch; gap: 14px; }
  .wheel-wrap { max-width: 300px; }
  .history-zone { align-self: center; max-width: 420px; }
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .panel-toggle { display: grid; }
  .side-panel {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 92vw); z-index: 30;
    transform: translateX(105%); transition: transform .3s cubic-bezier(.2,.9,.3,1);
    background: #0c100e; border-left: 1px solid var(--line-strong);
    box-shadow: -30px 0 80px -30px rgba(0,0,0,.9);
  }
  .layout.panel-open .side-panel { transform: none; }
  .layout.panel-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 25; }
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .brand-small { font-size: 17px; }
  .code-copy { display: none; }
  .code-pill { padding: 5px 12px; }
  .phase { order: 5; flex-basis: 100%; max-width: none; }
  .top-actions { margin-left: auto; gap: 5px; }
  .icon-btn { width: 34px; height: 34px; }
  .table-area { padding: 8px 8px 0; gap: 8px; }
  .rail { padding: 8px; border-radius: 20px; }
  .rail::after { inset: 6px; border-radius: 15px; }
  .felt { padding: 12px 10px 20px; gap: 12px; border-radius: 14px; }
  .controls {
    position: sticky; bottom: 0; z-index: 10; border-radius: 16px 16px 0 0; margin: 0 -8px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: 1fr auto; grid-template-areas: "money main" "tray tray" "actions actions";
    gap: 4px 10px; align-items: center;
    background: rgba(10,14,12,.97); backdrop-filter: blur(10px);
  }
  .money { grid-area: money; gap: 16px; }
  .money-label { font-size: 9.5px; }
  .money-value { font-size: 19px; line-height: 1.1; }
  .main-actions { grid-area: main; }
  .main-actions .btn { padding: 8px 16px; }
  .chip-tray { grid-area: tray; justify-content: flex-start; overflow-x: auto; padding: 8px 2px 2px; scrollbar-width: none; }
  .chip-tray::-webkit-scrollbar { display: none; }
  .tray-chip svg { width: 44px; height: 44px; }
  .actions { grid-area: actions; display: grid; grid-template-columns: repeat(4, 1fr); }
  .actions .btn-sm { padding: 5px 8px; font-size: 12.5px; }
  .stat-legend { flex-wrap: wrap; gap: 2px 10px; justify-content: flex-start; font-size: 10.5px; }
  .stat-legend span { white-space: nowrap; }
}

@media (max-width: 520px) {
  .brand-small { display: none; }
  .topbar { flex-wrap: wrap; }
}


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
