@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Playfair+Display:ital,wght@0,600;0,700;0,900;1,600;1,700&display=swap');

:root {
    --color-bg-start: #ffebf0;
    --color-bg-mid: #f3e7fc;
    --color-bg-end: #e5f0ff;
    --color-panel-bg: rgba(255, 255, 255, 0.88);
    --color-text: #3c1e48;
    --color-text-muted: #6e4d77;
    --color-gold: #FFD700;
    --color-gold-glow: rgba(255, 215, 0, 0.65);
    --color-btn-start: #ff6584;
    --color-btn-end: #ff8ca3;
    --color-secondary-start: #8e54e9;
    --color-secondary-end: #4776e6;
    --color-success: #2ec4b6;
    --font-heading: 'Playfair Display', serif;
    --font-ui: 'Nunito', sans-serif;
    --border-radius-lg: 28px;
    --border-radius-md: 18px;
    --shadow-soft: 0 12px 35px rgba(60, 30, 72, 0.12);
    --shadow-glow: 0 0 25px rgba(255, 101, 132, 0.35);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background: linear-gradient(135deg, var(--color-bg-start), var(--color-bg-mid), var(--color-bg-end));
    background-size: 300% 300%;
    animation: gradientBG 18s ease infinite;
    font-family: var(--font-ui);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

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

/* ==========================================================================
   CABEÇALHO PERSISTENTE DO REINO
   ========================================================================== */

#app-header {
    width: 100%;
    height: 75px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 2px solid rgba(255, 215, 0, 0.5);
    box-shadow: 0 4px 20px rgba(60, 30, 72, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 500;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-crown {
    font-size: 2.2rem;
    filter: drop-shadow(0 2px 8px var(--color-gold-glow));
    animation: crownFloat 3s ease-in-out infinite;
}

@keyframes crownFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-4px) rotate(4deg); }
}

.brand-titles {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 900;
    color: var(--color-text);
    line-height: 1.1;
}

.brand-subtitle {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    font-weight: 700;
}

.header-user-info {
    display: flex;
    align-items: center;
    gap: 18px;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 215, 0, 0.18);
    border: 2px solid rgba(255, 215, 0, 0.6);
    padding: 6px 16px;
    border-radius: 50px;
}

.user-avatar {
    font-size: 1.4rem;
}

.user-name {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--color-text);
}

.user-stats {
    display: flex;
    gap: 10px;
}

.stat-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: white;
    border: 2px solid rgba(255, 101, 132, 0.25);
    padding: 5px 12px;
    border-radius: 50px;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.stat-badge strong {
    color: var(--color-text);
    font-weight: 900;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.nav-btn {
    background: linear-gradient(135deg, var(--color-secondary-start), var(--color-secondary-end));
    border: 2px solid white;
    color: white;
    padding: 8px 18px;
    border-radius: 50px;
    font-family: var(--font-ui);
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(142, 84, 233, 0.25);
    transition: all 0.2s;
}

.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(142, 84, 233, 0.4);
}

.nav-btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: var(--color-text);
    border: 2px solid rgba(60, 30, 72, 0.15);
    box-shadow: none;
}

.nav-btn-secondary:hover {
    background: #ffe3e8;
    color: #e63946;
}

/* ==========================================================================
   VIEWPORT PRINCIPAL E TELAS
   ========================================================================== */

#app-viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
}

.screen-view {
    display: none;
    width: 100%;
    min-height: calc(100vh - 75px);
    padding: 30px;
    animation: fadeIn 0.4s ease forwards;
}

.screen-view.active {
    display: flex;
    flex-direction: column;
}

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

/* ==========================================================================
   1. TELA DE LOGIN
   ========================================================================== */

#screen-login {
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 520px;
    background: var(--color-panel-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 4px solid rgba(255, 215, 0, 0.8);
    border-radius: var(--border-radius-lg);
    padding: 45px 35px;
    box-shadow: var(--shadow-soft), var(--shadow-glow);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
}

.login-decor {
    position: relative;
    margin-bottom: 12px;
}

