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

body {
    font-family: 'Exo 2', sans-serif;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 44, 190, 0.4) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 48, 0.4) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 44, 190, 0.2) 0%, transparent 50%),
        linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 25%, #16213e 50%, #0a0a0a 100%);
    background-attachment: fixed;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
    color: #ffffff;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.1), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.1), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.1), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.1), transparent),
        radial-gradient(2px 2px at 160px 30px, rgba(255,255,255,0.1), transparent);
    background-repeat: repeat;
    background-size: 200px 200px;
    animation: particleFloat 20s linear infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes particleFloat {
    0% { transform: translateY(0px) rotate(0deg); }
    100% { transform: translateY(-200px) rotate(360deg); }
}

#wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    text-align: center;
    font-size: clamp(18px, 3vw, 32px);
    font-weight: 900;
    color: #ffffff;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.8) 0%, rgba(26, 26, 46, 0.9) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 8px 15px;
    text-shadow: 
        0 0 10px rgba(120, 44, 190, 0.8),
        0 0 20px rgba(120, 44, 190, 0.6),
        2px 2px 4px rgba(0, 0, 0, 0.8);
    border-bottom: 2px solid rgba(120, 44, 190, 0.3);
    font-family: 'Orbitron', 'Exo 2', sans-serif;
}

#header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(120, 44, 190, 0.1), transparent);
    animation: headerGlow 3s ease-in-out infinite alternate;
}

@keyframes headerGlow {
    0% { opacity: 0.3; }
    100% { opacity: 0.7; }
}

#turret {
    display: none;
}

#message {
    display: none;
}

#container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, rgba(26, 26, 46, 0.3) 0%, rgba(0, 0, 0, 0.8) 100%);
    z-index: 10;
    padding: 0;
    padding-top: 70px;
    padding-bottom: 40px; 
    box-sizing: border-box;
    gap: 0; 
}

#gameCanvasWrapper {
    position: relative;
    max-height: calc(100vh - 110px); 
    max-width: calc(100vw - 320px); 
    aspect-ratio: 8 / 7;
    
    width: min(calc(100vw - 320px), calc((100vh - 110px) * 8/7));
    height: min(calc(100vh - 110px), calc((100vw - 320px) * 7/8));
    
    transform-origin: center center;
    transition: transform 0.3s ease;
}

/* Game Canvas Wrapper positioning */

#gameCanvas {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a237e, #283593, #3949ab);
    border-radius: 15px;
    box-shadow: 
        0 0 30px rgba(120, 44, 190, 0.4),
        0 0 60px rgba(57, 73, 171, 0.3),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(120, 44, 190, 0.5);
    overflow: hidden;
}

/* Scale the actual p5.js canvas element to fit the container */
#gameCanvas canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    object-fit: contain; /* Maintain aspect ratio while scaling */
}

#gameCanvas::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, 
        rgba(120, 44, 190, 0.6),
        rgba(57, 73, 171, 0.6),
        rgba(255, 119, 48, 0.6),
        rgba(120, 44, 190, 0.6)
    );
    border-radius: 17px;
    z-index: -1;
    animation: borderGlow 4s linear infinite;
    opacity: 0.7;
}

@keyframes borderGlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Footer - Modern minimal design */
#footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.8) 0%, rgba(26, 26, 46, 0.9) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    padding: 8px;
    border-top: 1px solid rgba(120, 44, 190, 0.3);
    z-index: 1000;
    font-family: 'Exo 2', sans-serif;
}

#footer a {
    color: #7c2cbf;
    text-decoration: none;
    transition: color 0.3s ease;
}

#footer a:hover {
    color: #ff7730;
    text-shadow: 0 0 5px rgba(255, 119, 48, 0.5);
}

