/* Reset & Base Setup */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-drag: none;
}

:root {
    --bg-dark: #070509;
    --gold-magic: #dfb15b;
    --gold-glow: rgba(223, 177, 91, 0.4);
    --purple-magic: #7c3aed;
    --purple-dark: #2e1065;
    
    /* Potion Colors */
    --color-fire: #ff8800;
    --color-blood: #961409;
    --color-water: #00b4d8;
    --color-earth: #2a9d8f;
    --color-air: #e2e8f0;
    --color-quintessence: #d946ef;
}

body {
    background-color: var(--bg-dark);
    color: #f3f4f6;
    font-family: 'Raleway', sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    cursor: auto;
}

body.act-v-active,
body.act-v-active * {
    cursor: none !important;
}

/* Custom Magic Wand Pointer */
.magic-wand {
    position: fixed;
    width: 40px;
    height: 40px;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-10px, -30px);
    transition: transform 0.05s ease-out;
    display: none;
}

body.act-v-active .magic-wand {
    display: block !important;
}

.wand-shaft {
    position: absolute;
    width: 6px;
    height: 40px;
    background: linear-gradient(135deg, #451a03 0%, #78350f 50%, #92400e 100%);
    border-radius: 3px;
    transform: rotate(45deg);
    transform-origin: bottom center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
    border: 1px solid rgba(223,177,91,0.3);
}

.wand-tip {
    position: absolute;
    top: -4px;
    left: 23px;
    width: 10px;
    height: 10px;
    background-color: #fff;
    border-radius: 50%;
    box-shadow: 0 0 20px 8px #dfb15b, 0 0 8px 2px #fff;
    animation: pulseGlow 1s infinite alternate;
    transition: box-shadow 0.3s ease, background-color 0.3s ease;
}

.wand-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, rgba(223, 177, 91, 0.2) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    pointer-events: none;
    border-radius: 50%;
}

@keyframes pulseGlow {
    0% { transform: scale(0.9); opacity: 0.8; }
    100% { transform: scale(1.1); opacity: 1; }
}

/* Background Canvas and Dark Roots Overlay */
#particlesCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

#darkRootsOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 6;
    pointer-events: none;
    mix-blend-mode: color-burn;
    opacity: 0;
    background: radial-gradient(circle, transparent 30%, rgba(15, 5, 25, 0.95) 100%);
    box-shadow: inset 0 0 100px rgba(88, 28, 135, 0.4);
    transition: opacity 1.5s ease;
}

/* Screens Setup */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    background-color: var(--bg-dark);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

/* Intro Screen Glassmorphism */
.intro-glass-panel {
    background: rgba(15, 10, 20, 0.7);
    backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(223, 177, 91, 0.2);
    border-radius: 20px;
    padding: 3.5rem;
    max-width: 700px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(124, 58, 237, 0.1);
    transform: scale(0.95);
    animation: scaleUpPanel 0.8s forwards cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleUpPanel {
    to { transform: scale(1); }
}

.magic-crest {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    display: inline-block;
    width: 90px;
    height: 90px;
    line-height: 85px;
    background: radial-gradient(circle, var(--purple-dark) 0%, rgba(15,5,25,0) 80%);
    border-radius: 50%;
    border: 2px solid var(--gold-magic);
    box-shadow: 0 0 25px var(--gold-glow);
    animation: crestSpin 6s infinite linear;
}

@keyframes crestSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.crest-symbol {
    display: inline-block;
    animation: crestSymbolRevert 6s infinite linear;
}

@keyframes crestSymbolRevert {
    0% { transform: rotate(360deg); }
    100% { transform: rotate(0deg); }
}

.intro-title {
    font-family: 'Cinzel', serif;
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
    color: #fff;
    text-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
}

.accent-text {
    color: var(--gold-magic);
    text-shadow: 0 0 20px var(--gold-glow);
}

.intro-subtitle {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    letter-spacing: 3px;
    color: #9ca3af;
    margin-bottom: 2rem;
    text-transform: uppercase;
}

.intro-description {
    font-size: 1.05rem;
    line-height: 1.7;
    color: #d1d5db;
    margin-bottom: 2.5rem;
}

/* Magical Button */
.magic-btn {
    position: relative;
    background: linear-gradient(135deg, #1e1b4b 0%, #311042 100%);
    border: 2px solid var(--gold-magic);
    padding: 1.2rem 3rem;
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold-magic);
    letter-spacing: 2px;
    border-radius: 50px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(223, 177, 91, 0.2), inset 0 0 15px rgba(124, 58, 237, 0.2);
}

.magic-btn:hover {
    color: #fff;
    border-color: #fff;
    box-shadow: 0 0 30px rgba(223, 177, 91, 0.5), inset 0 0 20px rgba(124, 58, 237, 0.4);
    transform: translateY(-2px);
}

.btn-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0.1);
    transition: transform 0.5s ease-out;
    pointer-events: none;
}

