/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Color Variables */
:root {
    /* Primary Color Scheme */
    --primary-blue: #4a9eff;
    --secondary-blue: #2a7eff;
    --accent-blue: #6bb6ff;
    
    /* Background Colors */
    --bg-dark: #1a1a2e;
    --bg-mid: #16213e;
    --bg-overlay: rgba(0, 0, 0, 0.9);
    --bg-section: rgba(0, 0, 0, 0.3);
    --bg-item: rgba(255, 255, 255, 0.05);
    
    /* Status Colors */
    --color-danger: #ff4444;
    --color-success: #44ff44;
    --color-warning: #ff9944;
    --color-neutral: #cccccc;
    --danger-color: #ff4444;
    
    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    
    /* Border Colors */
    --border-primary: #444444;
    --border-accent: var(--primary-blue);
    
    /* Game Canvas */
    --canvas-bg: #2a4a2a;
}

/* Simplified Mobile-First Approach */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-weight: 400;
    background: var(--bg-dark);
    color: var(--text-primary);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: none;
    touch-action: manipulation;
    
    /* PWA Fullscreen and status bar hiding */
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    min-height: 100vh;
    min-height: 100dvh;
    
    /* iOS Safari PWA specific */
    height: -webkit-fill-available;
    min-height: -webkit-fill-available;
    
    /* Android TWA and PWA - extend into status bar area */
    padding-top: env(safe-area-inset-top, 0);
    padding-right: env(safe-area-inset-right, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: env(safe-area-inset-left, 0);
}

p, span, div, li, label, input, textarea {
    font-family: 'Comfortaa', 'Arial', sans-serif;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-weight: 600;
    letter-spacing: 0.03em;
}

button {
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-weight: 500;
}

/* Game Container - Simplified */
#gameContainer {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Fullscreen specific styles */
html:fullscreen,
html:-webkit-full-screen,
html:-moz-full-screen {
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
}

html:fullscreen body,
html:-webkit-full-screen body,
html:-moz-full-screen body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background: var(--bg-dark);
}

/* PWA fullscreen mode - Android TWA and installed PWAs */
@media (display-mode: fullscreen) {
    html, body {
        height: 100vh !important;
        height: 100dvh !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
        overflow: hidden;
        /* Remove any padding in fullscreen PWA mode */
        padding: 0 !important;
        margin: 0 !important;
    }
    
    #gameContainer {
        height: 100vh !important;
        height: 100dvh !important;
        width: 100vw !important;
    }
}

/* PWA standalone mode - fallback */
@media (display-mode: standalone) {
    html, body {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
        /* Use safe area insets in standalone mode */
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* iOS Safari PWA */
@supports (-webkit-touch-callout: none) {
    html, body {
        height: -webkit-fill-available;
        min-height: -webkit-fill-available;
    }
    
    @media (display-mode: fullscreen) {
        html, body {
            height: 100vh !important;
            height: 100dvh !important;
            height: -webkit-fill-available !important;
            min-height: -webkit-fill-available !important;
        }
    }
}

/* Canvas */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    background: var(--canvas-bg);
    display: block;
    /* Size will be set by JavaScript */
    image-rendering: pixelated; /* For crisp pixel art scaling */
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* UI Overlay */
#uiOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* HUD */
#hud {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    font-size: 14px; /* Base font size for consistent HUD text */
}

#healthBar {
    background: var(--bg-section);
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    padding: 6px;
    width: 160px;
    position: relative;
}

#healthFill {
    background: linear-gradient(90deg, var(--color-danger), var(--color-warning));
    height: 0.8rem;
    border-radius: 5px;
    width: 100%;
    transition: width 0.3s ease;
}

#healthText {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-weight: 600;
    font-size: 14px; /* Consistent with HUD base font size */
    text-shadow: 1px 1px 2px black;
    color: var(--text-primary);
}

#waveInfo, #scoreInfo {
    background: var(--bg-section);
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    padding: 6px;
    text-align: center;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-weight: 600;
    color: var(--text-primary);
}

#waveInfo {
    /* Make wave info more compact and horizontal */
    min-width: 140px; /* Further reduced width */
    flex-direction: row; /* Override to horizontal for wave info */
    align-items: center;
    justify-content: center;
}

#waveInfo span {
    display: inline-block; /* Change to horizontal layout */
    margin: 0 4px; /* Further reduced horizontal spacing */
    font-size: 14px; /* Consistent with HUD base font size */
}

#scoreInfo span {
    display: block;
    margin: 2px 0;
    font-size: 14px; /* Consistent with HUD base font size */
}