.login-crown-bubble {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border: 4px solid white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.8rem;
    box-shadow: 0 8px 25px var(--color-gold-glow);
    animation: crownFloat 3s ease-in-out infinite;
}

.decor-sparkle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.8rem;
    color: var(--color-gold);
    animation: sparkleSpin 4s linear infinite;
}

.decor-sparkle.left { left: -35px; }
.decor-sparkle.right { right: -35px; }

@keyframes sparkleSpin {
    0% { transform: translateY(-50%) rotate(0deg) scale(1); }
    50% { transform: translateY(-50%) rotate(180deg) scale(1.3); }
    100% { transform: translateY(-50%) rotate(360deg) scale(1); }
}

.login-title {
    font-family: var(--font-heading);
    font-size: 2.1rem;
    font-weight: 900;
    color: var(--color-text);
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 1.05rem;
    color: var(--color-text-muted);
    margin-bottom: 25px;
    line-height: 1.5;
}

.login-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    width: 100%;
}

.form-group label {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--color-text);
}

.form-group input {
    width: 100%;
    padding: 14px 18px;
    border-radius: var(--border-radius-md);
    border: 2px solid rgba(60, 30, 72, 0.15);
    background: white;
    font-family: var(--font-ui);
    font-size: 1.05rem;
    color: var(--color-text);
    outline: none;
    transition: all 0.2s;
}

.form-group input:focus {
    border-color: #ff6584;
    box-shadow: 0 0 0 4px rgba(255, 101, 132, 0.2);
}

.login-feedback {
    min-height: 24px;
    font-size: 0.95rem;
    font-weight: 800;
    transition: all 0.3s;
}

.login-feedback.error { color: #e63946; }
.login-feedback.success { color: #2a9d8f; }

.magic-btn {
    width: 100%;
    padding: 16px;
    border: 3px solid white;
    border-radius: 50px;
    font-family: var(--font-ui);
    font-size: 1.15rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    transition: all 0.2s;
}

.primary-btn {
    background: linear-gradient(135deg, var(--color-btn-start), var(--color-btn-end));
    color: white;
    box-shadow: 0 10px 25px rgba(255, 101, 132, 0.4);
}

.primary-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 14px 30px rgba(255, 101, 132, 0.55);
}

.auth-tabs {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-bottom: 25px;
    background: rgba(60, 30, 72, 0.06);
    padding: 6px;
    border-radius: 50px;
}

.auth-tab-btn {
    flex: 1;
    padding: 10px 18px;
    border: none;
    border-radius: 50px;
    background: transparent;
    color: var(--color-text-muted);
    font-family: var(--font-ui);
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.25s ease;
}

.auth-tab-btn.active {
    background: white;
    color: var(--color-text);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.register-btn {
    background: linear-gradient(135deg, var(--color-secondary-start), var(--color-secondary-end));
    color: white;
    box-shadow: 0 10px 25px rgba(142, 84, 233, 0.4);
}

.register-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 14px 30px rgba(142, 84, 233, 0.55);
}

.auth-switch {
    margin-top: 18px;
    font-size: 0.95rem;
    color: var(--color-text-muted);
    font-weight: 700;
}

.auth-switch-link {
    background: none;
    border: none;
    color: #ff6584;
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 900;
    cursor: pointer;
    text-decoration: underline;
    margin-left: 4px;
    transition: color 0.2s;
}

.auth-switch-link:hover {
    color: #e63946;
}

/* ==========================================================================
   2. TELA DA BIBLIOTECA DE HISTÓRIAS
   ========================================================================== */

#screen-library {
    max-width: 1400px;
    margin: 0 auto;
    gap: 30px;
}

.library-hero {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(15px);
    border: 3px solid rgba(255, 215, 0, 0.5);
    border-radius: var(--border-radius-lg);
    padding: 30px 20px;
    box-shadow: var(--shadow-soft);
}

.library-title {
    font-family: var(--font-heading);
    font-size: 2.4rem;
    font-weight: 900;
    color: var(--color-text);
}

