:root {
    --bg-color: #151515;
    --text-color: #ffffff;
    --accent: #ff4757;
    /* Red */
    --highlight: #ffeb3b;
    /* Yellow */
    --mancity-blue: #6CABDD;
    /* Man City Blue */

    --shadow-1: #c9c9c9;
    --shadow-2: #aaa;
    --shadow-3: #888;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    background-image: radial-gradient(#333 1px, transparent 1px);
    background-size: 30px 30px;
    background-attachment: fixed;
    color: var(--text-color);
    font-family: 'Helvetica Neue', sans-serif;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* =========================================
   VIEW 1: COUNTDOWN
   ========================================= */
#view-countdown {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 1s ease;

    background-color: var(--bg-color);
    background-image: radial-gradient(#333 1px, transparent 1px);
    background-size: 30px 30px;
}

.countdown-container {
    text-align: center;
    transform: rotateX(10deg);
    transform-style: preserve-3d;
    perspective: 1000px;
}

.snark {
    font-family: 'Roboto Mono', monospace;
    color: var(--accent);
    font-size: 1.3rem;
    margin-bottom: 30px;
    text-transform: uppercase;
    letter-spacing: 3px;
    animation: pulse 2s infinite;
}

.timer-wrapper {
    display: flex;
    gap: 30px;
    justify-content: center;
}

.number {
    font-family: 'Kanit', sans-serif;
    font-size: clamp(3rem, 10vw, 6rem);
    line-height: 1;
    color: #fff;
    text-shadow: 0 1px 0 var(--shadow-1), 0 2px 0 var(--shadow-2), 0 3px 0 var(--shadow-3), 0 30px 30px rgba(0, 0, 0, 0.5);
}

.label {
    color: #666;
    font-size: 0.9rem;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.enter-btn {
    margin-top: 40px;
    padding: 15px 40px;
    background: var(--accent);
    color: white;
    border: none;
    font-family: 'Kanit', sans-serif;
    font-size: 1.5rem;
    text-transform: uppercase;
    cursor: pointer;
    display: none;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(255, 71, 87, 0.4);
    animation: pulse 1s infinite;
}

/* =========================================
   VIEW 2: EXPERIENCE (Global)
   ========================================= */
#view-gallery {
    opacity: 0;
    pointer-events: none;
    transition: opacity 2s ease;
}

.viewport {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    perspective: 1200px;
    overflow: hidden;
    z-index: 1;
}

.world {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    transform-style: preserve-3d;
}

/* Intro Title & Wall */
.intro-title {
    position: absolute;
    /* Center exactly relative to the 0x0 .world container */
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);

    text-align: center;

    /* Responsive Width Logic */
    width: 90vw;
    /* Take up 90% of screen width */
    max-width: 600px;
    /* But never wider than 600px */

    transition: opacity 0.5s;
    z-index: 10;

    /* Box Styling */
    border: 6px solid #fff;
    padding: 30px 20px;
    /* Vertical, Horizontal */
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    border-radius: 12px;
    /* Soften edges slightly */
    box-sizing: border-box;
    /* Ensures padding doesn't stretch width */
}

.intro-title h1 {
    /* Fun, Casual Font */
    font-family: 'Permanent Marker', cursive;
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    /* Responsive font size */
    margin: 0;
    line-height: 1.1;
    color: #fff;
    text-shadow: 0 5px 0 rgba(0, 0, 0, 0.5);
    transform: rotate(-2deg);
    /* Playful tilt */
}

.intro-title p {
    font-family: 'Kalam', cursive;
    /* Handwritten feel */
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    margin-top: 20px;
    color: #eee;
    line-height: 1.4;
    font-weight: 700;
}

@media (max-width: 768px) {

    /* Only need to adjust frames/other elements here if needed */
    .intro-title {
        border-width: 4px;
        padding: 20px 15px;
    }
}

/* =========================================
   INTRO WALL & FRAMES
   ========================================= */

.intro-wall-item {
    position: absolute;
    background: #fff;
    padding: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d;
}