/* Pause Button */
#pauseBtn {
    background: var(--bg-section);
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 18px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    pointer-events: all;
    
    /* Enhanced touch support for iPhone Safari */
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    
    /* Enhanced visibility and touch area */
    min-width: 44px;
    min-height: 44px;
    position: relative;
    z-index: 50;
    
    /* Glow effect for better visibility */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#pauseBtn:hover {
    background: var(--primary-blue);
    border-color: var(--accent-blue);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#pauseBtn:active {
    transform: scale(0.95);
    background: var(--secondary-blue);
}

/* Mobile Controls - Always Visible */
#mobileControls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 140px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 10px;
    pointer-events: all;
    z-index: 50;
    background: linear-gradient(to top, rgba(26, 26, 46, 0.3), transparent);
}

/* Virtual Joystick */
#joystickArea {
    position: relative;
    width: 100px;
    height: 100px;
}

#joystickBase {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: var(--bg-section);
    top: 0;
}

#joystickStick {
    position: absolute;
    width: 40px;
    height: 40px;
    background: linear-gradient(45deg, var(--primary-blue), var(--secondary-blue));
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.1s ease;
    cursor: pointer;
}

/* Action Buttons */
#actionButtons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
}

.action-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-weight: 600;
    font-size: 20px; /* Larger font size for emoji display */
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
    min-width: 70px;
    /* Optimized for emoji-only buttons */
    width: 70px; /* Smaller width since no text */
    height: 50px; /* Slightly taller for better emoji visibility */
    display: flex;
    align-items: center;
    justify-content: center;
    /* Remove text-specific properties for emoji-only buttons */
    white-space: nowrap;
    overflow: hidden;
    /* Enhanced emoji rendering */
    line-height: 1;
    text-align: center;
}

/* Special styling for the main menu buttons */
#startGameBtn {
    background: linear-gradient(45deg, #ff7e5f, #feb47b);
}

#startGameBtn:hover {
    background: linear-gradient(45deg, #ff8a6f, #fec48b);
    box-shadow: 0 6px 16px rgba(255, 126, 95, 0.4);
}

#upgradesBtn {
    background: linear-gradient(45deg, #4a9eff, #6bb6ff);
}

#upgradesBtn:hover {
    background: linear-gradient(45deg, #5aafff, #7bc6ff);
    box-shadow: 0 6px 16px rgba(74, 158, 255, 0.4);
}

.action-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.action-btn.primary {
    background: linear-gradient(45deg, var(--color-danger), #ff6666);
    color: var(--text-primary);
    /* Remove different sizing for primary button */
    font-size: 13px;
    padding: 12px 16px;
}

.action-btn.skill {
    background: linear-gradient(45deg, var(--primary-blue), var(--accent-blue));
    color: var(--text-primary);
    /* Optimized for emoji display */
    font-size: 18px; /* Good size for emoji visibility */
    font-weight: 700;
    /* Compact layout for skill buttons */
    padding: 4px;
    width: 70px; /* Match the general action-btn width */
    height: 50px; /* Match the general action-btn height */
    line-height: 1;
    /* Enhanced visual feedback */
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.action-btn.skill:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(74, 158, 255, 0.4);
    border-color: var(--accent-blue);
}

.action-btn.skill:disabled {
    background: linear-gradient(45deg, #444444, #666666);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.action-btn.skill.btn-pulse {
    border-color: var(--color-success);
    box-shadow: 0 0 15px rgba(68, 255, 68, 0.5);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-mid));
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.screen.active {
    display: flex;
}

/* Main Menu */
#mainMenu {
    /* Use consistent background with optional image overlay */
    background: url('../assets/background.jpg') center/cover no-repeat,
                linear-gradient(135deg, var(--bg-dark), var(--bg-mid));
    /* background-blend-mode: overlay; */
}

#mainMenu h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-shadow: 4px 4px 4px rgba(0, 0, 0, 1);
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.menu-btn {
    padding: 12px 24px;
    margin: 0.8rem;
    border: none;
    border-radius: 8px;
    background: linear-gradient(45deg, var(--primary-blue), var(--secondary-blue));
    color: var(--text-primary);
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    min-width: 260px;
    max-width: 300px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    
    /* Enhanced touch support for iPhone Safari */
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 10;
}

.menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.menu-btn:active {
    transform: translateY(0);
}

