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

body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e6e0d0;
    font-family: 'Courier New', monospace;
    overflow: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 300 300' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.5' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.08;
    pointer-events: none;
    z-index: 1;
    mix-blend-mode: multiply;
}

.container {
    position: relative;
    width: 100%;
    max-width: 1200px;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    z-index: 2;
}

/* Envelope Wrapper */
.envelope-wrapper {
    position: relative;
    width: 1102px;
    height: 1102px;
    max-width: 90vw;
    max-height: 90vw;
}

/* Closed Envelope State */
.envelope-closed {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: auto;
    z-index: 10;
    transition: opacity 0.6s ease;
}

.envelope-closed .envelope-base {
    width: 100%;
    height: auto;
    display: block;
}

/* Fade out when opening */
.envelope-wrapper.opening .envelope-closed {
    opacity: 0;
    pointer-events: none;
}

/* Stamp Image - visible stamp in the middle */
.stamp-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    z-index: 11;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.stamp-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Hide stamp image when opening */
.envelope-wrapper.opening .stamp-image {
    opacity: 0;
}

/* Stamp shake animation */
@keyframes stamp-shake {
    0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
    25% { transform: translate(-50%, -50%) rotate(-2deg); }
    75% { transform: translate(-50%, -50%) rotate(2deg); }
}

/* Apply shake when hovering over stamp hotspot */
.stamp-hotspot:hover + .stamp-image {
    animation: stamp-shake 0.3s ease-in-out infinite;
}

/* Stamp Hotspot - positioned where the stamp is in closed.png */
.stamp-hotspot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    cursor: pointer;
    z-index: 12;
    transition: opacity 0.3s ease;
    border-radius: 50%;
}

.stamp-hotspot:active {
    transform: translate(-50%, -50%) scale(0.98);
}

/* Hide stamp when opening */
.envelope-wrapper.opening .stamp-hotspot {
    opacity: 0;
    pointer-events: none;
}

/* Opened Envelope State */
.envelope-opened {
    position: absolute;
    top: 46%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: auto;
    z-index: 9;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease 0.3s;
}

.envelope-opened img {
    width: 100%;
    height: auto;
    display: block;
}

.envelope-wrapper.opening .envelope-opened {
    opacity: 1;
    pointer-events: all;
}

/* Card Hotspots on the opened envelope */
.card-hotspot {
    position: absolute;
    z-index: 10;
}

/* Position hotspots over each card in letteropencard.png - matching reference layout */
/* Circular card (polaroid on LEFT) - sticking out top left */
.card-hotspot-1 {
    top: 8%;
    left: 12%;
    width: 30%;
    height: 42%;
}

/* Garden card (film negative in MIDDLE) - sticking out top center */
.card-hotspot-2 {
    top: 12%;
    left: 36%;
    width: 30%;
    height: 40%;
}

/* Sand card (stamp on RIGHT) - smallest, sticking out top right */
.card-hotspot-3 {
    top: 6%;
    right: 12%;
    width: 24%;
    height: 28%;
}

/* Fullsize Viewer */
.fullsize-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #e6e0d0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

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

.fullsize-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transform: translateX(15%);
}

#fullsizeImage {
    max-width: 45vw;
    max-height: 80vh;
    object-fit: contain;
    animation: fadeInScale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
}

/* Jiggle animation for all cards when in fullsize viewer */
.fullsize-viewer.active #fullsizeImage {
    animation: fadeInScale 0.4s ease-out;
    transition: transform 0.6s ease-out;
}

.fullsize-viewer.active #fullsizeImage:hover {
    transform: rotate(1.5deg) scale(1.05);
}

@keyframes jiggle {
    0%, 100% { transform: rotate(0deg) translateX(0); }
    25% { transform: rotate(-0.1deg) translateX(-0.2px); }
    75% { transform: rotate(0.1deg) translateX(0.2px); }
}

/* Click to enter element */
.click-to-enter {
    max-width: 250px !important;
    max-height: 250px !important;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease 0.3s;
    cursor: default !important;
}

.fullsize-viewer.active.show-enter .click-to-enter {
    opacity: 1;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Fullsize viewer stamp */
.fullsize-stamp {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 60px;
    height: 60px;
    cursor: pointer;
    z-index: 1000;
}

@keyframes jiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
    75% { transform: rotate(-2deg); }
}

.fullsize-stamp:hover {
    animation: jiggle 0.3s ease-in-out;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .envelope-wrapper {
        width: 95vw;
        height: 95vw;
    }
    
    .stamp {
        width: 15%;
        height: 15%;
    }
    
    .envelope-wrapper.opened .card {
        width: 60%;
    }
}