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

:root {
  --bg: #070f1a;
  --panel: #0c1829;
  --felt: #0d5c3d;
  --felt-deep: #084530;
  --gold: #c9a227;
  --cream: #f5f0e6;
  --red: #c41e3a;
  --red-deep: #8b1530;
  --black: #1a1a1a;
  --green: #0f7a3a;
  --win: #4ade80;
  --lose: #f87171;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--cream);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 50% at 70% 20%, rgba(201, 162, 39, 0.08), transparent 50%),
    radial-gradient(ellipse 50% 40% at 10% 80%, rgba(13, 92, 61, 0.15), transparent 50%),
    var(--bg);
}

/* HUD */
#hud {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: max(0.55rem, env(safe-area-inset-top)) 0.9rem 0.35rem;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.hud-left {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.15rem;
}

.hud-block {
  display: flex;
  flex-direction: column;
  min-width: 3.5rem;
}

.label {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.5;
}

.hud-block span:last-child {
  font-size: 1.05rem;
  font-weight: 750;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}

.icon-btn {
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  text-decoration: none;
  font-size: 1rem;
}

/* Layout */
.play-area {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(15rem, 20rem) minmax(0, 1fr);
  gap: 0.55rem;
  padding: 0.2rem 0.65rem 0.35rem;
  overflow: visible;
}

/* Left panel */
.side-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 0.85rem;
  border: 1px solid rgba(201, 162, 39, 0.28);
  background: linear-gradient(165deg, rgba(12, 24, 41, 0.97), rgba(6, 14, 24, 0.98));
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  user-select: text;
}

.panel-head {
  flex-shrink: 0;
  padding: 0.7rem 0.85rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.panel-head h2 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fde68a;
}

.panel-sub {
  margin-top: 0.2rem;
  font-size: 0.68rem;
  color: rgba(245, 240, 230, 0.5);
  line-height: 1.35;
}