/* Language Selector */
.language-selector {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.language-btn {
    padding: 8px 16px;
    margin: 0;
    min-width: 100px;
    font-size: 14px;
    border: 2px solid var(--primary-blue);
    background: rgba(74, 158, 255, 0.1);
    color: var(--primary-blue);
    transition: all 0.3s ease;
    /* Ensure touch events work properly */
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(74, 158, 255, 0.3);
    cursor: pointer;
}

.language-btn:hover {
    background: rgba(74, 158, 255, 0.2);
    transform: translateY(-1px);
}

.language-btn.active {
    background: var(--primary-blue);
    color: white;
    font-weight: 600;
}

.language-btn.active:hover {
    background: var(--secondary-blue);
}

/* Touch-specific styles for mobile devices */
.language-btn:active {
    background: rgba(74, 158, 255, 0.3);
    transform: translateY(0);
}

.language-btn.active:active {
    background: var(--secondary-blue);
    transform: translateY(0);
}

/* Additional touch support for settings button specifically */
#settingsBtn {
    /* Ensure button is always touchable */
    position: relative !important;
    z-index: 200 !important;
    pointer-events: auto !important;
    display: inline-block !important;
    /* iOS specific fixes */
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#settingsBtn:hover,
#settingsBtn:focus {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

#settingsBtn:active {
    transform: translateY(0);
    background: linear-gradient(45deg, #1e40af, #1e3a8a);
}

/* Reset Button Specific Styles */
.reset-btn {
    background: linear-gradient(45deg, #dc2626, #ef4444) !important;
    color: white !important;
}

.reset-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.6);
}

.reset-warning {
    color: #fbbf24;
    font-size: 14px;
    margin-bottom: 10px;
    font-weight: bold;
    text-align: center;
    background: rgba(245, 101, 101, 0.1);
    padding: 10px;
    border-radius: 6px;
    border-left: 4px solid #dc2626;
}

/* Battle Screen */
#battleScreen {
    background: transparent;
    z-index: 1;
}

#skillSelection h2 {
    margin-bottom: 0.8rem;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-size: 28px;
    font-weight: 600;
    color: var(--primary-blue);
    letter-spacing: 0.05em;
}

#skillOptions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    justify-content: center;
    max-width: 100%;
    padding: 0 8px;
}

.skill-option {
    background: var(--bg-section);
    border: 2px solid var(--border-accent);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 0;
    text-align: center;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    max-width: 240px;
    /* Ensure minimum width for readability */
    min-width: 90px;
    
    /* Enhanced touch support for iPhone Safari */
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 10;
}

.skill-option:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 0.8rem rgba(74, 158, 255, 0.3);
    border-color: var(--accent-blue);
}

.skill-emoji {
    font-size: 28px;
    margin-bottom: 6px;
    display: block;
    line-height: 1;
}

.skill-option h3 {
    color: var(--primary-blue);
    margin-bottom: 8px;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.skill-option p {
    color: var(--text-secondary);
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    /* Ensure text doesn't overflow on small screens */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* Show max 3 lines */
    -webkit-box-orient: vertical;
}

.skill-option.disabled {
    pointer-events: none;
    opacity: 0.6;
    cursor: not-allowed;
}

/* Battle Results */
#battleResults {
    /* Inherit the consistent screen background */
    text-align: center;
}

#battleResults h2 {
    margin-bottom: 0.8rem;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-size: 32px;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: color 0.3s ease;
    letter-spacing: 0.05em;
}

#battleStats {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin: 0 auto 0.8rem;
    max-width: 360px;
    border: 1px solid var(--border-accent);
    box-shadow: 0 0 0.8rem rgba(0, 0, 0, 0.3);
}

#battleStats p {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-size: 18px;
    font-weight: 500;
}

#battleStats p:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

#battleStats span {
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-weight: 600;
    color: var(--primary-blue);
}

#resultsContent {
    background: var(--bg-section);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

#battleStats p {
    font-size: 18px;
    margin: 10px 0;
    color: var(--text-secondary);
}

#battleStats span {
    color: var(--color-success);
    font-weight: bold;
}

#resultsButtons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}



/* Scrollable Screens - Simplified */
#settingsScreen, #baseScreen, #skillSelection {
    overflow-y: auto;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    position: relative;
    height: 100vh;
}

#settingsScreen h2 {
    padding: 0.8rem;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-size: 32px;
    font-weight: 600;
    color: var(--primary-blue);
    text-align: center;
    letter-spacing: 0.05em;
}

