* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Hide scrollbar for Chrome, Safari and Opera */
body::-webkit-scrollbar {
    display: none;
}

/* Body no-scroll when modal is active */
body.no-scroll {
    overflow: hidden;
    height: 100vh;
}

/* Loading Modal - Glassmorphism */
.loading-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 40px 50px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.loading-title {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    color: #333;
    letter-spacing: 0.15em;
    margin-bottom: 8px;
}

.loading-subtitle {
    font-family: 'Lora', serif;
    font-size: 1rem;
    color: #555;
    font-style: italic;
    margin-bottom: 30px;
}

.loading-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 10px;
}

.loading-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #d4af37, #ffc107, #d4af37);
    background-size: 200% 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
    animation: shimmer 1.5s infinite linear;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.loading-percentage {
    font-family: 'Lora', serif;
    font-size: 0.9rem;
    color: #777;
    margin-bottom: 25px;
}

.start-btn {
    background: linear-gradient(135deg, #d4af37, #c9a227);
    border: none;
    border-radius: 30px;
    padding: 14px 40px;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: #1a1a1a;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
    opacity: 0.5;
    pointer-events: none;
}

.start-btn:not(:disabled) {
    opacity: 1;
    pointer-events: auto;
}

.start-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.6);
    background: linear-gradient(135deg, #e5c348, #d4af37);
}

.start-btn:not(:disabled):active {
    transform: translateY(0);
}

.btn-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

.start-btn:not(:disabled):hover .btn-icon {
    transform: translateX(5px);
}

.modal-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.reset-btn {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #777;
    transition: all 0.3s ease;
    padding: 10px;
}

.reset-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #d4af37;
    transform: rotate(-30deg);
}

.reset-btn svg {
    width: 100%;
    height: 100%;
}

.reset-btn.clicked {
    animation: spin-reset 0.5s ease;
}

@keyframes spin-reset {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(-360deg);
    }
}

body {
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
    font-family: 'Lora', serif;
    background-color: #f5f5f5;
    color: #ccc;
    /* Default initial color */
}

body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../images/fondo.webp');
    background-repeat: repeat;
    pointer-events: none;
    z-index: 20;
    /* Above columns (10) but below header (100) and modals */
    mix-blend-mode: multiply;
    opacity: 0.6;
    /* Balanced for texture without over-darkening */
}

.story-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
}

/* Left Column: Text */
.text-column {
    padding: 0 5vw;
    /* Removed top padding, using spacer instead */
    background-color: #fff;
    min-height: 100vh;
}

.story-header {
    text-align: center;
    margin-bottom: 10vh;
    font-family: 'Cinzel', serif;
    color: #ccc;
}

.story-header h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.text-block {
    font-size: 1.25rem;
    line-height: 1.8;
    margin-bottom: 5rem;
    color: #d3d3d3;
    /* Light gray start */
    opacity: 0;
    /* Hidden initially */
    transform: translateY(20px);
    /* Slight offset for reveal */
}

/* Right Column: Images */
.image-column {
    position: relative;
    height: 100vh;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: sticky;
    top: 0;
}

.image-wrapper {
    position: relative;
    width: 80%;
    height: 80%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.story-image,
#animation-canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    visibility: hidden;
}

#animation-canvas {
    z-index: 10;
}

/* Fixed Header & Progress */
.fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px;
    /* Increased slightly to give breathing room */
    z-index: 9999;
    background-color: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    /* Stack logically, though absolute positioning handles the bar */
}

.header-progress-fill {
    position: absolute;
    bottom: 0;
    /* Align to bottom */
    left: 0;
    height: 8px;
    /* Reduced height (thin strip) */
    width: 0%;
    background-color: #d4af37;
    /* Gold color for progress */
    z-index: 5;
    /* Increased visibility */
}

.header-title {
    position: relative;
    z-index: 2;
    /* On top of progress fill */
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: #333;
    letter-spacing: 0.1em;
    margin: 0;
    /* Removed padding-bottom to center vertically better */
}

.page-markers {
    position: absolute;
    bottom: 0;
    /* Align to bottom, same as progress fill */
    left: 0;
    width: 100%;
    height: 8px;
    /* Match progress fill height */
    z-index: 3;
    pointer-events: none;
    /* Let clicks pass through if needed, but we want markers clickable */
}

