:root {
    --primary: #6a5acd; /* Slate blue */
    --secondary: #ff9ff3; /* Bubblegum pink */
    --accent: #feca57; /* Pastel yellow */
    --paper: #fff9e6; /* Creamy white */
    --text: #5a3d5c; /* Deep purple */
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: 'Comic Neue', cursive;
    overflow: hidden;
}

.scene {
    width: 420px;
    height: 600px;
    perspective: 1800px;
    position: relative;
    margin-top: 20px;
}

.book {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s;
    box-shadow: 0 15px 30px rgba(106, 90, 205, 0.3);
}

.book:hover {
    transform: translateY(-5px) rotate(2deg);
}

.page {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: left center;
    transition: transform 1s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    transform-style: preserve-3d;
    cursor: pointer;
    border-radius: 5px 10px 10px 5px;
}

.face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    padding: 30px;
    display: flex;
    flex-direction: column;
    background-color: var(--paper);
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23ff9ff3' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
}

.front {
    z-index: 2;
    box-shadow: inset 15px 0 20px -10px rgba(0,0,0,0.1);
    border-right: 1px dashed rgba(106, 90, 205, 0.3);
}

.back {
    transform: rotateY(180deg);
    z-index: 1;
    box-shadow: inset -15px 0 20px -10px rgba(0,0,0,0.1);
    border-left: 1px dashed rgba(106, 90, 205, 0.3);
}

.cover-front {
    background: linear-gradient(135deg, var(--primary), #8a7aff);
    color: white;
    border-radius: 5px 15px 15px 5px;
    justify-content: center;
    align-items: center;
    text-align: center;
    border-left: 10px solid #4b3d8f;
}

.cover-back {
    background: linear-gradient(135deg, var(--secondary), #ffb3f3);
    border-radius: 15px 5px 5px 15px;
    color: white;
    justify-content: center;
    align-items: center;
}

.cover-content, .end-content {
    border: 3px dotted white;
    padding: 30px;
    height: 85%;
    width: 85%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

h1 {
    font-family: 'Fredoka One', cursive;
    font-size: 3rem;
    margin: 0;
    color: white;
    text-shadow: 3px 3px 0 rgba(0,0,0,0.2);
    line-height: 1.2;
    letter-spacing: 1px;
}

h2 {
    font-family: 'Fredoka One', cursive;
    color: var(--primary);
    border-bottom: 3px dotted var(--accent);
    padding-bottom: 10px;
    font-size: 1.8rem;
    margin-top: 0;
}

p {
    line-height: 1.8;
    font-size: 1.2rem;
    color: var(--text);
    margin: 15px 0;
}

p::first-letter {
    font-family: 'Fredoka One', cursive;
    font-size: 3rem;
    float: left;
    line-height: 0.8;
    padding-right: 8px;
    color: var(--primary);
}

.author {
    margin-top: 15px;
    font-size: 1.1rem;
    color: white;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

.illustration {
    width: 100%;
    height: 180px;
    border: 4px solid white;
    border-radius: 10px;
    padding: 5px;
    background: white;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.1);
    margin: 15px 0;
    overflow: hidden;
}

.illustration img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
}

.page-num {
    position: absolute;
    bottom: 15px;
    width: 100%;
    text-align: center;
    font-family: 'Fredoka One', cursive;
    font-size: 0.9rem;
    color: var(--primary);
    left: 0;
}

.controls {
    margin-top: 40px;
    display: flex;
    gap: 15px;
    z-index: 10;
}

.control-btn {
    padding: 12px 20px;
    border: none;
    background: var(--primary);
    color: white;
    font-family: 'Fredoka One', cursive;
    cursor: pointer;
    transition: 0.3s;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    box-shadow: 0 4px 0 #4b3d8f;
}

.control-btn:hover {
    background: var(--secondary);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #d47ec6;
}

.control-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #4b3d8f;
}

.stars {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.star {
    color: var(--accent);
    filter: drop-shadow(0 0 2px gold);
    width: 24px;
    height: 24px;
}
.flipped {
    transform: rotateY(-180deg);
}
.page {
    pointer-events: none;
    transition: transform 1s ease-in-out, z-index 0.5s linear;
    transform-style: preserve-3d;
    z-index: 1;
}

.page.flipped {
    pointer-events: auto;
    transform: rotateY(-180deg);
    z-index: 10;
}

/* Animation for page turning */
@keyframes pageTurn {
    0% { transform: rotateY(0); }
    100% { transform: rotateY(-180deg); }
}

/* Responsive controls */
.controls {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    justify-content: center;
    background: rgba(255,255,255,0.8);
    padding: 10px;
    backdrop-filter: blur(5px);
}

/* Progress indicator */
.progress {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 5px;
    background: rgba(106, 90, 205, 0.2);
    border-radius: 5px;
    z-index: 100;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 5px;
    transition: width 0.3s ease;
}
@media (max-width: 500px) {
    .scene {
        width: 320px;
        height: 480px;
    }
    
    h1 {
        font-size: 2.2rem;
    }
    
    h2 {
        font-size: 1.4rem;
    }
    
    p {
        font-size: 1rem;
    }
    
    .illustration {
        height: 140px;
    }
    
    .controls {
        margin-top: 30px;
    }