#settingsContent {
    max-width: 800px;
    margin: 0 auto;
    max-height: calc(100vh - 128px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    
    /* Enhanced touch scrolling */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.info-section {
    background: var(--bg-section);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 12px;
    border-left: 4px solid var(--primary-blue);
}

.info-section h3 {
    color: var(--primary-blue);
    margin-bottom: 10px;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.info-section p {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.control-guide {
    margin-top: 10px;
}

.control-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
    padding: 10px;
    background: var(--bg-item);
    border-radius: 6px;
}

.control-icon {
    font-size: 0.8rem;
    margin-right: 12px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.control-text {
    color: var(--text-secondary);
    line-height: 1.5;
}

.control-text strong {
    color: var(--primary-blue);
}

.feature-list, .tips-list {
    margin: 15px 0;
    padding-left: 0.8rem;
}

.feature-list li, .tips-list li {
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.5;
}

.feature-list li strong, .tips-list li strong {
    color: var(--primary-blue);
}

.landscape-note {
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid var(--primary-blue);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    color: var(--text-secondary);
}

.landscape-note strong {
    color: var(--primary-blue);
}

/* Base Screen */
#baseScreen {
    /* Inherit the consistent screen background */
    overflow-y: auto;
    overflow-x: hidden;
    
    /* Enhanced touch scrolling */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    position: relative;
    box-sizing: border-box;
}

/* Base Screen when active - ensure sticky buttons work properly */
#baseScreen.active {
    display: flex !important;
    flex-direction: column;
    height: 100vh;
}



/* Apply Base & Upgrade styling to other screens */
.base-style-screen {
    /* Inherit the consistent screen background */
    overflow-y: auto;
    padding: 12px;
}

.base-style-screen h2 {
    margin-bottom: 0.8rem;
    font-size: 32px;
    color: var(--primary-blue);
    text-align: center;
}

.base-style-content {
    max-width: 800px;
    margin: 0 auto;
}

#baseScreen h2 {
    padding: 0.8rem;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-size: 32px;
    font-weight: 600;
    color: var(--primary-blue);
    text-align: center;
    letter-spacing: 0.05em;
    flex-shrink: 0; /* Ensure title doesn't shrink */
}

#baseContent {
    max-width: 800px;
    margin: 0 auto;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    padding-bottom: 60px; /* Add bottom padding for sticky buttons */
    
    /* Enhanced touch scrolling */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    position: relative;
    
    /* Ensure content doesn't interfere with sticky buttons */
    min-height: 0;
}

/* Upgrades Grid Layout */
.upgrades-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}

/* Individual upgrade categories */
.upgrade-category {
    background: var(--bg-section);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 12px;
    border-left: 4px solid var(--primary-blue);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.upgrade-category:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0.8rem rgba(74, 158, 255, 0.15);
}

.upgrade-category h3 {
    color: var(--primary-blue);
    margin-bottom: 12px;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(74, 158, 255, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.03em;
}

.upgrade-section {
    background: transparent;
    border-radius: 0;
    padding: 0;
    margin-bottom: 0;
}

.upgrade-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    margin: 8px 0;
    background: linear-gradient(135deg, var(--bg-item), rgba(255, 255, 255, 0.05));
    border-radius: 10px;
    border: 1px solid rgba(74, 158, 255, 0.1);
    transition: all 0.2s ease;
}

.upgrade-item:hover {
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.1), rgba(255, 255, 255, 0.08));
    border-color: rgba(74, 158, 255, 0.3);
    transform: translateX(4px);
}

.upgrade-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.upgrade-name {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 600;
}

.upgrade-current {
    font-size: 18px;
    color: var(--primary-blue);
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-weight: 600;
}

.upgrade-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--color-warning), #ffaa66);
    color: var(--text-primary);
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(255, 153, 68, 0.2);
    min-width: 85px;
    min-height: 44px; /* Ensure proper touch target size */
    
    /* Enhanced touch support for iPhone Safari */
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 10;
}

.upgrade-cost {
    font-size: 12px;
    opacity: 0.9;
}

.upgrade-bonus {
    font-size: 16px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.upgrade-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(255, 153, 68, 0.4);
    background: linear-gradient(135deg, #ffaa66, var(--color-warning));
}

.upgrade-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(255, 153, 68, 0.3);
}

.upgrade-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none;
}

/* New upgrade categories - reusable styles */
.new-upgrade-category {
    background: linear-gradient(145deg, var(--bg-section), rgba(255, 255, 255, 0.02));
    border-radius: 16px;
    padding: 0.8rem;
    border: 1px solid rgba(74, 158, 255, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 0.8rem;
}

.new-upgrade-category:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0.8rem rgba(74, 158, 255, 0.15);
}