/* Achievement Counter (Floating Action Button) */
.achievement-counter {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 70px;
    height: 70px;
    background-color: #ffc107;
    /* Amber/Yellow base */
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    /* Above everything */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 8px 24px rgba(0, 0, 0, 0.15);
    /* Drop shadow */
    cursor: default;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.achievement-counter:hover {
    transform: scale(1.05);
}

.achievement-counter.bump {
    animation: bump-counter 0.3s ease-out;
}

.achievement-counter .star-icon {
    width: 24px;
    height: 24px;
    color: #333;
    margin-bottom: -2px;
    /* Pull closer to number */
}

#achievement-count {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: #333;
    line-height: 1;
}

@keyframes bump-counter {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Flying Star Animation Element */
.flying-star {
    position: fixed;
    width: 20px;
    height: 20px;
    color: #ffc107;
    z-index: 10001;
    /* Above even the counter */
    pointer-events: none;
    filter: drop-shadow(0 0 5px rgba(255, 193, 7, 0.8));
}

.spark {
    position: fixed;
    width: 4px;
    height: 4px;
    background-color: #ffc107;
    border-radius: 50%;
    z-index: 10002;
    pointer-events: none;
}

/* Achievement Modal */
.achievement-modal {
    border: none;
    padding: 0;
    background: transparent;
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
}

.achievement-modal::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
}

.modal-content {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    margin: 5vh auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #333;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    z-index: 10;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Carousel */
.carousel-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 0;
}

.carousel-track {
    flex: 1;
    overflow: hidden;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-item {
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
    animation: fadeIn 0.3s ease-in;
}

.carousel-item.active {
    display: flex;
}

.carousel-item.locked {
    filter: blur(5px);
    pointer-events: none;
    user-select: none;
}

.carousel-item h3 {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: #333;
    margin: 0;
}

.carousel-item p {
    font-family: 'Lora', serif;
    font-size: 1.1rem;
    line-height: 1.6;
    color: #555;
    max-width: 500px;
}

.lock-icon {
    width: 60px;
    height: 60px;
    background-color: #ffc107;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #333;
    margin-bottom: 10px;
}

.unlock-requirement {
    font-family: 'Lora', serif;
    font-size: 0.9rem;
    color: #777;
    font-style: italic;
}

.carousel-nav {
    background: rgba(212, 175, 55, 0.2);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 2rem;
    cursor: pointer;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.carousel-nav:hover {
    background: rgba(212, 175, 55, 0.4);
    transform: scale(1.1);
}

.carousel-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: scale(1);
}

.carousel-indicators {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
}

.indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.2s;
}

.indicator.active {
    background: #ffc107;
    transform: scale(1.2);
}

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

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


/* Individual marker lines */
.page-marker {
    position: absolute;
    top: 0;
    height: 100%;
    width: 2px;
    background-color: rgba(0, 0, 0, 0.4);
    /* Slightly darker for visibility */
    cursor: pointer;
    pointer-events: auto;
    /* Re-enable pointer events for markers */
    transition: background-color 0.2s, opacity 0.3s, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0;
    /* Hidden by default */
    transform: scaleY(0);
    /* Start collapsed */
    transform-origin: bottom;
    /* Grow from bottom */
}

.page-marker.revealed {
    opacity: 1;
    /* Revealed when progress passes */
    transform: scaleY(1);
    /* Grow to full height */
}

.page-marker:hover {
    background-color: rgba(0, 0, 0, 0.8);
    width: 4px;
}

/* Scroll Indicator */
.scroll-indicator {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    opacity: 1;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.mouse {
    width: 30px;
    height: 50px;
    border: 2px solid #ccc;
    border-radius: 20px;
    position: relative;
}

.wheel {
    width: 4px;
    height: 8px;
    background-color: #ccc;
    border-radius: 2px;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    animation: scrollWheel 1.5s infinite;
}

.arrow {
    width: 15px;
    height: 15px;
    border-right: 2px solid #ccc;
    border-bottom: 2px solid #ccc;
    transform: rotate(45deg);
    animation: scrollArrow 1.5s infinite;
}

@keyframes scrollWheel {
    0% {
        top: 8px;
        opacity: 1;
    }

    100% {
        top: 25px;
        opacity: 0;
    }
}

@keyframes scrollArrow {
    0% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* Footer Reveal Styling */
.reveal-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50vh;
    background-color: #1a1a1a;
    color: #fff;
    z-index: -1;
    /* Behind content */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5vw;
}

.footer-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    max-width: 1200px;
    gap: 4rem;
    font-family: 'Lora', serif;
}

