﻿/* TweetSpin — color system */
:root {
  --bg-page: #05070b;
  --bg-0: #0a0e14;
  --bg-1: #10161f;
  --bg-2: #182230;
  --bg-panel: #141b26;
  --bg-input: #0c121a;
  --bg-elevated: #1c2633;
  --line: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.1);
  --text: #eef2f6;
  --muted: #8b98a8;
  --accent: #3dff9a;
  --accent-strong: #2ae87f;
  --accent-dim: rgba(61, 255, 154, 0.12);
  --accent-glow: rgba(61, 255, 154, 0.22);
  --red: #ff4d6d;
  --red-deep: #e83555;
  --black: #1a2330;
  --green: #1aad6f;
  --frame-max: 480px;
}

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

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-page);
  color: var(--text);
  font-family: "DM Sans", "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Default = standalone 5:6 card (browser). Embed mode overrides below. */
.app-shell {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top))
           max(12px, env(safe-area-inset-right))
           max(12px, env(safe-area-inset-bottom))
           max(12px, env(safe-area-inset-left));
  background:
    radial-gradient(ellipse 70% 50% at 50% -10%, rgba(61, 255, 154, 0.12), transparent 55%),
    radial-gradient(ellipse 50% 40% at 85% 80%, rgba(80, 140, 255, 0.08), transparent 50%),
    radial-gradient(ellipse 40% 35% at 10% 70%, rgba(255, 80, 120, 0.06), transparent 45%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-page) 100%);
}

.embed-frame {
  position: relative;
  width: min(100%, calc((100vh - 24px) * 5 / 6), var(--frame-max));
  aspect-ratio: 5 / 6;
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(61, 255, 154, 0.08), transparent 55%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 24px 64px rgba(0, 0, 0, 0.55),
    0 0 80px rgba(61, 255, 154, 0.06);
  container-type: size;
  container-name: embed;
}

body.is-desktop {
  --frame-max: none;
}

body.is-mobile {
  --frame-max: 520px;
}

body.is-mobile .app-shell {
  padding: 0;
  background: var(--bg-page);
}

body.is-mobile .top-bar {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw, calc(100vh * 5 / 6));
  z-index: 20;
  background: transparent;
}

body.is-mobile .embed-frame {
  width: min(100vw, calc(100vh * 5 / 6));
  max-height: 100vh;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

/* â”€â”€ Twitter / iframe embed: fill the player, same compact look â”€â”€ */
body.is-embed .app-shell {
  padding: 0;
  background: var(--bg-0);
}

body.is-embed .top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  width: auto;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  transform: none;
}

body.is-embed .embed-frame {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* â”€â”€ Header (transparent overlay) â”€â”€ */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: transparent;
  pointer-events: none;
}

.top-bar > * {
  pointer-events: auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  text-decoration: none;
  line-height: 0;
}

.brand-logo {
  display: block;
  height: clamp(36px, 11cqw, 48px);
  width: auto;
  object-fit: contain;
}

.timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  cursor: default;
}

