body {
    font-family: sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f0f0f0;
    margin: 0;
}

.container {
    text-align: center;
    background-color: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    position: relative;
    min-height: 400px;
    width: 350px;
}

h1 {
    margin-bottom: 1.5rem;
}

#answer-button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    background-color: #007bff;
    color: white;
    border-radius: 5px;
    transition: background-color 0.3s;
    margin-bottom: 1rem;
}

#answer-button:hover {
    background-color: #0056b3;
}

#animation-container {
    position: relative;
    height: 250px;
    margin-top: 1rem;
}

#capsule {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

#capsule-top, #capsule-bottom {
    width: 100px;
    height: 50px;
    background-color: #ff4b4b;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

#capsule-top {
    top: -50px;
    border-radius: 50px 50px 0 0;
}

#capsule-bottom {
    top: 0;
    background-color: #fff;
    border: 3px solid #ff4b4b;
    border-radius: 0 0 50px 50px;
}

#note {
    width: 120px;
    background-color: #fcfcac;
    border: 1px solid #e6e696;
    border-radius: 5px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    padding: 15px;
}

#answer-display {
    font-weight: bold;
    text-align: center;
    font-size: 0; /* Initially hidden */
    opacity: 0;
}

/* Animation Classes */
.animate #capsule {
    display: block;
    animation: capsule-shake 0.8s ease-in-out;
}

.animate #capsule-top {
    animation: capsule-open-top 1s ease-in-out 0.8s forwards;
}

.animate #capsule-bottom {
    animation: capsule-open-bottom 1s ease-in-out 0.8s forwards;
}

.animate #note {
    animation: note-emerge 1.5s ease-in-out 1s forwards;
}

.animate #answer-display {
    animation: text-appear 1s linear 2s forwards;
}

/* Keyframes */
@keyframes capsule-shake {
    0%, 100% { transform: translate(-50%, -50%) rotate(0); }
    25% { transform: translate(-55%, -50%) rotate(-5deg); }
    75% { transform: translate(-45%, -50%) rotate(5deg); }
}

@keyframes capsule-open-top {
    100% { transform: translate(-50%, -60px); }
}

@keyframes capsule-open-bottom {
    100% { transform: translate(-50%, 60px); }
}

@keyframes note-emerge {
    0% {
        transform: translate(-50%, -50%) scaleY(0);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -20%) scaleY(1);
        opacity: 1;
        height: 20px; /* Rolled paper */
    }
    100% {
        transform: translate(-50%, 0%) scaleY(1);
        opacity: 1;
        height: auto; /* Unrolled paper */
        min-height: 100px;
    }
}

@keyframes text-appear {
    100% {
        font-size: 1.1rem;
        opacity: 1;
    }
}