.new-upgrade-category h3 {
    color: var(--primary-blue);
    margin-bottom: 16px;
    font-size: 18px;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(74, 158, 255, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Grid layout for new sections */
.base-style-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-top: 10px;
}

/* For single column layout */
.base-style-grid.single-column {
    grid-template-columns: 1fr;
}

/* For three column layout */
.base-style-grid.three-column {
    grid-template-columns: repeat(3, 1fr);
}

/* Base style items (similar to upgrade items) */
.base-style-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    margin: 10px 0;
    background: linear-gradient(135deg, var(--bg-item), rgba(255, 255, 255, 0.05));
    border-radius: 12px;
    border: 1px solid rgba(74, 158, 255, 0.1);
    transition: all 0.2s ease;
}

.base-style-item:hover {
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.1), rgba(255, 255, 255, 0.08));
    border-color: rgba(74, 158, 255, 0.3);
    transform: translateX(4px);
}

.base-style-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.base-style-item-name {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
}

.base-style-item-current {
    font-size: 16px;
    color: var(--primary-blue);
    font-weight: bold;
}

/* Base style buttons (similar to upgrade buttons) */
.base-style-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--color-warning), #ffaa66);
    color: var(--text-primary);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(255, 153, 68, 0.2);
    min-width: 80px;
    
    /* Enhanced touch support for iPhone Safari */
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 10;
}

.base-style-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(255, 153, 68, 0.4);
    background: linear-gradient(135deg, #ffaa66, var(--color-warning));
}

.base-style-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(255, 153, 68, 0.3);
}

.base-style-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: linear-gradient(135deg, #666666, #888888);
    color: var(--text-muted);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transform: none !important;
}

/* Alternative button styles */
.base-style-btn.primary {
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-blue));
    box-shadow: 0 3px 8px rgba(74, 158, 255, 0.2);
}

.base-style-btn.primary:hover {
    box-shadow: 0 6px 12px rgba(74, 158, 255, 0.4);
}

.base-style-btn.success {
    background: linear-gradient(135deg, var(--color-success), #66ff66);
    box-shadow: 0 3px 8px rgba(68, 255, 68, 0.2);
}

.base-style-btn.success:hover {
    box-shadow: 0 6px 12px rgba(68, 255, 68, 0.4);
}

.base-style-btn.danger {
    background: linear-gradient(135deg, var(--color-danger), #ff6666);
    box-shadow: 0 3px 8px rgba(255, 68, 68, 0.2);
}

.base-style-btn.danger:hover {
    box-shadow: 0 6px 12px rgba(255, 68, 68, 0.4);
}

/* Player Stats - Compact Horizontal Layout */
#playerStats {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--bg-section);
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    margin-bottom: 0.5rem;
    border-left: 4px solid var(--primary-blue);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0; /* Ensure stats don't shrink */
}

.stat-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    box-sizing: border-box;
    padding: 0 8px;
    gap: 6px; /* Gap between label and value */
}

.stat-item:not(:last-child) {
    border-right: 1px solid rgba(74, 158, 255, 0.3);
}

.stat-label {
    font-size: 14px;
    color: var(--text-muted);
    font-family: 'Comfortaa', 'Arial', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-value {
    font-size: 0.8rem;
    color: var(--primary-blue);
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Loading Screen */
#loadingScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-mid));
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
}

.loading-content h2 {
    font-size: 32px;
    margin-bottom: 30px;
    color: var(--primary-blue);
}

.loading-bar {
    width: 300px;
    height: 0.8rem;
    background: var(--bg-item);
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto;
}

#loadingProgress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-blue), var(--accent-blue));
    width: 0%;
    transition: width 0.3s ease;
}

/* Orientation Screen */
#orientationScreen {
    /* Use consistent background with blur backdrop */
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-mid));
    /* Ensure orientation screen is above everything else */
    z-index: 2000 !important;
    /* Add backdrop blur to prevent interaction with elements below */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    /* Ensure it captures all pointer events */
    pointer-events: all;
}

.orientation-content {
    text-align: center;
    padding: 2rem 0.8rem;
    max-width: 400px;
    /* Ensure content is centered and visible */
    position: relative;
    z-index: 2001;
}

.orientation-content h2 {
    color: var(--primary-blue);
    margin: 0.8rem 0;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-size: 32px;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.orientation-content p {
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-size: 18px;
    font-weight: 400;
    line-height: 1.5;
}

.orientation-tip {
    background: var(--bg-section);
    border-radius: 12px;
    padding: 15px;
    margin-top: 0.8rem;
    border-left: 4px solid var(--primary-blue);
}

.orientation-tip p {
    color: var(--text-primary);
    font-size: 16px;
    margin: 0;
}

/* Subtle animation for orientation screen */
@keyframes orientationPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.9; }
}

