:root {
  --bg: #0a0a0e;
  --stage: #0c0c11;
  --panel: #15151c;
  --line: #1b1b24;
  --text: #f1f2f6;
  --hint: #868b99;
  --green: #2fa85a;
  --green-bright: #3ddc84;
  --red: #e23b4e;
  --amber: #e7b743;
  --pill: #1c1c24;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; }
#app { display: flex; flex-direction: column; min-height: 100vh;
  padding: env(safe-area-inset-top) 10px env(safe-area-inset-bottom); gap: 10px; }

/* ---------- top bar: balance + history pills + stats ---------- */
#topbar { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
.balance { font-weight: 800; font-size: 17px; white-space: nowrap; }
.history-wrap { margin-left: auto; display: flex; align-items: center; gap: 6px; overflow: hidden; }
.history { display: flex; gap: 6px; overflow: hidden; flex-direction: row-reverse; }
.histpill { flex: 0 0 auto; font-size: 13px; font-weight: 700; padding: 6px 9px; border-radius: 8px;
  border: 0; background: var(--pill); color: #c9ccd6; line-height: 1; }
.histpill.win { background: var(--green); color: #fff; }
.histpill.stats { display: inline-flex; align-items: center; justify-content: center; color: #c9ccd6;
  padding: 6px 8px; }
.histpill.stats:active { color: #fff; }

/* ---------- stage / graph ---------- */
#stage { position: relative; background: var(--stage); border-radius: 14px; overflow: hidden;
  aspect-ratio: 16 / 12; min-height: 320px; }
#graph { width: 100%; height: 100%; display: block; }

.mult-card { position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
  background: rgba(20,20,28,.55); padding: 14px 30px; border-radius: 16px; backdrop-filter: blur(2px);
  transition: background .2s; }
.mult-card.bust { background: rgba(226,59,78,.20); box-shadow: 0 0 0 1px rgba(226,59,78,.5) inset; }
.mult-val { font-size: 46px; font-weight: 800; letter-spacing: .5px; color: #fff;
  text-shadow: 0 2px 14px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
.mult-card.bust .mult-val { color: #ff5d6c; }
.crashed-label { font-size: 14px; font-weight: 800; letter-spacing: 2px; color: #fff;
  background: rgba(226,59,78,.55); padding: 5px 16px; border-radius: 8px; }

.net-status { position: absolute; right: 12px; bottom: 10px; font-size: 11px; color: var(--hint);
  display: flex; align-items: center; gap: 6px; pointer-events: none; }
.net-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-bright);
  box-shadow: 0 0 6px var(--green-bright); }
.net-status .dot.off { background: var(--red); box-shadow: 0 0 6px var(--red); }

/* summary strip — its OWN row below the graph (no longer overlapping the curve) */
#bottombar { padding: 2px 4px; }
.progress { height: 3px; border-radius: 2px; background: #1c1c24; overflow: hidden; margin-bottom: 7px; }
#progress-fill { height: 100%; width: 0%; background: var(--green-bright); transition: width .25s linear; border-radius: 2px; }
.bottom-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--hint); }
.players { display: flex; align-items: center; gap: 6px; }
.players .pdot { width: 7px; height: 7px; border-radius: 50%; background: var(--green-bright); }
.round-status { font-weight: 600; color: #aeb2bf; }

/* players' bets list */
#players { background: var(--panel); border-radius: 14px; padding: 10px 12px; }
.players-title { font-size: 12px; color: var(--hint); margin-bottom: 6px; }
#player-list { list-style: none; margin: 0; padding: 0; max-height: 30vh; overflow-y: auto; }
#player-list li { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0;
  border-bottom: 1px solid var(--line); }
#player-list li:last-child { border-bottom: 0; }
#player-list li .won { color: var(--green-bright); font-weight: 600; }
#player-list li .lost { color: var(--red); }
#player-list .empty { color: var(--hint); font-size: 12px; padding: 6px 0; }

/* ---------- bet panel ---------- */
#panel { background: var(--panel); border-radius: 14px; padding: 12px; }
.row { display: flex; gap: 10px; margin-bottom: 10px; }
.row label { flex: 1; font-size: 12px; color: var(--hint); display: flex; flex-direction: column; gap: 5px; }
.row input { font-size: 17px; padding: 11px; border-radius: 10px; border: 1px solid #262630;
  background: #0e0e14; color: var(--text); width: 100%; font-variant-numeric: tabular-nums; }
.row input:focus { outline: none; border-color: #3a3a48; }
.action { width: 100%; padding: 15px; font-size: 18px; font-weight: 800; border: 0; border-radius: 12px;
  background: var(--green); color: #fff; transition: opacity .15s, background .15s; letter-spacing: .3px; }
.action:disabled { opacity: .4; }
.action.cashout { background: var(--amber); color: #1a1a1a; }
.message { min-height: 16px; margin-top: 8px; font-size: 13px; text-align: center; color: var(--amber); }

/* ---------- modal (fairness + history) ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center;
  justify-content: center; padding: 18px; z-index: 50; }
.modal-card { background: var(--panel); border-radius: 16px; width: 100%; max-width: 460px;
  max-height: 82vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px;
  border-bottom: 1px solid var(--line); font-weight: 700; }
.modal-close { background: transparent; border: 0; color: var(--hint); font-size: 18px; }
.modal-body { padding: 14px 16px; }
.fair-label { font-size: 11px; color: var(--hint); text-transform: uppercase; letter-spacing: .5px; margin: 12px 0 6px; }
.fair-label:first-child { margin-top: 0; }
.fair-code { display: block; font-size: 11px; color: #b9bdc9; word-break: break-all; background: #0e0e14;
  padding: 8px 10px; border-radius: 8px; }
.fair-kv { font-size: 12px; color: var(--hint); margin-top: 6px; }
.fair-kv .fair-code { display: inline-block; margin-top: 4px; }
.m-history { display: flex; flex-wrap: wrap; gap: 6px; }
.fair-note { font-size: 11px; color: var(--hint); margin-top: 14px; line-height: 1.5; }

.hidden { display: none; }
