@import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@400;700&display=swap');

:root {
    --primary: #667eea;
    --primary-dark: #5a6fd6;
    --secondary: #764ba2;
    --accent: #ffd700;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --text-main: #333;
    --text-light: #666;
    --white: #ffffff;
    --success: #2ecc71;
    --error: #e74c3c;
    --shadow: 0 10px 20px rgba(0,0,0,0.15);
}

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

body {
    font-family: 'Comic Neue', 'Comic Sans MS', cursive;
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    padding-bottom: 90px; /* Espaço para o menu */
    overflow-x: hidden;
}

.container {
    width: 100%; max-width: 600px; margin: 0 auto; padding: 20px; position: relative; z-index: 1;
}

/* HEADER */
.header { text-align: center; margin-bottom: 30px; padding-top: 20px; }
.header h1 { font-size: 3em; color: var(--white); text-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.subtitle { color: var(--accent); font-size: 1.2em; font-weight: bold; margin-top: 5px; text-shadow: 0 2px 5px rgba(0,0,0,0.2); }

/* SEÇÕES */
.section { display: none; animation: fadeIn 0.5s ease-out; }
.section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* GRIDS GERAIS */
.stories-grid, .coloring-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px;
    padding-bottom: 20px;
}

/* --- CARD DE HISTÓRIA (COM IMAGEM) --- */
.story-card {
    background: var(--white);
    border-radius: 20px;
    padding: 0;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-align: left;
    position: relative;
}
.story-card:active { transform: scale(0.96); }

.story-card-image {
    width: 100%; height: 120px; object-fit: cover; background-color: #eee;
}

.story-card-content { padding: 12px; }

.story-title {
    font-weight: bold; font-size: 1em; color: var(--text-main); margin-bottom: 5px; line-height: 1.3;
}

.story-meta {
    display: flex; justify-content: space-between; align-items: center; font-size: 0.8em; color: #888; margin-top: 5px;
}

.story-ref {
    background: #f0f4ff; color: var(--primary); padding: 3px 8px; border-radius: 8px; font-weight: bold; font-size: 0.85em;
}

.favorite-btn {
    position: absolute; top: 8px; right: 8px; font-size: 1.2em; color: #ccc; background: rgba(255,255,255,0.9); border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 5px rgba(0,0,0,0.2); z-index: 2;
}

/* CARD DE DESENHO (Simples) */
.drawing-card {
    background: white; border-radius: 20px; padding: 10px; text-align: center; box-shadow: var(--shadow); cursor: pointer;
}
.drawing-card img { width: 100%; height: 120px; object-fit: contain; }
.drawing-title { font-weight: bold; margin-top: 5px; font-size: 0.9em; }


/* --- SEÇÃO DE PROGRESSO E TROFÉUS (Restaurada) --- */
.card {
    background: var(--white);
    border-radius: 25px;
    padding: 30px;
    box-shadow: var(--shadow);
    text-align: center;
    margin-top: 10px;
}

.card h2 { color: var(--text-main); margin-bottom: 10px; }
.card h3 { font-size: 1em; text-transform: uppercase; letter-spacing: 1px; }

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 25px 0;
}

.stat {
    background: #f0f4ff;
    padding: 15px;
    border-radius: 20px;
    color: var(--secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 2.5em;
    font-weight: bold;
    color: var(--primary);
    line-height: 1.2;
}

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

.badge {
    width: 65px; height: 65px;
    background: #e0e0e0;
    border-radius: 50%;
    display: flex;
    align-items: center; justify-content: center;
    font-size: 1.8em;
    color: #999;
    border: 4px solid white;
    box-shadow: 0 5px 10px rgba(0,0,0,0.1);
    transition: 0.5s;
    position: relative;
}

.badge.earned {
    background: linear-gradient(135deg, #ffd700, #f39c12);
    color: white;
    border-color: #f1c40f;
    box-shadow: 0 5px 15px rgba(243, 156, 18, 0.4);
    animation: pop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.badge i { color: inherit; } /* Ícone herda cor do pai */

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

/* LEITOR DE HISTÓRIA */
.modal {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--white); z-index: 2000; overflow-y: auto;
}
.modal-header {
    position: sticky; top: 0; background: var(--white); padding: 15px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; z-index: 10;
}
.btn-back, .btn-audio {
    background: var(--primary); color: white; border: none; padding: 8px 20px; border-radius: 20px; font-weight: bold; cursor: pointer; display: flex; align-items: center; gap: 5px;
}
#story-reader-content { padding: 20px; max-width: 700px; margin: 0 auto; font-size: 1.15em; line-height: 1.8; }
.story-illustration img { width: 100%; max-height: 250px; object-fit: cover; border-radius: 15px; margin-bottom: 20px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); }

/* QUIZ */
.quiz-question { font-size: 1.2em; font-weight: bold; margin: 20px 0; color: #444; }
.quiz-option {
    background: #fff; padding: 15px; border-radius: 15px; border: 2px solid #eee; margin-bottom: 10px; font-weight: bold; cursor: pointer; transition: 0.2s;
}
.quiz-option:active { transform: scale(0.98); }
.quiz-option.correct { background: #d4edda; border-color: #28a745; color: #155724; }
.quiz-option.incorrect { background: #f8d7da; border-color: #dc3545; color: #721c24; }
.quiz-feedback { margin-top: 15px; font-weight: bold; font-size: 1.1em; min-height: 25px; }

/* MENU INFERIOR */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; height: 80px; background: var(--white); display: flex; justify-content: space-around; align-items: center; border-radius: 25px 25px 0 0; z-index: 1000; max-width: 600px; margin: 0 auto; box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
}
.nav-item { display: flex; flex-direction: column; align-items: center; color: #999; font-size: 0.8em; padding: 10px; width: 70px; cursor: pointer; transition: 0.3s; }
.nav-item.active { color: var(--primary); transform: translateY(-5px); }
.nav-item i { font-size: 1.5em; margin-bottom: 5px; }

/* TELA DE PINTURA (FULLSCREEN) */
#coloring-screen {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: #fff; z-index: 5000; display: none; overflow: hidden; touch-action: none;
}
#coloring-screen.active { display: block; }
.color-palette {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,0.9); padding: 10px; border-radius: 30px; display: flex; gap: 8px; overflow-x: auto; max-width: 95%; box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}
.color-btn { width: 40px; height: 40px; border-radius: 50%; border: 3px solid white; flex-shrink: 0; transition: 0.2s; }
.color-btn.active { transform: scale(1.2) translateY(-5px); border-color: #333; }
.coloring-actions { position: absolute; top: 20px; right: 20px; display: flex; gap: 10px; }
.action-btn { width: 45px; height: 45px; border-radius: 50%; border: none; background: white; font-size: 1.2em; box-shadow: 0 4px 10px rgba(0,0,0,0.2); cursor: pointer; }

/* BACKGROUND PC/TABLET */
@media (min-width: 768px) {
    body { background-image: radial-gradient(circle at 10% 20%, rgba(255,255,255,0.1) 0%, transparent 20%), var(--bg-gradient); background-attachment: fixed; background-size: cover; }
    .bottom-nav { bottom: 20px; border-radius: 40px; width: 90%; }
    ::-webkit-scrollbar { width: 8px; }
    ::-webkit-scrollbar-track { background: #f1f1f1; }
    ::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 10px; }
}