.library-subtitle {
    font-size: 1.15rem;
    color: var(--color-text-muted);
    max-width: 700px;
}

.category-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.filter-btn {
    background: white;
    border: 2px solid rgba(60, 30, 72, 0.1);
    color: var(--color-text);
    padding: 8px 18px;
    border-radius: 50px;
    font-family: var(--font-ui);
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: #fff0f3;
    border-color: #ff8ca3;
    transform: translateY(-2px);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--color-btn-start), var(--color-btn-end));
    color: white;
    border-color: white;
    box-shadow: 0 4px 15px rgba(255, 101, 132, 0.4);
}

.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    width: 100%;
}

.story-card {
    background: var(--color-panel-bg);
    border: 3px solid white;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.story-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 18px 40px rgba(60, 30, 72, 0.18);
    border-color: rgba(255, 215, 0, 0.9);
}

.story-card.has-badge {
    border-color: rgba(255, 215, 0, 0.8);
}

.card-cover-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: #f0e6f6;
}

.card-cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.story-card:hover .card-cover-image {
    transform: scale(1.06);
}

.card-category-pill {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0,0,0,0.06);
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--color-text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.card-badge-stamp {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #4a235a;
    font-size: 0.82rem;
    font-weight: 900;
    padding: 4px 12px;
    border-radius: 50px;
    border: 2px solid white;
    box-shadow: 0 4px 12px var(--color-gold-glow);
    animation: pulseBadge 2.5s infinite;
}

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

.card-read-stamp {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(46, 196, 182, 0.95);
    color: white;
    font-size: 0.8rem;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 50px;
}

.card-details {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 10px;
}

.card-number-tag {
    font-size: 0.8rem;
    font-weight: 800;
    color: #ff6584;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-title {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1.25;
}

.card-excerpt {
    font-size: 0.95rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    flex-grow: 1;
}

.card-badge-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 215, 0, 0.12);
    border: 1px solid rgba(255, 215, 0, 0.4);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 800;
    color: #8c6000;
}

.card-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.card-btn {
    flex: 1;
    padding: 12px 8px;
    border: 2px solid white;
    border-radius: 50px;
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.card-btn-read {
    background: linear-gradient(135deg, #a18cd1, #fbc2eb);
    color: #3c1e48;
}

.card-btn-read:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(161, 140, 209, 0.45);
}

.card-btn-play {
    background: linear-gradient(135deg, var(--color-btn-start), var(--color-btn-end));
    color: white;
}

.card-btn-play:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(255, 101, 132, 0.45);
}

/* ==========================================================================
   3. TELA DO MODO LEITOR DE HISTÓRIA (LIVRO MÁGICO)
   ========================================================================== */

#screen-reader {
    max-width: 1200px;
    margin: 0 auto;
    justify-content: center;
    align-items: center;
}

.book-container {
    width: 100%;
    background: var(--color-panel-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 6px solid rgba(255, 215, 0, 0.85);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-soft), 0 0 30px rgba(255, 215, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.book-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 25px;
    background: linear-gradient(to bottom, rgba(255,255,255,0.9), rgba(255,255,255,0.5));
    border-bottom: 2px solid rgba(255, 215, 0, 0.4);
    gap: 15px;
}

.book-nav-back, .book-play-shortcut {
    border: 2px solid white;
    border-radius: 50px;
    padding: 8px 18px;
    font-family: var(--font-ui);
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.book-nav-back {
    background: white;
    color: var(--color-text);
}

.book-nav-back:hover {
    background: #f0e6f6;
    transform: translateX(-3px);
}

.book-story-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--color-text);
    text-align: center;
    flex: 1;
}

.book-play-shortcut {
    background: linear-gradient(135deg, var(--color-btn-start), var(--color-btn-end));
    color: white;
    box-shadow: 0 4px 12px rgba(255, 101, 132, 0.35);
}

.book-play-shortcut:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(255, 101, 132, 0.5);
}

.book-page-layout {
    display: flex;
    padding: 35px;
    gap: 35px;
    min-height: 480px;
}

