:root {
    --primary-color: #6366f1;
    --secondary-color: #f59e0b;
    --background: #ffffff;
    --card-bg: #f9fafb;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --border-radius: 12px;
    --border-color: #e5e7eb;
}

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

body {
    font-family: 'Georgia', 'Palatino', serif;
    background: var(--background);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px;
}

.logo {
    max-width: 150px;
    height: auto;
    margin-bottom: 20px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

header h1 {
    font-size: 3.5rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
    color: var(--text-light);
    font-size: 1.2rem;
    font-style: italic;
}

.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.card h2 {
    color: var(--primary-color);
    margin-bottom: 25px;
    font-size: 1.8rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.length-buttons,
.grade-buttons {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.length-btn,
.grade-btn {
    flex: 1;
    padding: 12px 15px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.length-btn:hover,
.grade-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.length-btn.active,
.grade-btn.active {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.button-group {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    flex: 1;
}

.btn-primary:hover {
    background: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 158, 11, 0.3);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

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

.loading {
    text-align: center;
    margin-top: 30px;
}

.spinner {
    border: 4px solid #f3f4f6;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Buchlayout */
.book-layout {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 40px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    min-height: 600px;
    transform-style: preserve-3d;
    perspective: 2000px;
    backface-visibility: hidden;
}

.book-closed {
    opacity: 0;
    transform: perspective(2000px) rotateY(90deg);
    transform-origin: left center;
}

.book-opening {
    animation: pageFlip 1.5s cubic-bezier(0.645, 0.045, 0.355, 1) forwards;
}

/* Lade-Animation Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-in-out;
    border-radius: var(--border-radius);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.loading-content {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    max-width: 95vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

/* Responsive Loading-Content Padding */
@media (max-width: 480px) {
    .loading-content {
        padding: 30px 20px;
    }
}

@media (max-width: 375px) {
    .loading-content {
        padding: 25px 15px;
    }
}

@media (max-width: 360px) {
    .loading-content {
        padding: 20px 12px;
    }
}

.loading-text {
    font-size: 1.4rem;
    color: var(--text-color);
    font-weight: 600;
    margin-top: 20px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Magische Buch-Animation */
.magic-book-animation {
    position: relative;
    width: 450px;
    height: 320px;
    margin: 0 auto;
    transform-origin: center center;
}

/* Responsive Skalierung für kleinere Bildschirme */
@media (max-width: 480px) {
    .magic-book-animation {
        width: 90vw;
        max-width: 360px;
        height: auto;
        aspect-ratio: 450 / 320;
    }
}

@media (max-width: 375px) {
    .magic-book-animation {
        width: 88vw;
        max-width: 320px;
    }
}

/* iPhone Mini und sehr kleine Bildschirme */
@media (max-width: 360px) {
    .magic-book-animation {
        width: 85vw;
        max-width: 280px;
    }
}

.magic-book {
    position: relative;
    width: 100%;
    height: 260px;
    perspective: 1500px;
    transform-style: preserve-3d;
}

/* Responsive Buch-Höhe */
@media (max-width: 480px) {
    .magic-book {
        height: 210px;
        perspective: 1200px;
    }
}

@media (max-width: 375px) {
    .magic-book {
        height: 180px;
        perspective: 1000px;
    }
}

@media (max-width: 360px) {
    .magic-book {
        height: 160px;
        perspective: 900px;
    }
}

.book-left-page,
.book-right-page {
    position: absolute;
    width: 48%;
    height: 100%;
    background: linear-gradient(to bottom, #faf8f3 0%, #f5f1e8 100%);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 20px;
    padding: 40px 30px;
}

/* Responsive Padding für kleinere Bildschirme */
@media (max-width: 480px) {
    .book-left-page,
    .book-right-page {
        padding: 30px 20px;
        gap: 15px;
    }
}

@media (max-width: 375px) {
    .book-left-page,
    .book-right-page {
        padding: 25px 15px;
        gap: 12px;
    }
}

@media (max-width: 360px) {
    .book-left-page,
    .book-right-page {
        padding: 20px 12px;
        gap: 10px;
    }
}

.book-left-page {
    left: 0;
    border-right: 3px solid #e8dcc4;
    transform: rotateY(-5deg);
    transform-origin: right center;
    animation: pageFlutter 3s ease-in-out infinite;
}

.book-right-page {
    right: 0;
    border-left: 3px solid #e8dcc4;
    transform: rotateY(5deg);
    transform-origin: left center;
    animation: pageFlutter 3s ease-in-out infinite 1.5s;
}

.book-spine {
    position: absolute;
    width: 4%;
    height: 100%;
    left: 48%;
    background: linear-gradient(to right, #8b5cf6, #6366f1);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
    z-index: 10;
}

@keyframes pageFlutter {
    0%, 100% { transform: rotateY(-5deg); }
    50% { transform: rotateY(-2deg); }
}

.page-text {
    display: flex;
    flex-direction: row;
    gap: 3px;
    width: 100%;
}

.floating-letter {
    font-size: 2.2rem;
    font-weight: bold;
    font-family: 'Georgia', serif;
    background: linear-gradient(135deg, #8b5cf6, #ec4899, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: floatLetter 2.5s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(139, 92, 246, 0.3));
    display: inline-block;
}

/* Responsive Schriftgröße für kleinere Bildschirme */
@media (max-width: 480px) {
    .floating-letter {
        font-size: 1.8rem;
    }
}

@media (max-width: 375px) {
    .floating-letter {
        font-size: 1.5rem;
    }
}

@media (max-width: 360px) {
    .floating-letter {
        font-size: 1.3rem;
    }
}

@keyframes floatLetter {
    0%, 100% { 
        transform: translateY(0) scale(1);
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    50% { 
        transform: translateY(-10px) scale(1.1);
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
}

.magic-sparkles {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.magic-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, #fbbf24, #f59e0b);
    border-radius: 50%;
    animation: particleFloat 3s ease-in-out infinite;
    box-shadow: 0 0 10px #fbbf24;
}

.magic-particle:nth-child(1) {
    left: 20%;
    top: 30%;
    animation-delay: 0s;
}

.magic-particle:nth-child(2) {
    left: 80%;
    top: 40%;
    animation-delay: 0.5s;
}

.magic-particle:nth-child(3) {
    left: 15%;
    top: 70%;
    animation-delay: 1s;
}

.magic-particle:nth-child(4) {
    left: 85%;
    top: 65%;
    animation-delay: 1.5s;
}

.magic-particle:nth-child(5) {
    left: 50%;
    top: 20%;
    animation-delay: 2s;
}

.magic-particle:nth-child(6) {
    left: 50%;
    top: 85%;
    animation-delay: 2.5s;
}

@keyframes particleFloat {
    0%, 100% {
        transform: translateY(0) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: scale(1);
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-50px) scale(0);
        opacity: 0;
    }
}

.magic-stars {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.star {
    position: absolute;
    font-size: 1.5rem;
    animation: starTwinkle 2s ease-in-out infinite;
}

.star:nth-child(1) {
    left: 10%;
    top: 15%;
    animation-delay: 0s;
}

.star:nth-child(2) {
    right: 10%;
    top: 25%;
    animation-delay: 0.7s;
}

.star:nth-child(3) {
    left: 15%;
    bottom: 20%;
    animation-delay: 1.4s;
}

.star:nth-child(4) {
    right: 15%;
    bottom: 15%;
    animation-delay: 2.1s;
}

@keyframes starTwinkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.2) rotate(180deg);
    }
}

@keyframes pageFlip {
    0% {
        opacity: 0;
        transform: perspective(2000px) rotateY(90deg) translateZ(-200px);
        box-shadow: -20px 0 50px rgba(0, 0, 0, 0.5);
    }
    20% {
        opacity: 1;
    }
    60% {
        transform: perspective(2000px) rotateY(-5deg) translateZ(0);
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.2);
    }
    80% {
        transform: perspective(2000px) rotateY(2deg) translateZ(0);
    }
    100% {
        opacity: 1;
        transform: perspective(2000px) rotateY(0deg) translateZ(0);
        box-shadow: var(--shadow);
    }
}

.book-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e5e7eb;
}

.book-header h2 {
    color: var(--primary-color);
    margin: 0;
    flex: 1;
}

.book-page {
    background: #faf8f3;
    padding: 40px;
    border-radius: 8px;
    border: 1px solid #e8e3d8;
    box-shadow: inset 0 1px 3px rgba(139, 119, 83, 0.08);
    margin-bottom: 30px;
    min-height: 400px;
}

.story-title {
    color: var(--primary-color);
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e8e3d8;
}

.story-text {
    font-size: 1.15rem;
    line-height: 1.8;
    color: var(--text-color);
    white-space: pre-wrap;
    text-align: justify;
}

.story-text p {
    margin-bottom: 20px;
}

.story-info {
    background: #f9fafb;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.story-info p {
    margin-bottom: 8px;
    color: var(--text-light);
}

.story-info strong {
    color: var(--text-color);
}

/* Responsive Design */
/* Footer */
footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 40px;
    color: #d1d5db;
    font-size: 0.9rem;
}

footer a {
    color: #d1d5db;
    text-decoration: none;
    transition: color 0.3s;
}

footer a:hover {
    color: var(--primary-color);
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2.5rem;
    }

    .card, .book-layout {
        padding: 20px;
    }

    .book-page {
        padding: 20px;
    }

    .story-text {
        font-size: 1rem;
    }

    .button-group {
        flex-direction: column;
    }
}
