body {
    margin: 0;
    padding: 0;
    font-family: 'Comic Sans MS', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 50%, #FFE4B5 100%);
    overflow: hidden;
    color: #2C3E50;
    /* Prevent text selection and callouts on mobile */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Prevent overscroll/bounce effect on mobile */
    overscroll-behavior: none;
    /* Ensure full height on mobile browsers */
    height: 100%;
    position: fixed;
    width: 100%;
}

html {
    height: 100%;
    overflow: hidden;
}

#game-container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    /* Prevent overscroll/bounce effect on mobile */
    overscroll-behavior: none;
    /* Ensure proper sizing on iOS */
    -webkit-overflow-scrolling: touch;
}

#ui-container {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    background: linear-gradient(135deg, #FF6B6B 0%, #4ECDC4 50%, #45B7D1 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 10;
    flex-wrap: wrap;
    max-height: 20vh;
    overflow-y: auto;
    border-radius: 0 0 15px 15px;
    position: relative;
    width: fit-content;
    margin: 0 auto;
    max-width: 90%;
}

#game-title {
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #FFFFFF;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 90px;
    background: linear-gradient(45deg, #FFD700, #FFA500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.3));
}

#resources {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    font-size: 11px;
    flex: 1;
    justify-content: center;
}

#food, #ants, #food-rate, #flying-ant-stats {
    display: flex;
    align-items: center;
    padding: 3px 8px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    border-radius: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin: 2px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    position: relative;
}

/* Subtle Score Display */
#score-display {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    margin: 2px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-weight: 500;
}

#score-display #session-timer,
#score-display #current-score {
    font-weight: bold;
    color: white;
}

/* Abilities Bar (God Powers) */
#abilities-bar {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin: 4px 2px;
    flex-wrap: wrap;
    justify-content: center;
}

.ability-btn {
    position: relative;
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, rgba(100, 50, 200, 0.4), rgba(150, 100, 255, 0.3));
    border: 2px solid rgba(150, 100, 255, 0.5);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ability-btn:hover:not(.on-cooldown) {
    background: linear-gradient(135deg, rgba(100, 50, 200, 0.6), rgba(150, 100, 255, 0.5));
    border-color: rgba(200, 150, 255, 0.8);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(150, 100, 255, 0.6);
}

.ability-btn:active:not(.on-cooldown) {
    transform: scale(0.95);
}

.ability-btn.on-cooldown {
    cursor: not-allowed;
    opacity: 0.5;
    background: linear-gradient(135deg, rgba(50, 50, 50, 0.4), rgba(80, 80, 80, 0.3));
    border-color: rgba(100, 100, 100, 0.5);
}

.ability-btn.active {
    border-color: rgba(255, 215, 0, 0.9);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    animation: pulse-ability 1s ease-in-out infinite;
}

@keyframes pulse-ability {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 215, 0, 1);
    }
}

.ability-icon {
    font-size: 24px;
    z-index: 2;
}

.ability-cooldown {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 3px;
    z-index: 3;
    display: none;
}

.ability-btn.on-cooldown .ability-cooldown {
    display: block;
}

/* Cooldown overlay */
.ability-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0%;
    background: rgba(0, 0, 0, 0.6);
    transition: height 0.1s linear;
    z-index: 1;
}

.ability-btn.on-cooldown::after {
    height: var(--cooldown-percent, 0%);
}

#food::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background-color: #EAD2AC;
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 8px rgba(255, 255, 150, 0.5);
}

#ants::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background-color: #3D2817;
    border-radius: 50%;
    margin-right: 6px;
}

#flying-ant-stats::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background-color: #4D3827;
    border-radius: 50%;
    margin-right: 6px;
    position: relative;
}

#flying-ant-stats::after {
    width: 10px;
    height: 4px;
    margin-left: -16px;
    margin-top: -6px;
}

#food-count, #ant-count, #ant-max, #food-per-second, #flying-ant-count, #flying-ant-max {
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

#upgrades {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
    justify-content: flex-end;
    max-width: 60%;
}

.upgrade-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
    margin-bottom: 5px;
}

#upgrades h3 {
    width: 100%;
    margin-top: 4px;
    margin-bottom: 2px;
    font-size: 12px;
    letter-spacing: 1px;
    color: #FFD700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
    text-align: center;
}