.phase-text {
  font-size: clamp(0.65rem, 2.7cqw, 0.75rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.timer-pill.betting .phase-text { color: var(--accent); }
.timer-pill.locked .phase-text { color: #ffc857; }
.timer-pill.spinning .phase-text { color: #6eb6ff; }
.timer-pill.results .phase-text { color: #d2a8ff; }

.countdown {
  font-size: clamp(1rem, 4.8cqw, 1.25rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 1.4em;
  text-align: center;
}

.top-bar-end {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.points-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(61, 255, 154, 0.1);
  border: 1px solid rgba(61, 255, 154, 0.28);
  font-weight: 800;
  font-size: clamp(0.85rem, 3.6cqw, 1rem);
  color: var(--accent);
}

.fairness-open-btn {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: clamp(0.72rem, 3cqw, 0.85rem);
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.fairness-open-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.wallet-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid rgba(171, 159, 242, 0.45);
  border-radius: 999px;
  background: rgba(171, 159, 242, 0.14);
  color: #e8e4ff;
  font: inherit;
  font-size: clamp(0.72rem, 3cqw, 0.85rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.wallet-btn:hover {
  filter: brightness(1.08);
  background: rgba(171, 159, 242, 0.22);
}

.wallet-btn:active {
  transform: scale(0.97);
}

.wallet-btn.is-connected {
  border-color: rgba(61, 255, 154, 0.35);
  background: rgba(61, 255, 154, 0.1);
  color: var(--accent);
}

.wallet-btn-icon {
  flex: 0 0 auto;
  opacity: 0.9;
}

.wallet-btn-label {
  font-variant-numeric: tabular-nums;
}

/* Mobile / X card: dock connect to bottom-right of the player */
body.is-embed .wallet-btn,
body.is-mobile .wallet-btn {
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 40;
  padding: 8px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

/* Fairness stays in the top bar on embed/mobile (not floating over chips) */
body.is-embed .fairness-open-btn,
body.is-mobile .fairness-open-btn {
  padding: 6px 10px;
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.35);
}

/* SOL send test — embed / mobile only */
.sol-test-btn {
  display: none;
}

body.is-embed .sol-test-btn,
body.is-mobile .sol-test-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  right: 10px;
  bottom: 54px;
  z-index: 40;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid rgba(255, 200, 80, 0.45);
  border-radius: 999px;
  background: rgba(255, 180, 40, 0.18);
  color: #ffe6a8;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

body.is-embed .sol-test-btn:disabled,
body.is-mobile .sol-test-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

body.is-desktop .sol-test-btn {
  display: none !important;
}

/* â”€â”€ Stage (embed/mobile default: overlay). Desktop overrides later. â”€â”€ */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0;
  border-radius: 0;
  overflow: hidden;
  border: none;
  background: var(--bg-0);
}

.controls-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 10px;
  background: linear-gradient(180deg, rgba(7, 13, 17, 0) 0%, rgba(7, 13, 17, 0.85) 35%, rgba(10, 18, 24, 0.96) 100%);
}

.control-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.control-block:first-child {
  flex: 1;
}

.control-label {
  display: none;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}

.live-round-btn {
  display: none;
}

.game-main {
  position: absolute;
  inset: 0;
}

.wheel-half {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.03), transparent 55%),
    #0d1219;
}

.wheel-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-12%) scale(0.9);
  transform-origin: center center;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

/* Full-size, centered wheel while board is away */
.stage.view-spin .wheel-layer,
.stage.view-locked .wheel-layer {
  transform: translateY(0) scale(1);
}

.stage.view-betting .wheel-layer {
  transform: translateY(-12%) scale(0.9);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}

.history-strip {
  position: absolute;
  top: 52px;
  left: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
  pointer-events: none;
}

.history-item {
  width: clamp(22px, 6.5cqw, 28px);
  height: clamp(22px, 6.5cqw, 28px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 800;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  flex: 0 0 auto;
  will-change: transform, opacity;
}

.history-item.red { background: var(--red); }
.history-item.black { background: #243440; }
.history-item.green { background: var(--green); }

.history-item.is-entering {
  animation: history-enter 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes history-enter {
  from {
    opacity: 0;
    transform: scale(0.45);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.wheel-meta {
  position: absolute;
  top: 52px;
  right: 10px;
  display: flex;
  gap: 6px;
  z-index: 5;
  pointer-events: none;
}

.wheel-meta span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.result-banner {
  position: absolute;
  left: 50%;
  top: 54%;
  transform: translate(-50%, -50%);
  z-index: 8;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(7, 13, 17, 0.88);
  border: 1px solid rgba(61, 255, 154, 0.45);
  font-size: clamp(0.85rem, 3.8cqw, 1.05rem);
  font-weight: 800;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  animation: popIn 0.25s ease;
}

@keyframes popIn {
  from { opacity: 0; transform: translate(-50%, -40%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

/* â”€â”€ Board overlays bottom of wheel (max ~half) â”€â”€ */
.board-half {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  height: min(52%, 300px);
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 10px 58px;
  background: var(--bg-0);
  box-shadow:
    0 -1px 0 rgba(255, 255, 255, 0.04),
    0 -12px 20px -8px rgba(0, 0, 0, 0.65);
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
  transition:
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s ease;
  will-change: transform, opacity;
}

/* Slide controls away with the board on embed/mobile */
.stage.view-locked .controls-panel,
.stage.view-spin .controls-panel {
  transform: translateY(108%);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s ease;
}

.stage.view-betting .controls-panel {
  transform: translateY(0);
  opacity: 1;
  transition:
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s ease;
}

.stage.view-locked .board-half,
.stage.view-spin .board-half {
  transform: translateY(108%);
  opacity: 0;
  pointer-events: none;
}

.stage.view-betting .board-half {
  transform: translateY(0);
  opacity: 1;
}

.board {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.board-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(28px, 0.7fr) 12fr minmax(28px, 0.75fr);
  gap: 3px;
}

.zero-cell {
  display: grid !important;
  place-items: center;
  background: var(--green) !important;
  border-radius: 8px;
  font-weight: 800;
  font-size: clamp(0.75rem, 3.2cqw, 0.95rem);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.06em;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  min-height: 0;
}

.number-tile,
.bet-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 5px;
  color: #fff;
  font-weight: 800;
  font-size: clamp(0.55rem, 2.4cqw, 0.78rem);
  cursor: pointer;
  min-width: 0;
  min-height: 0;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.number-tile:active,
.bet-button:active {
  transform: scale(0.96);
}

.number-tile.red { background: var(--red); }
.number-tile.black { background: var(--black); border: 1px solid var(--line-strong); }

.column-bets {
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
}

.column-bets .bet-button {
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  font-size: clamp(0.5rem, 2cqw, 0.68rem);
  color: var(--muted);
}

.dozen-row,
.outside-row {
  display: grid;
  gap: 3px;
  flex-shrink: 0;
  height: clamp(26px, 7.5cqh, 34px);
}

.dozen-row {
  grid-template-columns: repeat(3, 1fr);
}

.outside-row {
  grid-template-columns: repeat(6, 1fr);
}

.dozen-row .bet-button,
.outside-row .bet-button {
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  font-size: clamp(0.55rem, 2.3cqw, 0.72rem);
}

.outside-row .bet-button.red {
  background: var(--red);
  border-color: transparent;
}

.outside-row .bet-button.black {
  background: var(--black);
  border-color: var(--line-strong);
}

/* Chips / placed markers */
.bet-position {
  position: relative;
}

.placed-chips-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.placed-chip {
  --stack-i: 0;
  position: absolute;
  right: 2px;
  top: 2px;
  width: clamp(14px, 4.8cqw, 20px);
  height: clamp(14px, 4.8cqw, 20px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0;
  /* Anchor in top-right; later chips stack upward from there */
  transform: translateY(calc(var(--stack-i) * -4px));
  z-index: calc(1 + var(--stack-i));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.placed-chip img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.placed-chip span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.45rem;
  font-weight: 800;
  color: #37393b;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.35);
}

.table-bet-marker {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 11px;
  height: 11px;
  padding: 0 3px;
  border-radius: 8px;
  background: var(--accent);
  color: #062012;
  font-size: 0.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}

/* â”€â”€ Chips / total (shared) â”€â”€ */
.chip-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
  padding: 2px 0;
}

.chip {
  position: relative;
  width: clamp(24px, 7.2cqw, 32px);
  height: clamp(24px, 7.2cqw, 32px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.12s ease;
  flex: 1 1 0;
  max-width: 34px;
  min-width: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.chip:hover {
  transform: translateY(-1px);
}

.chip img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.chip span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(0.45rem, 2cqw, 0.62rem);
  font-weight: 800;
  color: #37393b;
  line-height: 1;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.35);
}

.chip.selected {
  outline: 2px solid #fff;
  outline-offset: 1px;
  transform: translateY(-2px);
}

.bet-total-field {
  flex-shrink: 0;
  min-width: 3.6em;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(7, 13, 17, 0.55);
  text-align: center;
  font-size: clamp(0.85rem, 3.4cqw, 1.05rem);
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.board-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  padding: 0 2px;
}

.board-actions button {
  margin: 0;
  padding: 0;
  width: auto;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.board-actions button:hover:not(:disabled) {
  color: var(--text);
}

.board-actions button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.board-action-icon {
  margin-right: 4px;
}


/* ═══════════════════════════════════════════════════════════
   Desktop — clean Stake-style UI (no slide animations)
   ═══════════════════════════════════════════════════════════ */
body.is-desktop .app-shell {
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  background:
    radial-gradient(ellipse 70% 50% at 50% -8%, rgba(61, 255, 154, 0.07), transparent 50%),
    radial-gradient(ellipse 45% 40% at 90% 85%, rgba(80, 140, 255, 0.06), transparent 50%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-page) 100%);
}

body.is-desktop .top-bar {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  z-index: 30;
  width: 100%;
  max-width: none;
  padding: 12px 28px;
  background: var(--bg-panel);
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0;
  pointer-events: auto;
  box-shadow: none;
  grid-template-columns: 1fr auto;
}

body.is-desktop .top-timer {
  display: none;
}

body.is-desktop .controls-timer {
  display: inline-flex;
  width: 100%;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bg-0);
  border: 1px solid transparent;
  cursor: default;
}

body:not(.is-desktop) .controls-timer {
  display: none;
}

body.is-desktop .embed-frame {
  width: min(1020px, calc(100vw - 48px));
  height: min(820px, calc(100vh - 96px));
  max-width: 1020px;
  max-height: calc(100vh - 96px);
  margin-bottom: 0;
  flex: 0 0 auto;
  aspect-ratio: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35),
    0 28px 80px rgba(0, 0, 0, 0.55);
  background: var(--bg-0);
  overflow: hidden;
}

body.is-desktop .brand-logo {
  height: 52px;
}

body.is-embed .brand-logo {
  height: 40px;
}

body.is-desktop .timer-pill {
  padding: 8px 16px;
  background: var(--bg-0);
  border: 1px solid transparent;
}

body.is-desktop .countdown { font-size: 1.2rem; }
body.is-desktop .top-bar-end {
  gap: 10px;
}
body.is-desktop .points-pill {
  font-size: 0.95rem;
  padding: 8px 14px;
  background: var(--accent-dim);
  border-color: var(--accent-glow);
  color: var(--accent);
}
body.is-desktop .wallet-btn,
body.is-desktop .fairness-open-btn {
  position: static;
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: 8px;
  box-shadow: none;
}

body.is-desktop .stage {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  background: var(--bg-0);
  overflow: hidden;
}

/* ── Left controls: always visible, never slides ── */
body.is-desktop .controls-panel,
body.is-desktop .stage.view-betting .controls-panel,
body.is-desktop .stage.view-locked .controls-panel,
body.is-desktop .stage.view-spin .controls-panel {
  position: relative !important;
  inset: auto !important;
  z-index: 5;
  flex: 0 0 280px;
  width: 280px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  padding: 16px 14px;
  background: var(--bg-panel);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  transform: none !important;
  opacity: 1 !important;
  pointer-events: auto;
  transition: none !important;
  will-change: auto;
}

body.is-desktop .stage.view-locked .controls-panel .chip,
body.is-desktop .stage.view-spin .controls-panel .chip,
body.is-desktop .stage.view-locked .controls-panel .bet-total-field,
body.is-desktop .stage.view-spin .controls-panel .bet-total-field,
body.is-desktop .stage.view-locked .controls-panel .live-round-btn,
body.is-desktop .stage.view-spin .controls-panel .live-round-btn,
body.is-desktop .stage.view-locked .controls-panel .control-block,
body.is-desktop .stage.view-spin .controls-panel .control-block,
body.is-desktop .stage.view-locked .controls-panel .controls-timer,
body.is-desktop .stage.view-spin .controls-panel .controls-timer {
  opacity: 0.4;
  pointer-events: none;
}

body.is-desktop .control-block {
  gap: 10px;
}

body.is-desktop .control-block:first-child {
  flex: 0 0 auto;
}

body.is-desktop .control-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

body.is-desktop .control-label strong {
  color: #ffffff;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Chip tray — scroll buttons + room for selected ring */
body.is-desktop .chip-tray {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
  background: var(--bg-0);
  padding: 8px 6px;
  overflow: visible;
}

body.is-desktop .chip-nav {
  flex: 0 0 26px;
  width: 26px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: var(--bg-elevated);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

body.is-desktop .chip-nav:hover {
  filter: brightness(1.12);
}

body.is-desktop .chip-field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  /* Extra inset so selected outline/ring is not clipped */
  padding: 5px 6px;
  margin: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  background: transparent;
  border: none;
  scroll-behavior: smooth;
}

body.is-desktop .chip-field::-webkit-scrollbar {
  display: none;
}

body.is-desktop .chip {
  width: 30px;
  height: 30px;
  max-width: none;
  flex: 0 0 30px;
  background: transparent;
  border: none;
  box-shadow: none;
  outline: none;
}

body.is-desktop .chip span {
  font-size: 0.72rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

body.is-desktop .chip.selected {
  outline: none;
  box-shadow:
    0 0 0 2px var(--bg-0),
    0 0 0 4px #ffffff;
  transform: none;
}

body.is-desktop .chip:hover {
  transform: none;
  filter: brightness(1.08);
}

/* Hide chip nav on embed/mobile */
body:not(.is-desktop) .chip-nav {
  display: none;
}

body.is-desktop .bet-total-field {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-radius: 8px;
  border: none;
  background: var(--bg-0);
  text-align: left;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
}

body.is-desktop .live-round-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  width: 100%;
  padding: 15px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #000;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

body.is-desktop .live-round-btn.is-betting {
  background: var(--accent);
  color: #000;
  opacity: 1;
}

body.is-desktop .live-round-btn.is-locked,
body.is-desktop .live-round-btn.is-spinning {
  background: var(--bg-elevated);
  color: var(--muted);
  opacity: 1;
}

/* ── Main: wheel + table (board stays put) ── */
body.is-desktop .game-main {
  position: relative;
  inset: auto;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #0d1219;
}

body.is-desktop .wheel-half {
  position: relative;
  inset: auto;
  flex: 1 1 72%;
  min-height: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.03), transparent 58%),
    #0d1219;
  overflow: hidden;
}

body.is-desktop .wheel-layer,
body.is-desktop .stage.view-betting .wheel-layer,
body.is-desktop .stage.view-spin .wheel-layer,
body.is-desktop .stage.view-locked .wheel-layer {
  transform: none !important;
  transition: none !important;
  /* Keep wheel fully visible — not clipped at top */
  inset: 8px 0 0 0;
}

body.is-desktop .history-strip {
  top: 12px;
  left: 16px;
  flex-direction: row;
  flex-wrap: wrap;
  max-width: 48%;
  gap: 6px;
}

body.is-desktop .history-item {
  width: 32px;
  height: 32px;
  font-size: 0.78rem;
}

body.is-desktop .wheel-meta {
  top: 16px;
  right: 16px;
  gap: 8px;
}

body.is-desktop .wheel-meta span {
  background: var(--bg-panel);
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 6px 10px;
}

body.is-desktop .result-banner {
  top: auto;
  bottom: 18px;
  transform: translateX(-50%);
  font-size: 1.2rem;
  padding: 10px 18px;
  border-radius: 8px;
  animation: none;
}

body.is-desktop .board-half,
body.is-desktop .stage.view-betting .board-half,
body.is-desktop .stage.view-locked .board-half,
body.is-desktop .stage.view-spin .board-half {
  position: relative !important;
  inset: auto !important;
  z-index: 5;
  flex: 0 0 auto;
  height: auto !important;
  max-height: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 20px 12px !important;
  background: var(--bg-0);
  backdrop-filter: none;
  box-shadow: none;
  transform: none !important;
  opacity: 1 !important;
  transition: none !important;
  will-change: auto;
  pointer-events: auto;
}

body.is-desktop .stage.view-locked .board-half,
body.is-desktop .stage.view-spin .board-half {
  pointer-events: none;
}

body.is-desktop .stage.view-locked .board-half .board,
body.is-desktop .stage.view-spin .board-half .board,
body.is-desktop .stage.view-locked .board-half .board-actions,
body.is-desktop .stage.view-spin .board-half .board-actions {
  opacity: 0.35;
}

body.is-desktop .board {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  gap: 3px;
}

body.is-desktop .board-main {
  gap: 3px;
  grid-template-columns: 36px 1fr 36px;
  min-height: 108px;
}

body.is-desktop .number-grid { gap: 3px; }

body.is-desktop .number-tile,
body.is-desktop .bet-button {
  border-radius: 3px;
  font-size: 0.72rem;
  min-height: 28px;
}

body.is-desktop .number-tile.red { background: var(--red); }
body.is-desktop .number-tile.black { background: var(--bg-elevated); border: none; }

body.is-desktop .zero-cell {
  font-size: 0.85rem;
  border-radius: 3px;
  background: var(--green) !important;
}

body.is-desktop .dozen-row,
body.is-desktop .outside-row {
  height: 30px;
  gap: 3px;
}

body.is-desktop .dozen-row .bet-button,
body.is-desktop .outside-row .bet-button,
body.is-desktop .column-bets .bet-button {
  font-size: 0.7rem;
  border-radius: 3px;
  background: var(--bg-elevated);
  border: none;
  color: #fff;
}

body.is-desktop .outside-row .bet-button.red {
  background: var(--red);
}

body.is-desktop .outside-row .bet-button.black {
  background: var(--bg-elevated);
}

body.is-desktop .board-actions {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 0;
}

body.is-desktop .board-actions button {
  font-size: 0.78rem;
  color: var(--muted);
  opacity: 1;
  transition: opacity 0.15s ease, color 0.15s ease;
}

body.is-desktop .board-actions button:disabled {
  opacity: 0.35;
}

body.is-desktop .stage.view-locked .board-actions button,
body.is-desktop .stage.view-spin .board-actions button {
  opacity: 0.35;
}

body.is-desktop .placed-chip {
  width: 20px;
  height: 20px;
  right: 3px;
  top: 3px;
  transform: translateY(calc(var(--stack-i) * -5px));
}

body.is-desktop .table-bet-marker {
  min-width: 15px;
  height: 15px;
  font-size: 0.6rem;
  background: var(--accent);
  color: #000;
}

.bet-history-panel {
  display: none;
}

/* ── Fairness modal (all shells) ── */
.fairness-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
}

.fairness-modal[hidden] {
  display: none !important;
}

.fairness-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(4px);
}

.fairness-modal-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
  border-radius: 16px;
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.fairness-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.fairness-modal-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.fairness-modal-head p {
  margin: 6px 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
}

.fairness-modal-close {
  margin: 0;
  padding: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}

.fairness-modal-body {
  padding: 12px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fairness-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-0);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.fairness-block h3 {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.fairness-help {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--muted);
}

.fairness-kv {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.fairness-kv > span {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
}

.fairness-kv code,
.fairness-copy code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

.fairness-kv-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.fairness-copy {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.fairness-copy.is-revealed code {
  color: var(--accent);
}

.fairness-inline {
  display: flex;
  gap: 8px;
}

.fairness-inline input,
.fairness-field input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: var(--bg-panel);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
}

.fairness-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--muted);
}

.fairness-action-btn {
  margin: 0;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  flex: 0 0 auto;
}

.fairness-action-primary {
  background: var(--accent);
  color: #04140c;
  width: 100%;
  margin-top: 2px;
}

.fairness-msg {
  margin: 0;
  min-height: 1.1em;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
}

.fairness-msg.is-good { color: var(--accent); }
.fairness-msg.is-bad { color: #ff8a9a; }
.fairness-msg .is-red { color: var(--red); }
.fairness-msg .is-black { color: #d0d7e0; }
.fairness-msg .is-green { color: var(--accent); }

.spin-check-result {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 4px;
}

.spin-check-result[hidden] {
  display: none !important;
}

.spin-check-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.spin-check-number {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.1;
}

.spin-check-number.is-red { color: var(--red); }
.spin-check-number.is-black { color: #d0d7e0; }
.spin-check-number.is-green { color: var(--accent); }

.spin-check-meta {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  word-break: break-all;
}

body.fairness-open {
  overflow: hidden;
}

html:has(body.is-desktop),
body.is-desktop {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

body.is-desktop .app-shell {
  height: auto;
  min-height: 100%;
  overflow: visible;
  padding-bottom: 40px;
  gap: 16px;
}

body.is-desktop .bet-history-panel {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  width: min(1020px, calc(100vw - 48px));
  max-width: 1020px;
  margin: 0 auto;
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  overflow: hidden;
}

.bet-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.bet-history-tabs {
  display: flex;
  gap: 6px;
}

.bet-history-tab {
  margin: 0;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.bet-history-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.bet-history-tab.is-active {
  color: var(--text);
  background: var(--bg-0);
  border-color: rgba(255, 255, 255, 0.06);
}

.bet-history-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.bet-history-table-wrap {
  padding: 0 8px 10px;
}

.bet-history-cols,
.bet-history-row {
  display: grid;
  grid-template-columns: minmax(110px, 1.4fr) minmax(90px, 1fr) minmax(70px, 0.8fr) minmax(70px, 0.8fr);
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
}

.bet-history-cols {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bet-history-list {
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.bet-history-list.is-loading {
  opacity: 0.55;
}

.bet-history-row {
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.bet-history-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.02);
}

.bet-history-user {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.bet-history-win {
  color: var(--accent);
}

.bet-history-row.is-lose .bet-history-win {
  color: var(--muted);
}

.bet-history-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}
