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

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 50%, #F0E68C 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Storybook Container */
.storybook-container {
    width: 100%;
    max-width: 500px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    position: relative;
    aspect-ratio: 431/648;
    border: 8px solid #8B4513;
}

/* Page Styles */
.page {
    display: none;
    width: 100%;
    height: 100%;
    position: relative;
    background: white;
}

.page.active {
    display: flex;
    flex-direction: column;
}

/* Cover Page */
.cover-page {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    justify-content: center;
    align-items: center;
    text-align: center;
}

.book-cover {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.cover-text {
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 15px;
    margin: 20px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.cover-text h1 {
    font-size: 1.8rem;
    color: #8B4513;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1rem;
    color: #666;
    margin-bottom: 20px;
}

.start-button {
    background: linear-gradient(45deg, #FF6B6B, #FF8E53);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.1rem;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.start-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Story Pages */
.story-page {
    padding: 20px;
    justify-content: space-between;
}

.page-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.illustration-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
}

.story-illustration {
    width: 100%;
    height: auto;
    max-height: 250px;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.story-text {
    background: rgba(255, 248, 220, 0.9);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    border: 2px solid #DEB887;
}

.story-text h2 {
    color: #8B4513;
    font-size: 1.3rem;
    margin-bottom: 10px;
    text-align: center;
}

.story-text p {
    font-size: 0.9rem;
    line-height: 1.4;
    color: #333;
    text-align: justify;
}

/* Audio Controls */
.audio-controls {
    text-align: center;
    margin-bottom: 10px;
}

.audio-button {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.audio-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.audio-button.playing {
    background: linear-gradient(45deg, #FF6B6B, #FF8E53);
    animation: pulse 1.5s infinite;
}

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

/* Navigation */
.navigation {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 15px;
    border-radius: 20px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.nav-button {
    background: linear-gradient(45deg, #6C5CE7, #A29BFE);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.nav-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.nav-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.page-indicator {
    font-size: 0.9rem;
    color: #333;
    font-weight: bold;
    min-width: 80px;
    text-align: center;
}

/* Auto-play Controls */
.auto-play-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
}

.auto-play-button {
    background: linear-gradient(45deg, #FF6B6B, #FF8E53);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.auto-play-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.3);
}

.auto-play-button.active {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    animation: pulse 2s infinite;
}

/* End Page */
.end-page {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    justify-content: center;
    align-items: center;
    text-align: center;
}

.end-content {
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.end-content h1 {
    font-size: 2rem;
    color: #8B4513;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.end-content p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 25px;
}

.restart-button {
    background: linear-gradient(45deg, #6C5CE7, #A29BFE);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.1rem;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.restart-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Responsive Design */
@media (max-width: 600px) {
    .storybook-container {
        max-width: 90vw;
        margin: 10px;
    }
    
    .cover-text h1 {
        font-size: 1.5rem;
    }
    
    .story-text h2 {
        font-size: 1.1rem;
    }
    
    .story-text p {
        font-size: 0.85rem;
    }
    
    .navigation {
        bottom: 5px;
        gap: 10px;
        padding: 6px 12px;
    }
    
    .nav-button {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .page-indicator {
        font-size: 0.8rem;
        min-width: 60px;
    }
}

@media (max-width: 400px) {
    .story-page {
        padding: 15px;
    }
    
    .story-text {
        padding: 12px;
    }
    
    .cover-text {
        padding: 15px;
        margin: 15px;
    }
    
    .cover-text h1 {
        font-size: 1.3rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Accessibility */
.nav-button:focus,
.audio-button:focus,
.start-button:focus,
.restart-button:focus,
.auto-play-button:focus {
    outline: 3px solid #FFD700;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .storybook-container {
        box-shadow: none;
        border: 2px solid #000;
    }
    
    .navigation,
    .auto-play-controls,
    .audio-controls {
        display: none;
    }
    
    .page {
        display: block !important;
        page-break-after: always;
    }
    
    .page:last-child {
        page-break-after: avoid;
    }
}