/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(180deg, #87CEEB 0%, #B0E0E6 50%, #E0F4FF 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
    overflow: hidden;
}

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

/* Particles Background */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.particle {
    position: absolute;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, transparent 70%);
    border-radius: 50%;
    animation: float 15s infinite ease-in-out;
    opacity: 0.6;
}

@keyframes float {
    0%, 100% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(-100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Stage Styles */
.stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 1;
}

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

/* Stage 1: Pack Selection */
.stage-selection {
    padding: 20px;
}

.title {
    font-family: 'Bangers', cursive;
    font-size: clamp(2rem, 6vw, 4rem);
    color: #1a365d;
    text-shadow:
        3px 3px 0 #ffd700,
        6px 6px 0 rgba(0,0,0,0.2);
    letter-spacing: 3px;
    margin-bottom: 10px;
    animation: titlePulse 2s infinite ease-in-out;
}

@keyframes titlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.subtitle {
    color: #2d3748;
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    margin-bottom: 40px;
    font-weight: 500;
}

/* 3D Carousel */
.carousel-container {
    width: 100%;
    max-width: 600px;
    height: 400px;
    perspective: 1200px;
    margin: 20px 0;
    position: relative;
}

/* Floor reflection effect */
.carousel-container::after {
    content: '';
    position: absolute;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 200px;
    background: linear-gradient(to bottom,
        rgba(0, 50, 100, 0.25) 0%,
        rgba(0, 50, 100, 0.1) 40%,
        transparent 100%);
    border-radius: 50%;
    filter: blur(15px);
    pointer-events: none;
}

.carousel {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.carousel-pack {
    position: absolute;
    width: 180px;
    height: 280px;
    left: 50%;
    top: 50%;
    margin-left: -90px;
    margin-top: -140px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 0.3s ease,
                filter 0.3s ease;
    transform-style: preserve-3d;
    background: linear-gradient(145deg, #3498db, #2980b9);
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    overflow: hidden;
}

/* Mirror reflection for carousel packs */
.carousel-pack::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 80%;
    background: inherit;
    border-radius: 12px;
    transform: scaleY(-1);
    opacity: 0.35;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.2) 30%, transparent 70%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.2) 30%, transparent 70%);
    pointer-events: none;
    filter: blur(1px);
}

.carousel-pack::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg,
        rgba(255,255,255,0.3) 0%,
        transparent 50%,
        rgba(0,0,0,0.2) 100%);
    pointer-events: none;
}

.carousel-pack.active {
    box-shadow: 0 30px 60px rgba(44, 82, 130, 0.4),
                0 0 30px rgba(255,215,0,0.3);
}

.carousel-pack .pack-art {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0;
    color: white;
    text-align: center;
}

