:root {
    /* Colors */
    --color-text-main: rgb(73, 66, 66);
    --color-shadow: rgba(0, 0, 0, 0.1);
    --color-white-fade: rgba(255, 255, 255, 0.2);

    /* Typography */
    --font-family-handwritten: "Dancing Script", cursive;
    --font-family-serif: 'Times New Roman', Times, serif;
    --font-size-base: 1rem;
    --font-size-h1: 2.5rem;
    --font-size-title: 1.8rem;
    
    /* Spacing */
    --spacing-xs: 0.2rem;
    --spacing-md: 0.8rem;
    --spacing-lg: 1.5rem;

    /* Transitions */
    --transition-fade: opacity 0.8s ease-in-out;
}

@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@400..700&display=swap');

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

body {
    font-family: var(--font-family-handwritten);
    font-optical-sizing: auto;
    color: var(--color-text-main);
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100vh;
    background: url(../images/bg.png);
    overflow: hidden;
}

.paper {
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Fixed to top */
    align-items: center;
    width: 95%;
    max-width: 95vw;
    height: 95vh;
    padding: 2rem 1.5rem;
    background-image: url("../assets/paper.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    text-align: center;
    overflow: hidden; /* Remove scrollbars */
}

header {
    margin-bottom: 1rem;
}

#flipbook {
    position: relative;
    width: 80%;
    max-width: 700px;
    margin-bottom: 1.5rem;
    aspect-ratio: 16/9;
    border-radius: 12px;
    box-shadow: 0 0 15px var(--color-white-fade);
    flex-shrink: 0;
}

.flip-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    border-radius: 20px;
    transition: var(--transition-fade);
}

.flip-image.active {
    opacity: 1;
}

.message {
    display: block; /* Allow inline flow */
    width: 90%;
    margin: 0 auto;
    text-align: center;
    min-height: 100px;
}

.txt-type {
    display: inline;
    font-size: 1.5rem;
    line-height: 1.6;
}

.fas.fa-pencil-alt {
    display: inline-block;
    margin-left: 5px;
    font-size: 1.5rem;
    vertical-align: middle;
    transition: transform 0.6s ease-in-out; /* Smooth flipping transition */
}

.pen-flipped {
    transform: rotate(180deg);
}

.erasing-animation {
    animation: erasingWiggle 0.4s infinite;
}

.writing-animation {
    animation: writingText 0.5s infinite;
}

@keyframes erasingWiggle {
    0%, 100% { transform: rotate(180deg) translate(0, 0); }
    50% { transform: rotate(180deg) translate(-10px, 0); }
}

@keyframes writingText {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(3px, -5px) rotate(10deg); }
}

/* Media Queries */
@media (min-width: 1200px) {
    h1 { font-size: 5rem; }
    .uil { font-size: 5rem; }
}

@media (max-width: 800px) {
    .container { padding: 0 var(--spacing-md); }
    h1 { font-size: 3rem; }
}

@media (max-width: 500px) {
    h1 { font-size: 2.5rem; }
    h2 { font-size: 1.5rem; }
}