<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Aviator Game</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
width: 100%;
height: 100%;
background: #07090e;
font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: #fff;
overflow: hidden;
position: fixed;
}
/* --- LOGIN PAGE STYLES --- */
.login-card {
background:
linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 58, 138, 0.9)),
radial-gradient(circle, rgba(255,255,255,0.04) 10%, transparent 10%),
#0f172a;
background-size: 100% 100%, 20px 20px, 100% 100%;
padding: 20px;
border-radius: 18px;
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8), inset 0 1px 3px rgba(255, 255, 255, 0.15);
width: 92%;
max-width: 360px;
text-align: center;
border: 1px solid #1e3a8a;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 3000;
}
#android-notif-bar {
display: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
background: linear-gradient(180deg, #10b981, #059669);
color: #fff;
padding: 5px 15px;
border-top-left-radius: 18px;
border-top-right-radius: 18px;
cursor: pointer;
text-align: center;
box-shadow: 0 2px 8px rgba(0,0,0,0.4);
z-index: 20;
}
.login-header {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
margin-top: 8px;
margin-bottom: 6px;
}
.login-card h2 {
color: #ffffff;
margin: 0;
font-size: 22px;
}
.plane-logo {
font-size: 24px;
color: #ff3333;
transform: rotate(-15deg);
}
.game-desc {
font-size: 10px;
color: #cbd5e1;
margin-bottom: 12px;
line-height: 1.3;
background: rgba(0, 0, 0, 0.4);
padding: 8px;
border-radius: 8px;
border-left: 3px solid #3b82f6;
}
.input-group {
margin-bottom: 10px;
text-align: left;
}
.input-group label {
font-size: 11px;
color: #94a3b8;
display: block;
margin-bottom: 3px;
font-weight: 500;
}
.input-group input {
width: 100%;
padding: 9px 12px;
background: #0b0e14;
border: 1px solid #1e3a8a;
border-radius: 8px;
color: #fff;
font-size: 14px;
outline: none;
}
.otp-container {
display: flex;
justify-content: space-between;
gap: 8px;
margin-bottom: 5px;
}
.otp-box {
width: 50px;
height: 45px;
background: #0b0e14;
border: 2px solid #1e3a8a;
border-radius: 10px;
color: #fff;
font-size: 20px;
font-weight: bold;
text-align: center;
outline: none;
}
#error-msg {
color: #ef4444;
font-size: 10px;
font-weight: bold;
text-align: left;
margin-bottom: 8px;
display: none;
}
.btn {
width: 100%;
padding: 10px;
background: linear-gradient(135deg, #10b981, #059669);
color: #fff;
border: none;
border-radius: 8px;
font-size: 14px;
font-weight: bold;
cursor: pointer;
margin-top: 3px;
}
#otp-popup {
display: none;
position: fixed;
top: 15px;
left: 50%;
transform: translateX(-50%);
background: #1f2937;
color: #fff;
padding: 12px 16px;
border-radius: 12px;
box-shadow: 0 10px 25px rgba(0,0,0,0.8);
border-left: 5px solid #10b981;
z-index: 4000;
max-width: 330px;
width: 92%;
text-align: left;
}
.popup-title { font-weight: bold; color: #10b981; font-size: 12px; margin-bottom: 2px; }
.popup-text { font-size: 10px; color: #d1d5db; line-height: 1.3; }
/* --- GAME SCREEN (EXACT 100vh FIT - NO SCROLL) --- */
#game-container {
display: none;
width: 100%;
height: 100vh;
max-height: 100vh;
background: #0f1117;
flex-direction: column;
justify-content: space-between;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
}
.game-top-bar {
background: #181c25;
padding: 6px 10px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #222834;
flex-shrink: 0;
}
.game-logo-text { color: #ff3333; font-style: italic; font-weight: bold; font-size: 16px; }
.user-info-box { display: flex; align-items: center; gap: 5px; }
.user-mobile-display { font-size: 8.5px; color: #94a3b8; background: #0b0e14; padding: 2px 5px; border-radius: 5px; border: 1px solid #222834; }
.wallet-container {
display: flex;
flex-direction: column;
align-items: flex-end;
}
.wallet-display {
color: #10b981;
font-weight: bold;
font-size: 10.5px;
background: #0b0e14;
padding: 3px 6px;
border-radius: 5px;
border: 1px solid #222834;
display: flex;
align-items: center;
gap: 3px;
}
.wallet-display::before {
content: "Balance:";
font-size: 7.5px;
color: #94a3b8;
margin-right: 2px;
}
.demo-balance-box {
display: none;
font-size: 8.5px;
color: #f59e0b;
background: #1f2937;
padding: 1px 5px;
border-radius: 3px;
margin-top: 1px;
border: 1px dashed #f59e0b;
font-weight: bold;
}
.box-blink-glow {
animation: boxGlowAnim 0.6s ease-in-out 3;
background: #064e3b !important;
border-color: #10b981 !important;
color: #34d399 !important;
}
@keyframes boxGlowAnim {
0% { transform: scale(1); box-shadow: 0 0 5px #10b981; }
50% { transform: scale(1.08); box-shadow: 0 0 15px #10b981; }
100% { transform: scale(1); box-shadow: 0 0 5px #10b981; }
}
.speaker-btn { background: #0b0e14; border: 1px solid #222834; color: #38bdf8; width: 22px; height: 22px; border-radius: 5px; cursor: pointer; font-size: 11px; display: flex; align-items: center; justify-content: center; }
.extra-action-bar {
background: #131720;
padding: 4px 8px;
display: flex;
justify-content: flex-end;
align-items: center;
gap: 5px;
border-bottom: 1px solid #222834;
flex-shrink: 0;
}
.action-chip {
background: #1f2937;
border: 1px solid #374151;
color: #38bdf8;
font-size: 9.5px;
font-weight: bold;
padding: 2px 6px;
border-radius: 4px;
cursor: pointer;
}
.action-chip.add-money {
background: #059669;
color: #fff;
border-color: #10b981;
}
.history-ribbon {
background: #131720;
padding: 4px 8px;
display: flex;
gap: 6px;
overflow: hidden;
white-space: nowrap;
border-bottom: 1px solid #222834;
flex-shrink: 0;
}
.history-item { font-size: 10px; font-weight: bold; padding: 1px 5px; border-radius: 3px; background: #1c222d; flex-shrink: 0; }
.fun-mode-banner {
background: linear-gradient(90deg, #10b981, #059669);
color: #fff;
font-size: 10px;
font-weight: bold;
text-align: center;
padding: 4px 8px;
letter-spacing: 0.5px;
text-transform: uppercase;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
flex-shrink: 0;
}
.banner-left-text { font-size: 8px; font-weight: bold; color: #fff; }
.banner-center-text { font-size: 11px; font-weight: bold; text-align: center; flex-grow: 1; }
.flight-arena {
background: radial-gradient(circle at center, #23314d 0%, #07090e 100%);
flex-grow: 1;
min-height: 120px;
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border-bottom: 1px solid #222834;
overflow: hidden;
}
.light-beam {
position: absolute;
width: 200%;
height: 200%;
background: linear-gradient(45deg, rgba(255,255,255,0.05) 0%, transparent 50%, rgba(56,189,248,0.05) 100%);
pointer-events: none;
}
.multiplier-display { font-size: 34px; font-weight: bold; color: #ffffff; letter-spacing: 1px; z-index: 2; text-shadow: 0 0 12px rgba(255,255,255,0.4); }
canvas { width: 100%; height: 100%; display: block; position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none; }
.arena-online-pill {
position: absolute;
left: 6px;
top: 6px;
background: rgba(15, 23, 42, 0.85);
border: 1px solid #222834;
padding: 2px 6px;
border-radius: 10px;
display: flex;
align-items: center;
gap: 4px;
z-index: 5;
}
.bright-green-dot {
width: 5px;
height: 5px;
background: #00ff66;
border-radius: 50%;
box-shadow: 0 0 5px #00ff66;
animation: brightBlink 1s infinite;
}
@keyframes brightBlink {
0% { opacity: 0.2; transform: scale(0.9); }
50% { opacity: 1; transform: scale(1.2); box-shadow: 0 0 8px #00ff66; }
100% { opacity: 0.2; transform: scale(0.9); }
}
.online-label-text { font-size: 9px; font-weight: bold; color: #00ff66; }
.arena-online-count { font-size: 10px; font-weight: bold; color: #ffffff; }
.next-round-box {
width: 100%;
height: 28px;
padding: 3px 6px;
background: #0f1117;
display: flex;
align-items: center;
flex-shrink: 0;
}
.progress-bar-container-square {
width: 100%;
height: 22px;
background: #181c25;
border: 1px solid #222834;
border-radius: 5px;
overflow: hidden;
position: relative;
}
.progress-bar-fill-square {
width: 100%;
height: 100%;
background: #10b981;
transition: width 0.05s linear, background-color 0.3s;
}
.progress-bar-text-inside {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 10px;
font-weight: bold;
color: #ffffff;
letter-spacing: 0.5px;
z-index: 2;
}
.flying-win-text {
position: absolute;
font-size: 13px;
font-weight: bold;
color: #10b981;
z-index: 9999;
pointer-events: none;
transition: all 0.9s cubic-bezier(0.15, 0.85, 0.35, 1.2);
background: rgba(15, 23, 42, 0.9);
padding: 2px 5px;
border-radius: 5px;
border: 1px solid #10b981;
}
.betting-section {
padding: 5px 6px;
display: flex;
flex-direction: column;
gap: 5px;
background: #0f1117;
flex-shrink: 0;
}
.bet-card {
background: #181c25;
border-radius: 8px;
padding: 6px 8px;
border: 1px solid #222834;
}
.bet-card-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 3px;
}
.bet-type-tabs { display: flex; background: #0b0e14; border-radius: 5px; padding: 2px; }
.tab-btn { background: transparent; border: none; color: #94a3b8; font-size: 9.5px; padding: 2px 8px; border-radius: 4px; cursor: pointer; font-weight: bold; }
.tab-btn.active { background: #222834; color: #fff; }
.auto-cashout-row {
display: none;
align-items: center;
justify-content: space-between;
font-size: 9.5px;
color: #94a3b8;
margin-bottom: 3px;
background: #0b0e14;
padding: 2px 5px;
border-radius: 5px;
border: 1px solid #222834;
}
.auto-cashout-input {
background: transparent;
border: none;
color: #38bdf8;
font-size: 10px;
font-weight: bold;
width: 40px;
text-align: right;
outline: none;
}
.bet-card-body {
display: flex;
gap: 8px;
align-items: center;
}
.amount-control {
display: flex;
align-items: center;
background: #0b0e14;
border-radius: 7px;
border: 1px solid #222834;
padding: 2px;
width: 45%;
}
.ctrl-btn { background: #1c222d; border: none; color: #fff; width: 22px; height: 22px; border-radius: 5px; font-weight: bold; cursor: pointer; font-size: 11px; }
.amount-input { background: transparent; border: none; color: #fff; text-align: center; width: 100%; font-size: 12px; font-weight: bold; outline: none; }
.big-action-btn {
width: 55%;
height: 38px;
padding: 3px;
background: #10b981;
color: #fff;
border: none;
border-radius: 7px;
font-size: 12px;
font-weight: bold;
cursor: pointer;
box-shadow: 0 3px 10px rgba(16, 185, 129, 0.4);
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.big-action-btn.cashout-active {
background: linear-gradient(135deg, #f97316, #ea580c);
}
.big-action-btn.faded-disabled {
background: #1e293b !important;
color: #64748b !important;
opacity: 0.8;
pointer-events: none;
}
.quick-amounts {
display: grid;
grid-template-columns: repeat(7, 1fr);
gap: 2px;
margin-top: 3px;
}
.quick-chip { background: #222834; border: none; color: #94a3b8; font-size: 8.5px; padding: 2px 0; border-radius: 3px; cursor: pointer; font-weight: bold; text-align: center; }
/* MODALS */
.modal-overlay {
display: none;
position: fixed;
top: 0; left: 0; width: 100%; height: 100%;
background: rgba(0, 0, 0, 0.85);
z-index: 3000;
justify-content: center;
align-items: center;
}
.modal-box {
background: #181c25;
border: 1px solid #222834;
border-radius: 12px;
width: 90%;
max-width: 330px;
padding: 16px;
text-align: left;
position: relative;
box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}
.modal-close-btn {
position: absolute;
top: 10px; right: 12px;
background: transparent;
border: none;
color: #94a3b8;
font-size: 16px;
font-weight: bold;
cursor: pointer;
}
.modal-title {
font-size: 14px;
font-weight: bold;
color: #fff;
margin-bottom: 10px;
border-bottom: 1px solid #222834;
padding-bottom: 6px;
}
.modal-field {
margin-bottom: 8px;
}
.modal-field label {
font-size: 10.5px;
color: #94a3b8;
display: block;
margin-bottom: 2px;
}
.modal-field input {
width: 100%;
padding: 7px 9px;
background: #0b0e14;
border: 1px solid #222834;
border-radius: 5px;
color: #fff;
font-size: 12px;
outline: none;
}
.qr-container {
text-align: center;
margin: 8px 0;
background: #fff;
padding: 8px;
border-radius: 6px;
display: inline-block;
width: 100%;
}
.qr-container img {
width: 110px;
height: 110px;
}
.upi-app-btn {
width: 100%;
padding: 8px;
background: #3b82f6;
color: #fff;
border: none;
border-radius: 5px;
font-size: 11px;
font-weight: bold;
cursor: pointer;
margin-bottom: 8px;
}
.modal-submit-btn {
width: 100%;
padding: 9px;
background: #10b981;
color: #fff;
border: none;
border-radius: 5px;
font-size: 12px;
font-weight: bold;
cursor: pointer;
margin-top: 6px;
}
.history-card-item {
background: #0b0e14;
border: 1px solid #222834;
padding: 7px;
border-radius: 5px;
margin-bottom: 5px;
font-size: 10.5px;
color: #cbd5e1;
}
</style>
</head>
<body>
<!-- 1. LOGIN SCREEN -->
<div class="login-card" id="login-section">
<div id="android-notif-bar" onclick="showPopupModal(10000)">
<div class="notif-bar-text">
<span>View OTP Notification</span>
<div class="notif-bar-arrow">▼</div>
</div>
</div>
<div class="login-header">
<div class="plane-logo">🛩️</div>
<h2>AVIATOR</h2>
</div>
<div class="game-desc">
100% Secure & Officially Verified Gaming Platform. No Fraud, Fair Play Guaranteed with Instant Verification.
</div>
<div id="step-1">
<div class="input-group">
<label>Enter Mobile Number</label>
<input type="tel" id="mobile" placeholder="Enter 10-digit number" maxlength="10">
</div>
<button class="btn" onclick="sendOtp()">Send OTP</button>
</div>
<div id="step-2" style="display:none;">
<div class="input-group">
<label id="otp-label">Enter 4-Digit OTP Code <span id="timer-blink" style="color: #38bdf8; float: right; font-weight: bold;"></span></label>
<div class="otp-container" id="otp-boxes-wrapper">
<input type="text" class="otp-box" id="digit-1" maxlength="1" oninput="moveToNext(this, 'digit-2')" onkeydown="handleBack(event, '', 'digit-1')">
<input type="text" class="otp-box" id="digit-2" maxlength="1" oninput="moveToNext(this, 'digit-3')" onkeydown="handleBack(event, 'digit-1', 'digit-2')">
<input type="text" class="otp-box" id="digit-3" maxlength="1" oninput="moveToNext(this, 'digit-4')" onkeydown="handleBack(event, 'digit-2', 'digit-3')">
<input type="text" class="otp-box" id="digit-4" maxlength="1" oninput="moveToNext(this, '')" onkeydown="handleBack(event, 'digit-3', 'digit-4')">
</div>
<div id="error-msg">❌ Wrong OTP! Please check notification.</div>
</div>
<button class="btn" id="login-btn" onclick="verifyOtp()">Login to Play</button>
</div>
</div>
<div id="otp-popup">
<div class="popup-title">📲 Aviator Security Alert</div>
<div class="popup-text" id="popup-message">Your verification code is generating...</div>
</div>
<!-- 2. GAME SCREEN -->
<div id="game-container">
<div class="game-top-bar">
<div class="game-logo-text">Aviator</div>
<div class="user-info-box">
<button class="speaker-btn" id="speaker-icon" onclick="toggleAudio()" title="Mute/Unmute Music">🔊</button>
<div class="user-mobile-display" id="logged-mobile-display">9876543210</div>
<div class="wallet-container">
<div class="wallet-display" id="wallet-balance-box">₹5,000.00</div>
<div class="demo-balance-box" id="demo-balance-box">Demo Bal: ₹5,000</div>
</div>
</div>
</div>
<div class="extra-action-bar">
<button class="action-chip add-money" onclick="openAddMoneyModal()">+ Add Money</button>
<button class="action-chip" onclick="openWithdrawModal()">Withdraw</button>
<button class="action-chip" onclick="openHistoryModal()">☰ History</button>
</div>
<div class="history-ribbon" id="history-ribbon-box">
<span class="history-item" style="color:#a855f7;">6.50x</span>
<span class="history-item" style="color:#38bdf8;">1.58x</span>
<span class="history-item" style="color:#38bdf8;">2.47x</span>
<span class="history-item" style="color:#ec4899;">1.90x</span>
<span class="history-item" style="color:#a855f7;">2.78x</span>
</div>
<div class="fun-mode-banner" id="fun-banner" onclick="handleBannerClick()">
<span class="banner-left-text" id="banner-left"></span>
<span class="banner-center-text" id="banner-text">DEMO PLAY</span>
</div>
<div class="flight-arena" id="flight-arena-box">
<div class="light-beam"></div>
<canvas id="gameCanvas"></canvas>
<div class="multiplier-display" id="multiplier-display">1.00x</div>
<div class="arena-online-pill">
<div class="bright-green-dot"></div>
<span class="online-label-text">Online</span>
<span class="arena-online-count" id="online-count-display">392</span>
</div>
</div>
<div class="next-round-box" id="next-round-box">
<div class="progress-bar-container-square" id="progress-bar-wrapper">
<div class="progress-bar-fill-square" id="progress-bar-fill"></div>
<div class="progress-bar-text-inside" id="next-round-text">PLACE YOUR BETS (6.0s)</div>
</div>
</div>
<div class="betting-section">
<!-- Bet Panel 1 -->
<div class="bet-card">
<div class="bet-card-top">
<div class="bet-type-tabs">
<button class="tab-btn active" id="tab-bet-1" onclick="switchTab(1, 'bet')">Bet</button>
<button class="tab-btn" id="tab-auto-1" onclick="switchTab(1, 'auto')">Auto</button>
</div>
</div>
<div class="auto-cashout-row" id="auto-row-1">
<span>Auto Cash Out</span>
<input type="text" class="auto-cashout-input" id="auto-cashout-1" value="2.00" placeholder="2.00x">
</div>
<div class="bet-card-body">
<div class="amount-control">
<button class="ctrl-btn" onclick="changeBetAmount(1, -10)">-</button>
<input type="text" class="amount-input" id="bet-amt-1" value="10">
<button class="ctrl-btn" onclick="changeBetAmount(1, 10)">+</button>
</div>
<button class="big-action-btn" id="action-btn-1" onclick="handleGameAction(1)">Bet <br><span style="font-size:9px;">10 INR</span></button>
</div>
<div class="quick-amounts">
<button class="quick-chip" onclick="setBet(1, 10)">10</button>
<button class="quick-chip" onclick="setBet(1, 20)">20</button>
<button class="quick-chip" onclick="setBet(1, 50)">50</button>
<button class="quick-chip" onclick="setBet(1, 100)">100</button>
<button class="quick-chip" onclick="setBet(1, 200)">200</button>
<button class="quick-chip" onclick="setBet(1, 500)">500</button>
<button class="quick-chip" onclick="setBet(1, 1000)">1000</button>
</div>
</div>
<!-- Bet Panel 2 -->
<div class="bet-card">
<div class="bet-card-top">
<div class="bet-type-tabs">
<button class="tab-btn active" id="tab-bet-2" onclick="switchTab(2, 'bet')">Bet</button>
<button class="tab-btn" id="tab-auto-2" onclick="switchTab(2, 'auto')">Auto</button>
</div>
</div>
<div class="auto-cashout-row" id="auto-row-2">
<span>Auto Cash Out</span>
<input type="text" class="auto-cashout-input" id="auto-cashout-2" value="2.00" placeholder="2.00x">
</div>
<div class="bet-card-body">
<div class="amount-control">
<button class="ctrl-btn" onclick="changeBetAmount(2, -10)">-</button>
<input type="text" class="amount-input" id="bet-amt-2" value="10">
<button class="ctrl-btn" onclick="changeBetAmount(2, 10)">+</button>
</div>
<button class="big-action-btn" id="action-btn-2" onclick="handleGameAction(2)">Bet <br><span style="font-size:9px;">10 INR</span></button>
</div>
<div class="quick-amounts">
<button class="quick-chip" onclick="setBet(2, 10)">10</button>
<button class="quick-chip" onclick="setBet(2, 20)">20</button>
<button class="quick-chip" onclick="setBet(2, 50)">50</button>
<button class="quick-chip" onclick="setBet(2, 100)">100</button>
<button class="quick-chip" onclick="setBet(2, 200)">200</button>
<button class="quick-chip" onclick="setBet(2, 500)">500</button>
<button class="quick-chip" onclick="setBet(2, 1000)">1000</button>
</div>
</div>
</div>
</div>
<div class="modal-overlay" id="custom-modal-overlay">
<div class="modal-box" id="modal-box-content"></div>
</div>
<script>
let generatedOtp = "";
let countdownTimer = null;
let userMobileNumber = "";
let userBalance = 5000.00;
let demoBalance = 5000.00;
let isFunModeActive = false;
let demoRoundCounter = 0;
let realRoundCounter = 0;
let isAudioMuted = false;
let backgroundMusicInterval = null;
let audioCtx = null;
let gamePhase = "waiting";
let currentMultiplier = 1.00;
let crashPoint = 2.00;
let hasUserCashedOut1 = false;
let hasUserCashedOut2 = false;
let betState1 = 0;
let currentBetAmount1 = 10;
let isAuto1 = false;
let betState2 = 0;
let currentBetAmount2 = 10;
let isAuto2 = false;
let gameInterval = null;
let userHistoryList = [];
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
let planePos = { x: 50, y: 120 };
let particles = [];
function updateCanvasSize() {
const arena = document.getElementById('flight-arena-box');
if (arena) {
canvas.width = arena.clientWidth || 400;
canvas.height = arena.clientHeight || 120;
}
}
window.addEventListener('resize', updateCanvasSize);
function getAudioContext() {
if (!audioCtx) {
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
}
if (audioCtx.state === 'suspended') { audioCtx.resume(); }
return audioCtx;
}
function playClickSound() {
if(isAudioMuted) return;
try {
const ctx = getAudioContext();
const osc = ctx.createOscillator();
const gain = ctx.createGain();
osc.frequency.setValueAtTime(600, ctx.currentTime);
gain.gain.setValueAtTime(0.2, ctx.currentTime);
gain.gain.exponentialRampToValueAtTime(0.01, ctx.currentTime + 0.08);
osc.connect(gain); gain.connect(ctx.destination);
osc.start(); osc.stop(ctx.currentTime + 0.08);
} catch(e) {}
}
function playCashoutWinSound() {
if(isAudioMuted) return;
try {
const ctx = getAudioContext();
[523.25, 659.25, 783.99, 1046.50].forEach((freq, index) => {
const osc = ctx.createOscillator();
const gain = ctx.createGain();
osc.type = 'triangle';
osc.frequency.setValueAtTime(freq, ctx.currentTime + (index * 0.05));
gain.gain.setValueAtTime(0.25, ctx.currentTime + (index * 0.05));
gain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 0.4 + (index * 0.05));
osc.connect(gain); gain.connect(ctx.destination);
osc.start(ctx.currentTime + (index * 0.05));
osc.stop(ctx.currentTime + 0.5 + (index * 0.05));
});
} catch(e) {}
}
function playCrashExplosionSound() {
if(isAudioMuted) return;
try {
const ctx = getAudioContext();
const bufferSize = ctx.sampleRate * 0.6;
const buffer = ctx.createBuffer(1, bufferSize, ctx.sampleRate);
const data = buffer.getChannelData(0);
for (let i = 0; i < bufferSize; i++) { data[i] = Math.random() * 2 - 1; }
const noise = ctx.createBufferSource();
noise.buffer = buffer;
const filter = ctx.createBiquadFilter();
filter.type = 'lowpass';
filter.frequency.setValueAtTime(500, ctx.currentTime);
filter.frequency.exponentialRampToValueAtTime(40, ctx.currentTime + 0.6);
const gain = ctx.createGain();
gain.gain.setValueAtTime(0.9, ctx.currentTime);
gain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 0.6);
noise.connect(filter); filter.connect(gain); gain.connect(ctx.destination);
noise.start(); noise.stop(ctx.currentTime + 0.6);
} catch(e) {}
}
function startBackgroundMusic() {
if(backgroundMusicInterval) clearInterval(backgroundMusicInterval);
const chords = [
[220, 277.18, 329.63],
[196.00, 246.94, 293.66],
[174.61, 220, 261.63],
[164.81, 207.65, 246.94]
];
let chordIndex = 0;
backgroundMusicInterval = setInterval(() => {
if(isAudioMuted) return;
try {
const ctx = getAudioContext();
const currentChord = chords[chordIndex % chords.length];
chordIndex++;
currentChord.forEach(freq => {
const osc = ctx.createOscillator();
const gain = ctx.createGain();
osc.type = 'triangle';
osc.frequency.setValueAtTime(freq, ctx.currentTime);
gain.gain.setValueAtTime(0.08, ctx.currentTime);
gain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 0.9);
osc.connect(gain); gain.connect(ctx.destination);
osc.start(); osc.stop(ctx.currentTime + 0.9);
});
} catch(e) {}
}, 1000);
}
function toggleAudio() {
isAudioMuted = !isAudioMuted;
document.getElementById("speaker-icon").innerText = isAudioMuted ? "🔇" : "🔊";
}
function handleBannerClick() {
playClickSound();
if (!isFunModeActive) {
isFunModeActive = true;
demoRoundCounter = 0;
document.getElementById("demo-balance-box").style.display = "block";
const banner = document.getElementById("fun-banner");
banner.style.background = "linear-gradient(90deg, #f97316, #ea580c)";
document.getElementById("banner-left").innerText = "DEMO ACTIVE";
document.getElementById("banner-text").innerText = "EXIT";
} else {
exitFunMode();
}
}
function exitFunMode() {
playClickSound();
isFunModeActive = false;
document.getElementById("demo-balance-box").style.display = "none";
const banner = document.getElementById("fun-banner");
banner.style.background = "linear-gradient(90deg, #10b981, #059669)";
document.getElementById("banner-left").innerText = "";
document.getElementById("banner-text").innerText = "DEMO PLAY";
}
function switchTab(panelId, type) {
playClickSound();
if(panelId === 1) {
isAuto1 = (type === 'auto');
document.getElementById("tab-bet-1").className = isAuto1 ? "tab-btn" : "tab-btn active";
document.getElementById("tab-auto-1").className = isAuto1 ? "tab-btn active" : "tab-btn";
document.getElementById("auto-row-1").style.display = isAuto1 ? "flex" : "none";
} else {
isAuto2 = (type === 'auto');
document.getElementById("tab-bet-2").className = isAuto2 ? "tab-btn" : "tab-btn active";
document.getElementById("tab-auto-2").className = isAuto2 ? "tab-btn active" : "tab-btn";
document.getElementById("auto-row-2").style.display = isAuto2 ? "flex" : "none";
}
}
function openAddMoneyModal() {
playClickSound();
if(isFunModeActive) {
alert("⚠️ Demo Mode Alert: Add Money is not available in Demo Play.");
return;
}
const overlay = document.getElementById("custom-modal-overlay");
const box = document.getElementById("modal-box-content");
box.innerHTML = `
<button class="modal-close-btn" onclick="closeModal()">×</button>
<div class="modal-title">Add Money to Wallet</div>
<div class="modal-field"><label>Enter Amount (Min ₹200)</label><input type="number" id="add-amt-input" value="200"></div>
<button class="upi-app-btn" onclick="openUpiApps()">📱 Pay via Google Pay / PhonePe</button>
<div class="qr-container">
<div style="font-size:9px; color:#000; font-weight:bold; margin-bottom:3px;">Scan QR to Pay</div>
<img src="https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=upi://pay?pa=merchant@upi&pn=Aviator&am=200" alt="QR">
</div>
<div class="modal-field"><label>Transaction ID / UPI Ref Number</label><input type="text" id="user-txid-input" placeholder="Enter 12-digit UPI Ref ID"></div>
<button class="modal-submit-btn" onclick="submitAddMoney()">Add Money</button>
`;
overlay.style.display = "flex";
}
function openUpiApps() {
let amt = document.getElementById("add-amt-input").value || 200;
window.location.href = `upi://pay?pa=merchant@upi&pn=Aviator&am=${amt}&cu=INR`;
}
function submitAddMoney() {
playClickSound();
let amtInput = document.getElementById("add-amt-input");
let txIdInput = document.getElementById("user-txid-input");
let val = parseFloat(amtInput.value);
if(isNaN(val) || val < 200) { alert("Minimum amount is ₹200!"); return; }
if(!txIdInput.value.trim()) { alert("Please enter Transaction ID!"); return; }
userBalance += val;
updateWalletUI();
userHistoryList.unshift({ type: "Deposit", amt: val, time: new Date().toLocaleTimeString(), detail: `TxID: ${txIdInput.value}` });
closeModal();
alert("🎉 Money added successfully!");
}
function openWithdrawModal() {
playClickSound();
if(isFunModeActive) {
alert("⚠️ Demo Mode Alert: Withdrawal not allowed from Demo Account.");
return;
}
const overlay = document.getElementById("custom-modal-overlay");
const box = document.getElementById("modal-box-content");
box.innerHTML = `
<button class="modal-close-btn" onclick="closeModal()">×</button>
<div class="modal-title">Withdraw Funds</div>
<div class="modal-field"><label>Account Holder Name</label><input type="text" id="wd-name" placeholder="Full Name"></div>
<div class="modal-field"><label>Account Number</label><input type="text" id="wd-acc" placeholder="Account Number"></div>
<div class="modal-field"><label>IFSC Code</label><input type="text" id="wd-ifsc" placeholder="IFSC Code"></div>
<div class="modal-field"><label>Amount (Min ₹500)</label><input type="number" id="wd-amt" value="500"></div>
<button class="modal-submit-btn" onclick="submitWithdraw()">Submit Request</button>
`;
overlay.style.display = "flex";
}
function submitWithdraw() {
playClickSound();
let amt = parseFloat(document.getElementById("wd-amt").value);
if(isNaN(amt) || amt < 500) { alert("Minimum withdrawal is ₹500!"); return; }
if(amt > userBalance) { alert("Insufficient balance!"); return; }
userBalance -= amt;
updateWalletUI();
userHistoryList.unshift({ type: "Withdrawal", amt: amt, time: new Date().toLocaleTimeString(), detail: `Bank Transfer` });
closeModal();
alert("✅ Withdrawal request submitted!");
}
function openHistoryModal() {
playClickSound();
const overlay = document.getElementById("custom-modal-overlay");
const box = document.getElementById("modal-box-content");
if(isFunModeActive) {
box.innerHTML = `<button class="modal-close-btn" onclick="closeModal()">×</button><div class="modal-title">Transaction History</div><div style="text-align:center; color:#f59e0b; padding:15px; font-weight:bold;">⚠️ Demo Mode! History available in Real Mode only.</div>`;
overlay.style.display = "flex";
return;
}
let historyHTML = `<button class="modal-close-btn" onclick="closeModal()">×</button><div class="modal-title">Transaction History</div>`;
if(userHistoryList.length === 0) {
historyHTML += `<div style="text-align:center; color:#94a3b8; padding:15px;">No transactions found.</div>`;
} else {
userHistoryList.forEach(item => {
historyHTML += `<div class="history-card-item"><div style="display:flex; justify-content:space-between; font-weight:bold; color:${item.type==='Deposit'?'#10b981':'#f97316'};"><span>${item.type}</span><span>₹${item.amt}</span></div><div style="font-size:9.5px; color:#94a3b8;">${item.time} | ${item.detail}</div></div>`;
});
}
box.innerHTML = historyHTML;
overlay.style.display = "flex";
}
function closeModal() {
playClickSound();
document.getElementById("custom-modal-overlay").style.display = "none";
}
function moveToNext(current, nextFieldID) {
if (current.value.length >= 1 && nextFieldID) document.getElementById(nextFieldID).focus();
}
function handleBack(event, prevFieldID, currentFieldID) {
if (event.key === 'Backspace' && document.getElementById(currentFieldID).value === '' && prevFieldID) {
document.getElementById(prevFieldID).focus();
}
}
function playNotificationSound() {
if(isAudioMuted) return;
try {
const ctx = getAudioContext();
[880, 1320, 1760].forEach((freq, idx) => {
const osc = ctx.createOscillator();
const gainNode = ctx.createGain();
osc.type = 'sine';
osc.frequency.setValueAtTime(freq, ctx.currentTime + (idx * 0.1));
gainNode.gain.setValueAtTime(0.5, ctx.currentTime + (idx * 0.1));
gainNode.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 0.4 + (idx * 0.1));
osc.connect(gainNode); gainNode.connect(ctx.destination);
osc.start(ctx.currentTime + (idx * 0.1)); osc.stop(ctx.currentTime + 0.5 + (idx * 0.1));
});
} catch(e) {}
}
function sendOtp() {
playClickSound();
userMobileNumber = document.getElementById("mobile").value;
if(userMobileNumber.length < 10) { alert("Enter valid 10-digit number!"); return; }
document.getElementById("step-1").style.display = "none";
document.getElementById("step-2").style.display = "block";
let remainingSecs = 4;
countdownTimer = setInterval(() => {
remainingSecs--;
if(remainingSecs >= 0) document.getElementById("timer-blink").innerText = `(${remainingSecs}s)`;
}, 1000);
setTimeout(() => {
clearInterval(countdownTimer);
document.getElementById("timer-blink").style.display = "none";
generatedOtp = String(Math.floor(Math.random() * 10000)).padStart(4, '0');
playNotificationSound();
document.getElementById("popup-message").innerHTML = `Your Aviator Gaming verification OTP is <b>${generatedOtp}</b>. Do not share this secure code with anyone. Valid for 2 minutes.`;
document.getElementById("otp-popup").style.display = "block";
setTimeout(() => { document.getElementById("otp-popup").style.display = "none"; document.getElementById("android-notif-bar").style.display = "block"; }, 8000);
}, 4000);
}
function showPopupModal(dur) {
document.getElementById("otp-popup").style.display = "block";
setTimeout(() => { document.getElementById("otp-popup").style.display = "none"; }, dur);
}
function verifyOtp() {
playClickSound();
let userOtp = document.getElementById("digit-1").value + document.getElementById("digit-2").value + document.getElementById("digit-3").value + document.getElementById("digit-4").value;
if(userOtp === generatedOtp) {
document.getElementById("login-section").style.display = "none";
document.getElementById("logged-mobile-display").innerText = userMobileNumber;
document.getElementById("game-container").style.display = "flex";
updateCanvasSize();
startBackgroundMusic();
runNewRound();
} else {
document.getElementById("error-msg").style.display = "block";
}
}
function setBet(panelId, amt) {
playClickSound();
if(panelId === 1) { currentBetAmount1 = amt; document.getElementById("bet-amt-1").value = amt; }
else { currentBetAmount2 = amt; document.getElementById("bet-amt-2").value = amt; }
updateButtonUI(panelId);
}
function changeBetAmount(panelId, val) {
playClickSound();
if(panelId === 1) { currentBetAmount1 = Math.max(10, currentBetAmount1 + val); document.getElementById("bet-amt-1").value = currentBetAmount1; }
else { currentBetAmount2 = Math.max(10, currentBetAmount2 + val); document.getElementById("bet-amt-2").value = currentBetAmount2; }
updateButtonUI(panelId);
}
function updateButtonUI(panelId) {
let btn = document.getElementById(`action-btn-${panelId}`);
let amt = panelId === 1 ? currentBetAmount1 : currentBetAmount2;
let state = panelId === 1 ? betState1 : betState2;
if (gamePhase === "waiting") {
btn.className = "big-action-btn";
btn.innerHTML = state === 1 ? `Cancel <br><span style="font-size:9px;">${amt} INR</span>` : `Bet <br><span style="font-size:9px;">${amt} INR</span>`;
btn.style.background = state === 1 ? "#ef4444" : "#10b981";
} else if (gamePhase === "flying") {
btn.className = state === 1 ? "big-action-btn cashout-active" : "big-action-btn faded-disabled";
btn.innerHTML = state === 1 ? `CASHOUT <br><span style="font-size:9px;" id="cashout-val-${panelId}">0.00 INR</span>` : `Wait <br><span style="font-size:9px;">-</span>`;
} else {
btn.className = "big-action-btn faded-disabled";
btn.innerHTML = `Wait <br><span style="font-size:9px;">-</span>`;
}
}
function handleGameAction(panelId) {
playClickSound();
let amt = panelId === 1 ? currentBetAmount1 : currentBetAmount2;
let state = panelId === 1 ? betState1 : betState2;
if (gamePhase === "waiting") {
let activeBal = isFunModeActive ? demoBalance : userBalance;
if (state === 0) {
if (activeBal < amt) { alert("Insufficient Balance!"); return; }
if (isFunModeActive) demoBalance -= amt; else userBalance -= amt;
if(panelId === 1) betState1 = 1; else betState2 = 1;
} else {
if (isFunModeActive) demoBalance += amt; else userBalance += amt;
if(panelId === 1) betState1 = 0; else betState2 = 0;
}
updateWalletUI();
updateButtonUI(panelId);
} else if (gamePhase === "flying" && state === 1 && currentMultiplier < crashPoint) {
executeCashout(panelId);
}
}
function executeCashout(panelId) {
playCashoutWinSound();
let amt = panelId === 1 ? currentBetAmount1 : currentBetAmount2;
let winAmount = amt * currentMultiplier * 2;
if(panelId === 1) hasUserCashedOut1 = true; else hasUserCashedOut2 = true;
triggerFlyingWinAnimation(`+₹${winAmount.toFixed(2)}`, panelId);
if (isFunModeActive) {
demoBalance += winAmount;
} else {
userBalance += winAmount;
}
updateWalletUI();
if(panelId === 1) betState1 = 2; else betState2 = 2;
updateButtonUI(panelId);
}
function updateWalletUI() {
document.getElementById("wallet-balance-box").innerText = `₹${userBalance.toFixed(2)}`;
document.getElementById("demo-balance-box").innerText = `Demo Bal: ₹${demoBalance.toFixed(2)}`;
}
function triggerFlyingWinAnimation(text, panelId) {
const gameContainer = document.getElementById("game-container");
const targetBox = isFunModeActive ? document.getElementById("demo-balance-box") : document.getElementById("wallet-balance-box");
const actionBtn = document.getElementById(`action-btn-${panelId}`);
const btnRect = actionBtn.getBoundingClientRect();
const targetRect = targetBox.getBoundingClientRect();
const containerRect = gameContainer.getBoundingClientRect();
let winText = document.createElement("div");
winText.className = "flying-win-text";
winText.innerText = text;
winText.style.left = (btnRect.left - containerRect.left + 15) + "px";
winText.style.top = (btnRect.top - containerRect.top - 15) + "px";
gameContainer.appendChild(winText);
setTimeout(() => {
winText.style.transform = `translate(${targetRect.left - btnRect.left}px, ${targetRect.top - btnRect.top}px) scale(0.6)`;
winText.style.opacity = "0.2";
}, 40);
setTimeout(() => {
winText.remove();
targetBox.classList.add("box-blink-glow");
setTimeout(() => {
targetBox.classList.remove("box-blink-glow");
}, 1800);
}, 900);
}
function addHistoryItem(val) {
const ribbon = document.getElementById("history-ribbon-box");
let span = document.createElement("span");
span.className = "history-item";
span.style.color = val >= 10 ? "#a855f7" : "#38bdf8";
span.innerText = val.toFixed(2) + "x";
ribbon.prepend(span);
if(ribbon.children.length > 8) ribbon.removeChild(ribbon.lastChild);
}
function runNewRound() {
gamePhase = "waiting";
currentMultiplier = 1.00;
hasUserCashedOut1 = false;
hasUserCashedOut2 = false;
let activeBetAmt = currentBetAmount1;
if (isFunModeActive) {
demoRoundCounter = (demoRoundCounter % 10) + 1;
crashPoint = demoRoundCounter <= 4 ? (Math.random() * 3.0 + 2.0).toFixed(2) : (Math.random() * 23.0 + 7.0).toFixed(2);
} else {
realRoundCounter = (realRoundCounter % 10) + 1;
if (activeBetAmt <= 20) {
crashPoint = realRoundCounter <= 4 ? (Math.random() * 2.0 + 2.0).toFixed(2) : (Math.random() * 5.0 + 7.0).toFixed(2);
} else {
crashPoint = realRoundCounter <= 2 ? (Math.random() * 0.15 + 1.00).toFixed(2) : (Math.random() * 4.0 + 2.0).toFixed(2);
}
}
if (isAuto1 && betState1 === 0) {
let activeBal = isFunModeActive ? demoBalance : userBalance;
if (activeBal >= currentBetAmount1) {
if (isFunModeActive) demoBalance -= currentBetAmount1; else userBalance -= currentBetAmount1;
betState1 = 1;
updateWalletUI();
}
} else if(betState1 === 2) betState1 = 0;
if (isAuto2 && betState2 === 0) {
let activeBal = isFunModeActive ? demoBalance : userBalance;
if (activeBal >= currentBetAmount2) {
if (isFunModeActive) demoBalance -= currentBetAmount2; else userBalance -= currentBetAmount2;
betState2 = 1;
updateWalletUI();
}
} else if(betState2 === 2) betState2 = 0;
updateButtonUI(1);
updateButtonUI(2);
document.getElementById("multiplier-display").innerHTML = "1.00x";
document.getElementById("multiplier-display").style.color = "#ffffff";
let progressWrapper = document.getElementById("progress-bar-wrapper");
progressWrapper.style.display = "block";
let totalTime = 6.0;
let remaining = totalTime;
let progressBarFill = document.getElementById("progress-bar-fill");
let nextRoundText = document.getElementById("next-round-text");
let progressInterval = setInterval(() => {
remaining -= 0.05;
let percent = (remaining / totalTime) * 100;
progressBarFill.style.width = percent + "%";
progressBarFill.style.backgroundColor = percent > 50 ? "#10b981" : (percent > 20 ? "#f97316" : "#ef4444");
nextRoundText.innerHTML = `PLACE YOUR BETS (${Math.max(0, remaining).toFixed(1)}s)`;
if (remaining <= 0) {
clearInterval(progressInterval);
progressWrapper.style.display = "none";
gamePhase = "flying";
updateButtonUI(1);
updateButtonUI(2);
flightFlyLoop();
}
}, 50);
}
class Flame {
constructor(x, y) {
this.x = x; this.y = y;
this.vx = -3 - Math.random() * 2;
this.vy = (Math.random() - 0.5) * 1.5;
this.size = Math.random() * 4 + 2;
this.alpha = 0.8;
}
update() {
this.x += this.vx; this.y += this.vy;
this.alpha -= 0.03; this.size += 0.1;
}
draw() {
ctx.save();
ctx.globalAlpha = Math.max(0, this.alpha);
ctx.fillStyle = '#ff3333';
ctx.beginPath(); ctx.arc(this.x, this.y, Math.max(0.1, this.size), 0, Math.PI * 2); ctx.fill();
ctx.restore();
}
}
class Particle {
constructor(x, y, isExp = false) {
this.x = x; this.y = y; this.isExp = isExp;
if (isExp) {
this.vx = (Math.random() - 0.5) * 14;
this.vy = (Math.random() - 0.5) * 14;
this.size = Math.random() * 12 + 4;
this.color = ['#ff3333', '#f97316', '#ffffff'][Math.floor(Math.random()*3)];
this.alpha = 1;
} else {
this.vx = -2; this.vy = 0.8;
this.size = Math.random() * 4 + 1;
this.alpha = 0.6;
}
}
update() {
this.x += this.vx; this.y += this.vy;
if (this.isExp) { this.alpha -= 0.025; this.size -= 0.05; }
else { this.alpha -= 0.02; }
}
draw() {
ctx.save();
ctx.globalAlpha = Math.max(0, this.alpha);
ctx.fillStyle = this.isExp ? this.color : 'rgba(255, 255, 255, 0.4)';
ctx.beginPath(); ctx.arc(this.x, this.y, Math.max(0.1, this.size), 0, Math.PI * 2); ctx.fill();
ctx.restore();
}
}
function drawDynamicPlane(x, y) {
ctx.save();
ctx.translate(x, y);
ctx.rotate(-0.25);
let sc = 1.1;
ctx.fillStyle = '#ff3333';
ctx.beginPath(); ctx.moveTo(28*sc, 0); ctx.lineTo(-18*sc, -10*sc); ctx.lineTo(-24*sc, -4*sc); ctx.lineTo(-24*sc, 4*sc); ctx.lineTo(-18*sc, 10*sc); ctx.closePath(); ctx.fill();
ctx.fillStyle = '#e11d48';
ctx.beginPath(); ctx.moveTo(2*sc, -2*sc); ctx.lineTo(-6*sc, -26*sc); ctx.lineTo(-14*sc, -26*sc); ctx.lineTo(-5*sc, -2*sc); ctx.fill();
ctx.beginPath(); ctx.moveTo(2*sc, 2*sc); ctx.lineTo(-6*sc, 26*sc); ctx.lineTo(-14*sc, 26*sc); ctx.lineTo(-5*sc, 2*sc); ctx.fill();
ctx.fillStyle = '#ffffff';
ctx.beginPath(); ctx.ellipse(9*sc, -2*sc, 5*sc, 3*sc, 0.2, 0, Math.PI*2); ctx.fill();
ctx.restore();
}
function flightFlyLoop() {
let flightStartTime = performance.now();
particles = [];
gameInterval = setInterval(() => {
updateCanvasSize();
ctx.clearRect(0, 0, canvas.width, canvas.height);
let elapsed = (performance.now() - flightStartTime) / 1000;
currentMultiplier += 0.05;
document.getElementById("multiplier-display").innerHTML = currentMultiplier.toFixed(2) + "x";
document.getElementById("multiplier-display").style.color = "#ffffff";
let prog = Math.min(elapsed / 8, 1);
planePos.x = 40 + prog * (canvas.width - 80);
planePos.y = canvas.height - 20 - Math.pow(prog, 0.75) * (canvas.height - 45);
particles.push(new Flame(planePos.x - 15, planePos.y));
if(Math.random() < 0.5) particles.push(new Particle(planePos.x - 18, planePos.y + (Math.random()-0.5)*12));
ctx.beginPath(); ctx.moveTo(0, canvas.height);
ctx.quadraticCurveTo(planePos.x * 0.4, canvas.height, planePos.x, planePos.y);
ctx.lineTo(planePos.x, canvas.height); ctx.closePath();
ctx.fillStyle = 'rgba(255, 51, 51, 0.2)'; ctx.fill();
ctx.beginPath(); ctx.moveTo(0, canvas.height);
ctx.quadraticCurveTo(planePos.x * 0.4, canvas.height, planePos.x, planePos.y);
ctx.strokeStyle = '#ff3333'; ctx.lineWidth = 4; ctx.stroke();
for(let i = particles.length - 1; i >= 0; i--) {
particles[i].update(); particles[i].draw();
if(particles[i].alpha <= 0) particles.splice(i, 1);
}
drawDynamicPlane(planePos.x, planePos.y);
if (betState1 === 1) {
let liveWin1 = currentBetAmount1 * currentMultiplier * 2;
document.getElementById("cashout-val-1").innerText = `${liveWin1.toFixed(2)} INR`;
let autoVal1 = parseFloat(document.getElementById("auto-cashout-1").value);
if (isAuto1 && !isNaN(autoVal1) && currentMultiplier >= autoVal1) executeCashout(1);
}
if (betState2 === 1) {
let liveWin2 = currentBetAmount2 * currentMultiplier * 2;
document.getElementById("cashout-val-2").innerText = `${liveWin2.toFixed(2)} INR`;
let autoVal2 = parseFloat(document.getElementById("auto-cashout-2").value);
if (isAuto2 && !isNaN(autoVal2) && currentMultiplier >= autoVal2) executeCashout(2);
}
let effCrash = parseFloat(crashPoint);
if ((hasUserCashedOut1 || hasUserCashedOut2) && currentMultiplier >= effCrash) {
crashPoint = isFunModeActive ? (Math.random() * 10.0 + 35.0).toFixed(2) : (Math.random() * 10.0 + 20.0).toFixed(2);
}
if (currentMultiplier >= parseFloat(crashPoint)) {
clearInterval(gameInterval);
gamePhase = "crashed";
document.getElementById("multiplier-display").innerHTML = `${parseFloat(crashPoint).toFixed(2)}x`;
document.getElementById("multiplier-display").style.color = "#ef4444";
playCrashExplosionSound();
addHistoryItem(parseFloat(crashPoint));
for(let i=0; i<80; i++) particles.push(new Particle(planePos.x, planePos.y, true));
let crashAnimLoop = setInterval(() => {
ctx.clearRect(0, 0, canvas.width, canvas.height);
for(let i = particles.length - 1; i >= 0; i--) {
particles[i].update(); particles[i].draw();
if(particles[i].alpha <= 0) particles.splice(i, 1);
}
if (particles.length === 0) {
clearInterval(crashAnimLoop);
}
}, 30);
if(betState1 === 1) betState1 = 0;
if(betState2 === 1) betState2 = 0;
updateButtonUI(1); updateButtonUI(2);
setTimeout(runNewRound, 2500);
}
}, 50);
}
</script>
</body>
</html>