.book-illustration-slot {
    flex: 4.5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.book-frame {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 20px;
    overflow: hidden;
    border: 5px solid white;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    background: #fdf5f7;
}

.book-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.book-frame:hover img {
    transform: scale(1.03);
}

.audio-narration-bar {
    width: 100%;
    display: flex;
    justify-content: center;
}

.audio-play-btn {
    background: white;
    border: 2px solid rgba(255, 101, 132, 0.4);
    color: var(--color-text);
    padding: 10px 22px;
    border-radius: 50px;
    font-family: var(--font-ui);
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    transition: all 0.2s;
}

.audio-play-btn:hover {
    background: #ffeef2;
    border-color: #ff6584;
    transform: translateY(-2px);
}

.audio-play-btn.playing {
    background: #ffe3e8;
    border-color: #e63946;
    color: #e63946;
    animation: pulseAudio 1.5s infinite;
}

@keyframes pulseAudio {
    0%, 100% { box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(230, 57, 70, 0); }
}

.book-text-content {
    flex: 5.5;
    background: rgba(255, 255, 255, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.02);
    position: relative;
}

.page-ribbon {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 800;
    color: #ff6584;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.ribbon-flower {
    font-size: 1.2rem;
}

.page-subtitle {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--color-text);
    margin-bottom: 20px;
    line-height: 1.25;
}

.page-body-text {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
}

.page-body-text p {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 600;
    line-height: 1.85;
    color: #2b1335;
    text-align: justify;
    text-shadow: 0 1px 1px rgba(255,255,255,0.8);
}

.book-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 35px;
    background: linear-gradient(to top, rgba(255,255,255,0.9), rgba(255,255,255,0.5));
    border-top: 2px solid rgba(255, 215, 0, 0.4);
}

.page-turn-btn {
    background: white;
    border: 3px solid white;
    color: var(--color-text);
    padding: 12px 28px;
    border-radius: 50px;
    font-family: var(--font-ui);
    font-weight: 900;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    transition: all 0.2s;
}

.page-turn-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.14);
}

.page-turn-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.primary-page-btn {
    background: linear-gradient(135deg, var(--color-btn-start), var(--color-btn-end));
    color: white;
    box-shadow: 0 6px 18px rgba(255, 101, 132, 0.35);
}

.primary-page-btn.finish-book-btn {
    background: linear-gradient(135deg, #2ec4b6, #20bf55);
    box-shadow: 0 6px 18px rgba(46, 196, 182, 0.45);
}

.page-bullets {
    display: flex;
    gap: 12px;
}

.page-bullet {
    font-size: 1.6rem;
    color: rgba(60, 30, 72, 0.25);
    cursor: pointer;
    transition: all 0.2s;
}

.page-bullet.visited {
    color: #ff8ca3;
}

.page-bullet.active {
    color: var(--color-gold);
    transform: scale(1.3);
    filter: drop-shadow(0 2px 6px var(--color-gold-glow));
}

/* ==========================================================================
   4. TELA DO MODO MINI-GAME INTERATIVO
   ========================================================================== */

#screen-minigame {
    justify-content: center;
    align-items: center;
    padding: 10px;
}

#game-container {
    width: 95%;
    max-width: 1300px;
    aspect-ratio: 16 / 9;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 35px;
    box-shadow: var(--shadow-soft);
    border: 6px solid rgba(255, 215, 0, 0.85);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

#game-header {
    height: 13%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    background: linear-gradient(to bottom, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0.2) 100%);
    border-bottom: 2px solid rgba(255, 215, 0, 0.4);
}

.game-top-btn {
    background: white;
    border: 2px solid rgba(60, 30, 72, 0.15);
    padding: 8px 18px;
    border-radius: 50px;
    font-family: var(--font-ui);
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.2s;
}

.game-top-btn:hover {
    background: #f0e6f6;
    transform: translateY(-2px);
}

.game-top-read {
    background: linear-gradient(135deg, #a18cd1, #fbc2eb);
    border-color: white;
}

.minigame-center-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.minigame-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-text);
}