.upgrade-btn {
    min-width: 110px;
    padding: 8px 12px;
    font-size: 11px;
    background: linear-gradient(135deg, #FF6B6B 0%, #4ECDC4 50%, #45B7D1 100%);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    transform: translateY(0);
}

.upgrade-btn i {
    margin-right: 4px;
    margin-bottom: 0;
    font-size: 10px;
}

.upgrade-btn:hover {
    background: linear-gradient(135deg, #FF8E8E 0%, #66D9D6 50%, #67C3F3 100%);
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
}

.upgrade-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.upgrade-btn:disabled,
.upgrade-btn.disabled {
    background: linear-gradient(to bottom, #cccccc, #aaaaaa);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
    pointer-events: none;
}

.upgrade-btn.disabled:hover {
    background: linear-gradient(to bottom, #cccccc, #aaaaaa);
    transform: none;
}


#game-canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    overflow: hidden;
}

canvas {
    display: block;
    touch-action: none; /* Disable browser handling of touch gestures */
    /* Remove width/height 100% to prevent CSS stretching - PIXI handles sizing */
}

/* 3D-specific styles */
.dg {
    z-index: 10 !important;
}

/* Cursor styles for interaction */
#game-canvas-container {
    cursor: pointer;
}

#game-title i {
    font-size: 16px;
    animation: antWiggle 3s ease-in-out infinite;
    display: inline-block;
}

@keyframes antWiggle {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(15deg) scale(1.1); }
    50% { transform: rotate(0deg) scale(1.05); }
    75% { transform: rotate(-15deg) scale(1.1); }
}

@keyframes sparkle {
    0%, 100% { opacity: 0; transform: scale(0) rotate(0deg); }
    50% { opacity: 1; transform: scale(1) rotate(180deg); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 215, 0, 0.5); }
    50% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.8); }
}

/* Flying ant specific styles */
#flying-ant-stats::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 5px;
    background-color: #DDDDDD;
    position: absolute;
    margin-left: -20px;
    margin-top: -7px;
    border-radius: 50%;
    opacity: 0.7;
    transform: rotate(-30deg);
}

.special-btn {
    background: linear-gradient(to bottom, #6A5ACD, #483D8B);
}

.special-btn:hover {
    background: linear-gradient(to bottom, #836FFF, #6959CD);
}

/* Override for disabled special buttons - must come after regular styles */
.special-btn:disabled,
.special-btn.disabled {
    background: linear-gradient(to bottom, #cccccc, #aaaaaa);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
    pointer-events: none;
    color: #666;
}

.special-btn:disabled:hover,
.special-btn.disabled:hover {
    background: linear-gradient(to bottom, #cccccc, #aaaaaa);
    transform: none;
    box-shadow: none;
}

.automation-btn {
    background: linear-gradient(to bottom, #FF8C00, #D2691E);
}

.automation-btn:hover {
    background: linear-gradient(to bottom, #FFA500, #FF8C00);
}

/* Override for disabled automation buttons - must come after regular styles */
.automation-btn:disabled,
.automation-btn.disabled {
    background: linear-gradient(to bottom, #cccccc, #aaaaaa);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
    pointer-events: none;
    color: #666;
}

.automation-btn:disabled:hover,
.automation-btn.disabled:hover {
    background: linear-gradient(to bottom, #cccccc, #aaaaaa);
    transform: none;
    box-shadow: none;
}

.hidden {
    display: none !important;
}

/* Adjust for smaller screen compatibility */
@media (max-width: 1200px) {
    #ui-container {
        flex-wrap: wrap;
        padding: 5px 10px;
        max-height: 40vh;
    }
    
    #game-title {
        width: auto;
        margin-bottom: 3px;
        justify-content: flex-start;
        font-size: 14px;
    }
    
    #resources {
        flex: 1;
        margin-bottom: 3px;
        justify-content: flex-start;
    }
    
    #upgrades {
        max-width: 100%;
        justify-content: center;
        gap: 5px;
    }
    
    .upgrade-section {
        min-width: 110px;
    }
}

/* Mobile-specific UI improvements */
@media (max-width: 768px) {
    #ui-container {
        padding: 6px 10px;
        max-height: 34vh;
        width: 100%;
        max-width: 100%;
        border-radius: 0 0 12px 12px;
        box-sizing: border-box;
    }

    #resources {
        gap: 6px;
        margin-bottom: 4px;
        padding: 0 6px;
        font-size: 12px;
    }

    #food, #ants, #flying-ant-stats {
        padding: 4px 8px;
        font-size: 12px;
        border-radius: 12px;
    }

    #food-rate {
        padding: 4px 8px;
        font-size: 12px;
        line-height: 1.2;
        border-radius: 10px;
    }

    #food-rate div { margin: 0; }

    #upgrades {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 6px;
        width: 100%;
    }

    .upgrade-section { min-width: 120px; margin: 0; }
    .upgrade-section h3 { font-size: 12px; margin: 4px 0; text-align: center; }

    .upgrade-btn {
        min-width: 110px;
        font-size: 12px;
        padding: 6px 8px;
        margin: 4px 0;
        min-height: 44px;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
    }

    .upgrade-btn i { margin-bottom: 0; font-size: 14px; }

    /* Make UI toggle more visible */
    #ui-toggle {
        width: 44px;
        height: 44px;
        font-size: 18px;
        background: rgba(0, 0, 0, 0.7);
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    }
}

