/* Utility class to hide elements during intro */
.hidden-during-intro {
    display: none !important;
}

/* Cinematic Intro Styles */
.cinematic-intro {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000;
    z-index: 10001;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    font-family: var(--font-fantasy);
}

.intro-scene {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.intro-scene.active {
    opacity: 1;
    pointer-events: auto;
}

.skip-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    color: rgba(252, 194, 6, 0.952);
    border: 1px solid rgba(252, 194, 6, 0.952);
    padding: 20px 30px;
    cursor: pointer;
    z-index: 10000;
    font-family: var(--font-ui);
    text-transform: uppercase;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.skip-btn:hover {
    color: var(--primary-gold);
    border-color: var(--primary-gold);
    background: rgba(0, 0, 0, 0.5);
}

/* Scene 1: Text */
.epic-text {
    color: white;
    font-size: clamp(2rem, 5vw, 5rem);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    opacity: 0;
    transform: scale(0.9);
}

.intro-scene.active .epic-text {
    animation: epicTextAnim 3s forwards;
}

@keyframes epicTextAnim {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
        filter: blur(10px);
    }

    20% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }

    80% {
        opacity: 1;
        transform: scale(1.1) translateY(0);
        filter: blur(0);
    }

    100% {
        opacity: 0;
        transform: scale(1.2) translateY(-20px);
        filter: blur(5px);
    }
}

