:root {
  --room: #061a14;        /* page, the dark room around the table */
  --felt: #0e3a2d;
  --felt-lit: #155040;
  --felt-deep: #082019;
  --ivory: #f1e8d2;
  --ivory-dim: rgba(241, 232, 210, .62);
  --ivory-faint: rgba(241, 232, 210, .14);
  --brass: #d6a84e;
  --brass-hi: #f0cf86;
  --brass-lo: #9c7426;
  --red: #c8323c;
  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --text: Figtree, system-ui, sans-serif;
  --dock-h: 64px;
  --col: 480px;           /* the app is a phone-width column on every screen */
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html {
  min-height: 100%;
  background: var(--noise), radial-gradient(130% 70% at 50% 0%, #0c3227 0%, var(--room) 70%) var(--room);
  background-attachment: fixed;
}
body {
  max-width: var(--col);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 16px calc(var(--dock-h) + 28px + env(safe-area-inset-bottom));
  color: var(--ivory);
  font: 500 15px/1.45 var(--text);
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input { font: inherit; color: var(--ivory); }
:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 2px; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
h2 { margin: 0 0 12px; font: 700 15px var(--text); color: var(--ivory); }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 12px; }
.brand { font: 900 28px/1 var(--display); letter-spacing: .5px; color: var(--ivory); }
.purse {
  display: flex; align-items: center; gap: 7px; height: 40px; padding: 0 16px 0 12px; border-radius: 20px;
  background: linear-gradient(180deg, rgba(214,168,78,.22), rgba(214,168,78,.08));
  box-shadow: inset 0 0 0 1px rgba(214,168,78,.45);
}
.purse-star { color: var(--brass-hi); font-size: 15px; }
.purse-amount { font: 800 22px/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: .3px; }
.purse.bump .purse-amount { animation: bump .5s ease; }
@keyframes bump { 40% { transform: scale(1.18); color: var(--brass-hi); } }

.panel { display: none; }
.panel.active { display: block; }

/* the felt table, the signature surface */
.table {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  min-height: 248px; padding: 28px 22px 22px; margin-bottom: 14px; border-radius: 28px; overflow: hidden;
  background: var(--noise), radial-gradient(90% 80% at 50% 35%, var(--felt-lit) 0%, var(--felt) 55%, var(--felt-deep) 100%);
  box-shadow:
    0 0 0 3px #2a1a0c,                                    /* wooden rail */
    0 0 0 5px rgba(214,168,78,.55),                       /* brass trim */
    inset 0 0 50px rgba(0,0,0,.45),
    0 18px 40px rgba(0,0,0,.45);
}
.table::before {                                          /* stitched edge */
  content: ""; position: absolute; inset: 9px; border-radius: 20px; pointer-events: none;
  border: 1.5px dashed rgba(241,232,210,.16);
}
.verdict { position: relative; margin: 0; min-height: 22px; text-align: center; font-weight: 600; color: var(--ivory-dim); }
.verdict.win { color: var(--brass-hi); }
.verdict.lose { color: #ff8a90; }

/* coin */
.coin-wrap { position: relative; perspective: 900px; padding-top: 6px; }
.coin { position: relative; width: 124px; height: 124px; transform-style: preserve-3d; }
.coin.flipping { transition: transform 1.5s cubic-bezier(.16,.8,.24,1); }
.coin .face {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 50%; backface-visibility: hidden;
  background:
    radial-gradient(circle at 34% 28%, rgba(255,247,215,.95) 0 8%, transparent 32%),
    radial-gradient(circle, var(--brass) 0 58%, var(--brass-lo) 59% 61%, var(--brass) 62% 100%);
  box-shadow: inset 0 0 0 5px var(--brass-lo), inset 0 0 0 7px var(--brass-hi), inset 0 -6px 14px rgba(80,50,0,.45);
}
.coin .face span { font: 900 52px/1 var(--display); color: #6a4a12; text-shadow: 0 1px 0 rgba(255,236,180,.7); }
.coin .tails { transform: rotateY(180deg); }
.coin-shadow { width: 90px; height: 12px; margin: 14px auto 0; border-radius: 50%; background: rgba(0,0,0,.4); filter: blur(5px); }

/* dice */
.dice-roll { font: 900 76px/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.dice-roll.win { color: var(--brass-hi); }
.dice-roll.lose { color: #ff8a90; }
.track { position: relative; width: 100%; height: 12px; border-radius: 6px; background: rgba(200,50,60,.55); box-shadow: inset 0 1px 2px rgba(0,0,0,.4); }
.track-win { position: absolute; top: 0; bottom: 0; border-radius: 6px; background: linear-gradient(180deg, var(--brass-hi), var(--brass)); transition: left .2s, width .2s; }
.marker {
  position: absolute; top: 50%; left: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 6px;
  background: var(--ivory); box-shadow: 0 3px 8px rgba(0,0,0,.5); transform: rotate(45deg) scale(0); transition: left .6s cubic-bezier(.2,.8,.2,1), transform .25s;
}
.marker.show { transform: rotate(45deg) scale(1); }
.dice-rule { position: relative; margin: -6px 0 0; font-size: 13px; font-weight: 600; color: var(--brass); }
.track-scale { display: flex; justify-content: space-between; width: 100%; margin-top: -8px; font-size: 11px; color: var(--ivory-dim); font-variant-numeric: tabular-nums; }

/* crash */
.crash-table { justify-content: flex-end; }
#crashCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.crash-value {
  position: absolute; top: 44%; left: 50%; transform: translate(-50%, -50%);
  font: 900 84px/1 var(--display); font-variant-numeric: tabular-nums; text-shadow: 0 4px 24px rgba(0,0,0,.5);
}
.crash-value.win { color: var(--brass-hi); }
.crash-value.lose { color: #ff8a90; }

/* options & inputs */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 14px; border-radius: 16px; background: rgba(0,0,0,.28); }
.options button { display: flex; align-items: center; justify-content: center; gap: 8px; height: 46px; border-radius: 12px; font-weight: 700; color: var(--ivory-dim); transition: background .2s, color .2s; }
.options button.active { background: var(--felt-lit); color: var(--ivory); box-shadow: inset 0 0 0 1px rgba(214,168,78,.5); }
.opt-glyph { font: 900 18px/1 var(--display); color: var(--brass); }

.slider { margin-bottom: 14px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; color: var(--ivory-dim); font-size: 14px; }
.slider-value b { color: var(--ivory); font: 800 19px var(--display); letter-spacing: .3px; }
input[type=range] { width: 100%; height: 28px; margin: 0; background: none; -webkit-appearance: none; appearance: none; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--ivory-faint); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--ivory-faint); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%;
  background: radial-gradient(circle, var(--brass-hi), var(--brass) 60%, var(--brass-lo)); box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--brass); }

.stepper { display: flex; gap: 6px; }
.stepper input {
  flex: 1; min-width: 0; height: 50px; text-align: center; border-radius: 14px; border: 0; outline: none;
  background: rgba(0,0,0,.3); font: 800 26px var(--display); box-shadow: inset 0 0 0 1px var(--ivory-faint);
}
.stepper input:focus { box-shadow: inset 0 0 0 1.5px var(--brass); }
.stepper button { width: 50px; border-radius: 14px; background: rgba(0,0,0,.3); font: 700 24px var(--display); color: var(--brass-hi); }
.presets { display: flex; gap: 6px; margin-top: 8px; }
.presets button { flex: 1; height: 34px; border-radius: 10px; background: rgba(0,0,0,.22); font: 800 16px var(--display); color: var(--ivory-dim); }
.presets button.active { color: var(--brass-hi); box-shadow: inset 0 0 0 1px rgba(214,168,78,.5); }

/* bet */
.bet { padding: 16px; border-radius: 22px; background: rgba(0,0,0,.26); box-shadow: inset 0 0 0 1px rgba(241,232,210,.06); }
.bet-head { display: flex; justify-content: space-between; align-items: center; color: var(--ivory-dim); font-size: 14px; }
.bet-tools { display: flex; gap: 4px; }
.bet-tools button { height: 30px; padding: 0 12px; border-radius: 9px; background: rgba(241,232,210,.07); font-size: 13px; font-weight: 700; color: var(--ivory-dim); }
.bet-amount { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; }
.bet-star { color: var(--brass); font-size: 26px; }
.bet-amount input {
  width: 100%; border: 0; outline: none; background: none; padding: 0;
  font: 900 54px/1.05 var(--display); font-variant-numeric: tabular-nums; letter-spacing: .5px;
}

/* poker chips */
.chips { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 16px; }
.chip {
  --c: #c8323c; --ink: var(--ivory);
  position: relative; width: 54px; height: 54px; flex: 0 0 auto; border-radius: 50%;
  background: repeating-conic-gradient(from 10deg, var(--c) 0 25deg, var(--ivory) 25deg 35deg);
  box-shadow: 0 4px 0 rgba(0,0,0,.45), 0 6px 12px rgba(0,0,0,.35);
  transition: transform .12s ease;
}
.chip span {
  position: absolute; inset: 7px; display: grid; place-items: center; border-radius: 50%;
  background: var(--c); color: var(--ink); font: 900 17px/1 var(--display);
  box-shadow: inset 0 0 0 2px rgba(241,232,210,.55), inset 0 0 0 4px var(--c), inset 0 0 0 5px rgba(241,232,210,.25);
}
.chip:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.35); }

