:root {
  --bg: #0f212e;
  --panel: #1a2c38;
  --panel2: #213743;
  --input: #0f212e;
  --border: #2f4553;
  --text: #ffffff;
  --muted: #b1bad3;
  --accent: #00e701;
  --accent-dark: #00b801;
  --red: #ed4163;
  --gold: #ffc800;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
}
#app { max-width: 1100px; margin: 0 auto; padding: 12px 16px 40px; }

header { display: flex; justify-content: space-between; align-items: center; padding: 10px 0 16px; }
.logo { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; }
.logo span { color: var(--accent); }
.header-right { display: flex; gap: 10px; align-items: center; }
.balance-pill { background: var(--panel); border-radius: 8px; padding: 8px 14px; color: var(--muted); font-size: 14px; }
.balance-pill strong { color: var(--text); margin-left: 6px; font-variant-numeric: tabular-nums; }
.ghost-btn {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.ghost-btn:hover { background: var(--panel2); }

main { display: grid; grid-template-columns: 340px 1fr; gap: 12px; }
@media (max-width: 800px) { main { grid-template-columns: 1fr; } }

#panel { background: var(--panel); border-radius: 12px; padding: 16px; align-self: start; }
.tabs { display: flex; background: var(--bg); border-radius: 8px; padding: 4px; margin-bottom: 16px; }
.tabs button {
  flex: 1; border: none; background: transparent; color: var(--muted);
  padding: 10px; border-radius: 6px; cursor: pointer; font-weight: 700; font-size: 14px;
}
.tabs button.active { background: var(--panel2); color: var(--text); }
.hidden { display: none !important; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-weight: 400; font-style: normal; }
.field input, .field select {
  width: 100%; background: var(--input); border: 2px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 10px 12px; font-size: 15px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.bet-row { display: flex; gap: 6px; }
.bet-row input { flex: 1; }
.mini-btn {
  background: var(--panel2); color: var(--text); border: none; border-radius: 8px;
  padding: 0 14px; cursor: pointer; font-weight: 700;
}
.mini-btn:hover { background: var(--border); }
.pct-row { display: flex; align-items: center; gap: 6px; }
.pct-row input { flex: 1; }
.pct-row em { color: var(--muted); font-style: normal; font-weight: 700; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.readouts { background: var(--bg); border-radius: 8px; padding: 4px 12px; margin: 4px 0 14px; }
.readouts div { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; }
.readouts div + div { border-top: 1px solid var(--border); }
.readouts span { color: var(--muted); }
.readouts strong { font-variant-numeric: tabular-nums; }
.bet-btn {
  width: 100%; padding: 14px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #062b06; font-size: 17px; font-weight: 800;
}
.bet-btn:hover:not(:disabled) { background: var(--accent-dark); }
.bet-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.bet-btn.stop { background: var(--red); color: #fff; }

#stage {
  background: var(--panel); border-radius: 12px; padding: 32px 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 420px; position: relative;
}
#target-chip {
  background: var(--bg); border-radius: 999px; padding: 8px 18px;
  color: var(--muted); font-size: 14px; margin-bottom: 18px;
}
#target-chip strong { color: var(--text); }
#result-number {
  font-size: 84px; font-weight: 800; letter-spacing: -2px;
  font-variant-numeric: tabular-nums; line-height: 1;
}
#result-number.win { color: var(--accent); }
#result-number.lose { color: var(--red); }
#result-status { margin-top: 14px; color: var(--muted); font-size: 16px; font-weight: 600; min-height: 24px; }
#result-status.win { color: var(--accent); }
#result-status.lose { color: var(--red); }
#recent { margin-top: 28px; display: flex; align-items: center; gap: 10px; max-width: 100%; }
.recent-label { color: var(--muted); font-size: 13px; }
#recent-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  background: var(--bg); border-radius: 6px; padding: 5px 10px; font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pill.high { color: var(--gold); }
.pill.mid { color: var(--accent); }
.pill.low { color: var(--muted); }

#history-section { background: var(--panel); border-radius: 12px; padding: 16px 20px; margin-top: 12px; }
#history-section h3 { margin: 0 0 10px; font-size: 16px; }
#history-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
#history-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--border); }
#history-table td { padding: 8px; border-bottom: 1px solid var(--bg); }
#history-table tr:last-child td { border-bottom: none; }
td.win-cell { color: var(--accent); font-weight: 700; }
td.lose-cell { color: var(--red); font-weight: 700; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.65); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-card {
  background: var(--panel); border-radius: 12px; padding: 24px; max-width: 560px; width: 100%;
  max-height: 90vh; overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head h3 { margin: 0; }
.modal-card h4 { margin: 18px 0 8px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
.muted code { color: var(--text); background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
#verify-out { margin-top: 10px; font-size: 14px; }
#seed-history { list-style: none; padding: 0; margin: 6px 0 0; }
#seed-history li { font-family: monospace; font-size: 11px; word-break: break-all; padding: 4px 0; }
input[readonly] { opacity: 0.75; }

/* --- Near-miss side bet --- */
.sidebet-box {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; margin-top: 14px;
}
.sidebet-head {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 14px; cursor: pointer; color: var(--gold);
}
.sidebet-head input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.sidebet-box .field { margin: 10px 0 0; }
.sidebet-box .readouts { margin: 10px 0 0; }
#sidebet-note { margin-top: 8px; }

/* --- Streak meter --- */
#streak-meter { margin-top: 10px; font-size: 14px; font-weight: 700; color: var(--gold); min-height: 20px; }
#streak-meter.idle { color: var(--muted); font-weight: 600; }

/* --- Crash-style reveal --- */
#result-number.target-hit {
  color: var(--accent);
  text-shadow: 0 0 26px rgba(0, 231, 1, 0.65);
}
#result-number.bust {
  color: var(--red);
  animation: bustflash 0.45s ease-out;
}
@keyframes bustflash {
  0% { text-shadow: 0 0 34px rgba(237, 65, 99, 0.9); transform: scale(1.22); }
  100% { text-shadow: none; transform: scale(1); }
}
.bonus-tag { color: var(--gold); font-size: 12px; font-weight: 700; }
