@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;900&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
    user-select: none;
}

body {
    background-color: #0f1523;
    color: #ffffff;
    display: flex;
    justify-content: center;
    margin: 0;
    /* Locks the app strictly to screen height avoiding scrolling */
    height: 100vh;
    height: 100dvh; 
    overflow: hidden; 
}

.app-container {
    width: 100%;
    max-width: 450px;
    background-color: #121928;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #0b101a;
    border-bottom: 2px solid #1e2841;
}

.header-left { display: flex; align-items: center; gap: 15px; font-size: 20px;}
#back-btn { cursor: pointer; }
.logo { display: flex; flex-direction: column; align-items: center; font-weight: 900; line-height: 1; }
.crown { font-size: 14px; color: #FFD700; }
.k { font-size: 24px; color: #ffffff; }
.header-logo { height: 35px; width: auto; object-fit: contain; }

/* Set header-right to relative for precise dropdown alignment */
.header-right { display: flex; align-items: center; gap: 10px; position: relative; }
.balance-box {
    background: #1e293b;
    padding: 4px 10px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.balance-label { font-size: 10px; color: #8e9bb0; }
.balance-amount { font-size: 14px; font-weight: 700; color: #ffffff; }
.icon-btn {
    background: none; border: none; color: #8e9bb0; font-size: 18px; cursor: pointer;
}
.menu-btn { background: #2f446b; color: white; padding: 8px 10px; border-radius: 4px; }

/* Game Screen */
.game-wrapper { 
    padding: 10px; 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    flex: 1; 
    overflow: hidden; 
}

.game-screen {
    width: 100%;
    flex: 1; /* Automatically scales remaining empty space dynamically */
    min-height: 150px; /* Safe minimum height protection */
    background-color: #5ec3e7; /* Sky blue matching the game */
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.bus-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s ease;
}

#bus-image { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    object-position: bottom; /* Prevents roof cropping */
}

#explosion-image {
    position: absolute; 
    top: 15%; /* Brings it slightly up from exact center so it sits on the bus */
    left: 50%;
    transform: translate(-50%, -50%); /* Centers it perfectly */
    width: 120%; /* Large dramatic explosion */
    height: auto;
    z-index: 3;
}

/* Speed effect simulated via CSS */
.speed-up { animation: vibrate 0.2s infinite; }
@keyframes vibrate {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(1px, -1px) scale(1.02); }
    100% { transform: translate(-1px, 1px) scale(1); }
}

/* UI Overlay - Moved to the sky & Reduced in size */
.overlay-ui {
    position: absolute; 
    top: 30%; /* Pushed into the top sky area */
    left: 50%;
    transform: translateX(-50%); /* Keeps it horizontally centered */
    z-index: 10; 
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.status-box .title { 
    font-size: 12px; /* Smaller title */
    font-weight: 700; 
    color: #fff; 
    margin-bottom: 2px;
}

.status-box .time, .status-box .multiplier {
    font-size: 22px; /* Reduced by over 50% from 45px */
    font-weight: 900;
    color: #ffffff;
    /* Replaced -webkit-text-stroke with an underlay text-shadow to prevent inner black spots */
    text-shadow: 
        -1px -1px 0 #000,  
         1px -1px 0 #000,
        -1px  1px 0 #000,
         1px  1px 0 #000,
         2px  2px 4px rgba(0,0,0,0.8);
}

.text-red { color: #ff3333 !important; }
.hidden { display: none !important; }

/* Betting Panels (Compact for better fit) */
.betting-area { 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    flex-shrink: 0; /* Prevents betting panels from squishing down */
}
.bet-panel {
    background-color: #31466a;
    border-radius: 8px; 
    padding: 8px 12px; 
    border: 1px solid #435b83;
}

.panel-top {
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 8px; gap: 10px;
}
.label { font-size: 12px; color: #a1b0c9; margin-bottom: 4px; display: block; }

.auto-cashout-box {
    display: flex; align-items: center; justify-content: space-between;
    background: #1a2538; border-radius: 6px; padding: 6px 10px; flex: 1;
}
.auto-cashout-inputs { display: flex; flex-direction: column; }
.auto-cashout-inputs .label { font-size: 11px; color: #8e9bb0; margin-bottom: 2px; }
.auto-cashout-inputs .input-wrapper { display: flex; align-items: center; color: #5a6a85; font-size: 16px; }
.transparent-input {
    background: transparent; border: none; color: #fff; font-size: 16px;
    width: 50px; outline: none; margin-left: 2px; font-weight: bold;
}
.transparent-input:disabled { color: #5a6a85; }

.auto-cashout-toggle {
    display: flex; flex-direction: column; background: #121a28; border-radius: 4px; overflow: hidden;
}
.auto-cashout-toggle .toggle-btn {
    font-size: 10px; padding: 4px 8px; cursor: pointer; text-align: center; color: #8e9bb0; font-weight: bold;
}
.auto-cashout-toggle .toggle-btn.active { background: #2f446b; color: #fff; }

.auto-bet-box {
    display: flex; align-items: center; background: #1a2538; border-radius: 20px; padding: 3px; padding-right: 12px; cursor: pointer;
}
.auto-bet-toggle {
    background: transparent; color: #8e9bb0; font-size: 11px; padding: 5px 12px; border-radius: 15px; font-weight: bold;
}
.auto-bet-toggle.active { background: #2f446b; color: #fff; }
.auto-bet-label { font-size: 11px; color: #fff; margin-left: 6px; font-weight: bold; }

.panel-bottom { display: flex; gap: 10px; align-items: flex-end; }
.stake-group { flex: 1; }
.dark-input {
    background: #1a2538; border: none; color: white; width: 100%;
    padding: 10px; border-radius: 6px; font-size: 15px; outline: none; font-weight: bold;
}
.quick-stake-group { flex: 1.5; }
.quick-buttons {
    display: flex; background: #1a2538; border-radius: 6px; overflow: hidden;
}
.quick-buttons button {
    flex: 1; background: transparent; border: none; border-right: 1px solid #2f446b;
    color: #a1b0c9; padding: 10px 0; font-size: 13px; font-weight: bold; cursor: pointer;
}
.quick-buttons button:last-child { border-right: none; }

/* Play / Cashout Buttons */
.play-btn {
    background: #FFD700; 
    color: #000; 
    border: none; 
    font-size: 15px; 
    font-weight: 900;
    border-radius: 6px; 
    padding: 0 15px; 
    height: 40px; 
    cursor: pointer; 
    transition: 0.2s;
}

/* Active Cashout Button Styling (Kept Yellow instead of Red/Orange) */
.play-btn.cashout { 
    background: #FFD700; /* Stays yellow */
    color: #000;         /* Text stays black */
}

.play-btn:active { transform: scale(0.95); }


/* ================= NEW FEATURES STYLING ================= */

/* Dropdown Menu Styles */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 15px); /* Align properly below header items */
    right: 0;
    background: #1e293b;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
    min-width: 150px;
    border: 1px solid #2f446b;
}

.dropdown-item {
    background: transparent;
    border: none;
    color: #fff;
    padding: 12px 15px;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.dropdown-item i { color: #5ec3e7; }
.dropdown-item:hover { background: #2f446b; }
.dropdown-item:not(:last-child) { border-bottom: 1px solid #2f446b; }

/* Recent Results Banner (Top of game screen) */
.recent-results {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 4px 8px; /* Greatly reduced padding */
    display: flex;
    gap: 4px; /* Tighter gap between pills */
    z-index: 20;
    overflow-x: auto;
    background: rgba(0, 0, 0, 0.35); /* Made slightly more transparent to blend in better */
    white-space: nowrap;
}

/* Hide Scrollbar for a seamless look */
.recent-results::-webkit-scrollbar { display: none; }
.recent-results { -ms-overflow-style: none; scrollbar-width: none; }

.result-pill {
    padding: 2px 6px; /* Greatly reduced padding */
    border-radius: 4px; /* Slightly sharper, smaller curve */
    font-size: 10px; /* Reduced font size to match standard game UI */
    font-weight: 700; /* Dropped from 900 so the small text remains readable */
    text-align: center;
    min-width: 36px; /* Shorter minimum width */
}

/* Style matches the UI screenshots */
.result-pill.range1 { background-color: #00BFFF; color: white; }
.result-pill.range2 { background-color: #800080; color: white; }
.result-pill.range3 { background-color: #800000; color: white; }
.result-pill.range4 { background-color: #0002FF; color: white; }
.result-pill.range5 { background-color: #008000; color: white; }
.result-pill.range6 { background-color: #FF7900; color: white; }
.result-pill.range7 { background-color: #FF00FF; color: white; }

/* --- EXIT MODAL --- */
.exit-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}
/* Slide up effect tied to removal of the .hidden class */
.exit-modal:not(.hidden) .exit-modal-content {
    animation: slideUpModal 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes slideUpModal {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.exit-modal-content {
    background: #ffffff;
    width: 100%;
    max-width: 450px;
    text-align: left;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
}
.exit-modal-header {
    padding: 12px 16px;
    color: #000;
    font-weight: 600;
    font-size: 0.9rem;
}
.exit-games-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 0 16px 16px 16px;
    width: 100%;
}
.exit-game-box {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    background: #e5e5e5;
}
.exit-game-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.exit-modal-actions { display: flex; width: 100%; height: 50px; }
.exit-action-btn {
    border: none;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0;
    outline: none;
}
.exit-action-btn.leave { background: #3f3f3f; color: white; flex: 0.35; }
.exit-action-btn.stay { background: #16a34a; color: white; flex: 0.65; }

.btn-effect {
    transition: transform 0.05s ease, filter 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}
.btn-effect:active:not(:disabled) {
    transform: scale(0.96);
    filter: brightness(1.1);
}

/* ================= NEW CASHOUT ANIMATIONS ================= */
.flying-money {
    position: fixed;
    z-index: 9999;
    width: 50px;
    height: 50px;
    object-fit: contain;
    pointer-events: none;
    /* Slowed down transition from 0.6s to 1.2s for a more visible flight */
    transition: top 1.2s cubic-bezier(0.25, 1, 0.5, 1), left 1.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.dance-shrink {
    /* Slowed down from 0.4s to 0.8s */
    animation: danceShrink 0.8s forwards ease-in-out;
}

@keyframes danceShrink {
    0% { transform: scale(1) rotate(0deg); }
    30% { transform: scale(1.4) rotate(15deg); }
    60% { transform: scale(1.4) rotate(-15deg); }
    100% { transform: scale(0) rotate(0deg); }
}

.emoji-flyer {
    position: fixed;
    z-index: 9998;
    pointer-events: none;
    font-size: 20px;
    /* Slowed down from 0.6s to 1.5s for a nice lingering effect */
    animation: sprinkle 1.5s ease-out forwards;
}

@keyframes sprinkle {
    0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
    100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0.6) rotate(45deg); }
}

.balance-pop {
    /* Slowed down to match the new money dance perfectly */
    animation: popUp 0.8s ease-out;
    display: inline-block;
}

@keyframes popUp {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); color: #4CAF50; }
    100% { transform: scale(1); color: #ffffff; }
}



/* ===== Production additions (do not alter original game styles) ===== */
.connecting-overlay {
    position: fixed;
    inset: 0;
    background: #0f1523;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}
.connecting-content {
    text-align: center;
    color: #fff;
}
.connecting-logo {
    margin-bottom: 16px;
    border-radius: 12px;
}
.connecting-content h2 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: #a1b0c9;
}
.connecting-spinner {
    display: flex;
    justify-content: center;
    gap: 8px;
}
.spinner-ring {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #5ec3e7;
    animation: bounce 1.2s infinite ease-in-out;
}
.spinner-ring:nth-child(2) { animation-delay: 0.15s; }
.spinner-ring:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1.1); opacity: 1; }
}
.connecting-error p { color: #f87171; margin-bottom: 12px; }
.retry-btn {
    background: #FFD700;
    color: #000;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
}

#notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-120%);
    background: #1e293b;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 10000;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    max-width: 90%;
    text-align: center;
    border: 1px solid #2f446b;
    pointer-events: none;
}
#notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
#notification.show.error { border-color: #b91c1c; background: #3f1a1a; }
#notification.show.success { border-color: #15803d; background: #14301f; }

.my-bets-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.my-bets-box {
    width: 92%;
    max-width: 380px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}
.my-bets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid #2f446b;
}
.my-bets-header h3 { margin: 0; font-size: 1.1rem; }
.modal-close {
    background: none;
    border: none;
    color: #8e9bb0;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}
.my-bets-list {
    overflow-y: auto;
    padding: 10px 12px;
    flex: 1;
}
.my-bet-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 8px;
    border-bottom: 1px solid #2f446b;
    font-size: 0.82rem;
}
.my-bet-item .timestamp { color: #8e9bb0; font-size: 0.72rem; display: block; }
.my-bet-item .amount { color: #fff; }
.my-bet-item .mult { color: #5ec3e7; margin-right: 10px; }
.my-bet-item .profit.win { color: #4ade80; font-weight: 700; }
.my-bet-item .profit.loss { color: #f87171; font-weight: 700; }
.bonus-badge {
    background: #f59e0b;
    color: #000;
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    font-weight: 700;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Bonus Prompt Modal */
.bonus-prompt-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}
.bonus-prompt-content {
    background: #1e293b;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    width: 85%;
    max-width: 320px;
    position: relative;
    border: 1px solid #2f446b;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}
.bonus-prompt-content h3 { color: #fff; margin-bottom: 10px; font-size: 18px; }
.bonus-prompt-content p { color: #8e9bb0; margin-bottom: 20px; font-size: 14px; }
.bonus-prompt-buttons { display: flex; gap: 10px; }
.bonus-choice-btn {
    flex: 1; padding: 10px; border: none; border-radius: 6px; font-size: 14px; font-weight: 700; cursor: pointer; transition: all 0.2s ease;
}
.bonus-choice-btn.bonus { background-color: #5ec3e7; color: #000; }
.bonus-choice-btn.bonus:hover { background-color: #4eb3d7; }
.bonus-choice-btn.real { background-color: #2f446b; color: #fff; }
.bonus-choice-btn.real:hover { background-color: #3b5585; }
.cancel-choice-btn {
    position: absolute; top: 10px; right: 15px; background: none; border: none; color: #8e9bb0; font-size: 24px; cursor: pointer; line-height: 1;
}
.cancel-choice-btn:hover { color: #fff; }

.secondary-balance {
    font-size: 9px;
    color: #a1b0c9;
    font-weight: 500;
    margin-top: 2px;
}