:root {
    --bg-gradient: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    --accent-gold: #ffd700;
    --accent-purple: #9d50bb;
    --accent-pink: #f2c94c;
    --text-color: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.1);
    --card-hover-bg: rgba(255, 255, 255, 0.2);
    --glass-blur: blur(12px);
    --primary-font: 'Quicksand', sans-serif;
    --header-font: 'Fredoka One', cursive;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--primary-font);
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
    flex: 1;
}

/* Stars Background */
.stars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

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

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

/* Header */
.magical-header {
    padding: 3rem 1rem 1rem;
    text-align: center;
}

.moon-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.5));
    animation: float 4s ease-in-out infinite;
}

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

h1 {
    font-family: var(--header-font);
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
    background: linear-gradient(to right, #fff, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.magical-header p {
    font-size: 1.1rem;
    opacity: 0.8;
}

/* Section Controls */
section {
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.hidden {
    display: none;
    opacity: 0;
    transform: translateY(20px);
}

.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Character Suggestions */
.section-title {
    font-family: var(--header-font);
    text-align: center;
    margin-bottom: 2rem;
    color: var(--accent-gold);
}

.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.suggestion-card {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    padding: 1.5rem 1rem;
    border-radius: 20px;
    text-align: center;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.suggestion-card:hover {
    background: var(--card-hover-bg);
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border-color: var(--accent-gold);
}

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

.suggestion-card .label {
    font-weight: 700;
    font-size: 0.9rem;
}

/* Input Area */
.input-group {
    position: relative;
    margin-bottom: 2rem;
}

textarea {
    width: 100%;
    min-height: 120px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 1.2rem;
    color: white;
    font-family: inherit;
    font-size: 1.1rem;
    resize: none;
    outline: none;
    transition: all 0.3s ease;
}

textarea:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-gold);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}

.char-counter {
    position: absolute;
    bottom: 10px;
    right: 15px;
    font-size: 0.8rem;
    opacity: 0.6;
}

/* Buttons */
.magical-btn {
    width: 100%;
    padding: 1.2rem;
    border: none;
    border-radius: 50px;
    background: linear-gradient(45deg, #ffd700, #f2c94c);
    color: #302b63;
    font-family: var(--header-font);
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.magical-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.6);
}

.magical-btn:active {
    transform: translateY(1px);
}

/* Loading State */
.loader-content {
    text-align: center;
    padding: 4rem 1rem;
}

.twinkling-loader {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.5); opacity: 1; filter: drop-shadow(0 0 20px #ffd700); }
}

/* Story Book */
.story-book {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: var(--glass-blur);
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    margin-bottom: 2rem;
}

.story-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.back-btn {
    background: none;
    border: none;
    color: var(--accent-gold);
    font-family: var(--header-font);
    cursor: pointer;
    font-size: 1rem;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    margin-left: 0.5rem;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.story-content {
    font-size: 1.25rem;
    line-height: 1.8;
    color: #f8f9fa;
}

.story-content p {
    margin-bottom: 1.5rem;
}

.story-content h3 {
    font-family: var(--header-font);
    color: var(--accent-gold);
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.8rem;
}

/* Footer */
.magical-footer {
    text-align: center;
    padding: 2rem;
    opacity: 0.6;
    font-size: 0.9rem;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }
    
    .suggestions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .story-book {
        padding: 1.5rem;
    }
    
    .story-content {
        font-size: 1.1rem;
    }
}
