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

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --text-dark: #1a1a1a;
    --text-light: rgba(255, 255, 255, 0.9);
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.4);
}

html {
    scroll-behavior: smooth;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--text-dark);
    overflow: hidden;
    position: relative;
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
}

#three-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
}

/* Hero Section */
.hero-section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    padding: 40px 20px;
}

.hero-content {
    text-align: center;
    z-index: 2;
}

.flashback-text-container {
    margin-bottom: 30px;
}

.flashback-text {
    font-size: clamp(4rem, 15vw, 12rem);
    font-weight: 900;
    letter-spacing: -0.05em;
    background: linear-gradient(135deg, #ffffff 0%, #667eea 50%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 80px rgba(102, 126, 234, 0.5);
    opacity: 0;
    transform: translateY(50px);
    animation: fadeInUp 1.2s ease-out forwards;
    position: relative;
    transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1), transform 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.flashback-text.fade-out {
    opacity: 0 !important;
    transform: scale(0.8) translateY(50px) !important;
}

.flashback-text-container.morph {
    animation: morphToContainer 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    will-change: transform, opacity;
}

/* Ensure morph animation doesn't cause overflow on mobile */
@media (max-width: 768px) {
    .flashback-text-container.morph {
        transform-origin: center center;
    }
}

@keyframes morphToContainer {
    0% {
        transform: scale(1) translate(0, 0);
        opacity: 1;
    }
    50% {
        transform: scale(0.5) translate(-20%, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(0) translate(-50%, 0);
        opacity: 0;
    }
}

/* Background animation when folder chosen */
body.folder-selected #three-canvas {
    animation: backgroundPulse 3s ease-in-out infinite;
}

@keyframes backgroundPulse {
    0%, 100% {
        filter: brightness(1) hue-rotate(0deg);
    }
    50% {
        filter: brightness(1.2) hue-rotate(30deg);
    }
}

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

.hero-subtitle {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: var(--text-light);
    font-weight: 300;
    letter-spacing: 0.1em;
    opacity: 0;
    animation: fadeInUp 1s ease-out 0.4s forwards;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.hero-subtitle.fade-out {
    opacity: 0 !important;
    transform: translateY(-30px) scale(0.9);
    visibility: hidden;
}

.fade-in-delay-1 {
    animation-delay: 0.3s;
}

.fade-in-delay-2 {
    animation-delay: 0.6s;
}

/* Floating Button */
.floating-btn {
    margin-top: 60px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 20px 50px;
    font-size: 1.3rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.5);
    display: inline-flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    animation: fadeInUp 1s ease-out 0.8s forwards, float 3s ease-in-out infinite 2s;
    position: relative;
    z-index: 10;
}

.floating-btn.fade-out {
    opacity: 0 !important;
    transform: translateY(30px) scale(0.8) !important;
    pointer-events: none;
    animation: none !important;
    visibility: hidden;
}

.floating-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 20px 50px rgba(102, 126, 234, 0.7);
}

.floating-btn:active {
    transform: translateY(-2px) scale(1.02);
}

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

/* Transparent Flashback Container (morphs from text) - positioned on left */
.flashback-container-morphed {
    position: fixed;
    top: 50%;
    left: 5%;
    transform: translateY(-50%);
    width: 50%;
    max-width: 700px;
    height: 60vh;
    min-height: 500px;
    max-height: 80vh;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    border-radius: 30px;
    overflow: hidden;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: all 2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    will-change: transform, opacity;
}

.flashback-container-morphed.show {
    opacity: 1;
    pointer-events: all;
    transform: translateY(-50%) scale(1);
}

.flashback-container-morphed.hidden {
    display: none;
}

/* Floating Controls (right side) */
.floating-controls {
    position: fixed;
    right: 5%;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease 1.5s;
    max-width: 250px;
}

.floating-controls.show {
    opacity: 1;
    pointer-events: all;
}