.play {
  display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; min-height: 64px; border-radius: 18px;
  background: linear-gradient(180deg, var(--brass-hi) 0%, var(--brass) 45%, var(--brass-lo) 100%);
  color: #2a1b04; box-shadow: inset 0 1px 0 rgba(255,245,215,.7), 0 5px 0 #5c430f, 0 10px 20px rgba(0,0,0,.4);
  transition: transform .1s, box-shadow .1s, filter .2s;
}
.play:active { transform: translateY(4px); box-shadow: inset 0 1px 0 rgba(255,245,215,.7), 0 1px 0 #5c430f, 0 4px 10px rgba(0,0,0,.4); }
.play:disabled { filter: saturate(.4) brightness(.8); }
.play-main { font: 900 25px/1.1 var(--display); letter-spacing: .4px; }
.play-sub { font-size: 13px; font-weight: 700; opacity: .75; }

/* history ledger */
.history { margin-top: 24px; }
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger li { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--ivory-faint); }
.ledger li:last-child { border-bottom: 0; }
.ledger .what { flex: 1; min-width: 0; }
.ledger .what b { display: block; font-weight: 700; }
.ledger .what small { color: var(--ivory-dim); font-size: 13px; }
.ledger .amt { font: 800 20px var(--display); font-variant-numeric: tabular-nums; }
.ledger .amt.w { color: var(--brass-hi); }
.ledger .amt.l { color: #ff8a90; }
.ledger .empty { color: var(--ivory-dim); justify-content: center; border: 0; padding: 18px 0; }
.status { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 8px; background: var(--ivory-faint); color: var(--ivory-dim); }
.status.paid { background: rgba(214,168,78,.2); color: var(--brass-hi); }
.status.rejected, .status.failed { background: rgba(200,50,60,.22); color: #ff8a90; }

/* wallet */
.vault {
  position: relative; padding: 26px 22px; margin-bottom: 16px; border-radius: 28px; overflow: hidden; text-align: center;
  background: var(--noise), radial-gradient(90% 90% at 50% 20%, var(--felt-lit), var(--felt) 60%, var(--felt-deep));
  box-shadow: 0 0 0 3px #2a1a0c, 0 0 0 5px rgba(214,168,78,.55), inset 0 0 40px rgba(0,0,0,.4);
}
.vault-label { margin: 0; color: var(--ivory-dim); font-weight: 600; }
.vault-amount { margin: 4px 0 0; display: flex; align-items: center; justify-content: center; gap: 10px; font: 900 64px/1 var(--display); font-variant-numeric: tabular-nums; }
.vault-amount span:first-child { color: var(--brass); font-size: 34px; }
.block { padding: 18px 16px; margin-bottom: 12px; border-radius: 22px; background: rgba(0,0,0,.26); box-shadow: inset 0 0 0 1px rgba(241,232,210,.06); }
.note { margin: -4px 0 12px; color: var(--ivory-dim); font-size: 13.5px; }
.amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.amounts button {
  height: 48px; border-radius: 14px; background: rgba(241,232,210,.06); font: 800 21px var(--display);
  box-shadow: inset 0 0 0 1px var(--ivory-faint); transition: background .15s;
}
.amounts button::before { content: "★ "; color: var(--brass); font-size: 15px; }
.amounts button:active { background: rgba(214,168,78,.2); }
.field-row { display: flex; gap: 6px; }
.field-row input {
  flex: 1; min-width: 0; height: 48px; padding: 0 14px; border: 0; border-radius: 14px; outline: none;
  background: rgba(0,0,0,.3); box-shadow: inset 0 0 0 1px var(--ivory-faint);
}
.field-row input:focus { box-shadow: inset 0 0 0 1.5px var(--brass); }
.field-row input::placeholder { color: rgba(241,232,210,.38); }
.brass, .ghost { height: 48px; padding: 0 20px; border-radius: 14px; font-weight: 700; }
.brass { background: linear-gradient(180deg, var(--brass-hi), var(--brass)); color: #2a1b04; }
.ghost { box-shadow: inset 0 0 0 1px rgba(214,168,78,.55); color: var(--brass-hi); }
.block .ledger { margin-top: 10px; }

.fair summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.fair summary::-webkit-details-marker { display: none; }
.fair summary::after { content: "+"; font: 700 22px var(--display); color: var(--brass); }
.fair[open] summary::after { content: "−"; }
.fair summary h2 { margin: 0; }
.fair[open] summary { margin-bottom: 12px; }
.seeds { margin: 0 0 12px; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13px; }
.seeds dt { color: var(--ivory-dim); }
.seeds dd { margin: 0; text-align: right; }
.seeds code { font-size: 12px; word-break: break-all; color: var(--ivory); }

/* bottom dock */
.dock {
  position: fixed; left: 50%; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr);
  width: 100%; max-width: var(--col); transform: translateX(-50%);
  height: calc(var(--dock-h) + env(safe-area-inset-bottom)); padding: 0 8px env(safe-area-inset-bottom);
  background: rgba(6,26,20,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 -1px 0 rgba(214,168,78,.25);
}
.dock button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--ivory-dim); }
.dock svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dock svg .dot { fill: currentColor; stroke: none; }
.dock button.active { color: var(--brass-hi); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--dock-h) + 14px + env(safe-area-inset-bottom)); z-index: 20;
  width: calc(min(100vw, var(--col)) - 32px);
  padding: 13px 16px; border-radius: 14px; text-align: center; font-weight: 600;
  background: #f1e8d2; color: #10261f; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  opacity: 0; transform: translate(-50%, 8px); transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .coin.flipping, .marker, .track-win, .toast, .play, .chip { transition: none; }
  .purse.bump .purse-amount { animation: none; }
}

/* wide screens (desktop browser, Telegram Desktop): frame the column */
@media (min-width: 560px) {
  .dock { border-radius: 20px 20px 0 0; box-shadow: 0 -1px 0 rgba(214,168,78,.25), 0 -10px 30px rgba(0,0,0,.35); }
}