.magic-btn:hover .btn-glow {
    transform: translate(-50%, -50%) scale(1);
}

.btn-text {
    position: relative;
    z-index: 2;
}

.audio-notice {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 1.5rem;
    letter-spacing: 1px;
}

/* Presentation Main Container */
#presentationContainer {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    padding: 1.5rem;
    z-index: 10;
    position: relative;
}

/* Header Controls */
.controls-header {
    display: grid;
    grid-template-columns: 2fr 5fr 2fr;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(10, 5, 15, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(223, 177, 91, 0.15);
    border-radius: 12px;
    margin-bottom: 1rem;
    z-index: 50;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.time-display {
    display: flex;
    flex-direction: column;
}

#currentActName {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gold-magic);
    letter-spacing: 1px;
    margin-bottom: 0.2rem;
}

#timer {
    font-size: 0.85rem;
    color: #9ca3af;
    letter-spacing: 1.5px;
}

/* Premium Progress Bar */
.progress-bar-container {
    position: relative;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin: 0 1.5rem;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.05);
}

.progress-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--purple-magic) 0%, var(--gold-magic) 100%);
    box-shadow: 0 0 15px var(--gold-magic);
    border-radius: 4px;
    transition: width 0.1s linear;
}

.marker {
    position: absolute;
    top: -4px;
    width: 14px;
    height: 14px;
    background-color: #070509;
    border: 2px solid rgba(223,177,91,0.5);
    border-radius: 50%;
    transform: translateX(-7px);
    transition: all 0.3s ease;
    z-index: 52;
}

.marker:hover {
    transform: translateX(-7px) scale(1.3);
    border-color: #fff;
    box-shadow: 0 0 10px var(--gold-magic);
}

.marker.visited {
    border-color: var(--gold-magic);
    background-color: var(--gold-magic);
    box-shadow: 0 0 8px var(--gold-glow);
}

/* Control Buttons */
.header-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
}

.control-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(223, 177, 91, 0.2);
    color: #f3f4f6;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.25s ease;
    font-size: 1rem;
}

.control-btn:hover {
    background: rgba(223, 177, 91, 0.1);
    border-color: var(--gold-magic);
    box-shadow: 0 0 10px var(--gold-glow);
    transform: scale(1.05);
}

/* Storyboard Viewport & Cinematic Scenes */
.storyboard-viewport {
    flex-grow: 1;
    position: relative;
    border-radius: 16px;
    border: 1px solid rgba(223, 177, 91, 0.15);
    overflow: hidden;
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.9);
}

.story-scene {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 1.2s ease, visibility 1.2s ease;
    z-index: 10;
}

.story-scene.active {
    opacity: 1;
    visibility: visible;
}

/* Background image with Ken Burns animation */
.scene-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transform: scale(1.02);
    filter: brightness(0.6) contrast(1.15) saturate(0.85);
}

.story-scene.active .scene-background {
    animation: kenburns 35s infinite alternate ease-in-out;
}

@keyframes kenburns {
    0% { transform: scale(1.02) translate(0, 0); }
    50% { transform: scale(1.15) translate(-1%, 0.5%); }
    100% { transform: scale(1.05) translate(0.5%, -1%); }
}

.scene-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(7, 5, 9, 0.2) 0%, rgba(7, 5, 9, 0.4) 60%, rgba(7, 5, 9, 0.9) 100%);
}

/* Parchment Text Container Overlay */
.parchment-container {
    position: absolute;
    bottom: 40px;
    left: 40px;
    right: 40px;
    max-width: 600px;
    background: rgba(15, 10, 20, 0.75);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(223, 177, 91, 0.3);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7), inset 0 0 20px rgba(223, 177, 91, 0.05);
    z-index: 20;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.8s ease, opacity 0.8s ease;
}

.story-scene.active .parchment-container {
    transform: translateY(0);
    opacity: 1;
    transition-delay: 0.4s;
}