/* Game Menu - Positioned to the right of canvas */
#gameMenu {
    position: relative;
    width: 300px;
    height: 100%;
    background: linear-gradient(145deg, 
        rgba(26, 26, 46, 0.95) 0%, 
        rgba(20, 20, 30, 0.98) 50%,
        rgba(16, 16, 26, 0.95) 100%
    );
    backdrop-filter: blur(20px) saturate(180%);
    color: #fff;
    border-radius: 15px;
    box-shadow: 
        10px 0 30px rgba(0, 0, 0, 0.5),
        inset -1px 0 1px rgba(120, 44, 190, 0.2);
    z-index: 200;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 15px 25px;
    box-sizing: border-box;
    font-family: 'Exo 2', sans-serif;
    border-left: 2px solid rgba(120, 44, 190, 0.4);
}

/* Add a subtle animated border to the game menu */
#gameMenu::before {
    content: '';
    position: absolute;
    top: 0;
    left: -2px;
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg, 
        transparent,
        rgba(120, 44, 190, 0.8),
        rgba(255, 119, 48, 0.8),
        rgba(120, 44, 190, 0.8),
        transparent
    );
    animation: menuBorderFlow 3s ease-in-out infinite alternate;
}

@keyframes menuBorderFlow {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

#menuInfo {
    display: flex;
    flex-direction: column;
    gap: 15px;
    color: #ddd;
    background: linear-gradient(145deg, 
        rgba(40, 40, 60, 0.8) 0%, 
        rgba(30, 30, 40, 0.9) 100%
    );
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 5px;
    border: 1px solid rgba(120, 44, 190, 0.3);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

#menuInfo img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

#menuInfo h2 {
    font-family: 'Russo One', sans-serif;
    font-size: 18px;
    padding-left: 15px;
    margin: 0;
    color: #FFD700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
}

.menu-stat {
    display: flex;
    align-items: center;
    gap: 10px; 
    flex-direction: row; 
    justify-content: flex-start;
}

#Money, #Health, #Wave {
    font-size: 20px;
    font-weight: 700;
    color: white;
    font-family: 'Russo One', sans-serif;
    margin-left: 5px; 
}

#menuButtons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
}

#menuButtons button {
    height: 65px;
    width: 100%;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Exo 2', sans-serif;
    text-transform: uppercase;
    border: none;
    background: linear-gradient(145deg, 
        rgba(120, 44, 190, 0.7) 0%, 
        rgba(80, 30, 130, 0.8) 50%,
        rgba(60, 20, 100, 0.9) 100%
    );
    color: white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
    box-shadow: 
        0 4px 15px rgba(120, 44, 190, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.4),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    letter-spacing: 1px;
    border: 1px solid rgba(120, 44, 190, 0.4);
    position: relative;
    overflow: hidden;
}

#menuButtons button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.2), 
        transparent
    );
    transition: left 0.5s ease;
}

#menuButtons button:hover::before {
    left: 100%;
}

#menuButtons button:hover {
    transform: translateY(-2px);
    background: linear-gradient(145deg, 
        rgba(140, 54, 210, 0.8) 0%, 
        rgba(100, 40, 150, 0.9) 50%,
        rgba(80, 30, 120, 1) 100%
    );
    box-shadow: 
        0 6px 20px rgba(120, 44, 190, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.5),
        inset 0 1px 1px rgba(255, 255, 255, 0.2);
    border-color: rgba(140, 54, 210, 0.6);
}

#menuButtons button:active {
    transform: translateY(0px);
    transition: transform 0.1s ease;
}

#menuButtons button:hover {
    transform: translateY(-3px);
    background: linear-gradient(145deg, #007acc, #005f99);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
    border-color: rgba(0, 122, 204, 0.5);
}

#menuButtons button:active {
    transform: translateY(1px);
}

.autoStartToggle {
    display: block;
    font-size: 12px;
    opacity: 0.8;
    font-family: 'Exo 2', sans-serif;
    margin-top: 5px;
    color: #FFD700;
}

.hoverButton {
    position: relative;
    background-color: transparent;
    color: white;
    border: 2px solid #007acc;
    padding: 10px 20px;
    font-size: 18px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.hoverButton:hover {
    background-color: #005f99;
}

/* Popup and Modal Styles */
.popupMessage {
    position: absolute;
    top: 50%;
    left: 50%;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 18px;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.3s, opacity 0.3s ease;
    z-index: 10;
}

#healthPopup, #moneypopup, #bossWarningPopup, #minionWarningPopup {
    position: fixed;
    left: 55%;
    padding: 11px 12px;
    width: 90px;
    border-radius: 15px;
    font-size: 18px;
    font-weight: bold;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    transform: translateX(-50%) translateY(20px);
}

