/* Reset */
:root {
    color-scheme: only light;
    /* Force Light Mode rendering */
    forced-color-adjust: none;
    /* Prevent browser from overriding colors */
    -webkit-tap-highlight-color: transparent;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
    /* Hack: Use Image instead of Color. Browsers rarely invert images in Dark Mode. */
    background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=');
    background-repeat: repeat;
    background-color: transparent !important;
    forced-color-adjust: none;
    isolation: isolate;
}

/* Protect Canvas from Filters */
canvas {
    filter: none !important;
    /* Block injected filters */
    -webkit-filter: none !important;
    forced-color-adjust: none;
    isolation: isolate;
    /* Create local stacking context */
    mix-blend-mode: normal !important;
    /* Force normal blending */
}

/* Whale Browser Specific Fixes */
.is-whale canvas {
    /* CSS Filters caused color distortion. 
       We now handle brightness boost inside JS (perfectGasEffect.js) 
       by adjusting HSL values directly. */
    filter: none !important;
    -webkit-filter: none !important;
}

/* 
   Pure CSS Background (Safety Net)
*/
#background-layer {
    position: absolute;
    inset: 0;
    background-image: url('/assets/image/gate/opening_image.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
}

/* Mobile Background Fallback */
@media (max-width: 768px) {
    #background-layer {
        background-image: url('/assets/image/gate/final_mobile_opening.png');
    }
}

/* Magnetic Menu Button */
/* Font 'Italiana' is imported in HTML head */

/* Magnetic Menu Button */
.magnetic-menu-btn {
    position: fixed;
    top: 40px;
    right: 40px;
    width: 100px;
    /* Large size */
    height: 100px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-family: 'Italiana', serif;
    /* Cool Serif Font */
    font-size: 18px;
    letter-spacing: 2px;
    cursor: pointer;
    z-index: 10002;
    /* User Request: Top Layer (Above Gas Effect 9999) */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
    /* Transform handled by JS */
}

.magnetic-menu-btn:hover,
.magnetic-menu-btn.magnetic-active {
    background: #FFD700;
    /* Deep Yellow (Gold) */
    border-color: #FFD700;
    color: #4B0082;
    /* Deep Purple */
    font-weight: bold;
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.8);
    /* Strong Yellow Glow */
    text-shadow: none;
    /* Clean text for readability against yellow */
    transform: scale(1.1);
}

/* Hidden State (When Menu is Open) */
.magnetic-menu-btn.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Mobile Button Adjustments */
@media (max-width: 768px) {
    .magnetic-menu-btn {
        font-size: 24px;
        /* Larger */
        font-weight: 900;
        /* Extra Bold */
    }
}

/* Whale Dark Mode: force true gold via image/boost to avoid browning */
.is-whale .magnetic-menu-btn:hover,
.is-whale .magnetic-menu-btn.magnetic-active {
    background-color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1' height='1'%3E%3Crect width='1' height='1' fill='%23FFD700'/%3E%3C/svg%3E");
    background-repeat: repeat;
    filter: saturate(1.4) brightness(1.3);
    -webkit-filter: saturate(1.4) brightness(1.3);
    mix-blend-mode: normal !important;
    forced-color-adjust: none;
    border-image-source: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1' height='1'%3E%3Crect width='1' height='1' fill='%23FFD700'/%3E%3C/svg%3E");
    border-image-slice: 1;
    color: #4B0082 !important;
    -webkit-text-fill-color: #4B0082;
    background-blend-mode: normal !important;
}

/* Menu Overlay (Dimmer) */
.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.menu-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Menu Modal (Centered Window) */
.menu-modal {
    position: relative;
    width: 90%;
    max-width: 600px;
    padding: 60px 40px;
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 215, 0, 0.3);
    /* Gold Border */
    border-radius: 2px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 215, 0, 0.1);
    text-align: center;
    transform: scale(0.95) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0;
}

.menu-overlay.active .menu-modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Mobile Modal Adjustments */
@media (max-width: 768px) {

    /* Change alignment to top */
    .menu-overlay {
        align-items: flex-start;
        padding-top: 2vh;
        /* Move even higher (User Request) */
    }

    .menu-modal {
        width: 98%;
        /* Maximize width */
        max-height: 80vh;
        /* Increase height (User Request) */
        overflow-y: auto;
        padding: 60px 0 20px 0;
        /* Zero side padding */

        /* Critical Scroll Fix */
        touch-action: pan-y;

        /* Reset Transform for Mobile */
        transform: none !important;
        margin: 0 auto;
        /* Center horizontally */
    }

    /* Override the active state transform for mobile */
    .menu-overlay.active .menu-modal {
        transform: none !important;
    }

    .menu-title {
        display: block !important;
        font-size: 1.5rem;
        letter-spacing: -0.02em;
        margin: 0 0 5px 0 !important;
        /* Only 5px bottom margin */
        padding: 0 !important;
        border: none !important;
        white-space: nowrap;
        line-height: 1.0;
    }

    .menu-list {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .menu-list li:first-child {
        margin-top: 0 !important;
    }

    .menu-list li {
        font-size: 1.1rem;
        /* Larger list items */
        padding: 5px 0 5px 5px;
        /* Minimal left padding */
        margin-bottom: 2px;
        /* Very tight spacing */
    }

    .menu-num {
        font-size: 0.8rem;
        margin-right: 8px;
    }
}

/* Close Button */
.menu-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: rgba(255, 255, 255, 0.1);
    /* Semi-transparent background */
    border: 1px solid rgba(255, 215, 0, 0.5);
    /* Gold border */
    border-radius: 50%;
    /* Circular */
    color: #FFD700;
    /* Gold X */
    font-size: 24px;
    /* Adjusted icon size */
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1;
    z-index: 1000;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.1);
    /* Subtle glow */
}