.scene-tag {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: var(--gold-magic);
    letter-spacing: 3px;
    text-transform: uppercase;
    display: inline-block;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.scene-title-text {
    font-family: 'Cinzel', serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.8rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.scene-desc {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #d1d5db;
}

.animate-fade-in {
    animation: fadeIn 1s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Subtitles Panel */
.subtitles-footer {
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(5, 3, 7, 0.9);
    border: 1px solid rgba(223, 177, 91, 0.15);
    border-radius: 12px;
    margin-top: 1rem;
    z-index: 50;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
}

.subtitles-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent 10%, var(--gold-magic) 50%, transparent 90%);
}

.subtitle-text {
    font-family: 'Cinzel', serif;
    font-size: 1.15rem;
    font-weight: 600;
    text-align: center;
    color: #f3f4f6;
    max-width: 850px;
    line-height: 1.6;
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* INTERACTIVE WIDGET: The Five Essences Cabinet */
.essence-cabinet {
    position: absolute;
    top: 110px;
    right: 40px;
    width: 500px;
    background: rgba(18, 12, 24, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(223, 177, 91, 0.25);
    border-radius: 28px;
    padding: 2.4rem;
    z-index: 55;
    box-shadow: 0 15px 35px rgba(0,0,0,0.7), inset 0 0 30px rgba(124, 58, 237, 0.1);
    transform: translateX(40px);
    opacity: 0;
    transition: transform 0.8s ease, opacity 0.8s ease;
}

.essence-cabinet.active {
    transform: translateX(0);
    opacity: 1;
}

.cabinet-title {
    text-align: center;
    margin-bottom: 2.4rem;
    border-bottom: 1px solid rgba(223,177,91,0.15);
    padding-bottom: 1.2rem;
}

.cabinet-title h3 {
    font-family: 'Cinzel', serif;
    font-size: 1.9rem;
    color: var(--gold-magic);
    letter-spacing: 2px;
}

.cabinet-title p {
    font-size: 1.5rem;
    color: #9ca3af;
    margin-top: 0.4rem;
}

.essence-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 2.4rem;
}

/* Alchemical Potion Bottles */
.essence-bottle {
    position: relative;
    width: 68px;
    height: 104px;
    background: rgba(255, 255, 255, 0.05);
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px 16px 28px 28px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.essence-bottle::before {
    /* Bottle neck */
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 12px;
    background: transparent;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-bottom: none;
    border-radius: 4px 4px 0 0;
}

.essence-bottle::after {
    /* Cork stopper */
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 10px;
    background: #78350f;
    border-radius: 2px;
}

.liquid {
    position: absolute;
    bottom: 4px;
    left: 4px;
    right: 4px;
    height: 60%;
    border-radius: 0 0 20px 20px;
    transition: height 0.4s ease, background 0.3s ease, box-shadow 0.3s ease;
    opacity: 0.2;
}

/* Element Styles */
.liquid.fire { background-color: var(--color-fire); }
.liquid.water { background-color: var(--color-water); }
.liquid.blood { background-color: var(--color-blood); }
.liquid.ice { background-color: var(--color-air); }
.liquid.quintessence { background-color: var(--color-quintessence); }

.bottle-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    box-shadow: none;
    pointer-events: none;
    transition: box-shadow 0.3s ease;
}

.essence-label {
    position: absolute;
    bottom: -36px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.3rem;
    color: #6b7280;
    transition: color 0.3s ease;
}

/* Hover & Active (Charged) States */
.essence-bottle:hover {
    transform: scale(1.15) translateY(-6px);
    border-color: rgba(255,255,255,0.4);
}

.essence-bottle.charged {
    border-color: #fff;
    animation: floatingBottle 2s infinite alternate ease-in-out;
}

.essence-bottle.charged .liquid {
    height: 80%;
    opacity: 0.95;
}

.essence-bottle.charged .essence-label {
    color: #f3f4f6;
    font-weight: 600;
}

/* Specific Charged Glows */
#essence-fire.charged {
    box-shadow: 0 0 30px rgba(255, 77, 0, 0.4);
    border-color: var(--color-fire);
}
#essence-fire.charged .liquid { box-shadow: inset 0 0 16px #fff, 0 0 20px var(--color-fire); }

#essence-water.charged {
    box-shadow: 0 0 30px rgba(0, 180, 216, 0.4);
    border-color: var(--color-water);
}
#essence-water.charged .liquid { box-shadow: inset 0 0 16px #fff, 0 0 20px var(--color-water); }