#healthPopup {
    top: 95px;
    background: linear-gradient(45deg, #eb6685, #f05d44);
    color: white;
}

#moneypopup {
    top: 30px; 
    background: linear-gradient(45deg, #eed12c, #FFA500);
    color: white;
}

#bossWarningPopup {
    top: 160px;
    left: 50%;
    width:100px;
    background: linear-gradient(45deg, #100846, #262ba8);
    color: white;
    font-size: 16px;
}

#minionWarningPopup {
    top: 210px;
    left: 50%;
    width: 140px;
    background: linear-gradient(45deg, #ff6600, #ffaa00);
    color: white;
    font-size: 16px;
    animation: pulseWarning 0.6s infinite alternate;
}

@keyframes pulseWarning {
    0% { transform: translateX(-50%) translateY(20px) scale(1); }
    100% { transform: translateX(-50%) translateY(20px) scale(1.05); }
}

#healthPopup.show, 
#moneypopup.show, 
#bossWarningPopup.show,
#minionWarningPopup.show {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    animation: popup 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

#healthPopup:hover,
#moneypopup:hover,
#bossWarningPopup:hover {
    transform: translateX(-50%) translateY(-5px);
}

.popupMenu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(145deg, rgba(40, 40, 40, 0.95), rgba(25, 25, 25, 0.95));
    backdrop-filter: blur(15px);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    min-width: 300px;
}

.popupMenu button {
    width: 100%;
    padding: 15px 20px;
    margin: 10px 0;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    background: linear-gradient(145deg, #64b5f6, #2196f3);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.popupMenu button:hover {
    background: linear-gradient(145deg, #2196f3, #1976d2);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(33, 150, 243, 0.3);
}

#openTutorialButton {
    position: fixed;
    bottom: 60px;
    left: 30px;
    min-width: 110px;
    height: 38px;
    padding: 0 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(30, 10, 60, 0.85) 0%, rgba(120, 44, 190, 0.18) 100%),
                linear-gradient(120deg, rgba(255, 119, 48, 0.08) 0%, rgba(120, 44, 190, 0.10) 100%);
    border: 2px solid rgba(120, 44, 190, 0.6);
    border-radius: 22px;
    box-shadow:
        0 0 0 2px rgba(120, 44, 190, 0.10),
        0 0 12px 2px rgba(120, 44, 190, 0.18),
        0 2px 8px rgba(0, 0, 0, 0.18),
        inset 0 1px 6px rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1100;
    overflow: hidden;
    font-size: 1.15rem;
    font-family: 'Orbitron', 'Exo 2', sans-serif;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    backdrop-filter: blur(10px) saturate(180%);
}
#openTutorialButton::before {
    content: '';
    position: absolute;
    top: -40%;
    left: -40%;
    width: 180%;
    height: 180%;
    background: conic-gradient(from 0deg, 
        rgba(255, 119, 48, 0.10) 0deg, 
        rgba(120, 44, 190, 0.13) 90deg, 
        rgba(255, 255, 255, 0.06) 180deg, 
        rgba(120, 44, 190, 0.13) 270deg, 
        rgba(255, 119, 48, 0.10) 360deg
    );
    filter: blur(1.5px);
    animation: tutorialSpinGlow 4s linear infinite;
    opacity: 0.5;
    z-index: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