#progress-bar {
    display: flex;
    gap: 12px;
}

.star {
    font-size: 2.2rem;
    color: rgba(60, 30, 72, 0.15);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.star.active {
    color: #FFD700;
    filter: drop-shadow(0 0 10px var(--color-gold-glow));
    transform: scale(1.25) rotate(12deg);
}

.minigame-top-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-btn {
    font-size: 2.2rem;
    background: none;
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.header-btn:hover {
    transform: scale(1.2) rotate(-8deg);
}

#scene-content {
    display: flex;
    flex-direction: row;
    height: 87%;
    padding: 25px;
    gap: 25px;
}

#image-slot {
    flex: 5.5;
    position: relative;
    background: white;
    border-radius: 25px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
    border: 4px solid white;
}

#scene-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#interactive-panel {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: auto;
}

#narrative-box {
    flex: 4.5;
    background: white;
    border-radius: 25px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
    border: 4px solid white;
    position: relative;
}

#narrative-box::before {
    content: "✨";
    position: absolute;
    top: 15px; left: 15px;
    font-size: 1.6rem;
    opacity: 0.5;
}

#narrative-text {
    font-family: var(--font-heading);
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.45;
    color: var(--color-text);
    flex-grow: 1;
    display: flex;
    align-items: center;
    overflow-y: auto;
    padding: 10px 0;
}

#action-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    min-height: 65px;
    align-items: center;
}

.action-btn {
    background: linear-gradient(135deg, var(--color-btn-start), var(--color-btn-end));
    border: 3px solid white;
    border-radius: 50px;
    padding: 12px 30px;
    font-size: 1.35rem;
    font-family: var(--font-ui);
    font-weight: 900;
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(255, 101, 132, 0.4);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.action-btn:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 10px 22px rgba(255, 101, 132, 0.55);
}

.option-choice-btn {
    background: linear-gradient(135deg, #a18cd1, #fbc2eb);
    color: #3c1e48;
    font-size: 1.2rem;
}

.feedback-text {
    font-size: 1.3rem;
    font-weight: 900;
    color: #2ec4b6;
    animation: fadeIn 0.3s;
}

/* ==========================================================================
   ELEMENTOS DE INTERAÇÃO DOS MINIGAMES
   ========================================================================== */

.game-sub-hint {
    position: absolute;
    top: 15px;
    left: 0;
    width: 100%;
    text-align: center;
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
    pointer-events: none;
    z-index: 10;
}

.wipe-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: opacity 0.1s linear;
}

.hint-text {
    position: absolute;
    top: 25%;
    width: 100%;
    text-align: center;
    color: white;
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
    text-shadow: 0 4px 12px rgba(0,0,0,0.5);
    pointer-events: none;
    z-index: 10;
    animation: floatAnim 3s ease-in-out infinite;
}

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

.draggable-item {
    position: absolute;
    left: 20%;
    top: 35%;
    width: 90px;
    height: 90px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border: 4px solid white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    cursor: grab;
    touch-action: none;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.draggable-item:active {
    cursor: grabbing;
    transform: scale(1.1);
}

.drop-target {
    position: absolute;
    left: 70%;
    top: 50%;
    width: 130px;
    height: 130px;
    border: 5px dashed rgba(255, 215, 0, 0.95);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 215, 0, 0.2);
    box-shadow: inset 0 0 25px rgba(255,215,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: targetPulse 2.5s infinite;
}

.target-symbol {
    font-size: 2.2rem;
    opacity: 0.7;
}

@keyframes targetPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.08); }
}

