/* Developer and welcome overlays */
#developer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, 
        rgba(138, 43, 226, 0.04) 0%,
        rgba(0, 191, 255, 0.02) 30%,
        rgba(75, 0, 130, 0.03) 60%,
        rgba(0, 0, 0, 0.98) 100%), 
        #000000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 400;
    cursor: pointer;
    opacity: 1;
    transition: opacity 1s ease-in-out;
}

#developer-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

#developer-logo {
    max-width: 90%;
    max-height: 90%;
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

#developer-logo.fade-in {
    opacity: 1;
}

#welcome-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, 
        rgba(138, 43, 226, 0.04) 0%,
        rgba(0, 191, 255, 0.02) 30%,
        rgba(75, 0, 130, 0.03) 60%,
        rgba(0, 0, 0, 0.98) 100%), 
        #000000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 300;
    cursor: default;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease-in-out;
}

#welcome-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

#welcome-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

#welcome-overlay.fade-out-slow {
    opacity: 0;
    pointer-events: none;
    transition: opacity 2s ease-in-out;
}

#welcome-logo {
    max-width: 80%;
    max-height: 80%;
    opacity: 0;
    transition: opacity 3s ease-in-out;
}

#welcome-logo.fade-in {
    opacity: 1;
}

#play-button-container {
    position: absolute;
    bottom: 15%;
    opacity: 0;
    transition: opacity 1s ease-in-out 1.5s;
}

#welcome-overlay.show #play-button-container {
    opacity: 1;
}

#play-button {
    background: none;
    border: none;
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(24px, 4vw, 48px);
    cursor: pointer;
    padding: 20px;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.8), 0 0 16px rgba(197, 138, 255, 0.7);
    transition: text-shadow 0.3s ease;
}

#play-button:hover {
    text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #c58aff, 0 0 40px #c58aff;
}

#play-button span {
    display: inline-block;
    animation: bounce 1.8s infinite ease-in-out;
}

/* Game overlays */
.overlay {
    position: absolute;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex; 
    justify-content: center; 
    align-items: center; 
    flex-direction: column;
    text-align: center; 
    z-index: 100; 
    pointer-events: auto; 
    transition: opacity 0.3s ease;
}

/* Ensure overlays are clickable when not hidden */
.overlay:not(.hidden) {
    pointer-events: auto !important;
}

.overlay:not(.hidden) button {
    pointer-events: auto !important;
}

/* Force all overlay buttons to be clickable */
#pause-overlay:not(.hidden) {
    pointer-events: auto !important;
}

#pause-overlay:not(.hidden) button {
    pointer-events: auto !important;
}

#game-over-overlay:not(.hidden) {
    pointer-events: auto !important;
}

#game-over-overlay:not(.hidden) button {
    pointer-events: auto !important;
}

/* Force specific button clickability - Enhanced */
#resume-button, #pause-return-home-button, #play-again-button, #return-home-button {
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative !important;
    z-index: 1000 !important;
}

/* Ensure game over overlay buttons are always clickable */
#game-over-overlay:not(.hidden) {
    pointer-events: auto !important;
    z-index: 200 !important;
}

#game-over-overlay:not(.hidden) button {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 1001 !important;
    position: relative !important;
}

/* Ensure pause overlay buttons are always clickable */
#pause-overlay:not(.hidden) {
    pointer-events: auto !important;
    z-index: 200 !important;
}

#pause-overlay:not(.hidden) button {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 1001 !important;
    position: relative !important;
}

/* Override any potential blocking elements */
.overlay button:not(.hidden) {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 1001 !important;
}

.overlay h1 { 
    font-size: 3em; 
    margin-bottom: 10px; 
}

.overlay p { 
    font-size: 1.2em; 
    margin-bottom: 20px; 
}

.overlay button {
    padding: 15px 30px; 
    font-size: 1.2em; 
    cursor: pointer; 
    background-color: #4a4a8a;
    border: 2px solid #8a8aff; 
    color: white; 
    border-radius: 10px; 
    margin-top: 20px;
    transition: background-color 0.2s, transform 0.2s;
}

.overlay button:hover { 
    background-color: #6a6aff; 
    transform: scale(1.05); 
}

/* Specific game over buttons */
#play-again-button, #return-home-button {
    padding: 15px 30px; 
    font-size: 1.2em; 
    cursor: pointer; 
    background-color: #4a4a8a;
    border: 2px solid #8a8aff; 
    color: white; 
    border-radius: 10px; 
    margin: 10px;
    transition: background-color 0.2s, transform 0.2s;
    pointer-events: auto; /* Ensure buttons are clickable */
}

#play-again-button:hover, #return-home-button:hover { 
    background-color: #6a6aff; 
    transform: scale(1.05); 
}

/* Pause overlay buttons */
#resume-button, #pause-return-home-button {
    padding: 15px 30px; 
    font-size: 1.2em; 
    cursor: pointer; 
    background-color: #4a4a8a;
    border: 2px solid #8a8aff; 
    color: white; 
    border-radius: 10px; 
    margin: 10px;
    transition: background-color 0.2s, transform 0.2s;
    pointer-events: auto;
}

#resume-button:hover, #pause-return-home-button:hover { 
    background-color: #6a6aff; 
    transform: scale(1.05); 
}

.overlay-logo {
    width: 200px;
    margin-bottom: 20px;
}

/* Specific overlays */
#loading-overlay .loader {
    border: 4px solid #f3f3f3; 
    border-top: 4px solid #8c6aff; 
    border-radius: 50%;
    width: 40px; 
    height: 40px; 
    animation: spin 1s linear infinite;
}

#final-score-details {
    margin: 20px 0;
    text-align: left;
}

#final-score-details p {
    margin: 5px 0;
    font-size: 1.2em;
}

#rating-container {
    margin-top: 20px;
}

.stars {
    font-size: 2em;
    cursor: pointer;
}

.star {
    color: #c58aff;
    transition: color 0.2s;
}

.star:hover, .star.filled {
    color: #ffff00;
}

#rating-thanks {
    margin-top: 10px;
    color: #d1c4e9;
    transition: opacity 0.3s;
}

.volume-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    width: 80%;
}

.volume-control label {
    margin-right: 10px;
}

.volume-control input[type="range"] {
    width: 100%;
}

/* Danger overlay */
#danger-overlay {
    position: absolute;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    pointer-events: none;
    z-index: 90;
    box-shadow: inset 0 0 150px 50px rgba(255, 0, 0, 0.35);
}

#danger-overlay.active {
    animation: pulse-danger 2s infinite ease-in-out;
}

#danger-overlay.wave-alert {
    animation: danger-wave 0.45s steps(2, jump-none) infinite;
    box-shadow: inset 0 0 220px 70px rgba(255, 60, 60, 0.55);
}