#openTutorialButton::after {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    border-radius: 18px;
    background: linear-gradient(120deg, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0.02) 100%);
    opacity: 0.5;
    z-index: 1;
    pointer-events: none;
}
#openTutorialButton:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow:
        0 0 0 6px rgba(120, 44, 190, 0.13),
        0 0 18px 6px rgba(255, 119, 48, 0.13),
        0 8px 18px rgba(120, 44, 190, 0.18),
        0 4px 12px rgba(0, 0, 0, 0.22),
        inset 0 2px 8px rgba(255, 255, 255, 0.13);
    border-color: rgba(255, 119, 48, 0.7);
    background: linear-gradient(135deg, rgba(140, 54, 210, 0.92) 0%, rgba(100, 40, 150, 0.92) 100%);
    color: #FFD700;
}
#openTutorialButton:active {
    transform: translateY(0px) scale(0.98);
    transition: transform 0.1s;
}
/* Remove .tutorial-icon styles since we use text now */
.tutorial-icon { display: none !important; }

@keyframes tutorialPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.13); }
}
@keyframes tutorialSpinGlow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Leaderboard Button */
#openLeaderboardBtn {
    position: fixed;
    bottom: 13cap;
    right: 50px;
    padding: 15px 25px;
    background: linear-gradient(135deg, #5c6bc0, #3949ab);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 100;
}

#openLeaderboardBtn:before {
    content: "🏆";
    font-size: 20px;
}

#openLeaderboardBtn:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 25px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #3949ab, #283593);
}

/* Leaderboard Popup */
#leaderboardPopup {
    width: 800px;
    max-height: 80vh;
    background: linear-gradient(145deg, #1a237e, #121858);
    border-radius: 20px;
    overflow: hidden;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

#leaderboardPopup.show {
    display: block;
}

#leaderboardPopup .popup-header {
    background: linear-gradient(90deg, #38428f, #242c7e);
    padding: 20px 30px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#leaderboardPopup .popup-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 28px;
    color: white;
}

#leaderboardPopup .popup-content {
    padding: 30px;
    color: white;
}

#addEntryButton {
    width: 100%;
    max-width: 250px;
    padding: 12px 25px;
    margin: 0;
    background: linear-gradient(135deg, #64b5f6, #2196f3);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

#addEntryButton:hover {
    background: linear-gradient(135deg, #2196f3, #1976d2);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(33, 150, 243, 0.3);
}

#leaderboardContents {
    padding: 15px;
    max-height: calc(80vh - 200px);
    overflow-y: auto;
    display: grid;
    gap: 15px;
}

.leaderboard-entry {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 15px;
    transition: transform 0.2s ease;
}

.leaderboard-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    width: 300px;
    margin: 0 auto 20px auto;
}

.leaderboard-entry:hover {
    transform: translateX(5px);
    background: rgba(255, 255, 255, 0.15);
}

.entry-rank {
    font-size: 24px;
    font-weight: bold;
    color: #64b5f6;
}

.entry-name {
    font-size: 18px;
}

.entry-score {
    font-weight: bold;
    color: #81c784;
}

.entry-date {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    min-width: 100px;
    text-align: right;
}

.leaderboard-filters {
    width: 100%;
    max-width: 250px;
    margin: 0;
    position: relative;
}

#difficultyFilter {
    width: 100%;
    padding: 12px 20px;
    font-size: 15px;
    background: linear-gradient(145deg, #283593, #1a237e);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.leaderboard-loading {
    text-align: center;
    padding: 20px;
    color: rgba(255,255,255,0.7);
}

.error-message {
    color: #ff6b6b;
    text-align: center;
    padding: 20px;
}

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

.trophy-icon {
    font-size: 2em;
    margin-bottom: 10px;
    display: inline-block;
    animation: bounce 1s infinite;
}

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

/* Difficulty Selection Screen - Enhanced */
.difficulty-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: 
    radial-gradient(circle at 30% 20%, rgba(120, 44, 190, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(255, 119, 48, 0.3) 0%, transparent 50%),
    linear-gradient(135deg, rgba(0,0,0,0.95) 0%, rgba(26, 26, 46, 0.98) 100%);
  backdrop-filter: blur(20px) saturate(180%);
  z-index: 1000;
  overflow: hidden;
}

.difficulty-screen::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.1), transparent),
    radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.1), transparent),
    radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.1), transparent);
  background-repeat: repeat;
  background-size: 200px 200px;
  animation: particleFloat 30s linear infinite;
  pointer-events: none;
}

