* { box-sizing: border-box; }

:root {
  --red: #c1121f;
  --black: #1a1a1a;
  --green: #0a6b3b;
  --felt: #0b5e34;
  --felt-dark: #084a29;
  --gold: #e7c873;
  --chip-shadow: rgba(0,0,0,.45);
}

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: radial-gradient(circle at 50% 0%, #20342a 0%, #0c1611 70%);
  color: #f3f3f3;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: linear-gradient(180deg, #14241c, #0b1610);
  border-bottom: 2px solid var(--gold);
}
.topbar h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 1px;
  color: var(--gold);
  text-shadow: 0 1px 0 #000;
}
.bank { display: flex; gap: 26px; }
.bank-item { display: flex; flex-direction: column; align-items: flex-end; }
.bank-item .label { font-size: 11px; text-transform: uppercase; opacity: .7; letter-spacing: 1px; }
.bank-item .value { font-size: 22px; font-weight: 700; color: var(--gold); }

.layout {
  display: flex;
  gap: 32px;
  padding: 28px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
}

/* ---------------- Wheel ---------------- */
.wheel-side { display: flex; flex-direction: column; align-items: center; gap: 14px; }
#wheel-container { position: relative; }
/* fixed pointer at top of wheel showing the landing slot */
.wheel-pointer {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; z-index: 3;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 20px solid var(--gold);
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.6));
}
#roulette-wheel {
  border-radius: 50%;
  box-shadow: 0 0 0 8px #3a2a12, 0 0 0 14px var(--gold), 0 18px 40px rgba(0,0,0,.6);
  background: #111;
  display: block;
  max-width: 100%;
  height: auto;
}
#wheel-container { max-width: 100%; }
.result-banner {
  display: flex; align-items: center; justify-content: center;
  width: 90px; height: 90px; border-radius: 50%;
  font-size: 40px; font-weight: 800; color: #fff;
  border: 3px solid var(--gold);
  box-shadow: 0 6px 18px rgba(0,0,0,.5);
  transition: transform .2s;
  animation: bannerPop .45s ease;
}
@keyframes bannerPop {
  0% { transform: scale(.3); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
.result-banner.hidden { display: none; }
.result-banner.red { background: var(--red); }
.result-banner.black { background: var(--black); }
.result-banner.green { background: var(--green); }

.history { display: flex; gap: 6px; flex-wrap: wrap; max-width: 420px; justify-content: center; }
.history .h {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; border: 1px solid rgba(255,255,255,.25);
}
.history .red { background: var(--red); }
.history .black { background: var(--black); }
.history .green { background: var(--green); }

/* ---------------- Chips ---------------- */
.table-side { display: flex; flex-direction: column; gap: 16px; }
.chips { display: flex; align-items: center; gap: 10px; }
.chips-label { opacity: .8; margin-right: 4px; }
.chip {
  width: 50px; height: 50px; border-radius: 50%;
  border: 3px dashed rgba(255,255,255,.85);
  font-weight: 800; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 6px var(--chip-shadow);
  transition: transform .1s, outline .1s; outline: 0 solid transparent;
}
.chip:hover { transform: translateY(-3px); }
.chip.selected { outline: 3px solid var(--gold); transform: translateY(-3px); }
.chip[data-val="1"]   { background: #d8d8d8; color: #222; }
.chip[data-val="5"]   { background: #c1121f; }
.chip[data-val="25"]  { background: #1b6b2f; }
.chip[data-val="100"] { background: #1a1a1a; }
.chip[data-val="500"] { background: #6a1b9a; }

/* ---------------- Betting layout ---------------- */
.felt {
  background: linear-gradient(160deg, var(--felt), var(--felt-dark));
  border: 4px solid var(--gold);
  border-radius: 10px;
  padding: 10px;
  box-shadow: inset 0 0 40px rgba(0,0,0,.4);
}
.bet-grid {
  display: grid;
  grid-template-columns: 46px repeat(12, 1fr) 46px;
  grid-template-rows: repeat(3, 46px);
  gap: 3px;
  position: relative; /* anchor for absolutely-positioned adjacency hotspots */
}
.cell {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff;
  border: 1px solid rgba(255,255,255,.4);
  cursor: pointer; user-select: none;
  transition: filter .1s;
}
.cell:hover { filter: brightness(1.25); }
.cell.red { background: var(--red); }
.cell.black { background: var(--black); }
.cell.green { background: var(--green); }

.cell.zero { grid-row: 1 / span 3; grid-column: 1; font-size: 18px; }
.cell.col-bet { background: rgba(0,0,0,.25); font-size: 13px; }

.outside { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; margin-top: 3px; }
.outside .cell { height: 42px; background: rgba(0,0,0,.28); font-size: 13px; }
.outside .cell.dozen { grid-column: span 2; }
.outside .cell.swatch-red { background: var(--red); }
.outside .cell.swatch-black { background: var(--black); }

/* ---------------- Adjacency bet hotspots (split / street / corner / line) ---- */
/* Thin transparent zones overlaid on the gridlines between number cells. They
   sit ABOVE the cells so clicks land on the border bet, and carry their own
   chip just like a normal cell. */
.hotspot {
  position: absolute;
  z-index: 4;
  cursor: pointer;
  border-radius: 3px;
  background: transparent;
  transition: background .1s, box-shadow .1s;
  /* center any rendered chip on the hotspot */
  display: flex; align-items: center; justify-content: center;
}
.hotspot:hover,
.hotspot:focus-visible {
  background: rgba(231, 200, 115, .45);
  box-shadow: 0 0 0 1px rgba(231, 200, 115, .9);
  outline: none;
}
.hotspot.has-chip { background: rgba(231, 200, 115, .18); }
/* a hotspot that is part of the winning bet rings gold like a cell */
.hotspot.winning {
  background: rgba(231, 200, 115, .35);
  box-shadow: 0 0 0 3px var(--gold), 0 0 14px 3px rgba(231, 200, 115, .85);
  z-index: 5;
  animation: winPulse 1.4s ease infinite;
}
/* chips placed on hotspots are not centered via cell flow — keep them centered
   on the hotspot itself (override the absolute centering used on cells). */
.hotspot .bet-chip {
  position: static;
  transform: none;
  top: auto; left: auto;
}

/* chip stack rendered on a bet cell */
.bet-chip {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff;
  border: 2px dashed rgba(255,255,255,.9);
  box-shadow: 0 2px 4px var(--chip-shadow);
  background: var(--gold); color: #222;
  pointer-events: none;
}

/* ---------------- Controls ---------------- */
.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  padding: 12px 18px; border: none; border-radius: 8px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  background: #2c3a32; color: #fff; transition: background .15s, transform .05s;
}
.btn:hover { background: #3a4d41; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--gold); color: #1a1a1a; font-size: 18px; padding: 12px 34px; }
.btn.primary:hover { background: #f0d488; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.message { min-height: 22px; font-weight: 600; color: var(--gold); }
.message.lose { color: #ff8a8a; }
.message.win { color: #8affa0; }

/* keyboard focus affordance */
.cell:focus-visible, .chip:focus-visible, .btn:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 2px;
}
.cell { outline: none; }

/* highlight the winning number / outside bets on the grid after a spin */
.cell.winning {
  box-shadow: 0 0 0 3px var(--gold), 0 0 14px 3px rgba(231,200,115,.85);
  z-index: 2;
  animation: winPulse 1.4s ease infinite;
}
@keyframes winPulse {
  0%,100% { filter: brightness(1.15); }
  50% { filter: brightness(1.6); }
}

/* chip on a cell: stack + gold ring, more legible */
.bet-chip {
  background: radial-gradient(circle at 35% 30%, #ffe9ad, var(--gold));
  border: 2px solid #fff;
  box-shadow: 0 2px 5px var(--chip-shadow), 0 0 0 1px rgba(0,0,0,.4);
}

/* balance value flashes green on win, red on loss */
.value.flash-win { animation: flashWin .9s ease; }
.value.flash-lose { animation: flashLose .9s ease; }
@keyframes flashWin {
  0% { color: #8affa0; transform: scale(1.25); text-shadow: 0 0 12px #8affa0; }
  100% { color: var(--gold); transform: scale(1); }
}
@keyframes flashLose {
  0% { color: #ff8a8a; transform: scale(1.25); text-shadow: 0 0 12px #ff8a8a; }
  100% { color: var(--gold); transform: scale(1); }
}

/* low / busted balance warning */
#balance.low { color: #ff8a8a; }

/* total-bet pill emphasis when bets are staked */
#staked.active { color: #8affa0; }

@media (max-width: 560px) {
  .topbar { flex-direction: column; gap: 8px; padding: 12px; }
  .bank { gap: 18px; }
  .layout { padding: 14px; gap: 18px; }
  .btn.primary { width: 100%; }
  .controls { width: 100%; }
}

/* Narrow phones: shrink the betting grid so it never overflows the screen. */
@media (max-width: 460px) {
  .layout { padding: 10px; }
  .felt { padding: 6px; }
  .bet-grid {
    grid-template-columns: 26px repeat(12, 1fr) 30px;
    grid-template-rows: repeat(3, 40px);
    gap: 2px;
  }
  .cell { font-size: 11px; }
  .cell.zero { font-size: 14px; }
  .cell.col-bet { font-size: 10px; }
  .outside { gap: 2px; }
  .outside .cell { height: 36px; font-size: 11px; }
  .bet-chip { width: 20px; height: 20px; font-size: 9px; }
  .chip { width: 42px; height: 42px; }
}

/* On touch / coarse pointers, make the hotspots easier to hit. The JS reads
   this hint (via a data attribute on the grid) to inflate hit areas. */
@media (hover: none), (pointer: coarse) {
  .hotspot { background: rgba(231, 200, 115, .12); }
}