.carousel-pack .pack-image-carousel {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.carousel-pack .pack-name {
    font-family: 'Bangers', cursive;
    font-size: 1.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-top: auto;
}

/* Pack theme colors */
.carousel-pack.pack-love {
    background: linear-gradient(145deg, #e91e63, #c2185b);
}

.carousel-pack.pack-destiny {
    background: linear-gradient(145deg, #9c27b0, #7b1fa2);
}

.carousel-pack.pack-eternal {
    background: linear-gradient(145deg, #ff9800, #f57c00);
}

.carousel-pack.pack-unity {
    background: linear-gradient(145deg, #4caf50, #388e3c);
}

.carousel-pack.pack-bliss {
    background: linear-gradient(145deg, #00bcd4, #0097a7);
}

/* Carousel Indicators */
.carousel-indicators {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(26, 54, 93, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
}

.indicator.active {
    background: #ffd700;
    transform: scale(1.3);
    box-shadow: 0 0 10px rgba(255,215,0,0.5);
}

/* Select Button */
.select-btn {
    margin-top: 30px;
    padding: 18px 50px;
    font-size: 1.3rem;
    font-family: 'Bangers', cursive;
    letter-spacing: 2px;
    color: #1a1a2e;
    background: linear-gradient(145deg, #ffd700, #ffb700);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(255,215,0,0.3);
}

.select-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(255,215,0,0.4);
}

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

.btn-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { left: -100%; }
    20% { left: 100%; }
    100% { left: 100%; }
}

/* Stage 2: Pack Opening */
.stage-opening {
    perspective: 1500px;
}

.pack-container {
    perspective: 1500px;
    width: 220px;
    height: 340px;
    position: relative;
}

/* Card peeking behind the pack */
.card-peek {
    position: absolute;
    width: 200px;
    height: 300px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 12px;
    overflow: hidden;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease, transform 0.5s ease;
}

.card-peek.visible {
    opacity: 1;
    transform: translate(-50%, -45%);
}

.card-peek-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.pack {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-out;
}

.pack-front {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    backface-visibility: hidden;
    overflow: hidden;
}

.pack-front-image {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.pack-front::after {
    display: none;
}

.pack-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    padding-top: 50px;
}

.pack-logo {
    font-family: 'Bangers', cursive;
    font-size: 2rem;
    color: #ffd700;
    text-shadow: 2px 2px 0 #e74c3c, 4px 4px 0 rgba(0,0,0,0.3);
    letter-spacing: 3px;
}

.pack-subtitle {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.9);
    margin-top: 5px;
    font-weight: 600;
}

.pack-image {
    width: 120px;
    height: 120px;
    margin-top: 20px;
    background: radial-gradient(circle, rgba(255,215,0,0.3) 0%, transparent 70%);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pack-image::before {
    content: '💍';
    font-size: 4rem;
}

.pack-back {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #2c3e50, #1a252f);
    border-radius: 12px;
    backface-visibility: hidden;
    transform: rotateY(180deg);
}

.pack-side {
    display: none;
}

.pack-left {
    width: 15px;
    height: 100%;
    left: -7.5px;
    transform: rotateY(-90deg) translateZ(7.5px);
    border-radius: 12px 0 0 12px;
}

.pack-right {
    width: 15px;
    height: 100%;
    right: -7.5px;
    transform: rotateY(90deg) translateZ(7.5px);
    border-radius: 0 12px 12px 0;
}

.pack-top-side {
    width: 100%;
    height: 15px;
    top: -7.5px;
    transform: rotateX(90deg) translateZ(7.5px);
}

.pack-bottom-side {
    width: 100%;
    height: 15px;
    bottom: -7.5px;
    transform: rotateX(-90deg) translateZ(7.5px);
}

/* Pack Top (tearable area) - now covers entire pack */
.pack-tear-zone {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    cursor: crosshair;
    z-index: 10;
    overflow: hidden;
}

.pack-top-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 220px;
    height: 340px;
    object-fit: cover;
    border-radius: 12px;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    clip-path: url(#tear-clip);
}

.tear-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    overflow: visible;
    z-index: 2;
}

.pack-top-fill {
    fill: url(#pack-top-gradient);
    fill: linear-gradient(180deg, #e74c3c 0%, #c0392b 100%);
    fill: #c0392b;
}

.tear-svg .pack-top-fill {
    fill: #c0392b;
}

.tear-line-visual {
    stroke: rgba(255, 255, 255, 0.9);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.8));
}

.tear-sparks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.tear-spark {
    position: absolute;
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, #fff 0%, #ffd700 50%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: sparkFade 0.3s forwards ease-out;
    pointer-events: none;
}

@keyframes sparkFade {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* Paper debris particles */
.tear-debris {
    position: absolute;
    width: 4px;
    height: 6px;
    background: linear-gradient(135deg, #f5f5f5, #d0d0d0);
    border-radius: 1px;
    transform: translate(-50%, -50%);
    animation: debrisFall forwards ease-out;
    pointer-events: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

@keyframes debrisFall {
    0% {
        transform: translate(-50%, -50%) rotate(0deg) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(0.5);
        opacity: 0;
    }
}

/* Paper fiber strands */
.tear-fiber {
    position: absolute;
    background: linear-gradient(to bottom, rgba(255,255,255,0.9), rgba(200,200,200,0.6));
    border-radius: 1px;
    transform-origin: top center;
    animation: fiberWave 0.5s ease-out forwards;
    pointer-events: none;
}

@keyframes fiberWave {
    0% {
        opacity: 1;
        transform: rotate(0deg) scaleY(0);
    }
    30% {
        transform: rotate(var(--rot, 0deg)) scaleY(1);
    }
    100% {
        opacity: 0;
        transform: rotate(var(--rot, 0deg)) scaleY(1) translateY(10px);
    }
}

/* Torn top piece that flies off */
.pack-torn-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    z-index: 11;
    opacity: 0;
    pointer-events: none;
    transform-origin: center center;
    overflow: hidden;
}

.pack-torn-top-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.pack-torn-top.flying-off {
    opacity: 1;
    animation: tornTopFlyOff 0.8s forwards ease-out;
}

@keyframes tornTopFlyOff {
    0% {
        transform: translateY(0) rotateX(0deg) rotateZ(0deg) scale(1);
        opacity: 1;
    }
    20% {
        transform: translateY(-10px) rotateX(-15deg) rotateZ(2deg) scale(1.02);
    }
    50% {
        transform: translateY(-80px) rotateX(-45deg) rotateZ(-5deg) scale(0.95);
        opacity: 0.9;
    }
    100% {
        transform: translateY(-200px) rotateX(-90deg) rotateZ(-10deg) translateZ(100px) scale(0.7);
        opacity: 0;
    }
}

.pack-top::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: repeating-linear-gradient(90deg,
        transparent 0px,
        transparent 8px,
        rgba(255,255,255,0.3) 8px,
        rgba(255,255,255,0.3) 10px);
    z-index: 1;
}

.pack-tear-line {
    position: absolute;
    top: 38px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.5) 20%,
        rgba(255,255,255,0.8) 50%,
        rgba(255,255,255,0.5) 80%,
        transparent 100%);
    opacity: 0.5;
}

.tear-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg,
        rgba(255,255,255,0.1) 0%,
        rgba(255,255,255,0.4) 100%);
    transition: width 0.05s linear;
}

.pack.tearing .pack-top {
    animation: tearShake 0.1s infinite;
}

@keyframes tearShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

.pack.torn .pack-top {
    animation: tearOff 0.5s forwards ease-out;
}

@keyframes tearOff {
    0% {
        transform: translateY(0) rotateX(0);
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) rotateX(-90deg);
        opacity: 0;
    }
}

.pack.opening {
    animation: packOpen 1s forwards ease-out;
}

@keyframes packOpen {
    0% {
        transform: rotateY(0);
    }
    50% {
        transform: rotateY(-15deg) translateZ(50px);
    }
    100% {
        transform: rotateY(0) translateY(-50px) scale(0.8);
        opacity: 0;
    }
}

.instruction {
    color: #1a365d;
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: bounce 2s infinite;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

.swipe-icon {
    font-size: 1.5rem;
    animation: swipeHint 1.5s infinite ease-in-out;
}

@keyframes swipeHint {
    0%, 100% { transform: translateX(-20px); }
    50% { transform: translateX(20px); }
}

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

/* Stage 3: Card Reveal - 3D Rotatable Stack */
.stage-reveal {
    perspective: 2000px;
}

.cards-scene {
    width: 280px;
    height: 400px;
    perspective: 2000px;
    position: relative;
}

.cards-container {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-out;
    cursor: grab;
}

.cards-container:active {
    cursor: grabbing;
}

.cards-container.animating {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Card Stack */
.card-stack {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.reveal-card {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.4s ease,
                left 0.6s ease;
    cursor: pointer;
}

.reveal-card .card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    backface-visibility: hidden;
    overflow: hidden;
}

.reveal-card .card-front {
    display: flex;
    justify-content: center;
    align-items: center;
}

.reveal-card .card-back {
    background: linear-gradient(145deg, #1a237e, #0d47a1);
    display: flex;
    justify-content: center;
    align-items: center;
    transform: rotateY(180deg);
}

.reveal-card .card-back::before {
    content: '';
    position: absolute;
    width: 80%;
    height: 80%;
    border: 3px solid rgba(255,215,0,0.5);
    border-radius: 50%;
}

.reveal-card .card-back::after {
    content: '?';
    font-size: 4rem;
    color: rgba(255,215,0,0.8);
    font-family: 'Bangers', cursive;
}

/* Card edge/side for 3D effect - hidden */
.reveal-card .card-edge {
    display: none;
}

.reveal-card .card-edge-left {
    width: 4px;
    height: 100%;
    left: -2px;
    top: 0;
    transform: rotateY(-90deg) translateZ(2px);
    border-radius: 12px 0 0 12px;
}

.reveal-card .card-edge-right {
    width: 4px;
    height: 100%;
    right: -2px;
    top: 0;
    transform: rotateY(90deg) translateZ(2px);
    border-radius: 0 12px 12px 0;
}

.reveal-card .card-edge-top {
    width: 100%;
    height: 4px;
    top: -2px;
    left: 0;
    transform: rotateX(90deg) translateZ(2px);
}

.reveal-card .card-edge-bottom {
    width: 100%;
    height: 4px;
    bottom: -2px;
    left: 0;
    transform: rotateX(-90deg) translateZ(2px);
}

.reveal-card.flipped {
    transform: rotateY(180deg);
}

.reveal-card.revealed {
    animation: cardSlideOut 0.6s forwards ease-out;
}

@keyframes cardSlideOut {
    0% {
        transform: rotateY(180deg) translateX(0) translateZ(0);
        opacity: 1;
    }
    100% {
        transform: rotateY(180deg) translateX(-150%) translateZ(-100px);
        opacity: 0;
    }
}

.reveal-card .card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* Chrome Rainbow Border for Final Card */
.reveal-card.final-card {
    border-radius: 16px;
}

.reveal-card.final-card::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    background: linear-gradient(
        45deg,
        #ff0000,
        #ff7300,
        #fffb00,
        #48ff00,
        #00ffd5,
        #002bff,
        #7a00ff,
        #ff00c8,
        #ff0000
    );
    background-size: 400% 400%;
    border-radius: 18px;
    z-index: -1;
    animation: chromeBorder 3s ease infinite;
    filter: blur(0px);
}

.reveal-card.final-card::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    background: linear-gradient(
        45deg,
        #ff0000,
        #ff7300,
        #fffb00,
        #48ff00,
        #00ffd5,
        #002bff,
        #7a00ff,
        #ff00c8,
        #ff0000
    );
    background-size: 400% 400%;
    border-radius: 18px;
    z-index: -2;
    animation: chromeBorder 3s ease infinite;
    filter: blur(15px);
    opacity: 0.7;
}

@keyframes chromeBorder {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Chrome shine overlay */
.reveal-card.final-card .card-front::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255,255,255,0.4),
        transparent
    );
    animation: chromeShine 2s ease-in-out infinite;
}