.floating-controls.hidden {
    display: none;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 14px 20px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 600;
    min-width: 140px;
    justify-content: flex-start;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateX(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.control-btn:active {
    transform: translateX(-3px);
}

.control-btn.download {
    background: rgba(102, 126, 234, 0.3);
    border-color: rgba(102, 126, 234, 0.5);
}

.control-btn.download:hover {
    background: rgba(102, 126, 234, 0.4);
}

.btn-label {
    font-size: 0.9rem;
}

.photo-counter-float {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 20px;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.settings-float {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 20px;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    width: 100%;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.video-info {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 15px;
    border-radius: 15px;
    color: white;
    font-size: 0.9rem;
    text-align: center;
    width: 100%;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.settings-float label {
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.settings-float input[type="range"] {
    width: 100%;
}

#speed-value {
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
}

.reset-menu {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}


.btn-icon {
    font-size: 1.5rem;
}

.hint {
    margin-top: 20px;
    color: #999;
    font-size: 0.95rem;
}

.hidden {
    display: none !important;
}

/* Gallery Section - now inside window */
.gallery-section {
    margin-top: 0;
}

.gallery-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.action-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn.secondary {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary-color);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.action-btn.secondary:hover {
    background: rgba(102, 126, 234, 0.2);
}


.flashback-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 600px;
    margin: 0 auto 40px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    background: #000;
}

.flashback-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 30px;
}

.flashback-container-morphed .flashback-media {
    width: 100%;
    height: 100%;
}

#flashback-image {
    animation: flashCut 0.1s ease-in-out;
}

#flashback-video {
    animation: flashCut 0.1s ease-in-out;
}

.flash-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    opacity: 0;
    pointer-events: none;
    animation: flash 0.08s ease-out;
    z-index: 2;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        rgba(0, 0, 0, 0.1) 50%,
        rgba(0, 0, 0, 0.3) 100%
    );
    pointer-events: none;
    z-index: 1;
}

@keyframes flashCut {
    0% {
        opacity: 0;
        transform: scale(1.05);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes flash {
    0% {
        opacity: 0.8;
    }
    100% {
        opacity: 0;
    }
}

.settings {
    margin-top: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    padding: 30px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.settings label {
    color: #666;
    font-weight: 600;
    font-size: 1rem;
}

.settings input[type="range"] {
    width: 250px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #e0e0e0, var(--primary-color));
    outline: none;
    -webkit-appearance: none;
}

.settings input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.5);
    transition: transform 0.2s;
}

.settings input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.settings input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.5);
}

#speed-value {
    color: var(--primary-color);
    font-weight: 700;
    min-width: 70px;
    font-size: 1rem;
}