.intro-wall-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* REMOVED GRAYSCALE FILTER AS REQUESTED */
    filter: none;
}

/* Timeline Frames - Updated for Text BELOW Image */
.frame {
    position: absolute;
    top: 0;
    left: 0;
    /* Adjusted sizing */
    width: 600px;
    height: auto;
    /* Allow height to grow */
    margin-left: -300px;
    margin-top: -200px;

    display: flex;
    flex-direction: column;
    /* Stack vertically */
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    transform-style: preserve-3d;

    /* Add a backing so text is readable against moving stars */
    background: rgba(0, 0, 0, 0.6);
    padding: 20px;
    border-radius: 12px;
    backdrop-filter: blur(5px);
}

.frame img {
    width: 100%;
    height: 350px;
    object-fit: cover;
    border-radius: 4px;
    opacity: 0.1;
    transition: all 0.8s ease;
}

.frame-content {
    width: 100%;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s ease 0.2s;
    /* No text shadow needed with background card */
}

.frame h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    color: var(--highlight);
    margin: 0 0 10px 0;
}

.frame h3 {
    font-family: 'Kanit', sans-serif;
    font-size: 1.2rem;
    color: #fff;
    margin: 0 0 5px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.frame p {
    font-size: 1rem;
    line-height: 1.5;
    color: #ddd;
}

.frame.focused img {
    opacity: 1;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.frame.focused .frame-content {
    opacity: 1;
    transform: translateY(0);
}

/* Mobile Frame Adjustments */
@media (max-width: 768px) {
    .frame {
        width: 85vw;
        margin-left: -42.5vw;
        margin-top: -30vh;
        padding: 15px;
    }

    .frame img {
        height: 250px;
    }
}



/* Scrolling Layout */
.scroll-container {
    position: relative;
    z-index: 10;
    width: 100%;
}

.gallery-spacer {
    width: 100%;
    pointer-events: none;
}

/* =========================================
   REALISTIC HOURGLASS STYLES
   ========================================= */
.hourglass-realistic {
    width: 120px;
    height: 180px;
    margin: 0 auto 40px auto;
    position: relative;
    /* Gentle floating animation */
    animation: floatHourglass 6s ease-in-out infinite;
}

@keyframes floatHourglass {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Wood Textures */
.wood-plate {
    position: absolute;
    width: 100%;
    height: 12px;
    background: linear-gradient(90deg, #5D4037, #8D6E63, #5D4037);
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    z-index: 5;
}

.wood-plate.top {
    top: 0;
}

.wood-plate.bottom {
    bottom: 0;
}

.wood-pillar {
    position: absolute;
    width: 6px;
    height: 100%;
    background: linear-gradient(90deg, #4E342E, #6D4C41);
    top: 0;
    z-index: 4;
}

.wood-pillar.left {
    left: 10px;
}

.wood-pillar.right {
    right: 10px;
}

/* Glass Structure */
.glass-chamber {
    position: absolute;
    top: 12px;
    bottom: 12px;
    left: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.glass-bulb {
    width: 100%;
    flex: 1;
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.1);
    overflow: hidden;
    z-index: 1;
}

.top-bulb {
    border-radius: 40% 40% 50% 50% / 10% 10% 40% 40%;
    border-bottom: none;
    clip-path: polygon(0% 0%, 100% 0%, 85% 100%, 15% 100%);
}

.bottom-bulb {
    border-radius: 50% 50% 40% 40% / 40% 40% 10% 10%;
    border-top: none;
    clip-path: polygon(15% 0%, 85% 0%, 100% 100%, 0% 100%);
}

.glass-neck {
    width: 6px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 1;
}

/* Glass Reflection Highlight */
.glass-shine {
    position: absolute;
    top: 10%;
    left: 15%;
    width: 10px;
    height: 40%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.4), transparent);
    border-radius: 10px;
    filter: blur(1px);
}

/* SAND */
.sand-fill {
    position: absolute;
    width: 100%;
    /* Realistic Sand Texture */
    background-color: #f6d365;
    background-image:
        radial-gradient(at 20% 20%, rgba(0, 0, 0, 0.1) 1px, transparent 1px),
        radial-gradient(at 80% 80%, rgba(255, 255, 255, 0.2) 1px, transparent 1px);
    background-size: 4px 4px;
}

/* Top sand drains downwards */
#sand-top {
    bottom: 0;
    left: 0;
    width: 100%;
    /* Start full, JS will adjust height */
    height: 100%;
    /* Curve the top of the sand slightly */
    border-radius: 50% 50% 0 0 / 20% 20% 0 0;
    transition: height 1s linear;
}

/* Bottom sand piles upwards */
#sand-bottom {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    /* Mound shape */
    border-radius: 50% 50% 0 0;
    transition: height 1s linear;
}

.stream {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 80px;
    background: #f6d365;
    opacity: 1;
    z-index: 0;
}

/* =========================================
   CAKE SECTION
   ========================================= */

.gift-content {
    position: relative;
    z-index: 10;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.gift-title {
    font-family: 'Permanent Marker', cursive;
    font-size: 4rem;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 71, 87, 0.5);
    margin-bottom: 5px;
    /* Ensure title stays above cake slightly */
    z-index: 5;
}

.gift-instructions {
    font-family: 'Kanit', sans-serif;
    color: #aaa;
    margin-bottom: 20px;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 0.9rem;
}

/* Confetti Layer */
#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #f00;
    animation: fall linear forwards;
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(720deg);
    }
}