/* Modal Styles - Optimized for Mobile/Landscape */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
}

.modal-content {
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-mid));
    border: 2px solid var(--border-accent);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    max-width: 400px;
    width: 90%;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 0 0 2rem rgba(74, 158, 255, 0.3);
    position: relative;
    margin: auto;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.modal-content h2 {
    color: var(--primary-blue);
    margin-bottom: 1.5rem;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    font-size: 24px;
    font-weight: 600;
}

.modal-buttons {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-buttons .menu-btn {
    flex: 1;
    min-width: 120px;
    max-width: 160px;
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

.fade-out {
    animation: fadeOut 0.5s ease-out;
}

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

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

.slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Button Effects */
.btn-pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Damage/Heal Text Animations */
.damage-text {
    position: absolute;
    pointer-events: none;
    font-weight: bold;
    font-size: 18px;
    color: #ff4444;
    text-shadow: 1px 1px 2px black;
    animation: damageFloat 1s ease-out forwards;
    z-index: 50;
}

.heal-text {
    color: #44ff44;
}

@keyframes damageFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.2);
    }
}

/* Skill Effects CSS */
.skill-cast-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 100;
}

.skill-cast-flash.heal {
    background: radial-gradient(circle at center, rgba(0, 255, 68, 0.3) 0%, transparent 70%);
    animation: skillFlash 0.3s ease-out;
}

.skill-cast-flash.damage_boost {
    background: radial-gradient(circle at center, rgba(255, 68, 68, 0.4) 0%, transparent 70%);
    animation: skillFlash 0.4s ease-out;
}

.skill-cast-flash.speed_boost {
    background: radial-gradient(circle at center, rgba(68, 170, 255, 0.35) 0%, transparent 70%);
    animation: skillFlash 0.25s ease-out;
}

.skill-cast-flash.shield {
    background: radial-gradient(circle at center, rgba(255, 170, 68, 0.45) 0%, transparent 70%);
    animation: skillFlash 0.5s ease-out;
}

.skill-cast-flash.explosive_shot {
    background: radial-gradient(circle at center, rgba(255, 102, 0, 0.5) 0%, transparent 70%);
    animation: skillFlash 0.35s ease-out;
}

.skill-cast-flash.multi_shot {
    background: radial-gradient(circle at center, rgba(170, 68, 255, 0.4) 0%, transparent 70%);
    animation: skillFlash 0.3s ease-out;
}

.skill-cast-flash.time_slow {
    background: radial-gradient(circle at center, rgba(68, 255, 255, 0.6) 0%, transparent 70%);
    animation: skillFlash 0.6s ease-out;
}

.skill-cast-flash.auto_repair {
    background: radial-gradient(circle at center, rgba(255, 255, 68, 0.3) 0%, transparent 70%);
    animation: skillFlash 0.4s ease-out;
}

@keyframes skillFlash {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
    100% {
        opacity: 0;
        transform: scale(1.3);
    }
}

/* Skill button feedback when casting */
.skill-btn.casting {
    animation: skillCast 0.3s ease-out;
    box-shadow: 0 0 0.8rem currentColor;
}

@keyframes skillCast {
    0% {
        transform: scale(1);
        box-shadow: 0 0 5px currentColor;
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 25px currentColor;
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 5px currentColor;
    }
}

/* Screen shake effect */
@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-2px, -1px); }
    20% { transform: translate(1px, 2px); }
    30% { transform: translate(-1px, 1px); }
    40% { transform: translate(2px, -1px); }
    50% { transform: translate(-1px, 2px); }
    60% { transform: translate(1px, 1px); }
    70% { transform: translate(-2px, 1px); }
    80% { transform: translate(2px, -2px); }
    90% { transform: translate(-1px, 1px); }
}

.screen-shake {
    animation: screenShake 0.2s ease-in-out;
}

/* Battle Type Selection Modal - Additional styles */

.modal.hidden {
    display: none !important;
}

/* Battle type modal content - use existing .modal-content styles */

.modal-header {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 0.8rem;
    gap: 0.8rem;
}

.modal-header h2 {
    color: var(--primary-blue);
    font-size: 24px;
    margin: 0;
    text-align: center;
}

.battle-type-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-instruction {
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 16px;
}

.battle-type-btn {
    display: flex;
    align-items: center;
    background: var(--bg-section);
    border: 2px solid var(--border-primary);
    border-radius: 10px;
    padding: 0.8rem;
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent; /* Remove default mobile tap highlight */
}

