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

body {
    font-family: 'Crimson Text', serif;
    background: linear-gradient(rgba(32, 29, 27, 0.36), rgba(32, 29, 27, 0.48)), url('ruined-city-background.png') center / cover fixed no-repeat;
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.book-container {
    max-width: 1200px;
    width: 100%;
    perspective: 1000px;
}

.page {
    background: #fefcf5;
    border-radius: 8px;
    box-shadow: 
        0 10px 30px rgba(0,0,0,0.1),
        inset 0 1px 0 rgba(255,255,255,0.6);
    padding: 60px 80px;
    position: relative;
    overflow: hidden;
    animation: pageEnter 1s ease-out;
    transform-style: preserve-3d;
}

.page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(139, 69, 19, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(139, 69, 19, 0.03) 0%, transparent 50%);
    pointer-events: none;
}

@keyframes pageEnter {
    from {
        transform: rotateY(-10deg) translateZ(-100px);
        opacity: 0;
    }
    to {
        transform: rotateY(0deg) translateZ(0px);
        opacity: 1;
    }
}

.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.title {
    font-size: 3.5rem;
    font-weight: 600;
    color: #2c1810;
    margin-bottom: 20px;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(44, 24, 16, 0.1);
}

.ornamental-border {
    width: 200px;
    height: 2px;
    margin: 0 auto;
    background: linear-gradient(to right, transparent, #8b4513, transparent);
    position: relative;
}

.ornamental-border::before,
.ornamental-border::after {
    content: '';
    position: absolute;
    top: -3px;
    width: 8px;
    height: 8px;
    background: #8b4513;
    border-radius: 50%;
}

.ornamental-border::before {
    left: -4px;
}

.ornamental-border::after {
    right: -4px;
}

.story-content {
    line-height: 1.8;
    color: #3a2517;
    font-size: 1.5rem;
}

.story-content p {
    margin-bottom: 24px;
    text-align: justify;
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
}

.story-content p:nth-child(1) { animation-delay: 0.2s; }
.story-content p:nth-child(2) { animation-delay: 0.4s; }
.story-content p:nth-child(3) { animation-delay: 0.6s; }
.story-content p:nth-child(4) { animation-delay: 0.8s; }
.story-content p:nth-child(5) { animation-delay: 1.0s; }
.story-content p:nth-child(6) { animation-delay: 1.2s; }
.story-content p:nth-child(7) { animation-delay: 1.4s; }
.story-content p:nth-child(8) { animation-delay: 1.6s; }
.story-content p:nth-child(9) { animation-delay: 1.8s; }
.story-content p:nth-child(10) { animation-delay: 2.0s; }
.story-content p:nth-child(11) { animation-delay: 2.2s; }
.story-content p:nth-child(12) { animation-delay: 2.4s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.opening {
    font-size: 1.8rem !important;
    font-style: italic;
    color: #2c1810 !important;
    text-align: center !important;
    margin-bottom: 40px !important;
    font-weight: 600;
}

.dialogue {
    font-style: italic;
    padding-left: 30px;
    border-left: 3px solid #8b4513;
    background: rgba(139, 69, 19, 0.05);
    padding: 20px 30px;
    border-radius: 0 8px 8px 0;
    position: relative;
    font-size: 1.4rem;
}

.dialogue::before {
    content: '"';
    font-size: 3rem;
    color: #8b4513;
    position: absolute;
    top: -10px;
    left: 10px;
    opacity: 0.3;
}

.ending {
    font-size: 1.4rem !important;
    font-style: italic;
    color: #4a2c1a !important;
    border-top: 1px solid #d4c4a8;
    padding-top: 30px !important;
    margin-top: 40px !important;
}

.page-footer {
    margin-top: 50px;
    text-align: center;
}

/* Add styles for fairy tale images */
.fairy-tale-image {
    width: 100%;
    max-width: 400px;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    margin: 30px auto;
    display: block;
    border: 3px solid #d4c4a8;
}

.image-caption {
    text-align: center;
    font-style: italic;
    font-size: 1.1rem;
    color: #8b4513;
    margin-top: 10px;
    margin-bottom: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .page {
        padding: 40px 30px;
        margin: 10px;
    }
    
    .title {
        font-size: 2.8rem;
    }
    
    .story-content {
        font-size: 1.4rem;
    }
    
    .opening {
        font-size: 1.6rem !important;
    }
    
    .header-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .exercise-controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .answer-input {
        min-width: 100px;
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .page {
        padding: 30px 20px;
    }
    
    .title {
        font-size: 2.2rem;
    }
    
    .story-content {
        font-size: 1.3rem;
    }
    
    .dialogue {
        padding: 15px 20px;
        margin-left: 0;
        font-size: 1.3rem;
    }
}

/* Hover effects for interactivity */
.page:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 15px 40px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.6);
    transition: all 0.3s ease;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Selection styling */
::selection {
    background: rgba(139, 69, 19, 0.2);
    color: #2c1810;
}

.page-turn-btn {
    background: linear-gradient(135deg, #8b4513, #a0522d);
    color: #fefcf5;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-family: 'Crimson Text', serif;
    font-size: 1.3rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(139, 69, 19, 0.3);
    transition: all 0.3s ease;
}

.header-btn {
    margin-top: 25px;
    margin-bottom: 0;
}

.header-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 25px;
}

.grammar-page {
    display: none;
}

.grammar-instruction {
    text-align: center;
    font-size: 1.4rem;
    color: #8b4513;
    margin-top: 20px;
    font-style: italic;
}

.exercise-container {
    margin: 40px 0;
}

.exercise-item {
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(139, 69, 19, 0.02);
    border-radius: 8px;
    border-left: 3px solid #d4c4a8;
    transition: all 0.3s ease;
}

.exercise-item:hover {
    background: rgba(139, 69, 19, 0.05);
    border-left-color: #8b4513;
}

.exercise-item p {
    font-size: 1.4rem;
    line-height: 1.6;
    margin: 0;
}

.answer-input {
    border: none;
    border-bottom: 2px solid #d4c4a8;
    background: transparent;
    padding: 5px 10px;
    margin: 0 5px;
    font-family: 'Crimson Text', serif;
    font-size: 1.3rem;
    color: #2c1810;
    transition: all 0.3s ease;
    min-width: 120px;
    text-align: center;
}

.answer-input:focus {
    outline: none;
    border-bottom-color: #8b4513;
    background: rgba(139, 69, 19, 0.05);
}

.answer-input.correct {
    border-bottom-color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
}

.answer-input.incorrect {
    border-bottom-color: #f44336;
    background: rgba(244, 67, 54, 0.1);
}

.exercise-controls {
    text-align: center;
    margin: 40px 0;
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.score-display {
    font-size: 1.5rem;
    font-weight: 600;
    color: #8b4513;
    padding: 10px 20px;
    background: rgba(139, 69, 19, 0.1);
    border-radius: 25px;
    min-width: 150px;
}

.characters-page {
    display: none;
}

.character-section {
    margin-bottom: 35px;
    padding: 25px;
    background: rgba(139, 69, 19, 0.03);
    border-radius: 12px;
    border-left: 4px solid #8b4513;
    transition: all 0.3s ease;
}

.character-section:hover {
    background: rgba(139, 69, 19, 0.06);
    transform: translateX(5px);
}

.character-title {
    font-size: 1.8rem;
    color: #2c1810;
    margin-bottom: 15px;
    font-weight: 600;
    border-bottom: 2px solid #d4c4a8;
    padding-bottom: 8px;
}

.main-characters-image {
    max-width: 500px;
    margin-bottom: 40px;
}

.mistakes-page {
    display: none;
    background: #f8fafc;
    color: #1e3a8a;
}

.mistakes-page .page-header {
    border-bottom: 2px solid #dbeafe;
    padding-bottom: 30px;
}

.mistakes-page .title {
    color: #1e3a8a;
}

.mistakes-page .ornamental-border {
    background: linear-gradient(to right, transparent, #3b82f6, transparent);
}

.mistakes-page .ornamental-border::before,
.mistakes-page .ornamental-border::after {
    background: #3b82f6;
}

.mistakes-instruction {
    text-align: center;
    font-size: 1.4rem;
    color: #3b82f6;
    margin-top: 20px;
    font-style: italic;
    padding: 20px;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 8px;
    border: 1px solid #dbeafe;
}

.mistakes-container {
    margin: 40px 0;
}

.mistake-item {
    margin-bottom: 35px;
    padding: 25px;
    background: rgba(59, 130, 246, 0.03);
    border-radius: 12px;
    border-left: 4px solid #3b82f6;
    transition: all 0.3s ease;
}

.mistake-item:hover {
    background: rgba(59, 130, 246, 0.08);
    transform: translateX(5px);
}

.mistake-item p {
    font-size: 1.4rem;
    line-height: 1.6;
    margin-bottom: 15px;
    color: #1e3a8a;
}

.mistake-highlight {
    background: rgba(239, 68, 68, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    color: #dc2626;
    border-bottom: 2px wavy #dc2626;
}

.correction-box {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
}

.correction-box label {
    font-weight: 600;
    color: #3b82f6;
    font-size: 1.3rem;
    min-width: 90px;
}

.correction-input {
    border: 2px solid #dbeafe;
    background: #ffffff;
    padding: 10px 15px;
    border-radius: 8px;
    font-family: 'Crimson Text', serif;
    font-size: 1.3rem;
    color: #1e3a8a;
    transition: all 0.3s ease;
    flex: 1;
    max-width: 300px;
}

.correction-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.correction-input.correct {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
    color: #065f46;
}

.correction-input.incorrect {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
    color: #991b1b;
}

.mistakes-controls {
    text-align: center;
    margin: 40px 0;
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.mistakes-btn {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-family: 'Crimson Text', serif;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    transition: all 0.3s ease;
}

.mistakes-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.mistakes-score {
    background: rgba(59, 130, 246, 0.1);
    border: 2px solid #dbeafe;
    color: #1e3a8a;
}

.mistakes-page .page-footer .mistakes-btn {
    background: linear-gradient(135deg, #6b7280, #4b5563);
    box-shadow: 0 4px 15px rgba(107, 114, 128, 0.3);
}

.mistakes-page .page-footer .mistakes-btn:hover {
    box-shadow: 0 6px 20px rgba(107, 114, 128, 0.4);
}

.audio-controls {
    margin: 20px 0;
    text-align: center;
}

.audio-btn {
    background: linear-gradient(135deg, #d4af37, #ffd700);
    color: #2c1810;
    border: none;
    padding: 15px 30px;
    border-radius: 30px;
    font-family: 'Crimson Text', serif;
    font-size: 1.4rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 auto;
}

.audio-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.4);
}

.audio-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.audio-btn.playing {
    background: linear-gradient(135deg, #dc3545, #ff6b7a);
    color: white;
}

.page-banner {
    display: block;
    width: calc(100% + 160px);
    height: clamp(180px, 28vw, 340px);
    object-fit: cover;
    object-position: center 42%;
    margin: -60px -80px 40px;
    border-radius: 8px 8px 0 0;
}

@media (max-width: 700px) {
    .page {
        padding: 30px 20px;
    }

    .page-banner {
        width: calc(100% + 40px);
        margin: -30px -20px 28px;
        height: 190px;
    }
}