.click-target {
    position: absolute;
    width: 75px;
    height: 75px;
    background: radial-gradient(circle, #ffe3e8, #ff6584);
    border: 4px solid white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    color: white;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    transition: transform 0.2s, opacity 0.2s;
    z-index: 50;
}

.click-target:hover {
    transform: scale(1.15);
}

.timing-target {
    position: absolute;
    left: 40%;
    top: 35%;
    width: 20%;
    height: 25%;
    border: 5px solid var(--color-gold);
    background: rgba(255, 215, 0, 0.3);
    border-radius: 20px;
    box-shadow: 0 0 25px var(--color-gold-glow);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 900;
    color: white;
    text-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.timing-mover {
    position: absolute;
    left: 5%;
    top: 37%;
    width: 60px;
    height: 60px;
    background: white;
    border-radius: 50%;
    border: 4px solid #ff6584;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    z-index: 60;
}

.pulse-anim {
    animation: gentlePulse 2s infinite;
}

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

.magic-particle {
    position: absolute;
    font-size: 1.8rem;
    pointer-events: none;
    animation: particleFly 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    z-index: 9999;
}

@keyframes particleFly {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

.success-banner-game {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid var(--color-gold);
    padding: 15px 30px;
    border-radius: 50px;
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--color-text);
    box-shadow: var(--shadow-soft);
    animation: popIn 0.3s;
}

@keyframes popIn {
    from { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ==========================================================================
   5. MODAL DE VITÓRIA / CELEBRAÇÃO (NUNCA MAIS TRAVA!)
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(30, 10, 40, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.victory-card {
    background: white;
    border: 5px solid var(--color-gold);
    border-radius: var(--border-radius-lg);
    max-width: 620px;
    width: 100%;
    padding: 45px 35px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.35), 0 0 40px var(--color-gold-glow);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 15px;
    position: relative;
    animation: scaleUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleUp {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.victory-crown-glow {
    font-size: 3.5rem;
    filter: drop-shadow(0 4px 15px var(--color-gold-glow));
    animation: crownFloat 2.5s infinite;
}

.victory-heading {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--color-text);
}

.victory-text {
    font-size: 1.15rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.victory-badge-showcase {
    background: rgba(255, 215, 0, 0.12);
    border: 3px solid rgba(255, 215, 0, 0.6);
    border-radius: 24px;
    padding: 20px 30px;
    margin: 10px 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.badge-glow-circle {
    width: 75px;
    height: 75px;
    background: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px var(--color-gold-glow);
}

.badge-huge-icon {
    font-size: 2.8rem;
}

.badge-real-name {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    color: #7b4f00;
}

.badge-unlocked-tag {
    font-size: 0.85rem;
    font-weight: 800;
    color: #ff6584;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.victory-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 10px;
}

.victory-btn {
    padding: 14px 20px;
    font-size: 1.1rem;
}

.secondary-btn {
    background: #f0e6f6;
    color: var(--color-text);
    border-color: rgba(60, 30, 72, 0.2);
}

.secondary-btn:hover {
    background: #e2d1eb;
}

#confetti-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 3000;
}

/* ==========================================================================
   RESPONSIVIDADE (TABLETS E SMARTPHONES)
   ========================================================================== */

@media (max-width: 950px) {
    #app-header {
        padding: 0 15px;
        height: auto;
        min-height: 70px;
        flex-wrap: wrap;
        gap: 10px;
        padding-top: 8px;
        padding-bottom: 8px;
    }
    .brand-title { font-size: 1.1rem; }
    .brand-subtitle { font-size: 0.75rem; }
    .screen-view { padding: 15px; }

    /* Leitor */
    .book-page-layout {
        flex-direction: column;
        padding: 20px;
        gap: 20px;
    }
    .page-body-text p {
        font-size: 1.25rem;
        line-height: 1.7;
    }

    /* Mini-game */
    #game-container {
        aspect-ratio: auto;
        height: auto;
        min-height: 600px;
    }
    #scene-content {
        flex-direction: column;
        height: auto;
    }
    #image-slot {
        height: 320px;
    }
    #narrative-box {
        min-height: 250px;
    }
    #narrative-text {
        font-size: 1.4rem;
    }
}

@media (max-width: 600px) {
    .header-user-info { display: none; }
    .library-title { font-size: 1.8rem; }
    .stories-grid { grid-template-columns: 1fr; }
    .book-header { flex-direction: column; }
    .book-story-title { font-size: 1.2rem; }
}