#essence-blood.charged {
    box-shadow: 0 0 30px rgba(178, 27, 27, 0.4);
    border-color: var(--color-earth);
}
#essence-blood.charged .liquid { box-shadow: inset 0 0 16px #fff, 0 0 20px var(--color-earth); }

#essence-ice.charged {
    box-shadow: 0 0 30px rgba(226, 232, 240, 0.4);
    border-color: var(--color-air);
}
#essence-ice.charged .liquid { box-shadow: inset 0 0 16px #fff, 0 0 20px var(--color-air); }

#essence-quintessence.charged {
    box-shadow: 0 0 40px rgba(217, 70, 239, 0.6);
    border-color: var(--color-quintessence);
}
#essence-quintessence.charged .liquid { box-shadow: inset 0 0 16px #fff, 0 0 30px var(--color-quintessence); }

/* Locked State for Quintessence */
.essence-bottle.locked {
    opacity: 0.4;
    cursor: not-allowed;
    border-style: dashed;
}

.essence-bottle.locked::before, .essence-bottle.locked::after {
    opacity: 0.5;
}

@keyframes floatingBottle {
    0% { transform: translateY(0); }
    100% { transform: translateY(-10px); }
}

/* Alchemical Progress Bar */
.purification-bar-container {
    height: 12px;
    background-color: rgba(255,255,255,0.05);
    border-radius: 6px;
    position: relative;
    margin-top: 2rem;
    overflow: hidden;
}

.purification-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--gold-magic) 0%, var(--purple-magic) 100%);
    box-shadow: 0 0 16px var(--purple-magic);
    transition: width 0.4s ease;
}

.purification-text {
    display: block;
    text-align: center;
    font-size: 1.4rem;
    color: #9ca3af;
    margin-top: 0.8rem;
    letter-spacing: 2px;
}

/* Screen Shaking (Dragon Roar Effect) */
.shake-screen {
    animation: screenShake 1.2s cubic-bezier(.36,.07,.19,.97) both;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
}

@keyframes screenShake {
    10%, 90% { transform: translate3d(-2px, 0, 0) rotate(-0.5deg); }
    20%, 80% { transform: translate3d(4px, 0, 0) rotate(1deg); }
    30%, 50%, 70% { transform: translate3d(-6px, 0, 0) rotate(-1deg); }
    40%, 60% { transform: translate3d(6px, 0, 0) rotate(1deg); }
}

/* Cabinet completion (purification spell finished) */
.cabinet-completion {
    margin-top: 1.5rem;
    padding: 1.2rem;
    border-top: 1px solid rgba(223, 177, 91, 0.25);
    text-align: center;
    display: none;
}

.cabinet-completion.active {
    display: block;
    animation: fadeInCompletion 0.6s ease forwards;
}

@keyframes fadeInCompletion {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.completion-title {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    color: var(--gold-magic);
    letter-spacing: 2px;
    margin-bottom: 0.4rem;
    text-shadow: 0 0 12px var(--gold-glow);
}

.completion-text {
    font-size: 0.85rem;
    color: #cbd5e6;
    letter-spacing: 0.5px;
    margin-bottom: 0.8rem;
}

.blog-link-btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    background: linear-gradient(135deg, #1e1b4b 0%, #311042 100%);
    border: 2px solid var(--gold-magic);
    border-radius: 50px;
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gold-magic);
    text-decoration: none;
    letter-spacing: 1px;
    transition: transform 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    cursor: pointer;
}

.blog-link-btn:hover {
    color: #fff;
    border-color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(223, 177, 91, 0.3);
}

.blog-link-btn.visible {
    display: inline-block;
}

/* Responsiveness adjustments */
@media(max-width: 900px) {
    .controls-header {
        grid-template-columns: 1fr;
        gap: 0.8rem;
        text-align: center;
    }
    
    .time-display {
        align-items: center;
    }
    
    .progress-bar-container {
        margin: 0;
    }
    
    .header-buttons {
        justify-content: center;
    }
    
    .essence-cabinet {
        position: fixed;
        top: auto;
        bottom: 120px;
        right: 50%;
        transform: translateX(50%);
        width: 90%;
        max-width: 640px;
    }
    
    .essence-cabinet.active {
        transform: translateX(50%);
    }
    
    .parchment-container {
        left: 20px;
        right: 20px;
        bottom: 20px;
        padding: 1.2rem;
    }
    
    .scene-title-text {
        font-size: 1.4rem;
    }
}