.difficulty-screen .title {
  font-family: 'Orbitron', 'Exo 2', sans-serif;
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 900;
  letter-spacing: 6px;
  color: #ffffff;
  text-shadow: 
    0 0 20px rgba(120, 44, 190, 0.8),
    0 0 40px rgba(120, 44, 190, 0.6),
    2px 2px 8px rgba(0, 0, 0, 0.8);
  margin-bottom: 3rem;
  text-align: center;
  animation: titlePulse 3s ease-in-out infinite alternate;
}

@keyframes titlePulse {
  0% { 
    text-shadow: 
      0 0 20px rgba(120, 44, 190, 0.8),
      0 0 40px rgba(120, 44, 190, 0.6),
      2px 2px 8px rgba(0, 0, 0, 0.8);
  }
  100% { 
    text-shadow: 
      0 0 30px rgba(255, 119, 48, 0.8),
      0 0 60px rgba(255, 119, 48, 0.6),
      2px 2px 8px rgba(0, 0, 0, 0.8);
  }
}

.button-container {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 90vw;
}

.difficulty-btn {
  padding: 1.5rem 3rem;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 3px;
  border: none;
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-transform: uppercase;
  color: white;
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
  font-family: 'Exo 2', sans-serif;
  min-width: 200px;
}

.difficulty-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.3), 
    transparent
  );
  transition: left 0.6s ease;
}

.difficulty-btn:hover::before {
  left: 100%;
}

.difficulty-btn:hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.4);
}

.difficulty-btn.easy {
  background: linear-gradient(145deg, 
    rgba(76, 175, 80, 0.9) 0%, 
    rgba(69, 160, 73, 0.95) 100%
  );
  box-shadow: 0 8px 20px rgba(76, 175, 80, 0.3);
}

.difficulty-btn.easy:hover {
  background: linear-gradient(145deg, 
    rgba(76, 175, 80, 1) 0%, 
    rgba(69, 160, 73, 1) 100%
  );
  box-shadow: 0 15px 35px rgba(76, 175, 80, 0.4);
}

.difficulty-btn.normal {
  background: linear-gradient(145deg, 
    rgba(255, 152, 0, 0.9) 0%, 
    rgba(245, 124, 0, 0.95) 100%
  );
  box-shadow: 0 8px 20px rgba(255, 152, 0, 0.3);
}

.difficulty-btn.normal:hover {
  background: linear-gradient(145deg, 
    rgba(255, 152, 0, 1) 0%, 
    rgba(245, 124, 0, 1) 100%
  );
  box-shadow: 0 15px 35px rgba(255, 152, 0, 0.4);
}

.difficulty-btn.hard {
  background: linear-gradient(145deg, 
    rgba(244, 67, 54, 0.9) 0%, 
    rgba(211, 47, 47, 0.95) 100%
  );
  box-shadow: 0 8px 20px rgba(244, 67, 54, 0.3);
}

.difficulty-btn.hard:hover {
  background: linear-gradient(145deg, 
    rgba(244, 67, 54, 1) 0%, 
    rgba(211, 47, 47, 1) 100%
  );
  box-shadow: 0 15px 35px rgba(244, 67, 54, 0.4);
}

.help-text {
    position: absolute;
    bottom: 15%;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9em;
    text-align: center;
    margin-top: 20px;
    font-style: italic;
}

#cancelSelectionOverlay {
    position: absolute; 
    top: 0; 
    left: 0; 
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, 
        rgba(120, 44, 190, 0.3) 0%, 
        rgba(80, 30, 130, 0.4) 50%,
        rgba(60, 20, 100, 0.5) 100%
    );
    backdrop-filter: blur(10px) saturate(180%);
    z-index: 1000;
    display: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    justify-content: center;
    align-items: center;
    border-left: 2px solid rgba(120, 44, 190, 0.6);
    border-radius: 15px;
}

#cancelSelectionOverlay.active {
    display: flex;
    pointer-events: auto;
    animation: overlaySlideIn 0.3s ease-out;
}

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