/* For phones - prioritize readability/tap targets */
@media (max-width: 480px) {
    #ui-container {
        padding: 8px 10px;
        max-height: 40vh;
        border-radius: 0 0 10px 10px;
    }

    #game-title { font-size: 12px; min-width: auto; margin-right: 4px; gap: 2px; }

    #resources { font-size: 13px; gap: 4px; }

    #food, #ants, #flying-ant-stats { padding: 6px 8px; font-size: 13px; border-radius: 10px; margin: 0; }
    #food-rate { padding: 6px 8px; font-size: 13px; border-radius: 10px; }

    /* Bottom sticky action bar */
    #action-bar {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        padding: 10px 8px calc(10px + env(safe-area-inset-bottom, 0));
        background: linear-gradient(135deg, rgba(255,107,107,0.95) 0%, rgba(78,205,196,0.95) 50%, rgba(69,183,209,0.95) 100%);
        backdrop-filter: blur(2px);
        z-index: 1000;
        gap: 8px;
        justify-content: space-around;
    }

    .action-btn {
        min-width: 70px;
        height: 54px;
        font-size: 13px;
        padding: 8px 6px;
        border-radius: 12px;
    }

    .action-btn i { font-size: 20px; margin-bottom: 3px; }
}

/* Ultra-condensed mode for phones */
.phone-condensed #ui-container {
    max-height: 10vh !important; /* Even more aggressive - just 10% */
    padding: 0px 1px !important;
    border-radius: 0 0 4px 4px !important;
}

.phone-condensed #action-bar {
    margin: 0px !important;
    gap: 0px !important; /* No gaps at all */
}

.phone-condensed .action-btn {
    min-width: 35px !important; /* Tiny buttons */
    height: 24px !important;
    font-size: 6px !important;
    padding: 0px !important;
    border-radius: 4px !important;
}

.phone-condensed .action-btn i {
    font-size: 8px !important;
}

/* Collapsed state for phones is almost invisible */
.phone-condensed.ui-collapsed #ui-container {
    max-height: 16px !important;
}

.phone-condensed.ui-collapsed #game-canvas-container {
    height: calc(100vh - 16px) !important;
}

/* Title screen mobile optimizations */
@media (max-width: 768px) {
    /* Ensure title screen elements are properly sized for mobile */
    canvas {
        width: 100vw !important;
        height: 100vh !important;
        object-fit: contain; /* Maintain aspect ratio */
    }
}

@media (max-width: 480px) {
    /* Phone-specific title screen adjustments */
    canvas {
        width: 100vw !important;
        height: 100vh !important;
    }
    
    /* Ensure UI doesn't interfere with title screen on phones */
    #ui-container {
        pointer-events: none; /* Allow clicks to pass through during title */
    }
    
    /* Re-enable UI interaction after title screen */
    .game-started #ui-container {
        pointer-events: auto;
    }
}

/* Add a collapsible UI option */
#ui-toggle {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 20;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
}

/* Mobile-specific UI toggle button */
@media (max-width: 768px) {
    #ui-toggle {
        width: 44px;
        height: 44px;
        font-size: 18px;
        background: rgba(0, 0, 0, 0.7);
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    }
}

