/* Aviator Crash Game - Styles */
:root {
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16162b;
    --bg-card: #1e1e38;
    --border: #2a2a4a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0c0;
    --text-muted: #666680;
    --accent-red: #ff6b6b;
    --accent-green: #2ecc71;
    --accent-blue: #3498db;
    --accent-yellow: #f39c12;
    --accent-purple: #9b59b6;
    --accent-orange: #e67e22;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
}

/* ========== HEADER ========== */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 8px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 800;
    color: var(--accent-red);
    text-decoration: none;
    flex-shrink: 0;
}

.logo span { color: var(--text-primary); font-weight: 300; }

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.balance-display {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.balance-display .currency { color: var(--accent-yellow); font-size: 11px; }
.balance-display .amount { color: var(--text-primary); font-size: 15px; }

.btn {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent-red); color: #fff; }
.btn-primary:hover { background: #ff5252; }
.btn-green { background: var(--accent-green); color: #000; }
.btn-green:hover { background: #27ae60; }
.btn-blue { background: var(--accent-blue); color: #fff; }
.btn-blue:hover { background: #2980b9; }
.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--accent-red); color: var(--accent-red); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ========== LAYOUT ========== */
.game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 15px;
}

/* ========== CRASH HISTORY ========== */
.history-bar {
    grid-column: 1 / -1;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 0;
    scrollbar-width: none;
}
.history-bar::-webkit-scrollbar { display: none; }

.history-item {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
}
.history-item:hover { transform: scale(1.1); }
.history-item.low { background: #e74c3c30; color: #e74c3c; }
.history-item.mid { background: #f39c1230; color: #f39c12; }
.history-item.high { background: #9b59b630; color: #9b59b6; }
.history-item.mega { background: #2ecc7130; color: #2ecc71; }

/* ========== GAME CANVAS ========== */
.game-area {
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
}

.game-canvas-wrap {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: hidden;
    background: linear-gradient(180deg, #0f0f23 0%, #1a1a2e 100%);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.multiplier-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    z-index: 10;
}

.multiplier-text {
    font-size: 72px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 40px rgba(255,255,255,0.3);
    transition: color 0.3s;
    line-height: 1;
}

.multiplier-text.crashed {
    color: var(--accent-red);
    animation: crashPulse 0.5s ease;
}

.multiplier-text.running {
    color: #fff;
}

.game-status {
    font-size: 16px;
    color: var(--text-secondary);
    margin-top: 8px;
    font-weight: 600;
}

.game-status.betting { color: var(--accent-yellow); }
.game-status.crashed { color: var(--accent-red); }

@keyframes crashPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ========== BET PANELS ========== */
.bet-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
}

.bet-panel {
    background: var(--bg-secondary);
    padding: 15px;
}

.bet-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.bet-panel-title {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.bet-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.bet-tab {
    flex: 1;
    padding: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: 0.2s;
}

.bet-tab.active {
    background: var(--accent-green);
    color: #000;
    border-color: var(--accent-green);
}

.bet-amount-wrap {
    position: relative;
    margin-bottom: 10px;
}

.bet-amount-input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

.bet-amount-input:focus {
    border-color: var(--accent-green);
}

.bet-quick-amounts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-bottom: 10px;
}

.quick-amt {
    padding: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: 0.2s;
}

.quick-amt:hover {
    background: var(--border);
    color: var(--text-primary);
}

.auto-cashout-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.auto-cashout-wrap label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.auto-cashout-input {
    flex: 1;
    padding: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    outline: none;
    width: 70px;
}

.auto-cashout-input:focus { border-color: var(--accent-yellow); }

.bet-button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.bet-button.place {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: #fff;
    box-shadow: 0 4px 15px rgba(46,204,113,0.3);
}

.bet-button.place:hover {
    box-shadow: 0 6px 20px rgba(46,204,113,0.5);
    transform: translateY(-1px);
}

.bet-button.cashout {
    background: linear-gradient(135deg, #e67e22, #d35400);
    color: #fff;
    box-shadow: 0 4px 15px rgba(230,126,34,0.3);
    animation: pulseBtn 1.5s infinite;
}

.bet-button.cashout:hover {
    box-shadow: 0 6px 20px rgba(230,126,34,0.5);
}

.bet-button.waiting {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.bet-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.bet-button .cashout-amount {
    font-size: 13px;
    font-weight: 400;
    display: block;
    margin-top: 2px;
}

@keyframes pulseBtn {
    0%, 100% { box-shadow: 0 4px 15px rgba(230,126,34,0.3); }
    50% { box-shadow: 0 4px 25px rgba(230,126,34,0.6); }
}

/* ========== SIDEBAR ========== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sidebar-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.sidebar-panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-panel-header h3 {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.live-bets-list {
    max-height: 350px;
    overflow-y: auto;
}

.live-bets-list::-webkit-scrollbar { width: 4px; }
.live-bets-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.live-bet-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    transition: background 0.2s;
}

.live-bet-item:hover { background: var(--bg-card); }
.live-bet-item:last-child { border-bottom: none; }

.live-bet-user {
    display: flex;
    align-items: center;
    gap: 6px;
}

.live-bet-user .avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-muted);
}

.live-bet-amount {
    color: var(--text-secondary);
    font-weight: 600;
}

.live-bet-cashout {
    font-weight: 700;
}

.live-bet-cashout.won { color: var(--accent-green); }
.live-bet-cashout.lost { color: var(--text-muted); }
.live-bet-cashout.active { color: var(--accent-yellow); }

/* ========== MODALS ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 30px;
    max-width: 420px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h2 {
    font-size: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.modal .form-group {
    margin-bottom: 15px;
}

.modal .form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.modal .form-group input {
    width: 100%;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
}

.modal .form-group input:focus { border-color: var(--accent-green); }

.modal .form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal .form-actions .btn { flex: 1; padding: 12px; font-size: 14px; }

.modal-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
}

.modal-tab {
    flex: 1;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: 0.2s;
}

.modal-tab.active {
    background: var(--accent-red);
    color: #fff;
    border-color: var(--accent-red);
}

.error-msg {
    color: var(--accent-red);
    font-size: 13px;
    margin-top: 5px;
    display: none;
}

.success-msg {
    color: var(--accent-green);
    font-size: 13px;
    margin-top: 5px;
    display: none;
}

/* ========== TOAST ========== */
.toast-container {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
    max-width: 300px;
}

.toast-success { background: var(--accent-green); color: #000; }
.toast-error { background: var(--accent-red); color: #fff; }
.toast-info { background: var(--accent-blue); color: #fff; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
    .game-container {
        grid-template-columns: 1fr;
    }
    .game-canvas-wrap { height: 300px; }
    .multiplier-text { font-size: 52px; }
}

@media (max-width: 600px) {
    .header {
        padding: 8px 10px;
        gap: 6px;
    }
    .logo { font-size: 16px; gap: 6px; }
    .logo span { display: none; }
    .header-right { gap: 6px; }
    .balance-display { padding: 5px 8px; gap: 4px; }
    .balance-display .currency { font-size: 10px; }
    .balance-display .amount { font-size: 13px; }
    .btn { padding: 5px 10px; font-size: 11px; }
    .btn-sm { padding: 4px 8px; font-size: 10px; }
    .game-container { padding: 8px; }
    .game-canvas-wrap { height: 250px; }
    .multiplier-text { font-size: 42px; }
    .bet-panels { grid-template-columns: 1fr; }
    .bet-panel { padding: 12px; }
}

@media (max-width: 380px) {
    .logo { font-size: 14px; }
    .balance-display { padding: 4px 6px; }
    .balance-display .amount { font-size: 12px; }
    .btn { padding: 4px 7px; font-size: 10px; }
}

/* ========== STARS BACKGROUND ========== */
.stars {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    overflow: hidden;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #fff;
    border-radius: 50%;
    opacity: 0.4;
    animation: twinkle 3s infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.2; }
    100% { opacity: 0.8; }
}

/* ========== PLANE TRAIL ========== */
.trail-dot {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--accent-red);
    border-radius: 50%;
    opacity: 0.5;
}

/* ========== WALLET MODAL ========== */
.wallet-section { display: none; }
.wallet-section.active { display: block; }

.transaction-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.transaction-item:last-child { border-bottom: none; }
.txn-positive { color: var(--accent-green); }
.txn-negative { color: var(--accent-red); }

/* Loading spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent-green);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== MY BETS RESULT ========== */
.my-bet-result {
    position: absolute;
    top: 10px;
    z-index: 20;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    animation: popIn 0.3s ease;
}

.my-bet-result.left { left: 15px; }
.my-bet-result.right { right: 15px; }
.my-bet-result.won { background: rgba(46,204,113,0.2); color: var(--accent-green); border: 1px solid var(--accent-green); }
.my-bet-result.lost { background: rgba(231,76,60,0.2); color: var(--accent-red); border: 1px solid var(--accent-red); }

@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
