/* ============================================================================
   Roulette — "Victorian private gaming room" (sister to the blackjack table)
   Pure HTML/CSS scene (no image assets): a single-zero wheel and a full European
   betting layout on green felt in a mahogany-and-brass room. Shares the blackjack
   palette + serifs so the two games read as one casino.
   ========================================================================== */

:root {
  --felt-green: #1e6b43;
  --mahogany: #5d3a1a;
  --brass: #c9a227;
  --wall-dark: #3a2417;
  --cream: #faf6ec;
  --shadow-warm: rgba(40, 20, 5, 0.6);
  --felt-lit: #2e7d4f;
  --felt-edge: #14532d;
  --mahogany-hi: #8b5a2b;
  --brass-hi: #d4af37;
  --brass-lo: #a07d20;
  --wall-panel: #4a2f1d;
  --damask-bg: #4a3415;
  --ink: #2b1d12;
  --num-red: #b3271f;
  --num-black: #1a1a1a;
  --num-green: #1e7a4a;
  --win: #d4af37;
  --lose: #d96a55;
  --serif-display: "Cinzel", "Playfair Display", Georgia, "Times New Roman", serif;
  --serif-body: "Playfair Display", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
.hidden { display: none !important; }
.btn, .chip, .cell, .dot, .link-btn, .chip-btn { touch-action: manipulation; }

body {
  margin: 0;
  font-family: var(--serif-body);
  background: var(--wall-dark);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  touch-action: manipulation;
}

/* ---------- Top bar: mahogany cornice + brass nameplate ---------- */
.topbar {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.55rem 1.1rem;
  background:
    linear-gradient(180deg, rgba(255, 226, 160, 0.07), rgba(0, 0, 0, 0.25)),
    repeating-linear-gradient(88deg, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 7px),
    linear-gradient(180deg, #2c1a0e, #221308);
  border-bottom: 2px solid rgba(201, 162, 39, 0.55);
  box-shadow: 0 3px 14px var(--shadow-warm);
  z-index: 5;
}
.brand {
  font-family: var(--serif-display);
  font-size: 1.32rem; font-weight: 800; letter-spacing: 0.14em;
  color: var(--brass-hi);
  text-shadow: 0 1px 0 rgba(40, 20, 5, 0.65), 0 0 18px rgba(212, 175, 55, 0.25);
}
.brand-sub {
  font-family: var(--serif-body); font-style: italic;
  font-size: 0.82rem; color: rgba(222, 198, 128, 0.7); letter-spacing: 0.02em;
}
.account { display: flex; align-items: center; gap: 0.8rem; font-size: 0.92rem; margin-left: auto; }
.player-name {
  width: 7.5rem; padding: 0.3rem 0.7rem; border-radius: 999px;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: rgba(0, 0, 0, 0.3); color: var(--cream); font: inherit;
}
.balance { color: rgba(250, 246, 236, 0.8); }
.balance strong { color: var(--brass-hi); font-variant-numeric: tabular-nums; }
.link-btn {
  background: none; border: none; color: rgba(250, 246, 236, 0.62);
  text-decoration: underline; cursor: pointer; font: inherit;
}
.link-btn:hover { color: var(--brass-hi); }

/* ---------- The room ---------- */
.felt {
  flex: 1; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; overflow: hidden; background: var(--damask-bg);
}
.felt::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(255, 214, 150, 0.10) 0 2px, rgba(0, 0, 0, 0.38) 2px 4px, transparent 4px 9%) bottom / 100% 30% no-repeat,
    linear-gradient(180deg, rgba(255, 220, 160, 0.10), rgba(0, 0, 0, 0.05) 22%, rgba(0, 0, 0, 0.28) 86%, rgba(0, 0, 0, 0.45)) bottom / 100% 30% no-repeat,
    linear-gradient(180deg, var(--wall-panel), var(--wall-dark)) bottom / 100% 30% no-repeat,
    linear-gradient(180deg, rgba(246, 226, 122, 0.85), var(--brass) 45%, #6e521a) bottom / 100% 7px no-repeat,
    radial-gradient(circle at 50% 50%, rgba(122, 92, 46, 0.30) 5%, transparent 7%) top / 58px 58px repeat,
    linear-gradient(180deg, #57401d, var(--damask-bg) 55%, #3c2a11);
  background-position: bottom, bottom, bottom, 0 70%, top, top;
}
.felt::after {
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: radial-gradient(120% 95% at 50% 42%, transparent 54%, rgba(24, 12, 3, 0.5) 90%, rgba(18, 8, 2, 0.74));
}
.chandelier {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background:
    radial-gradient(46% 34% at 50% 12%, rgba(255, 217, 138, 0.5), transparent 70%),
    radial-gradient(70% 52% at 50% 26%, rgba(255, 217, 138, 0.3), transparent 72%);
  mix-blend-mode: soft-light;
}

/* ---------- The table ---------- */
.table {
  position: relative; z-index: 1;
  width: min(1080px, 97vw);
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  padding: 1.4rem 1.6rem 1.7rem;
  border-radius: 22px;
  background:
    radial-gradient(ellipse 90% 120% at 50% 0%, var(--felt-lit), var(--felt-green) 55%, var(--felt-edge) 100%);
  border: 16px solid transparent;
  background-clip: padding-box;
  box-shadow:
    0 30px 64px var(--shadow-warm), 0 8px 22px rgba(40, 20, 5, 0.5),
    inset 0 0 0 2px rgba(201, 162, 39, 0.55),
    inset 0 0 70px rgba(10, 40, 24, 0.5);
  outline: 14px solid var(--mahogany);
  outline-offset: 0;
}
/* polished mahogany rail drawn as a thick border via a wrapper ring */
.table::before {
  content: ""; position: absolute; inset: -14px; border-radius: 30px; z-index: -1;
  background: linear-gradient(180deg, var(--mahogany-hi), var(--mahogany) 50%, var(--mahogany-lo, #3f2812));
  box-shadow: inset 0 2px 0 rgba(255, 236, 190, 0.25);
}

/* ---------- Wheel ---------- */
.wheel-stage {
  display: flex; align-items: center; justify-content: center; gap: 1.4rem;
  width: 100%; flex-wrap: wrap;
}
.wheel-wrap {
  position: relative; width: 200px; height: 200px; flex: none;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
}
.wheel { position: absolute; inset: 0; transform-origin: 50% 50%; will-change: transform; }
.wheel svg { display: block; width: 100%; height: 100%; }
.wheel-pointer {
  position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; z-index: 3;
  border-left: 11px solid transparent; border-right: 11px solid transparent;
  border-top: 18px solid var(--brass-hi);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.6));
}
.wheel-hub {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 96px; height: 96px; border-radius: 50%; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 42% 36%, #3a2a14, #1c130a);
  border: 2px solid var(--brass); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}
.hub-num {
  font-family: var(--serif-display); font-weight: 800; font-size: 2.1rem;
  color: var(--cream); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.hub-num.red { color: #ff7a72; }
.hub-num.black { color: #d7d2c6; }
.hub-num.green { color: #66d29a; }
.hub-num:empty::after { content: "•"; color: rgba(222, 198, 128, 0.4); }

/* recent results */
.history-box { display: flex; flex-direction: column; gap: 0.35rem; min-width: 140px; }
.history-label {
  font-family: var(--serif-display); font-size: 0.72rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: rgba(222, 198, 128, 0.7);
}
.history { display: flex; flex-wrap: wrap; gap: 4px; max-width: 220px; }
.hist-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  font-size: 0.78rem; font-weight: 800; color: #fff;
  font-variant-numeric: tabular-nums; border: 1px solid rgba(0, 0, 0, 0.4);
}
.hist-num.red { background: var(--num-red); }
.hist-num.black { background: var(--num-black); }
.hist-num.green { background: var(--num-green); }

/* ---------- The betting board ---------- */
.board-wrap { width: 100%; overflow-x: auto; }
.board {
  display: grid;
  grid-template-columns: 0.66fr repeat(12, 1fr) 0.7fr;
  grid-template-rows: repeat(3, 1fr) 0.82fr 0.82fr;
  gap: 3px;
  min-width: 560px;
  aspect-ratio: 14 / 6.2;
  background: rgba(8, 30, 18, 0.35);
  padding: 4px; border-radius: 8px;
  border: 1px solid rgba(201, 162, 39, 0.4);
}
.cell {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(250, 246, 236, 0.22);
  border-radius: 4px; cursor: pointer; user-select: none;
  font-family: var(--serif-display); font-weight: 700;
  transition: filter 0.12s ease, box-shadow 0.12s ease;
  min-height: 26px;
}
.cell:hover { filter: brightness(1.18); box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.7) inset; z-index: 2; }
.cell-label { pointer-events: none; }

.cell.num { color: #fff; font-size: clamp(0.7rem, 1.5vw, 1.05rem); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.cell.num.red { background: linear-gradient(180deg, #c12e25, var(--num-red)); }
.cell.num.black { background: linear-gradient(180deg, #2a2a2a, var(--num-black)); }
.cell.num.green, .cell.zero { background: linear-gradient(180deg, #279a5c, var(--num-green)); }
.cell.zero .cell-label { writing-mode: vertical-lr; transform: rotate(180deg); letter-spacing: 0; }

.cell.outside {
  background: linear-gradient(180deg, rgba(20, 60, 36, 0.6), rgba(12, 44, 26, 0.7));
  color: rgba(245, 240, 224, 0.92); font-size: clamp(0.62rem, 1.2vw, 0.86rem);
  letter-spacing: 0.04em;
}
.cell.column { font-size: clamp(0.6rem, 1.1vw, 0.8rem); }
.cell.chance-red { background: linear-gradient(180deg, #c12e25, var(--num-red)); color: #fff; }
.cell.chance-black { background: linear-gradient(180deg, #2a2a2a, var(--num-black)); color: #fff; }

/* inside-bet dots, glued to the grid lines */
.dot {
  position: relative; width: 15px; height: 15px; border-radius: 50%; z-index: 4;
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.35);
  cursor: pointer; transition: background 0.12s ease, transform 0.08s ease;
}
.dot:hover { background: rgba(212, 175, 55, 0.85); transform: scale(1.25); }
.dot.edge-left { justify-self: start; align-self: center; transform: translateX(-50%); }
.dot.edge-left:hover { transform: translateX(-50%) scale(1.25); }
.dot.edge-top { justify-self: center; align-self: start; transform: translateY(-50%); }
.dot.edge-top:hover { transform: translateY(-50%) scale(1.25); }
.dot.edge-bottom { justify-self: center; align-self: end; transform: translateY(50%); }
.dot.edge-bottom:hover { transform: translateY(50%) scale(1.25); }
.dot.edge-bottomleft { justify-self: start; align-self: end; transform: translate(-50%, 50%); }
.dot.edge-bottomleft:hover { transform: translate(-50%, 50%) scale(1.25); }
.dot.corner { justify-self: start; align-self: start; transform: translate(-50%, -50%); }
.dot.corner:hover { transform: translate(-50%, -50%) scale(1.25); }

/* a staked spot shows its chip total */
.spot-chip {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  min-width: 24px; height: 24px; padding: 0 5px; border-radius: 999px;
  display: none; align-items: center; justify-content: center;
  font-family: var(--serif-body); font-weight: 800; font-size: 0.72rem;
  color: var(--ink); background: linear-gradient(180deg, var(--brass-hi), var(--brass-lo));
  border: 1.5px solid rgba(60, 40, 8, 0.8); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  z-index: 6; pointer-events: none; font-variant-numeric: tabular-nums;
}
.dot-chip { min-width: 22px; height: 22px; font-size: 0.66rem; }
.staked .spot-chip { display: flex; }
.dot.staked { background: rgba(212, 175, 55, 0.9); }

/* settle highlights */
.cell.hit { box-shadow: 0 0 0 3px var(--brass-hi), 0 0 16px rgba(212, 175, 55, 0.8); z-index: 3; }
.staked.won .spot-chip { box-shadow: 0 0 0 2px var(--win), 0 0 12px rgba(212, 175, 55, 0.9); }
.staked.won { outline: 2px solid var(--win); }
.staked.lost { opacity: 0.6; }
.staked.lost .spot-chip { filter: grayscale(0.4) brightness(0.8); }

/* ---------- Controls ---------- */
.controls {
  padding: 0.8rem 1rem 1rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  background:
    linear-gradient(180deg, rgba(255, 226, 160, 0.06), transparent 30%),
    repeating-linear-gradient(89deg, rgba(0, 0, 0, 0.2) 0 1px, transparent 1px 8px),
    linear-gradient(180deg, #32200f, #20130a);
  border-top: 2px solid rgba(201, 162, 39, 0.5);
  box-shadow: 0 -4px 18px var(--shadow-warm);
}
.message {
  width: 100%; text-align: center; margin: 0; min-height: 1.3em;
  font-family: var(--serif-display); font-size: 1rem; font-weight: 700; letter-spacing: 0.03em;
  color: var(--brass-hi); text-shadow: 0 1px 3px rgba(20, 8, 0, 0.6);
}
.message.flash { animation: msgFlash 0.5s ease; }
@keyframes msgFlash { 0%, 100% { color: var(--brass-hi); } 30% { color: var(--lose); transform: scale(1.03); } }
.bet-readout {
  display: flex; gap: 1.6rem; font-size: 0.86rem; color: rgba(250, 246, 236, 0.8);
}
.bet-readout strong { color: var(--brass-hi); font-variant-numeric: tabular-nums; }

.chiptray { display: flex; gap: 0.8rem; }
.chip {
  position: relative; width: 50px; height: 50px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.84rem; color: var(--cream);
  background: var(--chip, #a93226); border: none; cursor: pointer;
  box-shadow: 0 3px 6px var(--shadow-warm); transition: transform 0.08s ease;
  text-shadow: 0 1px 1px rgba(20, 8, 0, 0.55); font-variant-numeric: tabular-nums;
}
.chip::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: repeating-conic-gradient(var(--cream) 0 17deg, var(--chip, #a93226) 17deg 60deg);
  -webkit-mask: radial-gradient(transparent 57%, #000 58%); mask: radial-gradient(transparent 57%, #000 58%);
}
.chip::after {
  content: ""; position: absolute; inset: 8px; border-radius: 50%;
  background: var(--chip, #a93226); border: 1.5px dashed rgba(212, 175, 55, 0.85);
  box-shadow: inset 0 2px 5px rgba(255, 240, 200, 0.25), inset 0 -3px 6px rgba(20, 8, 0, 0.35);
}
.chip .val { position: relative; z-index: 2; }
.chip-btn:hover:not(:disabled) { transform: translateY(-3px); }
.chip-btn:active:not(:disabled) { transform: translateY(1px) scale(0.97); }
.chip-btn.active { box-shadow: 0 0 0 3px var(--brass-hi), 0 0 14px rgba(212, 175, 55, 0.6); transform: translateY(-3px); }
.chip-btn:disabled { opacity: 0.4; cursor: default; }
.chip[data-v="5"] { --chip: #a93226; }
.chip[data-v="25"] { --chip: #1e7a4a; }
.chip[data-v="100"] { --chip: #26221c; }
.chip[data-v="500"] { --chip: #6b3fa0; }
.chip[data-v="1000"] { --chip: #1b150c; }
.chip[data-v="1000"]::after { border-color: var(--brass-hi); }

.action-row { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; }
.btn {
  min-width: 104px; padding: 0.72rem 1.2rem;
  font-family: var(--serif-display); font-size: 0.96rem; font-weight: 700; letter-spacing: 0.05em;
  color: var(--ink); background: linear-gradient(180deg, var(--brass-hi), var(--brass-lo));
  border: 1px solid rgba(60, 40, 8, 0.85); border-radius: 10px; cursor: pointer;
  transition: transform 0.06s ease, opacity 0.15s ease, filter 0.15s ease;
  text-shadow: 0 1px 0 rgba(255, 240, 190, 0.45);
  box-shadow: inset 0 2px 0 rgba(255, 244, 200, 0.65), inset 0 -3px 6px rgba(80, 52, 8, 0.55), 0 4px 10px var(--shadow-warm);
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn.primary {
  background: linear-gradient(180deg, #e9c34a, #b8901f);
  box-shadow: inset 0 2px 0 rgba(255, 248, 210, 0.75), inset 0 -3px 6px rgba(80, 52, 8, 0.55), 0 4px 12px var(--shadow-warm), 0 0 22px rgba(212, 175, 55, 0.3);
}
.btn.ghost {
  background: linear-gradient(180deg, rgba(201, 162, 39, 0.10), rgba(201, 162, 39, 0.02));
  color: rgba(250, 246, 236, 0.88); border: 1px solid rgba(201, 162, 39, 0.5); text-shadow: none;
  box-shadow: inset 0 1px 0 rgba(255, 240, 190, 0.12), 0 3px 8px var(--shadow-warm);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.34; cursor: default; }

.rules-note {
  width: 100%; max-width: 820px; margin: 0.2rem auto 0; text-align: center;
  font-family: var(--serif-body); font-size: 0.72rem; line-height: 1.5;
  letter-spacing: 0.01em; color: rgba(222, 198, 128, 0.62);
}

/* ---------- Result banner ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(24, 12, 3, 0.4);
  display: flex; align-items: center; justify-content: center; z-index: 20;
}
.result-card {
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(255, 226, 160, 0.08), transparent 55%),
    linear-gradient(180deg, #34200f, #241409);
  border: 2px solid rgba(201, 162, 39, 0.75);
  border-radius: 14px; padding: 1.2rem 2.4rem 1.4rem; text-align: center;
  box-shadow: 0 12px 44px var(--shadow-warm), inset 0 0 0 5px rgba(20, 10, 3, 0.6), inset 0 0 0 6px rgba(201, 162, 39, 0.35);
  animation: popIn 0.3s ease both;
}
.result-card.win { box-shadow: 0 0 56px rgba(212, 175, 55, 0.5), 0 12px 44px var(--shadow-warm), inset 0 0 0 5px rgba(20, 10, 3, 0.6), inset 0 0 0 6px rgba(201, 162, 39, 0.5); }
.result-emoji { font-size: 2.2rem; line-height: 1; color: var(--brass-hi); text-shadow: 0 0 16px rgba(212, 175, 55, 0.35); }
.result-number {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; margin: 0.3rem auto 0; border-radius: 50%;
  font-family: var(--serif-display); font-size: 1.7rem; font-weight: 800; color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.25);
}
.result-number.red { background: var(--num-red); }
.result-number.black { background: var(--num-black); }
.result-number.green { background: var(--num-green); }
.result-title { margin: 0.4rem 0 0.15rem; font-family: var(--serif-display); font-size: 1.7rem; font-weight: 800; letter-spacing: 0.05em; color: var(--cream); }
.result-card.win .result-title { color: var(--win); }
.result-detail { margin: 0 0 1.05rem; font-family: var(--serif-body); font-size: 1.25rem; font-weight: 700; opacity: 0.95; }
.result-card.win .result-detail { color: var(--win); }
@keyframes popIn { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .felt { padding: 0.4rem; }
  .table { padding: 0.9rem 0.7rem 1.1rem; gap: 0.7rem; border-width: 10px; outline-width: 9px; }
  .wheel-stage { gap: 0.8rem; }
  .wheel-wrap { width: 150px; height: 150px; }
  .wheel-hub { width: 70px; height: 70px; }
  .hub-num { font-size: 1.5rem; }
  .history { max-width: 150px; }
  .hist-num { width: 22px; height: 22px; font-size: 0.66rem; }
  .board { min-width: 460px; }
  .brand-sub { display: none; }
  .player-name { display: none; }
  .bet-readout { gap: 0.9rem; font-size: 0.76rem; }
  .chip { width: 44px; height: 44px; font-size: 0.76rem; }
  .btn { min-width: 0; flex: 1 1 40%; padding: 0.6rem 0.7rem; font-size: 0.84rem; min-height: 44px; }
  .dot { width: 13px; height: 13px; }
}