#cancelSelectionOverlay.hover-red {
    background: linear-gradient(145deg, 
        rgba(244, 67, 54, 0.4) 0%, 
        rgba(211, 47, 47, 0.5) 50%,
        rgba(183, 28, 28, 0.6) 100%
    );
    border-left-color: rgba(244, 67, 54, 0.8);
}

#gameMenu.red-blur {
    filter: blur(2px) brightness(0.8);
    background: linear-gradient(145deg, 
        rgba(244, 67, 54, 0.2) 0%, 
        rgba(26, 26, 46, 0.95) 50%,
        rgba(16, 16, 26, 0.95) 100%
    );
    border-left: 2px solid rgba(244, 67, 54, 0.6);
    transition: all 0.3s ease;
}

.overlay-content {
    color: white;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    text-shadow: 
        0 0 10px rgba(120, 44, 190, 0.8),
        2px 2px 4px rgba(0, 0, 0, 0.8);
    padding: 25px;
    background: linear-gradient(145deg, 
        rgba(26, 26, 46, 0.9) 0%, 
        rgba(20, 20, 30, 0.95) 100%
    );
    border-radius: 15px;
    border: 2px solid rgba(120, 44, 190, 0.6);
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.4),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    animation: overlayContentPulse 2s ease-in-out infinite;
    pointer-events: none;
    font-family: 'Exo 2', sans-serif;
    letter-spacing: 1px;
}

#cancelSelectionOverlay.hover-red .overlay-content {
    color: #ffdddd;
    background: linear-gradient(145deg, 
        rgba(244, 67, 54, 0.8) 0%, 
        rgba(211, 47, 47, 0.9) 100%
    );
    border-color: rgba(255, 119, 119, 0.8);
    text-shadow: 
        0 0 10px rgba(244, 67, 54, 1),
        2px 2px 4px rgba(0, 0, 0, 1);
    box-shadow: 
        0 8px 25px rgba(244, 67, 54, 0.4),
        inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

@keyframes overlayContentPulse {
    0%, 100% {
        opacity: 0.8;
        transform: scale(1);
        box-shadow: 
            0 8px 25px rgba(0, 0, 0, 0.4),
            inset 0 1px 1px rgba(255, 255, 255, 0.1);
    }
    50% {
        opacity: 1;
        transform: scale(1.02);
        box-shadow: 
            0 12px 30px rgba(120, 44, 190, 0.3),
            inset 0 1px 1px rgba(255, 255, 255, 0.2);
    }
}

/* Tooltip Styles */
.tooltip-container {
    position: relative;
    display: inline-block;
}

.tooltip {
    position: absolute;
    bottom: 120%; 
    left: 50%;
    transform: translateX(-50%); 
    width: 300px;
    padding: 20px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 100;
}

.tooltip:after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid rgba(255, 255, 255, 0.1);
}

.tooltip h3 {
    color: #fff;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.tooltip p {
    color: #ddd;
    margin-bottom: 15px;
    font-size: 0.9em;
}

.tooltip ul {
    list-style: none;
    padding: 0;
}

.tooltip li {
    color: #fff;
    margin: 8px 0;
    font-size: 0.9em;
}

.tooltip-container:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

/* Button subtext styles for speed and target mode display */
.button-subtext {
    display: block;
    font-size: 12px;
    opacity: 0.8;
    font-family: 'Exo 2', sans-serif;
    margin-top: 5px;
    color: #FFD700;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

/* Responsive Design for Smaller Screens */
@media screen and (max-width: 768px) {
    #header {
        font-size: clamp(20px, 6vw, 32px);
        padding: 10px 15px;
        letter-spacing: 2px;
        height: 80px; /* Reduced height for mobile */
    }
    
    #container {
        padding-top: 80px; /* Match reduced header height */
        padding-bottom: 40px;
    }
    
    #gameCanvasWrapper {
        /* Use smaller space calculation for mobile, accounting for smaller menu */
        max-height: calc(100vh - 120px); /* 80px header + 40px footer */
        max-width: calc(100vw - 270px); /* Account for 250px menu + 20px margin */
        width: min(calc(100vw - 270px), calc((100vh - 120px) * 8/7));
        height: min(calc(100vh - 120px), calc((100vw - 270px) * 7/8));
    }
    
    #gameMenu {
        width: 250px;
        padding: 15px;
    }
    
    #menuButtons button {
        height: 55px;
        font-size: 14px;
    }
    
    .difficulty-btn {
        padding: 1rem 2rem;
        font-size: 1rem;
        min-width: 150px;
    }
    
    .button-container {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    #openTutorialButton {
        width: 60px;
        height: 60px;
        bottom: 50px;
        left: 20px;
        font-size: 20px;
    }
}

