:root {
  --bg: #0b120e;
  --bg-alt: #0f1a14;
  --card: #15231b;
  --card-2: #1b2d22;
  --line: #22382b;
  --text: #e9f1ec;
  --muted: #9bb0a3;
  --gold: #f5c542;
  --gold-dark: #d9a520;
  --green: #2ecc71;
  --red: #ff5a5f;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); }
body {
  font-family: "Inter", system-ui, sans-serif;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); font-size: 0.85rem; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--line);
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 1.6rem;
  letter-spacing: 1px;
}
.logo b { color: var(--gold); font-weight: 400; }
.game-title {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 1.35rem;
  letter-spacing: 1px;
  color: var(--muted);
  padding-left: 16px;
  border-left: 1px solid var(--line);
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.balance {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}
.balance strong { color: var(--gold); font-size: 0.95rem; margin-left: 4px; font-variant-numeric: tabular-nums; }
.balance small { font-size: 0.7rem; }
.icon-btn {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.icon-btn:hover { border-color: var(--gold-dark); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  padding: 16px;
  max-width: 1440px;
  margin: 0 auto;
}
.stage-wrap { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.history {
  display: flex;
  gap: 6px;
  overflow: hidden;
  min-height: 28px;
  mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.chip {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.chip.lo { color: #ff8a8d; }
.chip.mid { color: var(--green); }
.chip.hi { color: var(--gold); border-color: rgba(245, 197, 66, 0.5); }

.stage {
  position: relative;
  height: calc(100vh - 140px);
  min-height: 440px;
  max-height: 780px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0e3524;
}
.stage canvas { display: block; width: 100%; height: 100%; }

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 5%;
}
.mult {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: clamp(3.6rem, 9vw, 7.5rem);
  line-height: 1;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.55);
  transition: color 0.2s;
}
.mult.waiting { color: rgba(255, 255, 255, 0.55); }
.mult.t2 { color: #b9f5cf; }
.mult.t10 { color: var(--gold); text-shadow: 0 0 30px rgba(245, 197, 66, 0.5); }
.mult.crashed { color: var(--red); animation: pop 0.35s ease-out; }
@keyframes pop { from { transform: scale(1.25); } to { transform: scale(1); } }

.status {
  margin-top: 8px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  font-weight: 600;
  font-size: 0.92rem;
  text-align: center;
  max-width: 92%;
}
.countdown {
  width: min(260px, 60%);
  height: 6px;
  margin-top: 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}
.countdown[hidden] { display: none; }
.countdown div { height: 100%; width: 0; background: var(--gold); }
.mine {
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(46, 204, 113, 0.18);
  border: 1px solid rgba(46, 204, 113, 0.5);
  color: #b9f5cf;
  font-weight: 700;
  font-size: 0.88rem;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 20px);
  opacity: 0;
  padding: 8px 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.75);
  font-size: 0.88rem;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- side panel ---------- */
.panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.controls { display: flex; flex-direction: column; gap: 10px; }
.controls > label { font-size: 0.8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

input[type="number"], .verify input {
  width: 100%;
  min-width: 0;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: 600 1rem "Inter", sans-serif;
  padding: 10px 12px;
  font-variant-numeric: tabular-nums;
}
input:focus { outline: 2px solid var(--gold-dark); outline-offset: 0; }
input:disabled { opacity: 0.45; }

.bet-row { display: grid; grid-template-columns: 48px 1fr 48px; gap: 8px; }
.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.mini {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 6px;
  font-weight: 700;
  font-size: 0.85rem;
}
.mini:hover { border-color: var(--gold-dark); color: var(--gold); }

.auto-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
}
.auto-label input { width: 16px; height: 16px; accent-color: var(--gold); }
.auto-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 700; }

.action {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px 12px;
  transition: transform 0.08s, filter 0.15s, background 0.2s;
}
.action:active { transform: scale(0.98); }
.action:hover { filter: brightness(1.08); }
.a-main { font-family: "Bebas Neue", Impact, sans-serif; font-size: 1.8rem; letter-spacing: 1px; line-height: 1; }
.a-sub { font-size: 0.85rem; font-weight: 600; opacity: 0.85; font-variant-numeric: tabular-nums; }
.action.gold { background: linear-gradient(180deg, var(--gold), var(--gold-dark)); color: #1b1404; }
.action.green { background: linear-gradient(180deg, #45e08a, #22a85a); color: #04210f; box-shadow: 0 0 24px rgba(46, 204, 113, 0.35); }
.action.ghost { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.action.outline { background: transparent; color: var(--gold); border: 2px solid var(--gold-dark); }
.hint { font-size: 0.75rem; color: var(--muted); text-align: center; }
kbd {
  font: 600 0.7rem "Inter", sans-serif;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--bg-alt);
}

.bets { flex: 1; min-height: 200px; display: flex; flex-direction: column; }
.bets-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; margin-bottom: 10px; }
#betsList { list-style: none; overflow-y: auto; max-height: 380px; }
#betsList li {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "n s" "a s";
  column-gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
#betsList li:nth-child(odd) { background: rgba(255, 255, 255, 0.025); }
#betsList li.me { background: rgba(245, 197, 66, 0.1); border: 1px solid rgba(245, 197, 66, 0.35); }
#betsList .n { grid-area: n; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#betsList .a { grid-area: a; color: var(--muted); font-size: 0.78rem; }
#betsList .s { grid-area: s; align-self: center; text-align: right; color: var(--muted); font-weight: 600; }
#betsList li.win .s { color: var(--green); }
#betsList li.lose .s { color: var(--red); }

/* ---------- fairness dialog ---------- */
.dialog {
  margin: auto;
  width: min(560px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(2px); }
.dialog h2 { font-family: "Bebas Neue", Impact, sans-serif; font-weight: 400; font-size: 2rem; letter-spacing: 1px; }
.dialog h3 { font-size: 0.95rem; margin: 18px 0 8px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.kv { display: flex; flex-direction: column; gap: 4px; margin: 14px 0; font-size: 0.8rem; color: var(--muted); }
code, pre {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.75rem;
  color: var(--text);
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  word-break: break-all;
}
pre { white-space: pre-wrap; margin: 8px 0; }
details summary { cursor: pointer; font-size: 0.88rem; font-weight: 600; }
.past { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.past-row {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
  align-items: center;
  text-align: left;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
}
.past-row:hover { border-color: var(--gold-dark); }
.past-row code { border: 0; padding: 0; background: none; color: var(--muted); font-size: 0.7rem; }
.verify { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 8px; }
.verify input { font: 0.8rem ui-monospace, Consolas, monospace; }
.note { margin-top: 16px; font-size: 0.75rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .stage { height: 58vh; min-height: 340px; }
  .game-title { display: none; }
  #betsList { max-height: 300px; }
}
@media (max-width: 520px) {
  .topbar { padding: 8px 16px; gap: 8px; }
  .logo { font-size: 1.3rem; }
  .logo > span:last-child { display: none; }
  .hide-sm { display: none; }
  .balance { padding: 5px 10px; }
}