.menu-close-btn:hover {
    background: rgba(255, 215, 0, 0.2);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    /* Stronger glow */
    transform: rotate(90deg) scale(1.1);
}

/* Dark Mode & Whale Fixes */
.menu-modal {
    /* ... existing styles ... */
    forced-color-adjust: none;
    /* Prevent browser color tampering */
}

.is-whale .menu-modal {
    background: rgba(30, 30, 30, 0.95) !important;
    /* Force dark background */
    border-color: rgba(255, 215, 0, 0.6) !important;
    /* Ensure border visibility */
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8) !important;
}

/* Common Dark Mode Overrides (Whale + System Dark) */
/* Common Dark Mode Overrides (Whale + System Dark) */

/* 1. Whale Specific Overrides */
.is-whale .menu-modal {
    background: rgba(60, 60, 60, 0.95) !important;
    border-color: rgba(255, 215, 0, 0.8) !important;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9) !important;
}

.is-whale .menu-title {
    color: #FFFF00 !important;
    /* Neon Yellow */
    text-shadow: 0 0 15px rgba(255, 255, 0, 0.6) !important;
    /* Stronger Yellow Glow */
    border-bottom-color: rgba(255, 255, 0, 0.5) !important;
}

.is-whale .menu-list li {
    color: #ffffff !important;
    border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}

.is-whale .menu-num {
    color: #FFFF00 !important;
    opacity: 1;
}

.is-whale .menu-list li:hover {
    background: rgba(255, 255, 0, 0.1) !important;
    color: #FFFF00 !important;
}

.is-whale .menu-close-btn {
    color: #FFFF00 !important;
    border-color: #FFFF00 !important;
    box-shadow: 0 0 15px rgba(255, 255, 0, 0.4) !important;
}

/* 2. System Dark Mode Overrides */
@media (prefers-color-scheme: dark) {
    .menu-modal {
        background: rgba(60, 60, 60, 0.95) !important;
        border-color: rgba(255, 215, 0, 0.8) !important;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.9) !important;
    }

    .menu-title {
        color: #FFFF00 !important;
        /* Neon Yellow */
        text-shadow: 0 0 15px rgba(255, 255, 0, 0.6) !important;
        border-bottom-color: rgba(255, 255, 0, 0.5) !important;
    }

    .menu-list li {
        color: #ffffff !important;
        border-bottom-color: rgba(255, 255, 255, 0.1) !important;
    }

    .menu-num {
        color: #FFFF00 !important;
        opacity: 1;
    }

    .menu-list li:hover {
        background: rgba(255, 255, 0, 0.1) !important;
        color: #FFFF00 !important;
    }

    .menu-close-btn {
        color: #FFFF00 !important;
        border-color: #FFFF00 !important;
        box-shadow: 0 0 15px rgba(255, 255, 0, 0.4) !important;
    }
}

/* Typography */
.menu-title {
    font-family: 'Noto Serif KR', serif;
    font-size: 2.2rem;
    font-weight: 700;
    color: #FFD700;
    margin-bottom: 40px;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 10px rgba(255, 215, 0, 0.2);
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    padding-bottom: 20px;
    display: inline-block;
}

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
    display: inline-block;
    width: 100%;
}

.menu-list li {
    font-family: 'Noto Serif KR', serif;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    padding: 15px 20px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

.menu-list li:last-child {
    border-bottom: none;
}

.menu-list li:hover {
    background: rgba(255, 215, 0, 0.1);
    color: #FFD700;
    padding-left: 30px;
    /* Slide effect */
    border-color: rgba(255, 215, 0, 0.3);
}

.menu-num {
    font-family: 'Italiana', serif;
    color: rgba(255, 215, 0, 0.5);
    font-size: 0.9rem;
    margin-right: 15px;
    width: 20px;
    display: inline-block;
    transition: color 0.3s ease;
}

.menu-list li:hover .menu-num {
    color: #FFD700;
}

/* Audio Toggle Button */
.audio-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.audio-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: scale(1.1);
}

.audio-toggle-btn svg {
    width: 24px;
    height: 24px;
}

/* 
   WebGL Container (Fluid Distortion)
*/
#hero-root {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
    pointer-events: none;
    /* Let clicks pass through */
}

/* Canvas will be injected with z-index: 50 by perfectGasEffect.js */