.message-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: rgba(10, 10, 30, 0.95);
    border: 2px solid rgba(150, 180, 255, 0.5);
    border-radius: 20px;
    padding: clamp(20px, 5vw, 40px);
    max-width: 500px;
    width: 90%;
    box-shadow: 0 0 50px rgba(100, 150, 255, 0.5),
        0 0 100px rgba(50, 100, 200, 0.3);
    z-index: 1000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.message-popup.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.message-popup::before {
    content: '🌌';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(24px, 6vw, 40px);
    animation: float 2s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-10px);
    }
}

.message-text {
    font-family: 'ME1-Font-Dialogue', serif;
    color: #fff;
    font-size: clamp(16px, 4vw, 20px);
    line-height: 1.6;
    text-align: center;
    margin-bottom: clamp(20px, 4vw, 30px);
    text-shadow: 0 0 10px rgba(150, 180, 255, 0.5);
}

.close-btn {
    font-family: 'ME1-Font-Dialogue', serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: clamp(10px, 2vw, 12px) clamp(20px, 4vw, 30px);
    border-radius: 25px;
    font-size: clamp(14px, 3vw, 16px);
    cursor: pointer;
    display: block;
    margin: 0 auto;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    touch-action: manipulation;
}

.close-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay.show {
    opacity: 1;
    pointer-events: all;
}

.final-button {
    font-family: 'ME1-Font-Dialogue', serif;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    padding: clamp(12px, 2.5vw, 16px) clamp(24px, 5vw, 40px);
    border-radius: 50px;
    font-size: clamp(16px, 3.5vw, 20px);
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 10px 40px rgba(245, 87, 108, 0.6);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 1s ease, visibility 0s linear 1s;
    touch-action: manipulation;
}

.final-button.show {
    opacity: 1;
    pointer-events: all;
    visibility: visible;
    transition: opacity 1s ease, visibility 0s linear 0s;
    animation: pulse 2s ease-in-out infinite;
}

.final-button:hover {
    transform: translateX(-50%) translateY(-5px);
    box-shadow: 0 15px 50px rgba(245, 87, 108, 0.8);
}

.final-button.launching {
    animation: rocketLaunch 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    pointer-events: none;
}

@keyframes rocketLaunch {
    0% {
        transform: translateX(-50%) translateY(0) rotate(0deg) scale(1);
        opacity: 1;
    }

    20% {
        transform: translateX(-50%) translateY(-50px) rotate(-5deg) scale(1.1);
    }

    40% {
        transform: translateX(-50%) translateY(-100px) rotate(5deg) scale(1.05);
    }

    100% {
        transform: translateX(-50%) translateY(-150vh) rotate(15deg) scale(0.8);
        opacity: 0;
    }
}

/* Rope that connects button to final message */
.final-rope {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 0;
    background: linear-gradient(180deg,
            rgba(139, 90, 43, 0.9) 0%,
            rgba(160, 110, 60, 0.8) 50%,
            rgba(139, 90, 43, 0.9) 100%);
    box-shadow: 0 0 10px rgba(139, 90, 43, 0.5);
    z-index: 899;
    opacity: 0;
    transform-origin: bottom center;
}

.final-rope.show {
    animation: ropeExtend 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes ropeExtend {
    0% {
        height: 0;
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    100% {
        height: 100vh;
        opacity: 1;
    }
}

.final-rope.pull {
    animation: ropePull 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes ropePull {
    0% {
        height: 100vh;
    }

    100% {
        height: 50vh;
    }
}

/* Final Message Box */
.final-message-box {
    position: fixed;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(10, 10, 30, 0.98) 0%, rgba(30, 20, 50, 0.98) 100%);
    border: 3px solid rgba(240, 147, 251, 0.8);
    border-radius: 30px;
    padding: clamp(30px, 6vw, 60px);
    max-width: 700px;
    width: 90%;
    box-shadow:
        0 0 80px rgba(240, 147, 251, 0.6),
        0 0 120px rgba(245, 87, 108, 0.4),
        inset 0 0 100px rgba(240, 147, 251, 0.1);
    z-index: 1500;
    opacity: 0;
}

.final-message-box.show {
    animation: messageBoxDrop 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) 1.5s forwards;
}

@keyframes messageBoxDrop {
    0% {
        top: -100%;
        opacity: 0;
        transform: translateX(-50%) rotate(-5deg);
    }

    60% {
        top: 52%;
        opacity: 1;
    }

    80% {
        top: 48%;
    }

    100% {
        top: 50%;
        opacity: 1;
        transform: translateX(-50%) translateY(-50%) rotate(0deg);
    }
}

.final-message-box::before {
    content: '🚀';
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(40px, 8vw, 60px);
    animation: rocketSpin 2s linear infinite;
}

@keyframes rocketSpin {
    0% {
        transform: translateX(-50%) rotate(0deg);
    }

    100% {
        transform: translateX(-50%) rotate(360deg);
    }
}

.final-message-box .final-message-content {
    font-family: 'ME123-Font-Title', serif;
    color: #fff;
    font-size: clamp(24px, 5vw, 36px);
    line-height: 1.6;
    text-align: center;
    margin-bottom: clamp(30px, 5vw, 40px);
    text-shadow:
        0 0 20px rgba(240, 147, 251, 0.8),
        0 0 40px rgba(245, 87, 108, 0.5);
    background: linear-gradient(135deg,
            #f093fb 0%,
            #f5576c 25%,
            #ffd54f 50%,
            #66bb6a 75%,
            #667eea 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: rainbowShift 5s linear infinite;
}

.final-message-box .confetti-emoji {
    font-size: clamp(30px, 6vw, 50px);
    display: inline-block;
    animation: confettiPop 0.6s ease-out;
}

@keyframes confettiPop {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }

    50% {
        transform: scale(1.3) rotate(180deg);
    }

    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

.final-message-box .celebrate-btn {
    font-family: 'ME1-Font-Dialogue', serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: clamp(14px, 3vw, 18px) clamp(30px, 6vw, 50px);
    border-radius: 50px;
    font-size: clamp(16px, 3.5vw, 22px);
    font-weight: bold;
    cursor: pointer;
    display: block;
    margin: 0 auto;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
    touch-action: manipulation;
}

.final-message-box .celebrate-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.7);
}

