body {
    background-color: #263194;
    background-image: radial-gradient(circle at center, #263194 0%, #1a226b 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    font-family: 'Quicksand', sans-serif;
    perspective: 1500px;
    overflow-x: hidden;
    position: relative;
    padding: 20px;
    box-sizing: border-box;
}

.container {
    width: 90vw;
    max-width: 380px;
    height: 450px;
    animation: float 3s ease-in-out infinite;
    transition: width 0.8s ease-in-out, height 0.8s ease-in-out, max-width 0.8s ease-in-out;
}

.container.enlarged {
    max-width: 500px;
    height: auto;
    min-height: 550px;
}

.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    transform-origin: left;
    box-shadow: 0 30px 40px rgba(0, 0, 0, 0.3);
    background-color: #ffffff;
    border-radius: 15px;
}

.card.open .card-front {
    display: none;
}

.card.open {
    height: auto;
}

.card.open .card-inside {
    position: relative;
    height: auto;
    min-height: 100%;
    display: block;
}

.card-front, .card-inside {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 1;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.front-content, .inside-content {
    position: relative;
    z-index: 5;
    padding: 20px;
}

#background-stamps {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.stamp {
    position: absolute;
    user-select: none;
    pointer-events: none;
}

.card-front {
    background: #892694;
    background: linear-gradient(135deg, #892694 0%, #af30bd 100%);
    color: white;
    z-index: 2;
    border: 4px solid #222244;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
}

.front-content h1 {
    font-family: 'Great Vibes', cursive;
    font-size: 3.5rem;
    margin-bottom: 20px;
    text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.1);
}

.pulse {
    animation: pulse 1.5s infinite;
    font-size: 1.2rem;
    opacity: 0.9;
}

.card-inside {
    background-color: #ece6d3;
    color: #333;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.inside-content {
    padding: 40px;
    transition: padding 0.8s ease-in-out;
}

.card.open .inside-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100%;
}

.container.enlarged .inside-content {
    padding: 60px;
}

.inside-content p,
.signature {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out, font-size 0.8s ease-in-out;
}

.inside-content h2 {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out, font-size 0.8s ease-in-out;
    margin-top: 0;
}

.card.open .inside-content h2 {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.5s;
}

.card.open .inside-content p:nth-of-type(1) {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.7s;
}

.card.open .inside-content p:nth-of-type(2) {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.9s;
}

.card.open .inside-content p:nth-of-type(3) {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 1.1s;
}

.card.open .inside-content .signature {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 1.3s;
    font-size: x-large;
}

.inside-content p:last-of-type {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 1.5s;
    margin-bottom: 10px;
}

.inside-content h2 {
    color: #892694;
    font-family: 'Great Vibes', cursive;
    font-size: 2.5rem;
}

.container.enlarged .inside-content h2 {
    font-size: 3rem;
}

.inside-content p {
    font-size: 1rem;
    margin: 10px 0;
}

.card.open .inside-content p {
    width: 100%;
}

.container.enlarged .inside-content p {
    font-size: 1.1rem;
}

.signature {
    margin-top: 15px;
    font-weight: bold;
    color: #af30bd;
    font-family: 'Dancing Script', cursive;
    font-size: 2rem;
    align-self: flex-end;
    width: 100%;
    text-align: right;
    padding-right: 20px;
    box-sizing: border-box;
}

.container.enlarged .signature {
    font-size: 2.8rem;
}

@media (max-width: 480px) {
    .container {
        width: 95vw;
        max-width: none;
    }

    .container.enlarged {
        width: 95vw;
        max-width: none;
        min-height: 80vh;
    }

    .inside-content {
        padding: 25px 15px;
    }

    .container.enlarged .inside-content {
        padding: 30px 20px;
    }

    .front-content h1 {
        font-size: 2.5rem;
    }

    .inside-content h2 {
        font-size: 2rem;
    }

    .container.enlarged .inside-content h2 {
        font-size: 2.2rem;
    }

    .inside-content p {
        font-size: 0.9rem;
    }

    .container.enlarged .inside-content p {
        font-size: 1rem;
    }

    .signature {
        font-size: 1.8rem;
    }

    .container.enlarged .signature {
        font-size: 2.2rem;
    }
}

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

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}
