:root {
    /* Color palette - night sky and warm candlelight */
    --night-dark: #0a0e27;
    --night-mid: #1a1f3a;
    --night-light: #2d3561;
    --water-dark: #0d1b2a;
    --water-light: #1b2838;
    --candle-glow: #ffd89b;
    --candle-bright: #fff4e6;
    --moon-glow: #e8f4f8;
    --text-primary: #e8f4f8;
    --text-secondary: #a5c9d4;
}

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

body {
    font-family: 'Manrope', sans-serif;
    overflow: hidden;
    background: var(--night-dark);
    color: var(--text-primary);
    height: 100vh;
    width: 100vw;
    
    /* Prevent mobile browser behaviors */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    touch-action: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.scene-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ============================================
   SKY LAYER - Background atmosphere
   ============================================ */

.sky-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        180deg,
        #0a0e27 0%,
        #1a1f3a 50%,
        #0d1b2a 100%
    );
    z-index: 1;
}

/* Twinkling stars */
.stars {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20% 30%, white, transparent),
        radial-gradient(2px 2px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 50% 50%, white, transparent),
        radial-gradient(1px 1px at 80% 10%, white, transparent),
        radial-gradient(2px 2px at 90% 60%, white, transparent),
        radial-gradient(1px 1px at 33% 85%, white, transparent),
        radial-gradient(1px 1px at 15% 60%, white, transparent),
        radial-gradient(1px 1px at 45% 20%, white, transparent),
        radial-gradient(2px 2px at 70% 40%, white, transparent),
        radial-gradient(1px 1px at 25% 45%, white, transparent),
        radial-gradient(2px 2px at 85% 25%, white, transparent),
        radial-gradient(1px 1px at 40% 90%, white, transparent),
        radial-gradient(1px 1px at 65% 15%, white, transparent),
        radial-gradient(2px 2px at 10% 75%, white, transparent),
        radial-gradient(1px 1px at 95% 50%, white, transparent),
        radial-gradient(1px 1px at 55% 65%, white, transparent),
        radial-gradient(2px 2px at 30% 35%, white, transparent),
        radial-gradient(1px 1px at 75% 80%, white, transparent),
        radial-gradient(1px 1px at 5% 20%, white, transparent),
        radial-gradient(2px 2px at 88% 88%, white, transparent),
        radial-gradient(1px 1px at 42% 55%, white, transparent),
        radial-gradient(1px 1px at 68% 45%, white, transparent),
        radial-gradient(2px 2px at 12% 38%, white, transparent),
        radial-gradient(1px 1px at 93% 72%, white, transparent),
        radial-gradient(1px 1px at 38% 12%, white, transparent);
    background-size: 
        200% 200%,
        200% 200%,
        150% 150%,
        180% 180%,
        220% 220%,
        190% 190%,
        210% 210%,
        160% 160%,
        195% 195%,
        175% 175%,
        205% 205%,
        185% 185%,
        215% 215%,
        170% 170%,
        225% 225%,
        165% 165%,
        230% 230%,
        155% 155%,
        240% 240%,
        145% 145%,
        235% 235%,
        168% 168%,
        212% 212%,
        178% 178%,
        192% 192%;
    background-position:
        0% 0%,
        30% 40%,
        60% 20%,
        80% 70%,
        10% 50%,
        40% 80%,
        70% 30%,
        25% 60%,
        55% 45%,
        15% 25%,
        85% 65%,
        35% 15%,
        65% 85%,
        20% 75%,
        90% 35%,
        45% 55%,
        75% 10%,
        5% 90%,
        95% 20%,
        50% 70%,
        32% 48%,
        78% 62%,
        18% 33%,
        92% 78%,
        48% 8%;
    opacity: 0.8;
    animation: twinkle 15s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Moon */
.moon {
    position: absolute;
    top: 15%;
    right: 20%;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle at 30% 30%, 
        #ffffff 0%,
        #f0f8ff 40%,
        var(--moon-glow) 100%
    );
    border-radius: 50%;
    box-shadow: 
        0 0 40px rgba(232, 244, 248, 0.6),
        0 0 80px rgba(232, 244, 248, 0.3),
        inset -10px -10px 30px rgba(0, 0, 0, 0.1);
    animation: moonGlow 6s ease-in-out infinite;
    opacity: 0;
    animation: moonGlow 6s ease-in-out infinite, fadeIn 3s ease-in 0.5s forwards;
}

@keyframes moonGlow {
    0%, 100% { 
        box-shadow: 
            0 0 40px rgba(232, 244, 248, 0.6),
            0 0 80px rgba(232, 244, 248, 0.3),
            inset -10px -10px 30px rgba(0, 0, 0, 0.1);
    }
    50% { 
        box-shadow: 
            0 0 50px rgba(232, 244, 248, 0.8),
            0 0 100px rgba(232, 244, 248, 0.4),
            inset -10px -10px 30px rgba(0, 0, 0, 0.1);
    }
}