/* Backdrop overlay for final message */
.final-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1400;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
}

.final-overlay.show {
    opacity: 1;
    pointer-events: all;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 10px 40px rgba(245, 87, 108, 0.6);
        transform: translateX(-50%) scale(1);
    }

    50% {
        box-shadow: 0 10px 60px rgba(245, 87, 108, 0.9);
        transform: translateX(-50%) scale(1.05);
    }
}

/* Bottom Right Controls Container */
.bottom-right-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1100;
    /* Higher than final-button */
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

/* Help/How to Play Dropdown */
.help-container {
    position: relative;
}

.help-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 150, 100, 0.2);
    border: 2px solid rgba(255, 180, 150, 0.5);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 150, 100, 0.3);
}

.help-toggle:hover {
    background: rgba(255, 150, 100, 0.4);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(255, 150, 100, 0.5);
}

.help-toggle .help-icon {
    font-size: 24px;
}

.help-dropdown {
    position: absolute;
    bottom: 60px;
    right: 0;
    background: rgba(10, 10, 30, 0.95);
    border: 2px solid rgba(255, 180, 150, 0.5);
    border-radius: 15px;
    padding: 20px;
    min-width: 280px;
    max-width: 320px;
    box-shadow: 0 0 30px rgba(255, 150, 100, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.help-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: all;
}

.help-dropdown-content h3 {
    font-family: 'ME123-Font-Title', sans-serif;
    color: #fff;
    font-size: 18px;
    margin: 0 0 15px 0;
    text-align: center;
    text-shadow: 0 0 10px rgba(255, 180, 150, 0.5);
}

.help-instructions {
    font-family: 'ME1-Font-Dialogue', serif;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    line-height: 1.8;
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-instructions li {
    margin-bottom: 12px;
    display: block;
    text-indent: -1.5em;
    padding-left: 1.5em;
}

.help-instructions li:last-child {
    margin-bottom: 0;
}

.help-instructions strong {
    color: rgba(255, 200, 150, 1);
    text-shadow: 0 0 5px rgba(255, 180, 150, 0.3);
}

/* Audio Controls Dropdown */
.audio-controls-container {
    position: relative;
}

.audio-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(100, 150, 255, 0.2);
    border: 2px solid rgba(150, 180, 255, 0.5);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(100, 150, 255, 0.3);
}

.audio-toggle:hover {
    background: rgba(100, 150, 255, 0.4);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(100, 150, 255, 0.5);
}

.audio-toggle .audio-icon {
    font-size: 24px;
}

.audio-dropdown {
    position: absolute;
    bottom: 60px;
    right: 0;
    background: rgba(10, 10, 30, 0.95);
    border: 2px solid rgba(150, 180, 255, 0.5);
    border-radius: 15px;
    padding: 20px;
    min-width: 250px;
    box-shadow: 0 0 30px rgba(100, 150, 255, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.audio-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: all;
}

.audio-dropdown-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Music Toggle Button Inside Dropdown */
.music-toggle-btn {
    font-family: 'ME1-Font-Dialogue', serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    width: 100%;
}

.music-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.music-toggle-btn.playing {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    animation: pulse-music 2s infinite;
}

.music-toggle-btn .music-icon {
    font-size: 18px;
}

.music-toggle-btn .music-label {
    font-weight: 500;
}

@keyframes pulse-music {

    0%,
    100% {
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    }

    50% {
        box-shadow: 0 4px 25px rgba(245, 87, 108, 0.8);
    }
}

/* Volume Controls */
.volume-control {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.volume-control label {
    font-family: 'ME1-Font-Dialogue', serif;
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 0 5px rgba(150, 180, 255, 0.5);
}

.volume-icon {
    font-size: 16px;
}

.volume-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.volume-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: rgba(150, 180, 255, 0.2);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    margin: 0;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.6);
    transition: all 0.3s ease;
    margin-top: -5px;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.8);
}

.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.6);
    transition: all 0.3s ease;
}

.volume-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.8);
}

.volume-slider::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: rgba(150, 180, 255, 0.2);
}

.volume-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: rgba(150, 180, 255, 0.2);
}

.volume-value {
    font-family: 'ME1-Font-Dialogue', serif;
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    min-width: 45px;
    text-align: right;
    font-weight: 500;
    line-height: 1;
}