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

:root {
    --purple-deep: #1a1a4e;
    --purple-mid: #2d2b6e;
    --purple-light: #4a3f8a;
    --purple-card: rgba(74, 63, 138, 0.4);
    --coral: #ff7b54;
    --teal: #54d4c6;
    --gold: #ffd93d;
    --pink: #ff9a9e;
    --white: #ffffff;
    --white-soft: rgba(255, 255, 255, 0.9);
    --white-muted: rgba(255, 255, 255, 0.6);
}

body {
    font-family: 'Quicksand', sans-serif;
    background: linear-gradient(135deg, var(--purple-deep) 0%, var(--purple-mid) 50%, var(--purple-light) 100%);
    min-height: 100vh;
    color: var(--white);
    overflow-x: hidden;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Star Field */
.star-field {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.star {
    position: absolute;
    background: var(--white);
    border-radius: 50%;
    animation: twinkle 3s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Header */
.app-header {
    text-align: center;
    padding: 2rem 1rem 1rem;
    position: relative;
    z-index: 1;
}

.book-icon {
    font-size: 4rem;
    animation: float 3s ease-in-out infinite;
    display: inline-block;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.app-title {
    font-family: 'Baloo 2', cursive;
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(90deg, var(--coral), var(--gold), var(--teal), var(--pink));
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-shift 5s ease infinite;
    margin: 0.5rem 0;
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.app-subtitle {
    font-size: 1.1rem;
    color: var(--white-soft);
    font-weight: 500;
}

/* Progress Steps */
.progress-container {
    max-width: 600px;
    margin: 1.5rem auto;
    padding: 0 1rem;
    position: relative;
    z-index: 1;
}

.progress-bar-bg {
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--coral), var(--teal));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.progress-steps {
    display: flex;
    justify-content: space-between;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.progress-step.active {
    opacity: 1;
}

.progress-step.current .step-icon {
    animation: pulse 1.5s ease infinite;
}

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

.step-icon {
    font-size: 1.5rem;
}

.step-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--white-muted);
}

.progress-step.active .step-label {
    color: var(--white);
}

/* Main Content */
.app-main {
    flex: 1;
    position: relative;
    z-index: 1;
    padding-bottom: 4rem;
}

/* Selection Screen */
.selection-screen {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

.screen-title {
    font-family: 'Baloo 2', cursive;
    font-size: 1.75rem;
    text-align: center;
    margin-bottom: 0.5rem;
}

.screen-subtitle {
    text-align: center;
    color: var(--white-muted);
    margin-bottom: 1.5rem;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (min-width: 640px) {
    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 900px) {
    .cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.settings-grid {
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 640px) {
    .settings-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Selection Card */
.selection-card {
    background: var(--purple-card);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.25rem 1rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.selection-card:hover:not(.disabled) {
    transform: translateY(-4px) scale(1.02);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.selection-card.selected {
    border-color: var(--teal);
    background: rgba(84, 212, 198, 0.2);
    box-shadow: 0 0 20px rgba(84, 212, 198, 0.3);
}

.selection-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.check-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: var(--teal);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    animation: pop 0.3s ease;
}

@keyframes pop {
    0% { transform: scale(0); }
    70% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.card-emoji {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

.card-name {
    font-family: 'Baloo 2', cursive;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--white);
}

.card-desc {
    font-size: 0.75rem;
    color: var(--white-muted);
    line-height: 1.4;
}

/* Navigation Buttons */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
}

.back-button {
    background: transparent;
    border: none;
    color: var(--white-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.75rem 1rem;
    transition: color 0.3s ease;
    font-family: 'Quicksand', sans-serif;
}

.back-button:hover {
    color: var(--white);
}

.next-button {
    background: linear-gradient(135deg, var(--coral), var(--pink));
    border: none;
    color: var(--white);
    font-size: 1rem;
    font-weight: 700;
    padding: 1rem 2rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Quicksand', sans-serif;
    box-shadow: 0 4px 15px rgba(255, 123, 84, 0.4);
}

.next-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 123, 84, 0.5);
}

.next-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.create-button {
    background: linear-gradient(135deg, var(--teal), var(--gold));
    box-shadow: 0 4px 15px rgba(84, 212, 198, 0.4);
}

.create-button:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(84, 212, 198, 0.5);
}

/* Loading Screen */
.loading-screen {
    max-width: 600px;
    margin: 0 auto;
    padding: 3rem 1rem;
    text-align: center;
    position: relative;
    z-index: 1;
}

.loading-book {
    font-size: 5rem;
    animation: float 2s ease-in-out infinite, book-glow 1.5s ease infinite;
    margin-bottom: 1.5rem;
}

@keyframes book-glow {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5)); }
    50% { filter: drop-shadow(0 0 25px rgba(255, 215, 0, 0.8)); }
}

.loading-title {
    font-family: 'Baloo 2', cursive;
    font-size: 2rem;
    background: linear-gradient(90deg, var(--coral), var(--gold), var(--teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.loading-messages {
    height: 2rem;
    margin-bottom: 1.5rem;
}

.loading-message {
    font-size: 1.1rem;
    color: var(--white-soft);
    animation: fade-in 0.5s ease;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.loading-bar-container {
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.loading-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--coral), var(--teal), var(--gold));
    background-size: 200% 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.loading-percent {
    color: var(--white);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.loading-hint {
    font-size: 0.875rem;
    color: var(--white-muted);
    margin-bottom: 2rem;
}

.selections-summary {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1.5rem;
}

.summary-title {
    font-weight: 700;
    margin-bottom: 1rem;
}

.summary-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.badge {
    background: rgba(255, 255, 255, 0.15);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.875rem;
    white-space: nowrap;
}

/* Story Viewer */
.story-viewer {
    max-width: 700px;
    margin: 0 auto;
    padding: 1rem;
    position: relative;
    z-index: 1;
}

.story-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.story-title {
    font-family: 'Baloo 2', cursive;
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.story-meta {
    color: var(--white-muted);
    font-size: 0.875rem;
}

.story-book {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.page-nav {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--white);
    font-size: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.page-nav:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.page-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

@media (max-width: 640px) {
    .page-nav {
        display: none;
    }
}

.page-content {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    overflow: hidden;
    border: 3px solid var(--purple-light);
    cursor: pointer;
}

.page-image-container {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--purple-mid);
}

.page-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.page-text {
    padding: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--white-soft);
    text-align: center;
    min-height: 100px;
}

.page-indicator {
    text-align: center;
    color: var(--white-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.page-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.page-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.page-dot.active {
    background: var(--teal);
    transform: scale(1.2);
}

.page-dot:hover {
    background: rgba(255, 255, 255, 0.5);
}

.restart-button {
    display: block;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: var(--white);
    font-size: 1rem;
    font-weight: 600;
    padding: 1rem 2rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Quicksand', sans-serif;
}

.restart-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 1.5rem;
    position: relative;
    z-index: 1;
    margin-top: auto;
}

.app-footer a {
    color: var(--white-muted);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.3s ease;
}

.app-footer a:hover {
    color: var(--white);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .app-title {
        font-size: 1.75rem;
    }
    
    .screen-title {
        font-size: 1.4rem;
    }
    
    .card-emoji {
        font-size: 2rem;
    }
    
    .card-name {
        font-size: 0.9rem;
    }
    
    .card-desc {
        font-size: 0.7rem;
    }
    
    .selection-card {
        padding: 1rem 0.75rem;
    }
    
    .step-label {
        display: none;
    }
    
    .progress-steps {
        padding: 0 1rem;
    }
}