@media screen and (max-width: 480px) {
    #header {
        height: 70px; /* Even smaller for mobile */
    }
    
    #container {
        padding-top: 70px; /* Match smaller header */
        padding-bottom: 40px;
    }
    
    #gameCanvasWrapper {
        /* Use even smaller space calculation for very small screens */
        max-height: calc(100vh - 110px); /* 70px header + 40px footer */
        max-width: calc(100vw - 220px); /* Account for 200px menu + 20px margin */
        width: min(calc(100vw - 220px), calc((100vh - 110px) * 8/7));
        height: min(calc(100vh - 110px), calc((100vw - 220px) * 7/8));
    }
    
    #gameMenu {
        width: 200px;
        padding: 10px;
    }
    
    #menuInfo {
        padding: 15px;
        gap: 10px;
    }
    
    #menuButtons button {
        height: 50px;
        font-size: 12px;
    }
    
    .difficulty-screen .title {
        font-size: clamp(1.5rem, 8vw, 2.5rem);
        margin-bottom: 2rem;
    }
}

/* High DPI Displays */
@media screen and (min-resolution: 2dppx) {
    #gameCanvas {
        image-rendering: crisp-edges;
    }
}

/* Landscape orientation on mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
    #header {
        padding: 5px 15px;
        font-size: clamp(16px, 4vw, 24px);
    }
    
    #container {
        top: 50px; /* Minimal spacing for landscape */
        bottom: 30px;
        padding: 5px;
    }
    
    #gameCanvasWrapper {
        width: min(400px, 70vw, calc(100vh - 90px));
        height: min(400px, 70vw, calc(100vh - 90px));
        transform: scale(0.85); /* Scale down for landscape */
    }
    
    #footer {
        padding: 5px;
        font-size: 12px;
    }
}

/* Ultra-wide screens */
@media screen and (min-width: 2000px) {
    #gameCanvasWrapper {
        transform: scale(1.4);
    }
    
    #gameMenu {
        width: 350px;
        padding: 30px;
    }
    
    #menuButtons button {
        height: 75px;
        font-size: 18px;
    }
}

/* Wave button hover tooltip */
#startWaveButton {
    position: relative;
}

#startWaveButton::after {
    content: attr(data-wave-status);
    position: absolute;
    right: -220px;
    top: 50%;
    transform: translateY(-50%);
    width: 200px;
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 6px;
    text-align: center;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.3s, opacity 0.3s ease;
    z-index: 10000;
    pointer-events: none;
    border: 1px solid rgba(120, 44, 190, 0.3);
}

#startWaveButton:hover::after {
    visibility: visible;
    opacity: 1;
}

/* Wave button text change on hover */
#startWaveButton[data-wave-ready="true"]:hover #waveButtonText {
    display: none;
}

#startWaveButton[data-wave-ready="true"]:hover .autoStartToggle {
    margin-top: 15px;
    transition: margin-top 0.2s ease;
}

#startWaveButton[data-wave-ready="true"]:hover::before {
    content: "Wave Ready";
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: 600;
    color: #4CAF50;
    z-index: 10;
    white-space: nowrap;
}

#startWaveButton[data-wave-ready="false"]:hover #waveButtonText {
    display: none;
}

#startWaveButton[data-wave-ready="false"]:hover .autoStartToggle {
    margin-top: 15px;
    transition: margin-top 0.2s ease;
}

#startWaveButton[data-wave-ready="false"]:hover::before {
    content: "Wave Not Ready";
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: 600;
    color: #f44336;
    z-index: 10;
    white-space: nowrap;
}