/* Gift Section */
.gift-section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 20;
    background: transparent;
}

.gift-layout {
    position: relative;
    /* Acts as the anchor */
    width: 100%;
    max-width: 1000px;
    height: 600px;
    /* Fixed height for the stage */
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}


#three-cake-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Bottom layer */
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* =========================================
   INTERACTIVE WISH CARD & LETTER
   ========================================= */

/* Message Wrapper - Overlays the cake */
.message-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    /* Top layer */
    display: flex;
    justify-content: center;
    /* Horizontally Center */
    align-items: center;
    /* Vertically Center */
    pointer-events: none;
    /* Let clicks pass through empty areas */
}

.hidden-message {
    /* Ensure auto pointer events so buttons work */
    pointer-events: auto;

    opacity: 0;
    transform: translateY(30px) scale(0.9);
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);

    background: rgba(20, 20, 20, 0.6);
    /* Semi-transparent dark */
    backdrop-filter: blur(15px);
    /* Strong blur for readability */
    -webkit-backdrop-filter: blur(15px);

    padding: 40px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    text-align: center;

    max-width: 500px;
    width: 90%;
}


/* Revealed State */
.hidden-message.revealed {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: softFloat 6s ease-in-out infinite;
}

/* Minimized State (Hides the card) */
.hidden-message.minimized {
    opacity: 0;
    transform: scale(0.5) translate(100px, 100px);
    /* Fly towards letter position */
    pointer-events: none;
}

.hidden-message h3 {
    color: var(--highlight);
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 0 15px rgba(255, 235, 59, 0.4);
}

.hidden-message p {
    font-size: 1.2rem;
    line-height: 1.8;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    /* Shadow to ensure readability on glass */
    font-weight: 300;
}


/* Minimize Button */
.minimize-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 30px;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.minimize-btn:hover {
    background: var(--accent);
}

/* --- THE LETTER ICON (Collapsed State) --- */
.letter-icon {
    position: absolute;
    right: 10%;
    /* Position to the right of cake */
    top: 50%;
    transform: translateY(-50%) scale(0);
    /* Start hidden/small */
    width: 60px;
    height: 40px;
    background: #eee;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
    overflow: hidden;
}

/* Envelope Graphics via CSS */
.letter-icon::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 30px 20px 30px;
    border-color: transparent transparent #ddd transparent;
    /* Bottom fold */
}

.letter-icon::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 25px 30px 0 30px;
    border-color: #f5f5f5 transparent transparent transparent;
    /* Top flap */
    transform-origin: top;
    transition: transform 0.3s;
}

.letter-icon:hover::after {
    transform: rotateX(180deg);
    /* Open flap on hover */
}

