body {
    margin: 0;
    padding: 0;
    font-family: sans-serif;
    color: rgb(53, 53, 53);
    background-image: url('/rimay_app/static/images/cuentos_historietas.png');
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
}

h1 {
    font-size: 3em;
    color: #ffffffff;
    margin: 60px 0 50px;
    text-align: center;
}

.cuentos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
    padding: 20px;
    max-width: 1200px;
    width: 100%;
}

.cuento-container {
    text-align: center;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 10px;
    transition: transform 0.3s ease;
}

.cuento-container:hover {
    transform: scale(1.05);
}

.cuento-image {
    width: 100%;
    max-width: 150px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.cuento-title {
    font-size: 1.2em;
    margin: 10px 0 0;
    color: #333;
}

.pdf-viewer {
    display: none;
    margin: 20px auto;
    max-width: 800px;
    width: 90%;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.pdf-viewer.active {
    display: block;
}

.pdf-viewer canvas {
    margin: 10px auto;
    display: block;
    border-bottom: 1px solid #eee;
}

#close-pdf {
    margin-bottom: 10px;
}

.back-button, .home-button {
    position: absolute;
    top: 20px;
    padding: 10px 20px;
    background-color: #FFA500;
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-size: 1.2em;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.back-button {
    left: 20px;
}

.back-button .icon {
    font-size: 1.5em;
}

.home-button {
    right: 20px;
    top: 60px;
}

.home-button .icon {
    font-size: 1.5em;
}

.back-button:hover, .home-button:hover {
    transform: scale(1.05);
}

.button {
    background-color: #ffd90069;
    color: rgb(53, 53, 53);
    border: none;
    padding: 10px 20px;
    font-size: 1.2em;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.button:hover {
    transform: scale(1.05);
    background-color: #ffd900;
}

/* Media queries para responsividad */
@media (max-width: 768px) {
    h1 {
        font-size: 2.5em;
    }
    .cuentos-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 15px;
    }
    .cuento-image {
        max-width: 120px;
    }
    .cuento-title {
        font-size: 1em;
    }
    .pdf-viewer {
        max-width: 90%;
        max-height: 60vh;
    }
    .back-button, .home-button {
        font-size: 1em;
        padding: 8px 15px;
    }
    .home-button {
        top: 50px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 2em;
    }
    .cuentos-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    .cuento-image {
        max-width: 100px;
    }
    .cuento-title {
        font-size: 0.9em;
    }
    .pdf-viewer {
        max-width: 95%;
        max-height: 50vh;
    }
    .button {
        font-size: 0.9em;
        padding: 6px 12px;
    }
    .back-button, .home-button {
        font-size: 0.9em;
        padding: 6px 12px;
    }
    .home-button {
        top: 40px;
    }
}