:root {
  color-scheme: dark;
  --bg: #08060d;
  --panel: rgba(26, 18, 37, .94);
  --panel-soft: rgba(38, 25, 55, .82);
  --purple: #9b52ff;
  --purple-dark: #5d20b7;
  --gold: #ffd66b;
  --gold-strong: #f5b942;
  --text: #fffaf0;
  --muted: #a99eb8;
  --green: #54e3a4;
  --red: #ff5a73;
  --border: rgba(255, 214, 107, .17);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 50% -10%, rgba(125, 45, 220, .32), transparent 38%),
    linear-gradient(180deg, #0c0814 0%, #07050a 100%);
}
button, input { font: inherit; }
button { color: inherit; }

.app-shell { width: min(100%, 540px); margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 12px calc(24px + env(safe-area-inset-bottom)); }
.topbar, .account-strip, .round-meta, .section-title, .players-head, .player-row, .bet-row { display: flex; align-items: center; }
.topbar { justify-content: space-between; margin-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand__mascot { width: 48px; height: 48px; object-fit: contain; filter: drop-shadow(0 4px 14px rgba(155,82,255,.5)); }
.brand strong { display: block; font-size: 17px; letter-spacing: .2px; }
.brand small { display: flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--muted); font-size: 11px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.live-dot.connected { background: var(--green); box-shadow: 0 0 10px var(--green); }
.icon-button, .text-button, .adjust-button, .quick-bets button { border: 1px solid var(--border); background: rgba(255,255,255,.055); }
.icon-button { min-width: 42px; height: 38px; border-radius: 13px; font-weight: 800; }

.account-strip { justify-content: space-between; padding: 11px 14px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 15px; background: linear-gradient(110deg, rgba(93,32,183,.28), rgba(245,185,66,.08)); font-size: 13px; color: var(--muted); }
.account-strip b { color: var(--gold); margin-left: 3px; }

.flight-card, .bet-card, .players-card { border: 1px solid var(--border); border-radius: 20px; background: var(--panel); box-shadow: 0 18px 45px rgba(0,0,0,.26); overflow: hidden; }
.flight-card { margin-bottom: 10px; }
.round-meta { justify-content: space-between; padding: 10px 13px 8px; color: var(--muted); font-size: 11px; }
.text-button { border-radius: 999px; padding: 6px 10px; color: var(--gold); font-size: 11px; }
.sky { position: relative; height: 260px; overflow: hidden; background: linear-gradient(180deg, #120a21, #090710 78%); }
.stars, .stars::before, .stars::after { position: absolute; inset: 0; content: ""; background-image: radial-gradient(#fff 0.7px, transparent .8px); background-size: 28px 28px; opacity: .24; }
.stars::before { transform: translate(13px, 9px); background-size: 42px 42px; opacity: .4; }
.stars::after { transform: translate(4px, 18px); background-size: 68px 68px; opacity: .38; }
.flight-chart { position: absolute; inset: auto 0 0; width: 100%; height: 70%; opacity: .95; }
.rocket { position: absolute; left: 10%; bottom: 17%; z-index: 3; transform: rotate(-8deg); transition: transform .12s linear, left .12s linear, bottom .12s linear; filter: drop-shadow(0 0 15px rgba(255,214,107,.38)); }
.rocket-body { display: block; font-size: 42px; }
.rocket-flame { position: absolute; width: 28px; height: 12px; right: 31px; bottom: 6px; border-radius: 50%; background: linear-gradient(90deg, transparent, #9b52ff, #ffd66b); filter: blur(3px); animation: flame .18s infinite alternate; }
@keyframes flame { to { width: 40px; transform: translateX(-5px) scaleY(.7); } }
.multiplier { position: absolute; z-index: 4; left: 0; right: 0; top: 33%; text-align: center; font-size: clamp(42px, 14vw, 68px); line-height: 1; font-weight: 900; color: var(--gold); text-shadow: 0 0 24px rgba(245,185,66,.28); letter-spacing: -2px; }
.phase-label { position: absolute; z-index: 4; left: 0; right: 0; top: 57%; text-align: center; color: var(--muted); font-size: 13px; }
.countdown { position: absolute; z-index: 4; left: 0; right: 0; top: 66%; text-align: center; color: #fff; font-size: 20px; font-weight: 800; }
.flight-card.crashed .sky { animation: crashFlash .48s ease; }
.flight-card.crashed .rocket { transform: translate(160px, 95px) rotate(130deg) scale(.7) !important; }
.flight-card.crashed .multiplier { color: var(--red); }
@keyframes crashFlash { 30% { background: #44101d; } }

.bet-card { padding: 13px; margin-bottom: 10px; }
.bet-row { gap: 8px; }
.adjust-button { flex: 0 0 48px; height: 52px; border-radius: 14px; color: var(--gold); font-weight: 900; }
.amount-field { flex: 1; min-width: 0; height: 52px; padding: 6px 12px; border: 1px solid rgba(155,82,255,.32); border-radius: 14px; background: #0d0914; }
.amount-field span { display: block; color: var(--muted); font-size: 10px; }
.amount-field input { width: 100%; padding: 2px 0 0; border: 0; outline: 0; background: transparent; color: #fff; font-size: 21px; font-weight: 800; }
.quick-bets { display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; margin: 9px 0; }
.quick-bets button { padding: 8px 4px; border-radius: 10px; color: #d8cce7; font-size: 12px; }
.action-button { width: 100%; min-height: 58px; border: 0; border-radius: 16px; background: linear-gradient(115deg, var(--purple-dark), var(--purple)); box-shadow: 0 8px 24px rgba(111,38,208,.28); font-size: 17px; font-weight: 900; }
.action-button.cashout { color: #1b1303; background: linear-gradient(115deg, var(--gold-strong), var(--gold)); box-shadow: 0 8px 24px rgba(245,185,66,.22); }
.action-button:disabled { filter: grayscale(.55); opacity: .46; box-shadow: none; }
.action-button small { display: block; margin-top: 2px; font-size: 10px; font-weight: 600; opacity: .76; }
.feedback { min-height: 15px; margin: 7px 2px -2px; color: var(--muted); text-align: center; font-size: 11px; }
.feedback.error { color: var(--red); }

.players-card { padding: 13px; }
.section-title { justify-content: space-between; margin-bottom: 10px; }
.section-title span { color: var(--muted); font-size: 11px; }
.players-head, .player-row { display: grid; grid-template-columns: 1fr .9fr 1.1fr; gap: 8px; }
.players-head { padding: 0 7px 7px; color: #746a81; font-size: 10px; text-transform: uppercase; }
.players-head span:nth-child(n+2), .player-row span:nth-child(n+2) { text-align: right; }
.players-list { max-height: 250px; overflow: auto; }
.player-row { padding: 9px 7px; border-top: 1px solid rgba(255,255,255,.045); font-size: 12px; }
.player-row b { color: #d7c8e9; }
.player-row .won { color: var(--green); }
.player-row .lost { color: var(--red); }
.player-row .active { color: var(--gold); }
.empty-list { padding: 24px 10px; color: var(--muted); text-align: center; font-size: 12px; }

.drawer { position: fixed; z-index: 20; inset: 0; pointer-events: none; opacity: 0; transition: opacity .2s ease; }
.drawer.open { pointer-events: auto; opacity: 1; }
.drawer__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.62); }
.drawer__panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 80vh; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); border-radius: 24px 24px 0 0; background: #130d1d; transform: translateY(102%); transition: transform .25s ease; overflow: auto; }
.drawer.open .drawer__panel { transform: translateY(0); }
.drawer__title { display: flex; align-items: center; justify-content: space-between; }
.drawer p { color: var(--muted); font-size: 12px; line-height: 1.55; }
.drawer label { display: block; margin-top: 13px; color: var(--muted); font-size: 10px; }
.drawer code { display: block; margin-top: 5px; padding: 10px; border: 1px solid rgba(255,255,255,.07); border-radius: 11px; background: #09060e; color: #dbc8ef; font-size: 10px; word-break: break-all; user-select: all; }
.verified { margin-top: 14px; padding: 10px; border-radius: 11px; background: rgba(255,214,107,.08); color: var(--gold); text-align: center; font-size: 12px; }
.verified.ok { background: rgba(84,227,164,.09); color: var(--green); }

.result-burst { position: fixed; z-index: 30; left: 50%; top: 42%; padding: 15px 23px; border: 1px solid var(--border); border-radius: 18px; background: rgba(12,8,18,.94); color: var(--gold); font-size: 22px; font-weight: 900; transform: translate(-50%,-50%) scale(.5); opacity: 0; pointer-events: none; }
.result-burst.show { animation: resultBurst 1.4s ease; }
@keyframes resultBurst { 18%,72% { opacity: 1; transform: translate(-50%,-50%) scale(1); } 100% { opacity: 0; transform: translate(-50%,-65%) scale(1.05); } }

@media (min-width: 480px) { .sky { height: 300px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