.ui-collapsed #ui-container {
    max-height: 40px;
    overflow: hidden;
}

.ui-collapsed #resources,
.ui-collapsed #upgrades h3,
.ui-collapsed .upgrade-btn {
    display: none;
}

.ui-collapsed #game-title {
    width: auto;
}

/* Add iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS-specific styles */
    html, body {
        height: 100%;
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
    
    #game-container {
        /* Support for iOS notch */
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    /* Fix for iOS Safari 100vh issue */
    #game-canvas-container {
        height: calc(100% - var(--ui-height, 30vh));
    }
}

/* Improve button tap targets on mobile */
@media (max-width: 768px) {
    .upgrade-btn {
        min-height: 42px; /* Increased from 36px for better mobile usability */
        padding: 4px;
        margin: 4px;
        min-width: 95px; /* Slightly wider for easier tapping */
    }
    
    /* Ensure buttons have enough space between them */
    #upgrades {
        gap: 5px;
    }
    
    /* Make UI toggle more tappable */
    #ui-toggle {
        width: 44px;
        height: 44px;
        font-size: 18px;
        background: rgba(0, 0, 0, 0.7);
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    }
}

/* Prevent text selection on mobile */
* {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection in input fields */
input, textarea {
    -webkit-user-select: text;
    -khtml-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

#food-rate {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 3px 6px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
    margin: 2px;
    font-size: 12px;
    line-height: 1.3;
}

#food-rate div {
    display: flex;
    align-items: center;
    margin: 1px 0;
}

#food-rate div:last-child::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: #EAD2AC;
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 5px rgba(255, 255, 150, 0.5);
}

#food-per-second-actual {
    color: #4CAF50;
    font-weight: bold;
}

/* Remove the theoretical rate styling */

/* Improve UI collapsed state for mobile */
.ui-collapsed #ui-container {
    max-height: 30px;
    overflow: hidden;
}

/* Add a mobile-specific collapsed state */
@media (max-width: 768px) {
    /* Make the collapsed UI even more compact */
    .ui-collapsed #ui-container {
        max-height: 22px; /* Reduced from 25px */
    }
    
    /* Make game canvas take more space when UI is collapsed */
    .ui-collapsed #game-canvas-container {
        height: calc(100vh - 22px);
    }
    
    /* Adjust UI toggle position for better visibility */
    #ui-toggle {
        top: 3px;
        right: 3px;
    }
    
    /* Make the collapsed UI show just the title and food count */
    .ui-collapsed #game-title {
        font-size: 12px;
        margin-right: 50px; /* Make room for the toggle button */
    }
    
    .ui-collapsed #food {
        position: absolute;
        right: 50px;
        top: 3px;
        background: none;
        box-shadow: none;
    }
    
    /* Hide everything else when collapsed on mobile */
    .ui-collapsed #resources > div:not(#food),
    .ui-collapsed #upgrades {
        display: none;
    }
}

/* Improve button layout for mobile */
@media (max-width: 768px) {
    .upgrade-btn span {
        display: inline;
        text-align: center;
        line-height: 1.2;
        font-size: 9px; /* Increased from 8px for better readability */
    }
    
    .upgrade-btn i {
        font-size: 11px; /* Increased from 10px for better visibility */
        margin-right: 4px;
        margin-bottom: 0;
    }
    
    /* Make queen stats more compact */
    #queen-stats {
        font-size: 9px !important;
        margin: 1px 0 !important;
        text-align: center;
    }
}

/* Action Bar Modal System - Enhanced for Better Readability */
#action-bar {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 6px 0;
    flex-wrap: wrap;
}

/* Mobile action bar - much more condensed */
@media (max-width: 768px) {
    #action-bar {
        gap: 4px;
        margin: 4px 0;
    }
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    min-width: 70px;
    height: 50px;
    background: linear-gradient(135deg, #FF6B6B 0%, #4ECDC4 50%, #45B7D1 100%);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
    font-size: 11px;
}

.action-btn i {
    font-size: 18px;
    margin-bottom: 3px;
}

