:root {
  --bg: #111229;
  --stage: #17183a;
  --panel: #1b1c40;
  --chip: #2a2b5e;
  --chip-border: #3a3c7a;
  --orange: #cc4210;
  --orange-line: #ee5a1f;
  --crimson: #b21f41;
  --text: #ffffff;
  --muted: #9a9cc2;
  --green: #86d13a;
  --red: #ff5a6e;
  --cashout: #3f7d12;
  --wallet-blue: #2b68a6;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
}

body {
  font-family: Roboto, "Geist", system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font-family: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid #ffd21f;
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.game {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* Stage */
.stage {
  position: relative;
  background: var(--stage);
  padding-top: 8px;
}

.tabs {
  display: flex;
  gap: 7px;
  padding: 0 10px 4px;
}

.tab {
  height: 25px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-outline {
  flex: 0 0 42%;
  background: transparent;
  border: 1px solid var(--orange-line);
  color: #ff7a45;
}

.tab-fill {
  flex: 1;
  border: 0;
  color: #fff;
  background: linear-gradient(90deg, #d9500f 0%, #c92a45 100%);
}

.tab-fill svg {
  width: 14px;
  height: 14px;
}

#graph {
  display: block;
  width: 100%;
  aspect-ratio: 780 / 275;
}

/* Bets */
.bets {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px 5px 10px;
}

.bet-box {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 7px;
  padding: 11px;
  background: var(--panel);
  border-radius: 10px;
}

.amount {
  position: relative;
}

.amount-input {
  width: 100%;
  height: 34px;
  padding: 0 34px 0 9px;
  border: 2px solid #6a70b8;
  border-radius: 5px;
  background: #fff;
  color: #111229;
  font-size: 14px;
  font-weight: 700;
}

.amount-clear {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 26px;
  height: 26px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: #1b1c40;
}

.amount-clear svg {
  width: 11px;
  height: 11px;
}

.chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 7px;
}

.chip {
  height: 27px;
  padding: 0;
  border: 1px solid var(--chip-border);
  border-radius: 5px;
  background: var(--chip);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
}

.chip:active {
  background: #3a3c7a;
}

.bet-right {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.auto-btn {
  height: 34px;
  padding: 0 4px;
  border: 1.5px solid var(--orange-line);
  border-radius: 5px;
  background: transparent;
  color: #ff7a45;
  font-size: clamp(10px, 3.2vw, 12.5px);
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.auto-btn[aria-pressed="true"] {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

.bet-btn {
  flex: 1;
  min-height: 61px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  border: 0;
  border-radius: 5px;
  background: var(--orange);
  color: #fff;
  transition: filter 0.12s ease;
}

.bet-btn:active {
  filter: brightness(0.9);
}

.bet-main {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.bet-sub {
  font-size: 11px;
  font-weight: 400;
}

.bet-sub:empty {
  display: none;
}

.bet-btn.is-cancel,
.bet-btn.is-cashout {
  background: linear-gradient(180deg, #ffe45f 0%, #ffcb25 64%, #f0a500 100%);
  color: #26202a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.27);
}
.bet-btn.is-cancel .bet-main,
.bet-btn.is-cashout .bet-main {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.amount-input:disabled,
.amount-clear:disabled,
.chip:disabled,
.bet-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.bet-btn.is-cancel:disabled {
  opacity: 1;
  cursor: default;
}

.auto-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.auto-row[hidden] {
  display: none;
}

.odds-wrap {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--chip-border);
  border-radius: 5px;
  background: var(--chip);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.odds-input {
  width: 58px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 0;
  padding: 6px 4px 9px;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(90deg, #b9480f 0%, #b21f41 100%);
  text-align: center;
}

.stat-label {
  font-size: 12.5px;
  font-weight: 400;
}

.stat-value {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.stat-value svg {
  width: 12px;
  height: 12px;
  flex: none;
}

.stat-cur {
  display: block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
}

/* Table */
.table-wrap {
  flex: 1;
  background: var(--stage);
  padding: 2px 0 12px;
}

.bets-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.bets-table th {
  padding: 9px 0 6px;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
  text-transform: uppercase;
}

.bets-table td {
  padding: 6px 2px;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bets-table tr.won td {
  color: var(--green);
}

.bets-table tr.lost td {
  color: var(--red);
}

.bets-table tr.me td {
  font-weight: 700;
}

/* Fixed reference-like bottom navigation: back arrow, balance/name, wallet and gift icons. */
.wallet {
  position: fixed;
  z-index: 11;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 480px);
  min-height: 49px;
  padding: 3px 4px calc(3px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 5px;
  color: #111;
  background: #fff;
  box-shadow: 0 -1px 6px rgba(0,0,0,.18);
}
.wallet-back {
  border: 0;
  padding: 0;
  flex: 0 0 34px;
  height: 39px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#0a0a0a;
  background:transparent;
}
.wallet-back svg { width: 21px; height: 21px; }
.wallet-balance {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 1px;
  color: #333;
  white-space: nowrap;
  line-height: 1.08;
}
.wallet-amount { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.wallet-label { font-size: 12px; font-weight: 400; }
.wallet-actions { display: flex; gap: 4px; flex-shrink: 0; }
.wallet-icon-button {
  display: flex;
  align-items:center;
  justify-content:center;
  width: 42px;
  height: 41px;
  border: 0;
  border-radius: 5px;
  color: #111;
}
.wallet-icon-button svg { width: 24px; height: 24px; }
.wallet-icon-primary { background: #ffb900; }
.wallet-icon-secondary { background: #dadada; }
.wallet-menu {
  position: absolute;
  bottom: calc(100% + 7px);
  right: 8px;
  padding: 13px;
  width: 226px;
  background: #f7f8fc;
  color: #16172c;
  border: 1px solid #d6d8e4;
  border-radius: 7px;
  box-shadow: 0 4px 18px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.wallet-menu[hidden] { display: none; }
.wallet-menu small { color: #595b70; font-size: 11px; }
.wallet-reset { border:0; border-radius: 5px; background: #305b99; color: #fff; min-height: 32px; font-size: 11px; font-weight: 700; }
/* Keep the disclaimer below the initial viewport; it is reached by scrolling. */
.table-wrap { min-height: 214px; }
/* Make page content and disclaimer scroll fully above the fixed bar. */
.game { padding-bottom: calc(53px + env(safe-area-inset-bottom, 0px)); }

/* Toast */
.toast {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 20;
  max-width: min(92vw, 420px);
  padding: 9px 14px;
  border-radius: 8px;
  background: #fff;
  color: #111229;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Dialogs */
dialog {
  width: min(92vw, 400px);
  max-height: 80vh;
  padding: 16px;
  border: 1px solid var(--chip-border);
  border-radius: 12px;
  background: var(--panel);
  color: #fff;
}

dialog::backdrop {
  background: rgba(8, 8, 24, 0.72);
}

.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.dlg-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.dlg-close {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--chip-border);
  border-radius: 6px;
  background: var(--chip);
  color: #fff;
}

.dlg-close svg {
  width: 11px;
  height: 11px;
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--chip);
  font-size: 12.5px;
  font-weight: 700;
}

.history-list li.mid {
  background: var(--orange);
}

.history-list li.high {
  background: var(--crimson);
}

.history-note,
.rules {
  font-size: 13px;
  line-height: 1.55;
  color: #d5d6ea;
}

.history-note {
  margin: 12px 0 0;
}

.rules {
  margin: 0;
  padding-left: 18px;
}

.rules li + li {
  margin-top: 6px;
}

/* In-stage notices, matched to the reference video's compact message strip. */
.round-message {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 56%;
  width: min(51%, 224px);
  min-height: 30px;
  padding: 6px 9px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid rgba(58, 61, 92, 0.84);
  border-radius: 5px;
  background: rgba(11, 13, 34, 0.88);
  box-shadow: 0 1px 7px rgba(0,0,0,.14);
  color: #9adf38;
  text-align: center;
  font-size: clamp(12px, 3.45vw, 16px);
  font-weight: 500;
  line-height: 1.14;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -47%) scale(.985);
  transition: opacity .19s ease, transform .19s ease;
}
.round-message.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }
.round-message.negative { color: #e45b28; }
.round-message.positive { color: #a7ea42; }
.round-message.win { color: #a7ea42; font-size: clamp(11px, 3.2vw, 14px); }
.round-message.neutral { color: #f7f7f8; }
.stat-value { font-size: 11.6px; font-variant-numeric: tabular-nums; letter-spacing: -.18px; }
.stat-label { font-size: 11.7px; }
.stat-cur { font-size: 11.6px; }
.demo-disclaimer {
  padding: 18px 12px 28px;
  background: #14152f;
  color: #afb1d0;
  border-top: 1px solid rgba(255,255,255,.07);
  line-height: 1.55;
  font-size: 11px;
  text-align: center;
}
.demo-disclaimer strong { color: #fff; }
@media (max-width: 350px){
 .stat-value,.stat-cur {font-size:10.3px}
 .stat-label {font-size:10.2px}
}

/* Accepted (countdown) vs collectible (flight) button states. */
.bet-btn.is-accepted {
  background: #a97721;
  color: #f7d097;
  box-shadow: none;
}
.bet-btn.is-accepted:disabled { opacity: 0.68; cursor: default; }
.bet-btn.is-accepted .bet-main { font-size: 13.5px; font-weight: 700; letter-spacing: .1px; }
.bet-btn.is-cashout { background: #ffab00; color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.12); }
.bet-btn.is-cashout .bet-main { font-size: 15px; }

/* Stack successful results from both control panels, one above the other. */
.round-message.stacked { flex-direction: column; gap: 3px; width: min(63%, 262px); }
.round-message .result-line { display: block; white-space: nowrap; }
.round-message.stacked .result-line + .result-line {
  padding-top: 3px; border-top: 1px solid rgba(150,220,90,.25);
}


/* V9: borderless, free-floating green win messages. Separate double wins
   vertically by a deliberate gap, never with a separator line or card. */
.round-message.win,
.round-message.win.stacked {
  width: max-content;
  max-width: calc(100% - 22px);
  min-height: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  text-shadow: 0 2px 7px rgba(0,0,0,.7);
}
.round-message.win.stacked { gap: 15px; }
.round-message.win.stacked .result-line + .result-line {
  border: 0;
  padding: 0;
}