/* ============================================
   RIPPLE CANVAS - Water surface simulation
   ============================================ */

#rippleCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1.5;
    opacity: 1.0;
    image-rendering: auto;
    image-rendering: -webkit-optimize-contrast;
    border: 2px solid rgba(255, 0, 0, 0.5); /* DEBUG: Red border to see canvas */
}

/* ============================================
   WATER CANVAS - Where tea lights float
   ============================================ */

#waterCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* ============================================
   WELCOME TEXT - Centered, gentle typography
   ============================================ */

.welcome-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 3;
    max-width: 600px;
    padding: 2rem;
    opacity: 0;
    animation: fadeIn 2s ease-in 1s forwards;
    
    /* Make text non-selectable */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: none;
}

.welcome-text h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 300;
    letter-spacing: 0.05em;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(232, 244, 248, 0.3);
    
    /* Gentle wave animation */
    display: inline-block;
    animation: fadeIn 2s ease-in 1s forwards, textWave 4s ease-in-out infinite;
    animation-delay: 1s, 2s;
}

.welcome-text p {
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    font-weight: 300;
    line-height: 1.8;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    
    /* Subtle wave with offset timing */
    animation: fadeIn 2s ease-in 1.5s forwards, textWave 4s ease-in-out infinite;
    animation-delay: 1.5s, 2.3s;
}

.welcome-text .hint {
    font-size: 0.9rem;
    font-style: italic;
    opacity: 0.7;
    margin-top: 2rem;
    animation: fadeIn 2s ease-in 2s forwards, textWave 4s ease-in-out infinite;
    animation-delay: 2s, 2.6s;
}

/* Gentle wave motion like a flag in breeze */
@keyframes textWave {
    0%, 100% { 
        transform: translateY(0) rotate(0deg);
    }
    25% { 
        transform: translateY(-3px) rotate(0.3deg);
    }
    50% { 
        transform: translateY(0) rotate(0deg);
    }
    75% { 
        transform: translateY(3px) rotate(-0.3deg);
    }
}

/* ============================================
   DIVE HINT - Appears after interaction
   ============================================ */

.dive-hint {
    position: fixed; /* Changed from absolute for better mobile support */
    bottom: 8vh; /* Using vh for consistent placement on tall screens */
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
    
    /* Make non-selectable */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.dive-hint.visible {
    opacity: 1;
}

.dive-hint p {
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    text-shadow: 0 0 10px rgba(165, 201, 212, 0.3);
    cursor: pointer;
    animation: float 3s ease-in-out infinite;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    .moon {
        width: 120px;
        height: 120px;
        top: 10%;
        right: 10%;
    }

    .welcome-text {
        padding: 1.5rem;
        max-width: 90%;
    }

    .welcome-text h1 {
        margin-bottom: 1rem;
        font-size: clamp(2.2rem, 6vw, 3rem); /* Larger on mobile */
    }

    .welcome-text p {
        margin-bottom: 0.5rem;
        font-size: clamp(1rem, 2.5vw, 1.2rem); /* Larger on mobile */
    }
    
    .welcome-text .hint {
        font-size: 0.95rem; /* Slightly larger */
    }
    
    .dive-hint p {
        font-size: 1.3rem; /* Much larger on mobile */
        font-weight: 500; /* Bolder for visibility */
    }
}

@media (max-width: 480px) {
    .moon {
        width: 80px;
        height: 80px;
    }

    .welcome-text .hint {
        font-size: 0.9rem;
        margin-top: 1.5rem;
    }
    
    .dive-hint {
        bottom: 10vh; /* Higher up on small screens */
    }
}

/* Extra tall screens (like modern phones) */
@media (max-height: 700px) and (orientation: portrait) {
    .dive-hint {
        bottom: 12vh; /* Even higher on short viewports */
    }
}

/* Very tall screens need special positioning */
@media (min-aspect-ratio: 9/20) {
    .dive-hint {
        bottom: 6vh; /* Adjust for ultra-tall screens */
    }
}

/* ============================================
   WATER WASH TRANSITION - Bottom-up sweep
   ============================================ */

.water-wash {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0;
    background: linear-gradient(
        to top,
        #0d1b2a 0%,
        #0d1b2a 40%,
        #1a2c42 65%,
        rgba(26, 44, 66, 0.7) 85%,
        rgba(10, 22, 40, 0.3) 95%,
        transparent 100%
    );
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: none;
}

.water-wash.active {
    opacity: 1;
    animation: washUp 2s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

@keyframes washUp {
    0% {
        height: 0;
        opacity: 0.7;
    }
    50% {
        height: 60vh;
        opacity: 0.95;
    }
    100% {
        height: 100vh;
        opacity: 1;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .stars,
    .moon,
    .dive-hint p,
    .welcome-text {
        animation: none;
    }
    
    .welcome-text {
        opacity: 1;
    }
    
    .moon {
        opacity: 1;
    }
}