.action-btn:hover {
    background: linear-gradient(135deg, #FF8E8E 0%, #66D9D6 50%, #67C3F3 100%);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    border-color: rgba(255, 255, 255, 0.6);
}

/* Override for disabled action buttons - must come after regular styles */
.action-btn:disabled,
.action-btn.disabled {
    background: linear-gradient(to bottom, #cccccc, #aaaaaa);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
    pointer-events: none;
    color: #666;
}

.action-btn:disabled:hover,
.action-btn.disabled:hover {
    background: linear-gradient(to bottom, #cccccc, #aaaaaa);
    transform: none;
    box-shadow: none;
}

/* Modal Backdrop */
.modal-backdrop {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 350px;
    max-width: 95vw;
    max-height: calc(100vh - 40px);
    z-index: 9999;
    display: none;
    overflow: visible;
}

.modal-backdrop.show {
    display: block;
}

/* Modal Container */
.modal-container {
    background: linear-gradient(135deg, #FF6B6B 0%, #4ECDC4 50%, #45B7D1 100%);
    border-radius: 15px;
    padding: 15px;
    width: 100%;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    color: white;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 8px;
}

.modal-title {
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.modal-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-section {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.modal-section h3 {
    margin: 0 0 8px 0;
    color: #FFD700;
    text-align: center;
    font-size: 14px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

.modal-btn {
    width: 100%;
    padding: 8px;
    margin: 4px 0;
    background: linear-gradient(135deg, #FF6B6B 0%, #4ECDC4 50%, #45B7D1 100%);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
}

.modal-btn i {
    margin-right: 8px;
}

.modal-btn span:first-child {
    text-align: left !important;
    flex: 1;
    margin-right: 10px;
}

.modal-btn span:last-child {
    text-align: right !important;
    flex-shrink: 0;
    min-width: 50px;
}

.modal-btn:hover {
    background: linear-gradient(135deg, #FF8E8E 0%, #66D9D6 50%, #67C3F3 100%);
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.modal-btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.modal-btn:disabled,
.modal-btn.disabled,
button.modal-btn:disabled,
button.modal-btn.disabled {
    background: linear-gradient(to bottom, #cccccc, #aaaaaa) !important;
    cursor: not-allowed !important;
    transform: none !important;
    opacity: 0.7 !important;
    pointer-events: none !important;
    color: #666 !important;
    box-shadow: none !important;
}

.modal-btn.disabled:hover,
.modal-btn:disabled:hover,
button.modal-btn.disabled:hover,
button.modal-btn:disabled:hover {
    background: linear-gradient(to bottom, #cccccc, #aaaaaa) !important;
    transform: none !important;
    box-shadow: none !important;
}

.modal-stats {
    font-size: 11px;
    margin-top: 10px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    text-align: center;
}

/* Mobile Modal Adjustments */
@media (max-width: 768px) {
    .action-btn { min-width: 70px; height: 54px; font-size: 13px; padding: 8px 6px; }
    .action-btn i { font-size: 20px; margin-bottom: 3px; }
    
    .modal-backdrop {
        position: fixed !important;
        top: 5px !important;
        left: 5px !important;
        right: 5px !important;
        bottom: 5px !important;
        width: auto !important;
        height: auto !important;
        max-width: none !important;
        max-height: none !important;
        overflow: visible !important;
        z-index: 9999 !important;
        transform: none !important;
    }
    
    .modal-container {
        padding: 16px !important;
        margin: 0 !important;
        border-radius: 16px !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        overflow-y: auto !important;
        box-sizing: border-box !important;
    }
    
    .modal-header {
        position: sticky !important;
        top: 0 !important;
        background: linear-gradient(135deg, #FF6B6B 0%, #4ECDC4 50%, #45B7D1 100%) !important;
        z-index: 10 !important;
        margin-bottom: 15px !important;
        padding-bottom: 10px !important;
    }
    
    .modal-title {
        font-size: 20px !important;
        text-align: center !important;
        margin-bottom: 0 !important;
    }
    
    .modal-content {
        gap: 12px !important;
        padding-bottom: 20px !important;
    }
    
    .modal-section {
        padding: 12px !important;
        border-radius: 12px !important;
        margin-bottom: 8px !important;
    }
    
    .modal-section h3 {
        font-size: 16px !important;
        margin-bottom: 10px !important;
    }
    
    .modal-btn {
        font-size: 16px !important;
        padding: 14px 10px !important;
        min-height: 52px !important;
        border-radius: 10px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        margin: 4px 0 !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    
    .modal-btn span {
        display: block !important;
    }
    
    .modal-btn span:first-child {
        text-align: left !important;
        flex: 1 !important;
        margin-right: 10px !important;
    }
    
    .modal-btn span:last-child {
        text-align: right !important;
        flex-shrink: 0 !important;
        min-width: 50px !important;
    }
    
    .modal-close {
        width: 32px !important;
        height: 32px !important;
        font-size: 16px !important;
        flex-shrink: 0 !important;
    }
    
    .modal-stats {
        font-size: 12px !important;
        line-height: 1.4 !important;
        padding: 8px !important;
        margin-top: 8px !important;
    }
    
    /* Disabled button states - must override mobile styles */
    .modal-btn:disabled,
    .modal-btn.disabled {
        background: linear-gradient(to bottom, #cccccc, #aaaaaa);
        cursor: not-allowed;
        transform: none;
        opacity: 0.7;
        pointer-events: none;
        color: #666;
    }
    
    .modal-btn:disabled:hover,
    .modal-btn.disabled:hover {
        background: linear-gradient(to bottom, #cccccc, #aaaaaa);
        transform: none;
        box-shadow: none;
    }
    
    .upgrade-btn:disabled,
    .upgrade-btn.disabled {
        background: linear-gradient(to bottom, #cccccc, #aaaaaa);
        cursor: not-allowed;
        transform: none;
        opacity: 0.7;
        pointer-events: none;
        color: #666;
    }
    
    .upgrade-btn:disabled:hover,
    .upgrade-btn.disabled:hover {
        background: linear-gradient(to bottom, #cccccc, #aaaaaa);
        transform: none;
        box-shadow: none;
    }
    
    /* Mobile disabled styles for action buttons */
    .action-btn:disabled,
    .action-btn.disabled {
        background: linear-gradient(to bottom, #cccccc, #aaaaaa);
        cursor: not-allowed;
        transform: none;
        opacity: 0.7;
        pointer-events: none;
        color: #666;
        box-shadow: none;
    }

    .action-btn:disabled:hover,
    .action-btn.disabled:hover {
        background: linear-gradient(to bottom, #cccccc, #aaaaaa);
        transform: none;
        box-shadow: none;
    }
    
    /* Mobile disabled styles for special buttons */
    .special-btn:disabled,
    .special-btn.disabled {
        background: linear-gradient(to bottom, #cccccc, #aaaaaa);
        cursor: not-allowed;
        transform: none;
        opacity: 0.7;
        pointer-events: none;
        color: #666;
        box-shadow: none;
    }

    .special-btn:disabled:hover,
    .special-btn.disabled:hover {
        background: linear-gradient(to bottom, #cccccc, #aaaaaa);
        transform: none;
        box-shadow: none;
    }
    
    /* Mobile disabled styles for automation buttons */
    .automation-btn:disabled,
    .automation-btn.disabled {
        background: linear-gradient(to bottom, #cccccc, #aaaaaa);
        cursor: not-allowed;
        transform: none;
        opacity: 0.7;
        pointer-events: none;
        color: #666;
        box-shadow: none;
    }

    .automation-btn:disabled:hover,
    .automation-btn.disabled:hover {
        background: linear-gradient(to bottom, #cccccc, #aaaaaa);
        transform: none;
        box-shadow: none;
    }
}

/* Notification Banner (Toast) */
.notification-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translate(-50%, 100%);
    max-width: 80%;
    padding: 10px 20px;
    border-radius: 6px;
    text-align: center;
    font-weight: bold;
    color: #fff;
    z-index: 9999;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
    opacity: 0;
    pointer-events: none; /* clicks pass through */
}

.notification-banner.show {
    transform: translate(-50%, 0);
    opacity: 1;
}

/* Color themes – tuned to match game palette */
.notification-banner.info    {
    background: linear-gradient(to bottom, #555, #333);
    color: #FFD700; /* gold text for consistency */
}

.notification-banner.success {
    background: linear-gradient(to bottom, #4CAF50, #3e8e41); /* same green as upgrade buttons */
    color: #fff;
}

.notification-banner.warning {
    background: linear-gradient(to bottom, #FFD700, #C8A400); /* gold accent */
    color: #333;
}

.notification-banner.error   {
    background: linear-gradient(to bottom, #d32f2f, #b71c1c);
    color: #fff;
} 