/* Scene 2: Mage */
.scene-mage {
    background: radial-gradient(circle at center, #2a1035 0%, #000 70%);
}

.character-container {
    position: relative;
    height: 80vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.char-img {
    height: 100%;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 30px rgba(0, 0, 0, 0.8));
    opacity: 0;
    transform: translateX(-50px);
}

.intro-scene.active .char-img {
    animation: charEnter 0.8s ease-out forwards;
}

@keyframes charEnter {
    from {
        opacity: 0;
        transform: translateX(-50px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.magic-effect {
    position: absolute;
    top: 40%;
    left: 55%;
    width: 20px;
    height: 20px;
    background: #b05aff;
    border-radius: 50%;
    box-shadow: 0 0 20px #b05aff, 0 0 50px #d49aff, 0 0 100px #fff;
    opacity: 0;
}

.intro-scene.active .magic-effect {
    animation: magicPulse 3s infinite;
}

@keyframes magicPulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(5);
        opacity: 0.8;
        box-shadow: 0 0 40px #b05aff, 0 0 80px #d49aff, 0 0 150px #fff;
    }

    100% {
        transform: scale(8);
        opacity: 0;
    }
}

/* Scene 3: Archer */
.scene-archer {
    background: linear-gradient(to bottom, #0f150f, #000);
}

.background-trees {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('https://placehold.co/1920x1080/051105/000000?text=.&bg=transparent');
    /* Placeholder for trees/dark forest feel */
    opacity: 0.3;
}

.intro-scene.active .archer-img {
    animation: charEnterRight 0.8s ease-out forwards;
}

@keyframes charEnterRight {
    from {
        opacity: 0;
        transform: translateX(50px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.arrow {
    position: absolute;
    width: 100px;
    height: 4px;
    background: linear-gradient(to right, transparent, #fff);
    top: 50%;
    left: 60%;
    opacity: 0;
    filter: drop-shadow(0 0 5px cyan);
}

.intro-scene.active .arrow-1 {
    animation: arrowShot 0.6s linear forwards 1s;
}

.intro-scene.active .arrow-2 {
    animation: arrowShot 0.6s linear forwards 1.3s;
    top: 45%;
}

.intro-scene.active .arrow-3 {
    animation: arrowShot 0.6s linear forwards 1.6s;
    top: 55%;
}

@keyframes arrowShot {
    0% {
        opacity: 1;
        transform: translateX(0);
    }

    100% {
        opacity: 0;
        transform: translateX(200vw);
    }
}

/* Scene 4: Knight */
.scene-knight {
    background: linear-gradient(to bottom, #151005, #000);
}

.rock-obstacle {
    position: absolute;
    width: 300px;
    height: 300px;
    background-color: #333;
    left: 60%;
    bottom: 0;
    /* Changed from top: 60% relative to container to be more stable visually */
    clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
    opacity: 1;
    transition: all 0.1s;
}

.intro-scene.active .rock-obstacle {
    animation: rockShatter 0.2s forwards 1.5s;
    bottom: 20%;
    /* Position it relatively */
}

@keyframes rockShatter {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1) rotate(5deg);
        background-color: #555;
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.slash-effect {
    position: absolute;
    width: 200%;
    height: 5px;
    background: white;
    top: 50%;
    left: -50%;
    transform: rotate(-45deg);
    opacity: 0;
    box-shadow: 0 0 20px white;
}

.intro-scene.active .slash-effect {
    animation: slashAnim 0.3s linear forwards 1.4s;
}

@keyframes slashAnim {
    0% {
        opacity: 0;
        width: 0;
    }

    50% {
        opacity: 1;
        width: 200%;
    }

    100% {
        opacity: 0;
        width: 200%;
    }
}

/* Scene 5: Finale */
.scene-final {
    background: radial-gradient(circle at center, #1a1025 0%, #000 80%);
    flex-direction: column;
}

.team-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 20px;
    margin-bottom: 50px;
}

.final-char {
    height: 40vh;
    opacity: 0;
    transform: translateY(50px);
}

.scene-final.active .mage-final {
    animation: finalCharAppear 0.8s ease forwards 0.5s;
}

.scene-final.active .knight-final {
    animation: finalCharAppear 0.8s ease forwards 0s;
    z-index: 2;
}

.scene-final.active .archer-final {
    animation: finalCharAppear 0.8s ease forwards 0.8s;
}

@keyframes finalCharAppear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.final-title {
    text-align: center;
    opacity: 0;
}

.scene-final.active .final-title {
    animation: titleFadeIn 2s ease forwards 1.5s;
}

.final-title h1 {
    color: var(--primary-gold);
    font-size: clamp(2rem, 6vw, 6rem);
    margin-bottom: 10px;
    letter-spacing: 5px;
    text-shadow: 0 0 30px rgba(197, 160, 89, 0.6);
}

.title-underline {
    width: 0;
    height: 2px;
    background: white;
    margin: 0 auto 30px;
}

.scene-final.active .title-underline {
    animation: underlineGrow 1s ease forwards 2s;
}

@keyframes underlineGrow {
    to {
        width: 50%;
    }
}

@keyframes titleFadeIn {
    to {
        opacity: 1;
    }
}

.enter-btn {
    background: transparent;
    border: 2px solid var(--primary-gold);
    color: var(--primary-gold);
    padding: 15px 40px;
    font-family: var(--font-fantasy);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    opacity: 0;
    transform: translateY(20px);
}

.scene-final.active .enter-btn {
    animation: btnEnter 0.5s ease forwards 3s;
}

@keyframes btnEnter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.enter-btn:hover {
    background: var(--primary-gold);
    color: #000;
    box-shadow: 0 0 30px rgba(197, 160, 89, 0.6);
}

.intro-logo {
    max-width: 600px;
    width: 80%;
    height: auto;
    filter: drop-shadow(0 0 20px rgba(197, 160, 89, 0.4));
    margin-bottom: 20px;
}

/* ------------------------------------------- */
/*               MOBILE RESPONSIVE             */
/* ------------------------------------------- */

@media (max-width: 768px) {

    /* General Tweaks */
    .cinematic-intro {
        /* Fix potential viewport height issues on mobile browsers with URL bars */
        min-height: -webkit-fill-available;
    }

    /* Scene 1: Text */
    .epic-text {
        font-size: clamp(1.8rem, 8vw, 3rem);
        text-align: center;
        padding: 0 20px;
        line-height: 1.2;
    }

    /* Scene 2: Mage */
    .character-container {
        height: 60vh;
        /* Reduce height to fit better in portrait */
        width: 100%;
    }

    .char-img {
        max-width: 80vw;
        height: auto;
        max-height: 70vh;
    }

    .magic-effect {
        top: 35%;
        left: 50%;
        transform: translate(-50%, -50%);
        /* Center the starting point */
    }

    /* Scene 3: Archer */
    .arrow {
        width: 60px;
        /* Shorter arrows for narrower screens */
        left: auto;
        right: 100%;
        /* Start from left edge */
    }

    @keyframes arrowShot {
        0% {
            opacity: 1;
            transform: translateX(0);
        }

        100% {
            opacity: 0;
            transform: translateX(120vw);
            /* Ensure it crosses the screen */
        }
    }

    /* Adjust arrow starting positions for mobile so they are visible */
    .intro-scene.active .arrow-1 {
        top: 40%;
        left: 10%;
        right: auto;
    }

    .intro-scene.active .arrow-2 {
        top: 45%;
        left: 10%;
        right: auto;
    }

    .intro-scene.active .arrow-3 {
        top: 50%;
        left: 10%;
        right: auto;
    }

    /* Scene 4: Knight */
    .rock-obstacle {
        width: 150px;
        height: 150px;
        left: 50%;
        margin-left: -75px;
        /* Center horizontally */
        bottom: 10%;
    }

    .intro-scene.active .rock-obstacle {
        bottom: 15%;
    }

    /* Scene 5: Finale */
    .team-container {
        gap: 5px;
        /* Reduce gap */
        align-items: flex-end;
        height: 40vh;
        /* Constrain height */
        margin-bottom: 20px;
    }

    .final-char {
        height: auto;
        max-height: 25vh;
        /* Smaller characters in finale */
        width: auto;
        max-width: 30vw;
    }



    .final-title h1 {
        font-size: clamp(1.8rem, 8vw, 2.5rem);
        padding: 0 10px;
    }

    .enter-btn {
        padding: 12px 30px;
        font-size: 1.2rem;
    }

    /* Ensure skip button is easily tappable */
    .skip-btn {
        padding: 12px 20px;
        font-size: 0.9rem;
        top: 15px;
        right: 15px;
    }
}