.battle-type-btn:hover, 
.battle-type-btn:active,
.battle-type-btn.active {
    background: var(--bg-item);
    border-color: var(--primary-blue);
    transform: translateY(-2px);
}

/* Active state for touch feedback */
.battle-type-btn.active {
    background-color: rgba(74, 158, 255, 0.3);
    transform: scale(0.98);
    transition: all 0.1s ease;
}

/* Add a subtle pulsing effect to indicate clickability */
.battle-type-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, rgba(74, 158, 255, 0.2) 0%, rgba(0, 0, 0, 0) 70%);
    opacity: 0;
    transition: opacity 1s ease;
}

.battle-type-btn:hover::after {
    opacity: 1;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.7; }
    50% { transform: scale(1.05); opacity: 0.3; }
    100% { transform: scale(0.95); opacity: 0.7; }
}

.battle-icon {
    font-size: 28px;
    margin-right: 15px;
}

.battle-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.battle-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.battle-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 3px;
}

.battle-reward {
    color: #ffdd44; /* Gold color for rewards */
    font-size: 12px;
    font-weight: bold;
}

.battle-click-hint {
    color: var(--primary-blue);
    font-size: 0.8rem;
    margin-left: 10px;
    animation: bounce 1.5s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(5px); }
}

.modal-close-btn {
    position: absolute;
    top: 0.5rem;
    right: 0rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent; /* Remove default mobile tap highlight */
    font-weight: normal;
    line-height: 1;
    padding: 0;
    margin: 0;
    z-index: 1001;
}

.modal-close-btn:hover,
.modal-close-btn:active {
    background: rgba(255, 77, 77, 0.2);
    color: var(--color-danger);
    border-color: var(--color-danger);
    transform: scale(1.1);
}

/* Custom Confirm Dialog Styles */
.confirm-dialog {
    border: 3px solid var(--danger-color, #ff4d4d);
    box-shadow: 0 0 0.8rem rgba(255, 77, 77, 0.3);
}

.confirm-dialog .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
}

.confirm-dialog .modal-header h2 {
    color: var(--danger-color, #ff4d4d);
    margin: 0;
    font-size: 24px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    flex: 1;
}

.confirm-dialog .modal-close-btn {
    position: absolute;
    top: 0.8rem;
    right: 0rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: bold;
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Comfortaa', 'Arial', sans-serif;
}

.confirm-dialog .modal-close-btn:hover,
.confirm-dialog .modal-close-btn:active {
    background: rgba(255, 77, 77, 0.2);
    color: var(--color-danger);
    border-color: var(--color-danger);
    transform: scale(1.1);
}

.confirm-message {
    color: var(--text-primary);
    font-size: 18px;
    margin-bottom: 15px;
    font-weight: bold;
}

.confirm-bullets {
    text-align: left;
    margin: 15px 0;
    padding-left: 0.8rem;
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.5;
}

.confirm-bullets li {
    margin-bottom: 8px;
}

.confirm-warning {
    color: var(--text-secondary);
    font-style: italic;
    margin: 15px 0;
    font-size: 16px;
}

.confirm-buttons {
    display: flex;
    justify-content: center;
    margin-top: 0.8rem;
    gap: 15px;
}

.confirm-btn {
    background: var(--danger-color, #ff4d4d);
    color: white;
    border: 2px solid #cc0000;
    border-radius: 10px;
    padding: 15px 30px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Comfortaa', 'Arial', sans-serif;
    min-width: 11rem;
}

.confirm-btn:hover,
.confirm-btn:active {
    background: #cc0000;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255, 77, 77, 0.5);
}

/* Base Screen Battle Button */
#baseButtons {
    display: flex;
    justify-content: center;
    gap: 15px;
    position: sticky;
    bottom: 0;
    z-index: 5;
    width: 100%;
    box-sizing: border-box;
    background: linear-gradient(to top, var(--bg-dark), transparent);
}

#startBattleFromBaseBtn {
    background: linear-gradient(to bottom, #ff7e5f, #feb47b);
    color: #fff;
    font-weight: bold;
    padding: 12px 25px;
    font-size: 18px;
}

/* Version Info Styles */
.version-info {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 1000;
    text-align: right;
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 300;
    line-height: 1.2;
    pointer-events: none;
    user-select: none;
    opacity: 0.7;
}

.version-number {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.copyright {
    font-size: 10px;
    color: var(--text-muted);
}



/* Hide version info when loading screen is active */
#loadingScreen.active ~ .version-info {
    display: none;
}

/* ===== TEMPLATE SYSTEM STYLES ===== */

/* Templates container - hidden by default */
#templates {
    display: none !important;
}