@keyframes chromeShine {
    0% {
        left: -100%;
    }
    50%, 100% {
        left: 200%;
    }
}

.tap-instruction {
    color: #1a365d;
    font-weight: 600;
    margin-top: 30px;
    animation: pulse 1.5s infinite;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

.drag-instruction {
    color: #2d4a6d;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

.drag-instruction .rotate-icon {
    animation: rotateHint 2s ease-in-out infinite;
}

@keyframes rotateHint {
    0%, 100% { transform: rotateY(0deg); }
    50% { transform: rotateY(30deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Stage 4: Final Invitation */
.stage-final {
    perspective: 2000px;
}

.invitation-container {
    perspective: 2000px;
}

.invitation-card {
    width: 320px;
    height: 450px;
    position: relative;
    transform-style: preserve-3d;
    animation: cardEntrance 1.5s ease-out forwards;
    cursor: pointer;
}

@keyframes cardEntrance {
    0% {
        transform: translateY(100vh) rotateY(1080deg) scale(0.2);
        opacity: 0;
    }
    60% {
        transform: translateY(-20px) rotateY(360deg) scale(1.05);
        opacity: 1;
    }
    80% {
        transform: translateY(10px) rotateY(0deg) scale(0.98);
    }
    100% {
        transform: translateY(0) rotateY(0deg) scale(1);
    }
}

.invitation-card .card-inner {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-out;
}

.invitation-card .card-front,
.invitation-card .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    backface-visibility: hidden;
    overflow: hidden;
    box-shadow: 0 30px 60px rgba(0,0,0,0.5),
                0 0 40px rgba(255,215,0,0.3);
}

.invitation-card .card-front {
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
}

.invitation-card .card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
}

.invitation-card .card-back {
    background: linear-gradient(145deg, #1a237e, #0d47a1);
    transform: rotateY(180deg);
}

.card-pattern {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 50% 50%, rgba(255,215,0,0.1) 0%, transparent 50%),
        repeating-linear-gradient(45deg, transparent 0px, transparent 10px, rgba(255,215,0,0.05) 10px, rgba(255,215,0,0.05) 20px);
}

/* Holographic effect on card */
.invitation-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        transparent 0%,
        rgba(255,255,255,0.1) 25%,
        transparent 50%,
        rgba(255,255,255,0.1) 75%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 10;
    border-radius: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.invitation-card:hover::before {
    opacity: 1;
}

/* Sparkles */
.sparkles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.sparkle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, #ffd700 0%, transparent 70%);
    border-radius: 50%;
    animation: sparkle 1s forwards ease-out;
}

@keyframes sparkle {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: scale(2) rotate(180deg);
        opacity: 0;
    }
}

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

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 20px;
    top: -20px;
    animation: confettiFall 3s forwards ease-in;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotateZ(0deg) rotateY(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotateZ(720deg) rotateY(720deg);
        opacity: 0;
    }
}