.panel-block {
  padding: 0.55rem 0.75rem 0.45rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.panel-block h3 {
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #86efac;
  margin-bottom: 0.4rem;
}

.history-block {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-bottom: none;
  overflow: hidden;
}

.history-block h3 span {
  font-weight: 500;
  opacity: 0.65;
  letter-spacing: 0;
  text-transform: none;
}

.odds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.odds-table th {
  text-align: left;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(245, 240, 230, 0.45);
  padding: 0.15rem 0.2rem 0.3rem;
  font-weight: 650;
}

.odds-table th:nth-child(2),
.odds-table th:nth-child(3),
.odds-table td:nth-child(2),
.odds-table td:nth-child(3) {
  text-align: right;
}

.odds-table td {
  padding: 0.28rem 0.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  color: rgba(245, 240, 230, 0.85);
}

.odds-table td:nth-child(2) {
  color: #fde68a;
  font-weight: 750;
}

.odds-note {
  margin-top: 0.4rem;
  font-size: 0.62rem;
  line-height: 1.35;
  color: rgba(245, 240, 230, 0.42);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.35rem;
}

.stat {
  display: flex;
  flex-direction: column;
  padding: 0.35rem 0.4rem;
  border-radius: 0.4rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat .sl {
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.45;
}

.stat span:last-child {
  font-size: 0.92rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.history-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-content: flex-start;
  overflow: auto;
  flex: 1;
  min-height: 0;
  padding-bottom: 0.35rem;
  -webkit-overflow-scrolling: touch;
}

.history-empty {
  font-size: 0.7rem;
  color: rgba(245, 240, 230, 0.4);
  margin-top: 0.25rem;
}

.history-empty[hidden] {
  display: none !important;
}

.hist-pip {
  min-width: 1.7rem;
  height: 1.7rem;
  padding: 0 0.25rem;
  border-radius: 0.3rem;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  animation: pip-in 0.28s ease both;
}

.hist-pip.red {
  background: linear-gradient(160deg, #e11d48, var(--red-deep));
}
.hist-pip.black {
  background: linear-gradient(160deg, #374151, #111);
}
.hist-pip.green {
  background: linear-gradient(160deg, #22c55e, #166534);
}
.hist-pip.latest {
  outline: 2px solid #fde68a;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
}

@keyframes pip-in {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Right column */
.table-col {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.wheel-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.6rem 0 0.25rem; /* room for speech bubble above square */
  overflow: visible;
}

.wheel-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  width: 100%;
  max-width: 100%;
  overflow: visible;
  position: relative;
}

/* House column: Squipy + result plaque under him (never over wheel) */
.croupier-col {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  z-index: 6;
  min-width: 5.2rem;
}

/* ── Croupier square (left of wheel) ───────────────── */
.croupier {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 5.2rem;
  z-index: 6;
  overflow: visible;
}

.croupier-sq {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 0.55rem;
  background: linear-gradient(160deg, #c4b5fd, #7c3aed 55%, #5b21b6);
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 16px rgba(167, 139, 250, 0.5);
  display: grid;
  place-items: center;
  transform-origin: center center;
  will-change: transform;
  transition: filter 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  z-index: 2;
}

.croupier-label {
  margin-top: 0.3rem;
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  opacity: 0.45;
  font-weight: 650;
}

/* Speech bubble — ABOVE the square, left side (never over the wheel) */
.speech-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.35rem);
  transform: translateX(-50%);
  z-index: 20;
  width: max-content;
  max-width: min(11.5rem, 28vw);
  padding: 0.4rem 0.55rem 0.45rem;
  border-radius: 0.75rem 0.75rem 0.75rem 0.75rem;
  background: linear-gradient(165deg, #fffbeb, #fef3c7 70%, #fde68a);
  color: #1c1917;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(180, 83, 9, 0.2);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.3;
  pointer-events: none;
  transform-origin: bottom center;
  max-height: 4.2rem;
  overflow: hidden;
  text-align: center;
}

.speech-bubble[hidden] {
  display: none !important;
}

.speech-bubble.show {
  display: block !important;
  animation: bubble-pop 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.speech-bubble.hide {
  animation: bubble-out 0.25s ease forwards;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -0.32rem;
  width: 0.55rem;
  height: 0.55rem;
  margin-left: -0.28rem;
  background: #fef3c7;
  border-right: 2px solid rgba(255, 255, 255, 0.85);
  border-bottom: 2px solid rgba(255, 255, 255, 0.85);
  transform: rotate(45deg);
}

.speech-text {
  display: block;
}

@keyframes bubble-pop {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.65) translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) scale(1) translateY(0);
  }
}

@keyframes bubble-out {
  to {
    opacity: 0;
    transform: translateX(-50%) scale(0.85) translateY(4px);
  }
}

/* Face pieces */
.sq-face {
  position: relative;
  width: 1.75rem;
  height: 1.25rem;
}

.sq-face .brow {
  position: absolute;
  top: -0.08rem;
  width: 0.48rem;
  height: 0.12rem;
  background: #0f172a;
  border-radius: 2px;
  transition: transform 0.15s ease, top 0.15s ease;
}

.sq-face .brow.left {
  left: 0.12rem;
}
.sq-face .brow.right {
  right: 0.12rem;
}

.sq-face .eye {
  position: absolute;
  top: 0.18rem;
  width: 0.34rem;
  height: 0.34rem;
  background: #0f172a;
  border-radius: 50%;
  transition: width 0.15s ease, height 0.15s ease, top 0.15s ease, border-radius 0.15s ease;
}

.sq-face .eye.left {
  left: 0.14rem;
}
.sq-face .eye.right {
  right: 0.14rem;
}

.sq-face .eye::after {
  content: "";
  position: absolute;
  top: 0.05rem;
  right: 0.05rem;
  width: 0.1rem;
  height: 0.1rem;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 50%;
}

.sq-face .mouth {
  position: absolute;
  left: 50%;
  bottom: 0.02rem;
  width: 0.72rem;
  height: 0.3rem;
  border-bottom: 2.5px solid #0f172a;
  border-radius: 0 0 50% 50%;
  transform: translateX(-50%);
  transition: width 0.15s ease, height 0.15s ease, border 0.15s ease, bottom 0.15s ease;
}

.sq-face .cheek {
  position: absolute;
  bottom: 0.28rem;
  width: 0.28rem;
  height: 0.18rem;
  border-radius: 50%;
  background: rgba(244, 114, 182, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sq-face .cheek.left {
  left: -0.05rem;
}
.sq-face .cheek.right {
  right: -0.05rem;
}

/* Moods */
.croupier-sq[data-mood="idle"] .mouth {
  /* default smile */
}

.croupier-sq[data-mood="think"] .eye {
  transform: translateX(0.06rem);
}
.croupier-sq[data-mood="think"] .brow.left {
  transform: rotate(-8deg);
}
.croupier-sq[data-mood="think"] .brow.right {
  transform: rotate(-12deg);
}

.croupier-sq[data-mood="chip"] .mouth {
  width: 0.85rem;
  height: 0.32rem;
}
.croupier-sq[data-mood="chip"] .cheek {
  opacity: 0.7;
}

.croupier-sq[data-mood="wow"] .brow.left,
.croupier-sq[data-mood="wow"] .brow.right {
  top: -0.18rem;
}
.croupier-sq[data-mood="wow"] .eye {
  width: 0.44rem;
  height: 0.44rem;
  top: 0.08rem;
}
.croupier-sq[data-mood="wow"] .mouth {
  width: 0.5rem;
  height: 0.45rem;
  border: 2.5px solid #0f172a;
  border-radius: 50%;
  border-bottom: 2.5px solid #0f172a;
  bottom: -0.05rem;
}

.croupier-sq[data-mood="sneaky"] .brow.left {
  transform: rotate(16deg);
}
.croupier-sq[data-mood="sneaky"] .eye.left {
  height: 0.16rem;
  border-radius: 2px;
  top: 0.26rem;
}
.croupier-sq[data-mood="sneaky"] .eye.left::after {
  display: none;
}
.croupier-sq[data-mood="sneaky"] .mouth {
  width: 0.9rem;
  transform: translateX(-42%);
}

.croupier-sq[data-mood="spin"] .brow.left {
  transform: rotate(10deg);
  top: 0;
}
.croupier-sq[data-mood="spin"] .brow.right {
  transform: rotate(-10deg);
  top: 0;
}
.croupier-sq[data-mood="spin"] .eye {
  height: 0.22rem;
  top: 0.22rem;
}
.croupier-sq[data-mood="spin"] .mouth {
  width: 0.4rem;
  height: 0.12rem;
  border-radius: 0;
  bottom: 0.14rem;
}

.croupier-sq[data-mood="suspense"] .brow.left,
.croupier-sq[data-mood="suspense"] .brow.right {
  top: -0.16rem;
}
.croupier-sq[data-mood="suspense"] .eye {
  width: 0.42rem;
  height: 0.42rem;
  top: 0.1rem;
}
.croupier-sq[data-mood="suspense"] .mouth {
  width: 0.35rem;
  height: 0.35rem;
  border: 2.5px solid #0f172a;
  border-radius: 50%;
  bottom: 0.02rem;
}

.croupier-sq[data-mood="gloat"] .brow.left {
  transform: rotate(20deg);
  top: 0.04rem;
}
.croupier-sq[data-mood="gloat"] .brow.right {
  transform: rotate(-20deg);
  top: 0.04rem;
}
.croupier-sq[data-mood="gloat"] .eye {
  height: 0.12rem;
  border-radius: 2px;
  top: 0.3rem;
}
.croupier-sq[data-mood="gloat"] .eye::after {
  display: none;
}
.croupier-sq[data-mood="gloat"] .mouth {
  width: 1rem;
  height: 0.4rem;
  border-bottom: 3px solid #0f172a;
  bottom: -0.02rem;
}
.croupier-sq[data-mood="gloat"] .cheek {
  opacity: 0.85;
}

.croupier-sq[data-mood="sad"] .brow.left {
  transform: rotate(14deg);
  top: 0.06rem;
}
.croupier-sq[data-mood="sad"] .brow.right {
  transform: rotate(-14deg);
  top: 0.06rem;
}
.croupier-sq[data-mood="sad"] .mouth {
  width: 0.55rem;
  height: 0.28rem;
  border-bottom: none;
  border-top: 2.5px solid #0f172a;
  border-radius: 50% 50% 0 0;
  bottom: 0.08rem;
}

.croupier-sq[data-mood="meh"] .eye {
  height: 0.14rem;
  border-radius: 2px;
  top: 0.28rem;
}
.croupier-sq[data-mood="meh"] .eye::after {
  display: none;
}
.croupier-sq[data-mood="meh"] .mouth {
  width: 0.48rem;
  height: 0;
  border-radius: 0;
  bottom: 0.16rem;
  transform: translateX(-50%) rotate(-6deg);
}

.croupier-sq[data-mood="pout"] .mouth {
  width: 0.5rem;
  height: 0.22rem;
  border-bottom: none;
  border-top: 2.5px solid #0f172a;
  border-radius: 50% 50% 0 0;
  bottom: 0.1rem;
}

/* Body motions */
.croupier-sq.react-spin {
  animation: croupier-spin 0.95s ease-in-out infinite;
}

.croupier-sq.react-push {
  animation: croupier-push 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.croupier-sq.react-bet {
  animation: croupier-bet 0.4s ease;
}

.croupier-sq.react-bounce {
  animation: croupier-bounce 0.45s ease;
}

@keyframes croupier-spin {
  0%,
  100% {
    transform: rotate(-18deg) translate(2px, 0) scale(1.02);
  }
  50% {
    transform: rotate(22deg) translate(-3px, -2px) scale(1.08);
  }
}

@keyframes croupier-push {
  0% {
    transform: rotate(0) scale(1);
  }
  30% {
    transform: rotate(-25deg) scale(1.12) translateX(-4px);
  }
  60% {
    transform: rotate(28deg) scale(1.1) translateX(6px);
  }
  100% {
    transform: rotate(0) scale(1);
  }
}

@keyframes croupier-bet {
  0%,
  100% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.12) translateY(-3px);
  }
}

@keyframes croupier-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-6px) scale(1.06);
  }
}

.wheel-wrap {
  position: relative;
  width: min(26rem, 60vw, 54vh);
  height: min(26rem, 60vw, 54vh);
  flex-shrink: 0;
  z-index: 2;
}

.wheel-outer {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #2a2118, #1a1410 55%, #0c0a08);
  box-shadow:
    0 0 0 4px #c9a227,
    0 0 0 7px #5c4030,
    0 12px 30px rgba(0, 0, 0, 0.55),
    inset 0 0 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.wheel {
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  /* wheel is fixed — only the ball moves */
  transform: none !important;
}

.wheel-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  /* conic gradient set by JS */
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.wheel-labels {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
}

.wheel-num {
  position: absolute;
  width: 1.5rem;
  height: 1.05rem;
  margin-left: -0.75rem;
  margin-top: -0.52rem;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 3px rgba(0, 0, 0, 0.95),
    0 1px 2px rgba(0, 0, 0, 0.9);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  z-index: 2;
  pointer-events: none;
}

.wheel-num.green {
  color: #ecfdf5;
  font-size: 0.62rem;
}

.wheel-hub {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 18%;
  height: 18%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fde68a, #b45309 70%, #78350f);
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  z-index: 3;
  /* keep hub under numbers (numbers sit farther out on the rim) */
  pointer-events: none;
}

.hub-core {
  width: 42%;
  height: 42%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fef3c7, #a16207);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.ball-track {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  /* only this layer rotates — ball orbits fixed wheel */
  will-change: transform;
}

.ball {
  position: absolute;
  left: 50%;
  top: 5.5%;
  width: 0.78rem;
  height: 0.78rem;
  margin-left: -0.39rem;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, #d4d4d8 50%, #71717a);
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.55),
    0 0 6px rgba(255, 255, 255, 0.35);
  opacity: 0;
}

.ball.visible {
  opacity: 1;
}

/* Result sits under HOUSE / Squipy (not absolute on the wheel) */
.result-plaque {
  position: relative;
  right: auto;
  top: auto;
  transform: none;
  min-width: 3.4rem;
  max-width: 5.5rem;
  padding: 0.4rem 0.55rem;
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(253, 230, 138, 0.5);
  text-align: center;
  z-index: 7;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

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

.result-num {
  display: block;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.result-num.red {
  color: #fb7185;
}
.result-num.black {
  color: #e5e7eb;
}
.result-num.green {
  color: #4ade80;
}

.result-label {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.65;
}

.message {
  margin-top: 0.45rem;
  min-height: 1.25rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.88rem;
  color: #fef3c7;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  padding: 0 0.5rem;
}

.message.win {
  color: var(--win);
}
.message.lose {
  color: var(--lose);
}

/* Bet stage: chips | board | actions — clustered around the board (not full-width) */
.bet-stage {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.45rem 0.55rem;
  padding: 0.2rem 0.45rem 0.15rem;
  width: 100%;
  max-width: 100%;
  min-height: 0;
}

.chip-col {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0.35rem;
  flex-shrink: 0;
  padding: 0.15rem 0;
  order: 1;
}

.chip-col .ctrl-label {
  text-align: center;
  margin-right: 0;
  margin-bottom: 0.1rem;
}

.chip-col .chip {
  min-width: 3.4rem;
  width: 100%;
}

.board-wrap {
  order: 2;
}

.action-col {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0.35rem;
  flex-shrink: 0;
  min-width: 6.6rem;
  order: 3;
}

.action-col .btn {
  width: 100%;
  min-width: 6.4rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.action-col .btn .key-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 800;
  color: #fde68a;
  letter-spacing: 0.02em;
}

.action-col .btn.primary .key-label {
  color: #1c1917;
}

.action-col .btn.key-flash {
  outline: 2px solid #fde68a;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.35);
  background: rgba(253, 230, 138, 0.18);
  transform: scale(1.03);
}

/* Betting board — center of the cluster */
.board-wrap {
  display: grid;
  place-items: center;
  padding: 0.1rem 0.1rem;
  overflow: auto;
  min-width: 0;
  flex: 0 1 auto;
}

.board {
  display: grid;
  grid-template-columns: 1.7rem repeat(12, minmax(1.25rem, 1.75rem)) 1.7rem;
  grid-template-rows: repeat(5, minmax(1.35rem, 1.7rem));
  gap: 2px;
  width: max-content;
  max-width: 100%;
  padding: 0.45rem;
  border-radius: 0.55rem;
  background:
    radial-gradient(ellipse 80% 70% at 50% 50%, #127a52 0%, var(--felt) 50%, var(--felt-deep) 100%);
  border: 5px solid #5c4030;
  box-shadow:
    inset 0 0 0 2px var(--gold),
    0 8px 20px rgba(0, 0, 0, 0.4);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 0.2rem;
  font-weight: 800;
  font-size: 0.72rem;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  transition: filter 0.12s ease, transform 0.1s ease;
  min-width: 0;
  min-height: 0;
}

.cell:hover:not(:disabled) {
  filter: brightness(1.15);
  z-index: 2;
}

.cell:active:not(:disabled) {
  transform: scale(0.96);
}

.cell:disabled {
  cursor: default;
  opacity: 0.85;
}

.cell.red {
  background: linear-gradient(160deg, #e11d48, var(--red-deep));
}
.cell.black {
  background: linear-gradient(160deg, #2d2d2d, #0a0a0a);
}
.cell.green {
  background: linear-gradient(160deg, #16a34a, #14532d);
}
.cell.outside {
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.55rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
}

.cell.highlight-win {
  outline: 2px solid #fde68a;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.55);
  z-index: 3;
}

.chip-stack {
  position: absolute;
  right: 0.12rem;
  bottom: 0.1rem;
  min-width: 0.95rem;
  height: 0.95rem;
  padding: 0 0.18rem;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #fef3c7, #d97706);
  color: #1c1917;
  font-size: 0.55rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.45);
  line-height: 1;
  pointer-events: none;
}

/* Controls footer (hint / version only) */
.controls {
  flex-shrink: 0;
  padding: 0.3rem 0.6rem max(0.55rem, env(safe-area-inset-bottom));
  text-align: center;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.3));
}

.ctrl-label {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.5;
  margin-right: 0.15rem;
}

.chip {
  min-width: 2.9rem;
  padding: 0.4rem 0.5rem;
  border-radius: 999px;
  border: 2px dashed rgba(255, 255, 255, 0.35);
  background: radial-gradient(circle at 30% 30%, #fef3c7, #d97706 70%);
  color: #1c1917;
  font-weight: 800;
  font-size: 0.75rem;
  cursor: pointer;
}

.chip.active {
  outline: 2px solid #fde68a;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.45);
}

.chip.chip-allin {
  background: radial-gradient(circle at 30% 30%, #fecaca, #dc2626 70%);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
  min-width: 3.6rem;
}

.chip.chip-allin.active {
  outline-color: #fca5a5;
  box-shadow: 0 0 14px rgba(248, 113, 113, 0.5);
}

.chip:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn {
  min-width: 5.2rem;
  padding: 0.55rem 0.85rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: var(--cream);
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.btn.primary {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  border-color: transparent;
  color: #1c1917;
}

.btn.ghost {
  background: transparent;
  opacity: 0.9;
}

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

.btn .key-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 800;
  color: #1c1917;
}

.btn.ghost .key-label {
  color: #fde68a;
}

.hint {
  font-size: 0.65rem;
  opacity: 0.4;
  margin-top: 0.1rem;
}

.version {
  margin-top: 0.3rem;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  opacity: 0.4;
  color: #86efac;
}

@media (max-width: 900px) {
  .play-area {
    grid-template-columns: minmax(13rem, 16.5rem) minmax(0, 1fr);
  }

  .wheel-wrap {
    width: min(20rem, 52vw, 46vh);
    height: min(20rem, 52vw, 46vh);
  }

  .bet-stage {
    gap: 0.35rem 0.4rem;
  }

  /* Keep cells tappable — board scrolls horizontally if needed */
  .board {
    grid-template-columns: 2rem repeat(12, minmax(1.55rem, 1.85rem)) 2rem;
    grid-template-rows: repeat(5, minmax(1.55rem, 1.85rem));
  }

  .cell {
    font-size: 0.7rem;
    min-height: 1.55rem;
  }

  .action-col {
    min-width: 5.8rem;
  }

  .action-col .btn {
    min-width: 5.6rem;
    font-size: 0.75rem;
    padding: 0.42rem 0.45rem;
  }

  .croupier-col {
    min-width: 4.2rem;
  }

  .croupier {
    width: 4.2rem;
  }

  .croupier-sq {
    width: 2.85rem;
    height: 2.85rem;
  }

  .speech-bubble {
    max-width: min(9.5rem, 32vw);
    font-size: 0.62rem;
  }

  .wheel-num {
    font-size: 0.52rem;
    width: 1.1rem;
    margin-left: -0.55rem;
  }

  .result-plaque {
    position: relative;
    transform: none;
    margin: 0;
    min-width: 3rem;
  }
}

/* Mobile: scrollable column — wheel+house → table → bets → stats */
@media (max-width: 720px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #app {
    height: auto;
    min-height: calc(100dvh - var(--rg-bar));
    overflow: visible;
  }

  .play-area {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    grid-template-rows: none;
    overflow: visible;
    flex: none;
    height: auto;
    min-height: 0;
    gap: 0.65rem;
    padding: 0.15rem 0.5rem 0.5rem;
  }

  /* Wheel + House first */
  .table-col {
    order: 1;
    flex: none;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  /* Stats / odds last */
  .side-panel {
    order: 2;
    flex: none;
    max-height: none;
    overflow: visible;
  }

  .history-block {
    flex: none;
    overflow: visible;
  }

  .history-strip {
    max-height: 8rem;
  }

  .wheel-stage {
    flex: none;
    padding: 1.6rem 0 0.35rem;
    min-height: 0;
  }

  .wheel-row {
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.65rem;
  }

  .croupier-col {
    align-self: center;
  }

  .wheel-wrap {
    width: min(15.5rem, 72vw, 42vh);
    height: min(15.5rem, 72vw, 42vh);
    /* Wheel only — result lives under House now */
    overflow: visible;
  }

  .bet-stage {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: 0.15rem 0 0.35rem;
  }

  /* Table first, then chips + actions */
  .board-wrap {
    order: 1;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.2rem;
  }

  .chip-col {
    order: 2;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.3rem;
    width: 100%;
  }

  .chip-col .ctrl-label {
    width: 100%;
    font-size: 0.62rem;
    margin-bottom: 0.05rem;
  }

  /* Compact chips — closer to LV blackjack mobile size */
  .chip,
  .chip-col .chip {
    min-width: 2.45rem;
    width: auto;
    min-height: 0;
    padding: 0.32rem 0.42rem;
    font-size: 0.68rem;
    border-width: 1.5px;
  }

  .chip.chip-allin,
  .chip-col .chip.chip-allin {
    min-width: 2.9rem;
    padding: 0.32rem 0.45rem;
    font-size: 0.65rem;
  }

  .action-col {
    order: 3;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    min-width: 0;
    width: 100%;
    gap: 0.3rem;
  }

  .action-col .btn {
    width: auto;
    min-width: 4.4rem;
    min-height: 2.2rem;
    padding: 0.4rem 0.55rem;
    font-size: 0.75rem;
  }

  .action-col .btn .key-label {
    font-size: 0.68rem;
  }

  /* Smaller pile amounts on the board */
  .chip-stack {
    min-width: 0.85rem;
    height: 0.85rem;
    padding: 0 0.14rem;
    font-size: 0.48rem;
  }

  .board {
    grid-template-columns: 1.7rem repeat(12, minmax(1.45rem, 1.7rem)) 1.7rem;
    grid-template-rows: repeat(5, minmax(1.45rem, 1.7rem));
    margin: 0 auto;
    transform: scale(0.95);
    transform-origin: top center;
  }

  .odds-table {
    font-size: 0.65rem;
  }

  .controls {
    position: sticky;
    bottom: 0;
    z-index: 10;
  }
}

@media (max-width: 560px) {
  .wheel-row {
    gap: 0.55rem 0.75rem;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: center;
  }

  .croupier-col {
    min-width: 3.6rem;
    gap: 0.35rem;
    /* Keep house+result as a clear column left of the wheel */
    align-self: center;
  }

  .croupier {
    width: 3.2rem;
  }

  .croupier-sq {
    width: 2.45rem;
    height: 2.45rem;
  }

  .speech-bubble {
    max-width: 7.5rem;
    font-size: 0.58rem;
  }

  .wheel-wrap {
    width: min(13.5rem, 70vw);
    height: min(13.5rem, 70vw);
    flex-shrink: 0;
  }

  .result-plaque {
    min-width: 3.1rem;
    max-width: 4.2rem;
    padding: 0.35rem 0.4rem;
    /* Clear, readable under Squipy — not on the wheel */
    background: rgba(8, 12, 20, 0.88);
    border-color: rgba(253, 230, 138, 0.65);
  }

  .result-num {
    font-size: 1.25rem;
  }

  .result-label {
    font-size: 0.55rem;
  }

  .wheel-stage {
    padding-top: 1.25rem;
  }

  .board {
    grid-template-columns: 1.85rem repeat(12, minmax(1.55rem, 1.75rem)) 1.85rem;
    grid-template-rows: repeat(5, minmax(1.55rem, 1.75rem));
    transform: none;
  }

  .cell {
    font-size: 0.68rem;
    min-height: 1.55rem;
  }

  .action-col .btn {
    min-height: 2.15rem;
    min-width: 4.1rem;
    padding: 0.38rem 0.5rem;
    font-size: 0.72rem;
  }

  .chip,
  .chip-col .chip {
    min-width: 2.25rem;
    min-height: 0;
    padding: 0.28rem 0.36rem;
    font-size: 0.64rem;
  }

  .chip.chip-allin,
  .chip-col .chip.chip-allin {
    min-width: 2.7rem;
    font-size: 0.6rem;
  }

  .chip-stack {
    min-width: 0.8rem;
    height: 0.8rem;
    font-size: 0.45rem;
  }

  .side-panel {
    border-radius: 0.75rem;
  }

  .panel-head {
    padding: 0.55rem 0.7rem 0.4rem;
  }

  .message {
    font-size: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hist-pip,
  .wheel,
  .ball-track,
  .croupier-sq.react-spin,
  .croupier-sq.react-push,
  .croupier-sq.react-bet,
  .croupier-sq.react-bounce,
  .speech-bubble.show,
  .speech-bubble.hide {
    transition: none !important;
    animation: none !important;
  }
}