.footer-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.footer-col h3 {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: #d4af37;
    /* Gold to match header progress */
}

.footer-col p {
    font-size: 1.2rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    color: #ccc;
}

.footer-link,
.amazon-btn {
    display: inline-block;
    color: #fff;
    text-decoration: none;
    font-family: 'Cinzel', serif;
    position: relative;
    /* For pseudo-element */
    padding-bottom: 5px;
    width: fit-content;
    transition: color 0.3s;
}

/* Specific styling for the text link to have the dot-to-line effect */
.footer-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    /* Start as a dot */
    height: 4px;
    /* Dot height */
    background-color: #d4af37;
    border-radius: 50%;
    /* Make it round */
    transition: width 0.3s ease, border-radius 0.3s ease, height 0.3s ease;
}

.footer-link:hover::after {
    width: 100%;
    /* Expand to full width */
    height: 1px;
    /* become a line */
    border-radius: 0;
    /* Remove roundness */
}

.footer-link:hover,
.amazon-btn:hover {
    color: #d4af37;
}

.amazon-btn {
    border-bottom: 1px solid #d4af37;
    /* Keep original style for button */
    transition: color 0.3s, border-color 0.3s;
}

.amazon-btn:hover {
    border-color: #fff;
}

.amazon-btn {
    background-color: #d4af37;
    color: #000;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-weight: bold;
}

.amazon-btn:hover {
    background-color: #fff;
    color: #000;
}

/* Ensure main content pushes up to reveal footer */
.story-container {
    margin-bottom: 50vh;
    /* Matches footer height */
    position: relative;
    z-index: 10;
    background-color: transparent;
    /* Individual columns handle bg, ensuring cover */
}

/* Ensure columns cover the footer completely */
.text-column,
.image-column {
    background-color: #fff;
    /* Enforce opacity */
}

.image-column {
    background-color: #f0f0f0;
}

/* --- Responsive & Mobile Improvements --- */

/* Rotate Device Icon */
.rotate-device-icon {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9000;
    display: none;
    /* Hidden by default */
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    pointer-events: none;
    /* Pass through clicks */
    opacity: 0;
}

.rotate-device-icon svg {
    width: 50px;
    height: 50px;
    color: #333;
    animation: rotateIcon 2s infinite ease-in-out;
}

.rotate-device-icon span {
    font-family: 'Lora', serif;
    font-size: 0.9rem;
    color: #555;
    text-align: center;
}

@keyframes rotateIcon {

    0%,
    100% {
        transform: rotate(0deg);
    }

    50% {
        transform: rotate(-90deg);
    }
}

/* Media Query for Mobile Portrait */
@media (max-width: 768px) and (orientation: portrait) {
    .rotate-device-icon {
        display: flex;
        animation: fadeInOut 5s forwards;
        /* Show for 5s then fade out */
    }
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        pointer-events: none;
    }
}

/* Compact Header on Scroll (Responsive) */
@media (max-width: 768px),
(max-width: 1024px) and (orientation: landscape) and (max-height: 600px) {
    .fixed-header {
        transition: height 0.3s ease, background-color 0.3s ease, border-bottom 0.3s ease;
    }

    .fixed-header.compact {
        height: 10px;
        /* Only show the progress bar height */
        background-color: transparent;
        border-bottom: none;
        box-shadow: none;
    }

    .header-title {
        transition: opacity 0.3s ease, transform 0.3s ease;
    }

    .fixed-header.compact .header-title {
        opacity: 0;
        transform: translateY(-20px);
        pointer-events: none;
    }

    /* Adjust page markers specific for compact view if needed */
    .fixed-header.compact .page-markers::after {
        /* Optional: Add a subtle background to the rail if transparent header is too invisible */
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(255, 255, 255, 0.2);
        z-index: -1;
    }
}

/* Landscape Mobile Fix: Ensure footer fits vertically */
@media (max-width: 900px) and (orientation: landscape) {
    .reveal-footer {
        height: 100vh;
        /* Use full height to avoid clipping content */
        padding: 0 2vw;
        /* Reduce side padding */
    }

    .story-container {
        margin-bottom: 100vh;
        /* Match new footer height */
    }

    .footer-content {
        gap: 2rem;
        /* Reduce gap */
    }

    .footer-col h3 {
        font-size: 1.5rem;
        /* Smaller headings */
        margin-bottom: 1rem;
    }

    .footer-col p {
        font-size: 1rem;
        /* Smaller text */
        margin-bottom: 1rem;
    }
}