/* Visible State for Letter */
.letter-icon.visible {
    transform: translateY(-50%) scale(1);
    animation: floatLetter 3s ease-in-out infinite;
}

@keyframes floatLetter {

    0%,
    100% {
        transform: translateY(-50%);
    }

    50% {
        transform: translateY(-60%);
    }
}

@media (min-width: 900px) {
    .gift-layout {
        flex-direction: column;
        /* Reset flex direction */
    }

    #three-cake-container,
    .message-wrapper {
        width: 100%;
        /* Force full width */
        position: absolute;
        /* Keep absolute positioning */
    }

    .message-wrapper {
        padding-left: 0;
        /* Remove padding from previous layout */
    }
}

/* Mobile Adjustment for Letter Position */
@media (max-width: 768px) {
    .letter-icon {
        right: 20px;
        top: 20%;
        /* Move higher on mobile so it doesn't block sticker wall scroll */
    }
}

@keyframes softFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}


/* =========================================
   SECTION: STICKER WALL (Below Gift)
   ========================================= */
.sticker-section {
    background-color: var(--bg-color);
    background-image: radial-gradient(#333 1px, transparent 1px);
    background-size: 30px 30px;
    background-attachment: fixed;
    position: relative;
    padding: 100px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 20;
    /* Keep above 3D world */
}

.wall-header h2 {
    font-family: 'Permanent Marker', cursive;
    font-size: clamp(3rem, 5vw, 5rem);
    margin-bottom: 50px;
    text-align: center;
    transform: rotate(-2deg);
}

.sticker-wall {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    max-width: 1200px;
}

.sticker-wrapper {
    width: 160px;
    height: 160px;
    position: relative;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.sticker-inner {
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.sticker-wrapper.flipped .sticker-inner {
    transform: rotateY(180deg);
}

.sticker-front,
.sticker-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Kalam', cursive;
    font-weight: bold;
    color: #222;
    box-shadow: 3px 5px 15px rgba(0, 0, 0, 0.3);

    /* RUGGED PAPER LOOK via Border Radius */
    /* This creates slightly uneven corners */
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;

    /* Subtle paper texture via gradient */
    background-image: linear-gradient(to bottom right, rgba(0, 0, 0, 0.05), transparent);
}

.tape {
    display: none;
}


.sticker-back {
    background-color: #fdfbf7 !important;
    transform: rotateY(180deg);
    padding: 10px;
    font-size: 0.9rem;
    flex-direction: column;
    text-align: center;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .timer-wrapper {
        flex-wrap: wrap;
        gap: 15px;
    }

    .number {
        font-size: 3.5rem;
    }

    .intro-title {
        width: 90vw;
        margin-left: -45vw;
        padding: 20px;
        border-width: 4px;
    }

    .intro-title h1 {
        font-size: 3rem;
    }

    .frame {
        width: 90vw;
        margin-left: -45vw;
        margin-top: -25vh;
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }

    .frame img {
        width: 100%;
        height: 250px;
    }

    .frame-content {
        width: 100%;
    }

    .gift-title {
        font-size: 2.5rem;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* =========================================
   FOOTER
   ========================================= */
footer {
    width: 100%;
    padding: 60px 0;
    text-align: center;
    background: transparent;
    color: #fff;
    position: relative;
    z-index: 20;
}

footer p {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    opacity: 0.8;
    margin: 0;
}

.dev-name {
    color: var(--accent);
    font-style: italic;
}

.mute-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mute-btn:hover {
    background: var(--accent);
    transform: scale(1.1);
}

.gift-title,
.wall-header h2 {
    font-family: 'Permanent Marker', cursive;
    font-size: clamp(3rem, 6vw, 5rem);
    /* Responsive sizing */
    color: #fff;
    text-shadow: 0 5px 15px rgba(255, 71, 87, 0.6);
    /* Consistent Glow */
    margin-bottom: 30px;
    text-align: center;
    transform: rotate(-2deg);
    /* Consistent playful tilt */
    line-height: 1.2;
}