.final-buttons {
    position: absolute;
    bottom: 50px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.save-btn {
    padding: 15px 40px;
    font-size: 1.1rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: #1a1a2e;
    background: linear-gradient(145deg, #ffd700, #ffb700);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(255,215,0,0.3);
    display: flex;
    align-items: center;
    gap: 10px;
}

.save-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(255,215,0,0.4);
}

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

.save-icon {
    font-size: 1.2rem;
}

.restart-btn {
    padding: 15px 40px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: #1a365d;
    background: rgba(255,255,255,0.4);
    border: 2px solid rgba(26, 54, 93, 0.3);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.restart-btn:hover {
    background: rgba(255,255,255,0.6);
    border-color: rgba(26, 54, 93, 0.5);
    transform: translateY(-3px);
}

/* Responsive - Landscape/Horizontal screens */
@media (orientation: landscape) {
    /* Final stage horizontal layout - buttons on side */
    .stage-final {
        padding: 20px;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 40px;
    }

    .invitation-container {
        margin-top: 0;
    }

    .final-buttons {
        position: relative;
        bottom: auto;
        flex-direction: column;
        gap: 20px;
        align-items: flex-start;
    }

    .save-btn {
        padding: 14px 28px;
        font-size: 1rem;
        white-space: nowrap;
    }

    .restart-btn {
        padding: 12px 24px;
        font-size: 0.9rem;
        white-space: nowrap;
    }

    /* Adjust card size for landscape on smaller screens */
    .invitation-card {
        max-height: 80vh;
        width: auto;
        aspect-ratio: 0.71;
    }
}

/* Responsive - Tablets */
@media (min-width: 601px) and (max-width: 1024px) {
    .carousel-container {
        height: 380px;
    }

    .carousel-pack {
        width: 160px;
        height: 250px;
        margin-left: -80px;
        margin-top: -125px;
    }

    .pack-container {
        width: 200px;
        height: 310px;
    }

    .card-peek {
        width: 180px;
        height: 270px;
    }

    .invitation-card {
        width: 300px;
        height: 420px;
    }

    .cards-scene {
        width: 260px;
        height: 370px;
    }

    .cards-container {
        width: 240px;
        height: 340px;
    }

    .reveal-card {
        width: 240px;
        height: 340px;
    }

    /* Final stage tablet optimization - horizontal layout */
    .stage-final {
        padding: 20px;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 30px;
    }

    .invitation-container {
        margin-top: 0;
    }

    .final-buttons {
        position: relative;
        bottom: auto;
        flex-direction: column;
        gap: 20px;
        align-items: flex-start;
    }

    .save-btn {
        padding: 14px 28px;
        font-size: 1rem;
        white-space: nowrap;
    }

    .restart-btn {
        padding: 12px 24px;
        font-size: 0.9rem;
        white-space: nowrap;
    }
}

/* Responsive - Mobile */
@media (max-width: 600px) {
    .carousel-container {
        height: 350px;
    }

    .carousel-pack {
        width: 140px;
        height: 220px;
        margin-left: -70px;
        margin-top: -110px;
    }

    .pack-container {
        width: 180px;
        height: 280px;
    }

    /* Card peek should be smaller than pack on mobile */
    .card-peek {
        width: 160px;
        height: 240px;
    }

    .invitation-card {
        width: 260px;
        height: 370px;
    }

    .cards-scene {
        width: 220px;
        height: 320px;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .cards-container {
        width: 200px;
        height: 280px;
    }

    .reveal-card {
        width: 200px;
        height: 280px;
    }

    /* Final stage mobile optimization */
    .stage-final {
        padding: 15px;
        padding-top: 30px;
        justify-content: flex-start;
    }

    .invitation-container {
        margin-top: 10px;
    }

    .final-buttons {
        position: relative;
        bottom: auto;
        margin-top: 20px;
        gap: 12px;
    }

    .save-btn {
        padding: 12px 30px;
        font-size: 1rem;
    }

    .restart-btn {
        padding: 10px 25px;
        font-size: 0.9rem;
    }
}

/* Loading placeholder for invitation image */
#invitation-image {
    background: linear-gradient(145deg, #e0e0e0, #f5f5f5);
    min-height: 100%;
}

#invitation-image[src="invitation-card.png"]:not([src=""]) {
    object-fit: contain;
}