.reset-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px auto 30px;
    padding: 25px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.menu-btn {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-btn:hover {
    background: var(--primary-gradient);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.menu-btn:active {
    transform: translateY(0);
}

/* Loading Overlay (transparent) */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    color: white;
}

.loading-overlay p {
    margin-top: 25px;
    font-size: 1.3rem;
    font-weight: 500;
}

.loading-progress {
    margin-top: 20px;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 1024px) {
    .flashback-container-morphed {
        width: 45%;
        left: 2%;
    }
    
    .floating-controls {
        right: 2%;
        max-width: 200px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .flashback-text {
        font-size: clamp(2.5rem, 10vw, 6rem);
    }
    
    .hero-subtitle {
        font-size: clamp(1rem, 4vw, 1.4rem);
    }
    
    .floating-btn {
        padding: 12px 25px;
        font-size: 0.95rem;
        margin-top: 30px;
    }
    
    .flashback-container-morphed {
        width: calc(100% - 20px);
        top: 15px;
        height: calc(50vh - 15px);
        min-height: 280px;
        max-height: 50vh;
        border-radius: 20px;
    }
    
    .flashback-container-morphed.show {
        transform: translateX(-50%) scale(1);
    }
    
    .floating-controls {
        bottom: 15px;
        left: 10px;
        right: 10px;
        max-width: calc(100% - 20px);
        width: calc(100% - 20px);
        gap: 10px;
        max-height: calc(45vh - 15px);
    }
    
    .control-btn {
        min-width: calc(50% - 3px);
        flex: 1 1 calc(50% - 3px);
        max-width: calc(50% - 3px);
        padding: 10px 12px;
        font-size: 0.85rem;
    }
    
    .control-btn .btn-label {
        font-size: 0.8rem;
    }
    
    .photo-counter-float {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    .settings-float {
        padding: 12px;
    }
    
    .video-info {
        padding: 10px;
        font-size: 0.8rem;
    }
    
    .support-footer {
        bottom: 8px;
        display: none; /* Hide on small screens to prevent overlap */
    }
    
    .coffee-logo {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .support-text {
        font-size: 0.7rem;
        padding: 5px 10px;
    }
}

@media (max-width: 768px) {
    .hero-section {
        min-height: 100vh;
        padding: 20px 15px;
    }
    
    .hero-content {
        width: 100%;
        max-width: 100%;
    }
    
    .flashback-text {
        font-size: clamp(3rem, 12vw, 8rem);
    }
    
    .floating-btn {
        padding: 14px 30px;
        font-size: 1rem;
        margin-top: 40px;
    }
    
    /* Reduce float animation on mobile to prevent overflow */
    .floating-btn {
        animation: fadeInUp 1s ease-out 0.8s forwards, floatMobile 3s ease-in-out infinite 2s;
    }
    
    @keyframes floatMobile {
        0%, 100% {
            transform: translateY(0);
        }
        50% {
            transform: translateY(-6px);
        }
    }
    
    /* Flashback container - centered at top on mobile to leave room for controls */
    .flashback-container-morphed {
        width: calc(100% - 30px);
        max-width: 500px;
        left: 50%;
        top: 20px;
        transform: translateX(-50%);
        height: calc(55vh - 20px);
        min-height: 300px;
        max-height: 55vh;
    }
    
    .flashback-container-morphed.show {
        transform: translateX(-50%) scale(1);
    }
    
    /* Floating controls - positioned at bottom on mobile */
    .floating-controls {
        position: fixed;
        bottom: 20px;
        left: 15px;
        right: 15px;
        top: auto;
        transform: none;
        flex-direction: column;
        align-items: stretch;
        max-width: calc(100% - 30px);
        gap: 12px;
        width: calc(100% - 30px);
        max-height: calc(40vh - 20px);
        overflow-y: auto;
    }
    
    .floating-controls.show {
        transform: none;
        opacity: 1;
        pointer-events: all;
    }
    
    .control-group {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        justify-content: center;
        gap: 8px;
    }
    
    .control-btn {
        min-width: calc(50% - 4px);
        flex: 1 1 calc(50% - 4px);
        max-width: calc(50% - 4px);
        padding: 12px 16px;
        font-size: 0.9rem;
        justify-content: center;
    }
    
    .control-btn .btn-label {
        font-size: 0.85rem;
    }
    
    .photo-counter-float {
        width: 100%;
        padding: 10px 16px;
        font-size: 1rem;
    }
    
    .settings-float {
        width: 100%;
        padding: 16px;
    }
    
    .video-info {
        width: 100%;
        padding: 12px;
        font-size: 0.85rem;
    }
    
    .reset-menu {
        width: 100%;
        min-width: auto;
    }
    
    .menu-btn {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
}

/* Support Footer */
.support-footer {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.support-footer.show {
    opacity: 1;
    pointer-events: all;
    animation: fadeInUp 0.8s ease forwards;
}

.support-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.support-link:hover {
    transform: translateY(-5px);
}

.coffee-logo {
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.support-link:hover .coffee-logo {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    transform: scale(1.1);
}

.support-text {
    font-size: 0.95rem;
    font-weight: 500;
    text-align: center;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    letter-spacing: 0.5px;
}

.support-link:hover .support-text {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
}


@media (max-width: 768px) {
    /* Hide support footer on mobile to prevent overlap with controls */
    .support-footer {
        display: none !important;
    }
    
    .coffee-logo {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
    
    .support-text {
        font-size: 0.75rem;
        padding: 6px 12px;
    }
}