/* Notification System */
#notificationContainer {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    pointer-events: none;
    max-width: 90%;
}

.notification {
    margin-bottom: 10px;
    padding: 12px 20px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(-20px);
    animation: slideInFadeIn 0.3s ease-out forwards;
    transition: all 0.3s ease-out;
}

.notification.info {
    background: rgba(74, 158, 255, 0.9);
    border: 1px solid var(--primary-blue);
}

.notification.success {
    background: rgba(68, 255, 68, 0.9);
    border: 1px solid var(--color-success);
}

.notification.warning {
    background: rgba(255, 153, 68, 0.9);
    border: 1px solid var(--color-warning);
}

.notification.error {
    background: rgba(255, 68, 68, 0.9);
    border: 1px solid var(--color-danger);
}

.notification.battle-notification {
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #ff7e5f;
    border-radius: 15px;
    padding: 20px 30px;
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 0 30px rgba(255, 126, 95, 0.5);
    animation: battleNotificationFadeInOut 2s ease-out forwards;
}

.notification.battle-notification .battle-notification-content {
    display: block;
}

.notification.fade-out {
    animation: slideOutFadeOut 0.3s ease-out forwards;
}

@keyframes slideInFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOutFadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

@keyframes battleNotificationFadeInOut {
    0% { 
        opacity: 0; 
        transform: translate(-50%, -50%) scale(0.8); 
    }
    15% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1.05); 
    }
    20% { 
        transform: translate(-50%, -50%) scale(1); 
    }
    90% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1); 
    }
    100% { 
        opacity: 0; 
        transform: translate(-50%, -50%) scale(0.8); 
    }
}

/* Damage Text System */
#damageTextContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

.damage-text {
    position: absolute;
    font-size: 18px;
    font-weight: bold;
    color: #ff4444;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    animation: damageTextFloat 1s ease-out forwards;
    pointer-events: none;
    z-index: 1000;
}

.damage-text.heal-text {
    color: #44ff44;
}

.damage-text .damage-value {
    display: block;
}

@keyframes damageTextFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    50% {
        opacity: 1;
        transform: translateY(-30px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateY(-60px) scale(0.8);
    }
}

/* Flash Effects System */
#flashEffectsContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 998;
}

.skill-cast-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    animation: flashEffect 0.5s ease-out forwards;
    pointer-events: none;
}

@keyframes flashEffect {
    0% {
        opacity: 0;
    }
    50% {
        opacity: 0.7;
    }
    100% {
        opacity: 0;
    }
}

/* Skill Selection Enhancement */
.skill-option {
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--primary-blue);
    border-radius: 12px;
    padding: 20px;
    margin: 10px 0;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.skill-option:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-blue);
    transform: scale(1.02);
}

.skill-option.selected {
    background: rgba(74, 158, 255, 0.2);
    border-color: var(--accent-blue);
    transform: scale(1.05);
}

.skill-option.processing {
    opacity: 0.6;
    transform: scale(0.95);
    pointer-events: none;
}

.skill-option .skill-emoji {
    font-size: 48px;
    margin-bottom: 10px;
    display: block;
}

.skill-option .skill-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.skill-option .skill-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.skill-option .skill-type {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 0;
}

.skill-option .skill-type-value {
    color: var(--primary-blue);
    font-weight: 500;
}

/* Screen shake animation for skill effects */
@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-2px, -1px); }
    20% { transform: translate(-1px, 1px); }
    30% { transform: translate(1px, -2px); }
    40% { transform: translate(-1px, 2px); }
    50% { transform: translate(2px, -1px); }
    60% { transform: translate(-2px, 1px); }
    70% { transform: translate(1px, -1px); }
    80% { transform: translate(-1px, -2px); }
    90% { transform: translate(2px, 1px); }
}

.screen-shake {
    animation: screenShake 0.5s ease-in-out;
}

/* Bonus Message System */
.bonus-message {
    color: #ffdd44;
    font-size: 1.2em;
    font-weight: bold;
    margin: 10px 0;
    text-align: center;
    padding: 5px;
    border-radius: 5px;
    background-color: rgba(0, 0, 0, 0.5);
    border: 1px solid #ffdd44;
    animation: bonusMessageGlow 2s ease-in-out infinite;
}

.bonus-message-content {
    display: block;
}

@keyframes bonusMessageGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(255, 221, 68, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 221, 68, 0.6);
    }
}

