/* ROULETTE — shares the hakoniwa five-tone palette with BLACKJACK 21.
 * Mobile-first portrait betting layout (3 columns × 12 rows). */
:root {
  --c-dark: #50514F; --c-red: #F25F5C; --c-yellow: #FFE066; --c-blue: #247BA0; --c-teal: #70C1B3;
  --bg: #f4f6f5; --surface: #fff; --surface-2: #eef1f0; --ink: #50514F; --muted: #8c8e8b;
  --line: rgba(80,81,79,0.16); --line-soft: rgba(80,81,79,0.08);
  --felt: #2f8f6e; --felt-2: #25785c; --green: #1f8f5f;
  --win: #3aa893; --lose: #e8483f;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: radial-gradient(120% 70% at 50% -8%, #fff 0%, #f2f4f3 60%, #e7eae9 100%) fixed;
  color: var(--ink); line-height: 1.6; padding-bottom: 24px;
}
h1, h2, h3 { font-family: 'Cinzel', serif; }
a { color: var(--c-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ---- header ---- */
.topbar { text-align: center; padding: 16px 16px 8px; }
.brand { display: flex; align-items: center; justify-content: center; gap: 9px; }
.brand h1 { margin: 0; font-size: clamp(1.2rem, 6vw, 2rem); letter-spacing: 0.14em; color: var(--c-dark); }
.pip { font-size: 0.7rem; } .pip.red { color: var(--c-red); } .pip.black { color: var(--c-dark); }
.tagline { color: var(--muted); font-size: 0.82rem; margin: 4px 0 12px; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 100px; }
.tab { font-family: 'Cinzel', serif; font-size: 0.78rem; letter-spacing: 0.06em; border: none; background: transparent; color: var(--muted); padding: 8px 20px; border-radius: 100px; cursor: pointer; transition: 0.2s; }
.tab.is-active { color: #fff; background: var(--c-blue); }

.panel { display: none; max-width: 560px; margin: 0 auto; padding: 0 12px; }
.panel.is-active { display: block; animation: fade 0.35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- play tools ---- */
.play-tools { display: flex; gap: 8px; margin: 6px 0 10px; }
.tool-btn { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; line-height: 1.2; font-family: 'JetBrains Mono', monospace; font-size: 0.74rem; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); cursor: pointer; }
.tool-btn:active { background: var(--surface-2); }

/* ---- rail / stats ---- */
.rail { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.chip-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 7px 8px; text-align: center; }
.chip-stat .ck { display: block; font-size: 0.56rem; color: var(--muted); letter-spacing: 0.06em; }
.chip-stat span:last-child { font-weight: 600; font-size: 0.95rem; color: var(--c-blue); }

/* ---- wheel ---- */
.wheel-zone { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.wheel { position: relative; width: 150px; height: 150px; flex: 0 0 auto; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #5a4326 0%, #3a2a18 70%, #241a0f 100%);
  box-shadow: 0 6px 18px rgba(0,0,0,0.35), inset 0 0 0 4px #6b5230; }
.wheel-face { position: absolute; inset: 8px; border-radius: 50%; will-change: transform; }
.wheel-face svg { width: 100%; height: 100%; display: block; }
.ball-arm { position: absolute; inset: 0; will-change: transform; pointer-events: none; }
.ball { position: absolute; top: 9px; left: 50%; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0%, #d9d9d9 60%, #9a9a9a 100%); box-shadow: 0 1px 3px rgba(0,0,0,0.6); }
.wheel-pointer { position: absolute; top: -2px; left: 50%; transform: translateX(-50%); width: 0; height: 0;
  border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 11px solid var(--c-yellow); z-index: 3; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.5)); }

.tote { flex: 1; min-width: 0; }
.tote-num { width: 64px; height: 64px; border-radius: 12px; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 600; margin: 0 auto; }
.tote-num.red { background: var(--c-red); } .tote-num.black { background: var(--c-dark); } .tote-num.green { background: var(--green); }
.tote-num.flash { animation: toteFlash 0.5s ease; }
@keyframes toteFlash { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
.tote-label { text-align: center; font-size: 0.56rem; color: var(--muted); letter-spacing: 0.1em; margin: 3px 0 6px; }
.history-strip { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; }
.hs-pip { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 0.62rem; color: #fff; font-weight: 600; }
.hs-pip.red { background: var(--c-red); } .hs-pip.black { background: var(--c-dark); } .hs-pip.green { background: var(--green); }

/* ---- banner (countdown / no more bets) ---- */
.banner { text-align: center; font-family: 'Cinzel', serif; letter-spacing: 0.1em; font-size: 0.92rem; padding: 9px; border-radius: 10px; margin-bottom: 8px; }
.banner.open { background: rgba(58,168,147,0.16); color: #1f6f5f; border: 1px solid rgba(58,168,147,0.4); }
.banner.nomore { background: var(--c-red); color: #fff; animation: nmb 0.5s steps(2) 3; }
@keyframes nmb { 50% { opacity: 0.45; } }

/* ---- authentic betting board ---- */
.board-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 14px; }
.board { position: relative; min-width: 500px; display: grid;
  grid-template-columns: 0.8fr repeat(12, 1fr) 0.8fr; grid-template-rows: repeat(3, 38px) 28px 28px; gap: 3px;
  background: radial-gradient(130% 90% at 50% 0%, var(--felt) 0%, var(--felt-2) 95%); padding: 6px; box-shadow: inset 0 0 30px rgba(0,0,0,0.2); }
/* triple-zero (Sands): widen the zero column so 0 + 000/00 fit as a hex honeycomb */
.board.sands { min-width: 560px; grid-template-columns: 3.4fr repeat(12, 1fr) 0.8fr; }
.cell { position: relative; border: 1px solid rgba(255,255,255,0.32); border-radius: 4px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #fff; user-select: none; font-weight: 600; transition: filter 0.12s; }
.cell:active { filter: brightness(1.25); }
.cell.win { box-shadow: 0 0 0 3px var(--c-yellow), 0 0 14px rgba(255,224,102,0.8); z-index: 4; }
/* Zero section: real tables angle the inner (number-facing) edge so 0/00/000
 * form pentagons + a central triangle, converging toward the middle number.
 * Drawn as an SVG; labels overlaid as HTML (the viewBox is stretched non-uniformly). */
.bzero { grid-column: 1; grid-row: 1 / span 3; position: relative; padding: 0; background: none; border: none; border-radius: 0; }
.zero-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.zpath { fill: var(--green); stroke: rgba(255,255,255,0.45); stroke-width: 1.4; vector-effect: non-scaling-stroke; cursor: pointer; transition: fill 0.12s; }
.zpath:active { fill: #25a06d; }
.zpath.win { fill: #2aa06e; stroke: var(--c-yellow); stroke-width: 3; }
.zlabel { position: absolute; transform: translate(-50%, -50%); color: #fff; font-weight: 600; pointer-events: none; white-space: nowrap; }
.bnum { font-size: 0.86rem; }
.bnum.red { background: var(--c-red); } .bnum.black { background: var(--c-dark); }
.bcol { font-size: 0.6rem; background: rgba(255,255,255,0.08); }
.bdoz { font-size: 0.66rem; letter-spacing: 0.02em; background: rgba(255,255,255,0.08); }
.bout { font-size: 0.62rem; letter-spacing: 0.02em; background: rgba(255,255,255,0.08); }
.bout.red-bet { background: var(--c-red); } .bout.black-bet { background: var(--c-dark); }

/* clickable inside-bet spots (split/street/corner/six-line) */
.spots-layer { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.spot { position: absolute; width: 26px; height: 26px; transform: translate(-50%, -50%); border-radius: 50%; cursor: pointer; pointer-events: auto; }
.spot::after { content: ''; position: absolute; top: 50%; left: 50%; width: 10px; height: 10px; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(255,255,255,0.26); border: 1px solid rgba(255,255,255,0.5); transition: background 0.12s, transform 0.1s; }
.spot:active::after { background: rgba(255,224,102,0.75); transform: translate(-50%, -50%) scale(1.4); }

/* chips overlay (rendered at each bet's anchor point); chips are draggable */
.chips-layer { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.chip-badge { position: absolute; transform: translate(-50%, -50%); min-width: 22px; height: 22px; padding: 0 4px; border-radius: 100px; color: #3a3a1a; border: 2px solid #fff; font-size: 0.6rem; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,0.45); pointer-events: auto; touch-action: none; cursor: grab; }
.chip-badge.dragging { cursor: grabbing; z-index: 9; opacity: 0.92; box-shadow: 0 4px 12px rgba(0,0,0,0.5); }
.chip-badge.c1 { background: #8fc0d8; } .chip-badge.c5 { background: #f4a6a4; }
.chip-badge.c25 { background: #8fd6bb; } .chip-badge.c100 { background: #c9b86a; }
.chip-badge.win { animation: chipWin 0.6s ease infinite alternate; box-shadow: 0 0 0 2px var(--c-yellow), 0 1px 4px rgba(0,0,0,0.45); }
@keyframes chipWin { from { transform: translate(-50%, -50%) scale(1); } to { transform: translate(-50%, -50%) scale(1.18); } }
.chip-badge.lose { animation: chipLose 0.5s ease forwards; }
@keyframes chipLose { to { opacity: 0; transform: translate(-50%, -130%) scale(0.6); } }

/* dolly (winning-number marker) */
.dolly { position: absolute; z-index: 7; transform: translate(-50%, -50%); width: 16px; height: 22px; pointer-events: none;
  background: linear-gradient(#ffe7a0, #d8a93a); border: 1px solid #8a6a1e; border-radius: 4px 4px 50% 50%; box-shadow: 0 2px 6px rgba(0,0,0,0.5); }
.dolly::after { content: ''; position: absolute; top: 3px; left: 50%; transform: translateX(-50%); width: 7px; height: 7px; border-radius: 50%; background: #8a6a1e; }

.message { text-align: center; margin: 12px 0 4px; font-size: 0.9rem; color: var(--ink); min-height: 1.3em; }

/* ---- chips ---- */
.chiprow { display: flex; justify-content: center; gap: 12px; margin: 8px 0; }
.chip { width: 54px; height: 54px; border-radius: 50%; border: 3px dashed rgba(255,255,255,0.8); color: #fff; font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: transform 0.1s; }
.chip:active { transform: scale(0.92); }
.chip.is-active { transform: scale(1.12); box-shadow: 0 0 0 3px var(--c-yellow); }
.chip.c1 { background: var(--c-blue); } .chip.c5 { background: var(--c-red); }
.chip.c25 { background: var(--green); } .chip.c100 { background: var(--c-dark); border-color: var(--c-yellow); color: var(--c-yellow); }

/* ---- controls ---- */
.controls { display: grid; gap: 8px; margin: 8px 0; }
.bet-controls { grid-template-columns: 1fr 1fr 1fr 1.4fr; }
.result-controls { grid-template-columns: 1fr; }
.action { font-family: 'Cinzel', serif; letter-spacing: 0.05em; padding: 14px 8px; border-radius: 12px; border: none; color: #fff; background: var(--c-blue); cursor: pointer; transition: transform 0.08s, filter 0.2s; font-size: 0.9rem; }
.action:active { transform: translateY(1px); }
.action:disabled { opacity: 0.4; filter: grayscale(0.4); cursor: default; }
.action.spin { background: var(--c-red); }
.action.ghost { background: transparent; color: var(--c-blue); border: 1px solid var(--c-blue); font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; padding: 13px 4px; }
.action.run { width: 100%; margin-top: 4px; }

.game-controls { display: flex; align-items: center; gap: 8px; margin: 14px 0 4px; padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.gc-label { font-size: 0.6rem; color: var(--muted); letter-spacing: 0.08em; }
.gc-btn { flex: 1; min-width: 64px; font-family: 'JetBrains Mono', monospace; font-size: 0.74rem; padding: 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); cursor: pointer; }
.gc-btn.warn { color: var(--lose); border-color: rgba(232,72,63,0.4); }

/* ---- history panel ---- */
.history { margin: 14px 0; }
.history-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.history-title { font-family: 'Cinzel', serif; font-size: 0.9rem; }
.link-btn { background: none; border: none; color: var(--c-blue); font-size: 0.74rem; cursor: pointer; }
.history-list { display: flex; flex-wrap: wrap; gap: 5px; }
.hl-row { display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 0.74rem; }
.hl-num { width: 26px; height: 26px; border-radius: 6px; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.hl-num.red { background: var(--c-red); } .hl-num.black { background: var(--c-dark); } .hl-num.green { background: var(--green); }
.hl-delta.pos { color: var(--win); } .hl-delta.neg { color: var(--lose); }

.play-foot { text-align: center; margin: 18px 0 8px; font-size: 0.82rem; }

/* ---- simulation form ---- */
.sim-form { margin-top: 6px; }
.sim-intro { font-size: 0.82rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c-blue); border-radius: 10px; padding: 11px 13px; }
.seg { display: inline-flex; gap: 2px; background: var(--surface-2); border-radius: 10px; padding: 3px; margin: 10px 0; }
.seg-btn { font-family: 'JetBrains Mono', monospace; font-size: 0.74rem; border: none; background: transparent; color: var(--muted); padding: 7px 18px; border-radius: 8px; cursor: pointer; }
.seg-btn.is-active { background: var(--surface); color: var(--c-blue); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.block { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 14px; padding: 12px; margin: 10px 0; display: grid; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 0.72rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.help { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 0.6rem; cursor: help; font-style: normal; }
.field select, .field input[type="number"] { font-family: 'JetBrains Mono', monospace; font-size: 0.9rem; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 10px; appearance: none; }
.field input[type="range"] { width: 100%; accent-color: var(--c-blue); }
.detail-only { display: none; } .detail-only.show { display: block; }

.sim-progress { margin: 12px 0; display: flex; align-items: center; gap: 10px; }
.bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 100px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--c-blue); transition: width 0.1s; }
#progText { font-size: 0.72rem; color: var(--muted); min-width: 36px; }

.sim-results { margin-top: 14px; }
.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 9px 8px; text-align: center; }
.stat .sk { display: block; font-size: 0.56rem; color: var(--muted); letter-spacing: 0.04em; margin-bottom: 3px; }
.stat .sv { font-size: 1rem; font-weight: 600; color: var(--c-blue); }
.sv.pos { color: var(--win); } .sv.neg { color: var(--lose); }
.chart-wrap { margin-top: 14px; }
.chart-wrap h3 { font-size: 0.82rem; color: var(--muted); margin: 0 0 6px; font-family: 'JetBrains Mono', monospace; letter-spacing: 0.04em; }
canvas { width: 100%; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.sim-meta { font-size: 0.72rem; color: var(--muted); margin-top: 10px; }

/* ---- bottom sheets ---- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(50,52,50,0.45); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-width: 560px; margin: 0 auto; max-height: 88dvh; overflow-y: auto; background: var(--bg); border-radius: 22px 22px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.2,0.8,0.2,1); }
.sheet-backdrop.is-open .sheet { transform: translateY(0); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 1.1rem; }
.x { background: none; border: none; font-size: 1.5rem; color: var(--muted); cursor: pointer; line-height: 1; }
.sheet .field { margin-bottom: 12px; }
.sheet-note { font-size: 0.78rem; color: var(--muted); margin: 8px 0 14px; }
#infoBody table { border-collapse: collapse; width: 100%; font-size: 0.78rem; }
#infoBody th, #infoBody td { border: 1px solid var(--line); padding: 7px 8px; text-align: left; }
#infoBody th { background: var(--surface-2); font-family: 'Cinzel', serif; font-size: 0.74rem; }
#infoBody td:last-child, #infoBody th:last-child { text-align: right; }

/* ---- helptip / toast ---- */
.helptip { position: fixed; z-index: 80; max-width: 220px; background: var(--c-dark); color: #fff; font-size: 0.74rem; line-height: 1.5; padding: 9px 11px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); opacity: 0; pointer-events: none; transition: opacity 0.15s; }
.helptip.show { opacity: 1; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px); z-index: 90; background: var(--c-dark); color: #fff; font-size: 0.82rem; padding: 11px 18px; border-radius: 100px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.toast.show { opacity: 1; transform: translateX(-50%); }

.foot { max-width: 560px; margin: 30px auto 0; padding: 18px 16px; text-align: center; color: var(--muted); font-size: 0.74rem; border-top: 1px solid var(--line); }
