/* ===================================================================
   Archivo: Estilos CSS para "Duelo de Polinomios"
   Fecha: 22-08-2025 10:00 (Actualización para Polinomios)
   Motivo: Adaptación de UI para el nuevo enfoque temático.
   Versión: 5.1.0 (Base)
   =================================================================== */
:root {
    --color-bg: #0d1b2a;
    --color-container: #1b263b;
    --color-primary: #415a77;
    --color-secondary: #e0e1dd;
    --color-accent: #ff6b6b;
    --color-correct: #57cc99;
    --color-incorrect: #f44336;
    --color-gold: #ffd700;
    --row-highlight-color: rgba(0,0,0,0.1);
    --color-borde: #778da9; /* Añadido para consistencia */
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html {
    height: 100%;
}
body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--color-bg);
    background-image: url('https://soybrillante.com/astria_heroe_fracciones.jpg'); 
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--color-secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100%;
    padding: 10px;
    overflow: hidden; /* Importante para las transiciones de pantalla */
}
.app-container {
    width: 100%;
    max-width: 550px;
    background: rgba(27, 38, 59, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    padding: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    position: relative; /* Para el overlay */
    overflow: hidden; /* Para que las transiciones no se desborden */
    min-height: 600px; /* Altura mínima para evitar saltos */
    display: flex;
    flex-direction: column;
}
.screen {
    display: none;
    flex-grow: 1; /* Para que ocupen el espacio disponible */
    flex-direction: column;
    animation: slideIn 0.6s ease-out forwards;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 20px; /* Ajusta el padding para que coincida con el container */
    overflow-y: auto; /* Si el contenido es largo */
    box-sizing: border-box;
}
.screen.active {
    display: flex;
    animation: slideIn 0.6s ease-out forwards;
}

/* Animaciones de transición */
@keyframes slideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(-100%); }
}

.screen.fade-out {
    animation: fadeOut 0.5s ease-in forwards;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}


/* Overlay para mensajes motivadores y Adsense */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 27, 42, 0.95); /* Fondo oscuro semitransparente */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1001; /* Mayor que los modales */
    display: none;
    justify-content: center;
    align-items: center;
    text-align: center;
    animation: fadeIn 0.4s ease-out;
}

.overlay-content {
    padding: 30px;
    border-radius: 15px;
    background: rgba(27, 38, 59, 0.95);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
    max-width: 90%;
    transform: translateY(20px);
    animation: slideUpContent 0.5s ease-out forwards;
    border: 2px solid var(--color-gold);
}

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

.overlay-content .main-title {
    font-size: 3rem;
    margin-bottom: 15px;
    color: var(--color-gold);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.overlay-content p {
    font-size: 1.4rem;
    color: var(--color-secondary);
    margin-bottom: 30px;
    line-height: 1.6;
}

.adsense-slot {
    margin: 25px auto;
    background-color: rgba(0,0,0,0.3);
    padding: 10px;
    border-radius: 8px;
    min-height: 100px; /* Para simular el espacio de AdSense */
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--color-borde);
    font-size: 0.9rem;
    border: 1px dashed var(--color-borde);
}

.overlay-continue-btn {
    width: auto;
    padding: 12px 30px;
    font-size: 1.3rem;
    margin-top: 20px;
}

/* Base de los estilos existentes */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.logo {
    width: 150px;
    cursor: pointer;
}
.hud-item {
    background: rgba(0,0,0,0.2);
    padding: 5px 15px;
    border-radius: 10px;
    font-weight: 700;
    text-align: center;
    display: flex;
    align-items: center;
    gap: 8px;
}
.hud-item .label {
    font-size: 0.7rem;
    color: var(--color-gold);
}
.hud-item .value {
    font-family: 'Oswald', sans-serif;
    font-size: 1.4rem;
}
h1, .main-title {
    font-family: 'Oswald', sans-serif;
    font-size: 2.5rem;
    color: var(--color-gold);
    margin-bottom: 1rem;
    text-align: center;
}
.btn {
    font-family: 'Oswald', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 12px;
    padding: 15px 20px;
    border: none;
    font-size: 1.2rem;
    text-transform: uppercase;
    width: 100%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.btn:hover:not(:disabled) {
    transform: translateY(-5px) scale(1.02);
    filter: brightness(1.1);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}
.btn:disabled {
    background-color: var(--color-primary) !important;
    color: var(--color-borde) !important;
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.btn-principal {
    background: linear-gradient(145deg, #ff6b6b, #d63434);
    color: white;
}
.btn-back {
    background-color: var(--color-primary);
    color: var(--color-secondary);
    margin-top: 15px;
}
.btn-secundario {
    background-color: var(--color-borde);
    color: var(--color-secondary);
}
.mode-selection {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-top: 20px;
}
.btn-modo-leccion {
    background: linear-gradient(145deg, #4facfe, #00f2fe);
    color: white;
}
.btn-modo-reloj {
    background: linear-gradient(145deg, #ffc300, #ffaa00);
    color: var(--color-bg);
}
.level-selection, .time-selection {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 20px 0;
}
.level-btn, .time-btn {
    position: relative;
    overflow: hidden; /* Para el efecto de brillo */
}
.level-btn::before, .time-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 0;
    height: 200%;
    background: rgba(255, 255, 255, 0.15);
    transform: rotate(45deg);
    transition: all 0.7s ease;
    opacity: 0;
}
.level-btn:hover::before, .time-btn:hover::before {
    left: 120%;
    opacity: 1;
}

.level-btn .lock-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    pointer-events: none;
    color: var(--color-accent);
}
.progress-stars {
    font-size: 0.8rem;
    margin-top: 5px;
    letter-spacing: 2px;
    pointer-events: none;
    color: var(--color-gold);
}
.question-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
#pregunta-box {
    flex-grow: 1;
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    font-weight: 600;
    text-align: center;
    background-color: rgba(0,0,0, 0.2);
    padding: 20px;
    border-radius: 10px;
    min-height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
}
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.action-btn {
    background: var(--color-primary);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
.action-btn:hover {
    background-color: var(--color-accent);
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}
.action-btn.sparkle {
    animation: sparkle-animation 1s ease-in-out;
}
@keyframes sparkle-animation {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7); }
    50% { transform: scale(1.2); box-shadow: 0 0 20px 10px rgba(255, 215, 0, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
}
#options-panel {
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
#calculando-panel {
    font-family: 'Oswald', sans-serif;
    font-size: 1.8rem;
    color: var(--color-gold);
    padding: 20px;
    text-align: center;
    animation: pulse-text 1.5s infinite;
}
@keyframes pulse-text {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}
#options-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
.option-btn {
    background-color: var(--color-primary);
    color: var(--color-secondary);
    text-align: left;
    display: flex;
    align-items: center;
}
.option-btn.correct {
    background-color: var(--color-correct) !important;
    color: #111 !important;
    animation: correct-answer 0.8s ease-out forwards;
}
@keyframes correct-answer {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(87, 204, 153, 0.7); }
    50% { transform: scale(1.05); box-shadow: 0 0 15px 5px rgba(87, 204, 153, 0.5); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(87, 204, 153, 0.0); }
}
.option-btn.incorrect {
    background-color: var(--color-incorrect) !important;
    color: white !important;
    animation: shake 0.5s ease;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 90% { transform: translateX(-10px); }
    50% { transform: translateX(10px); }
}
.option-prefix {
    font-family: 'Oswald', sans-serif;
    margin-right: 10px;
    background-color: rgba(255,255,255,0.1);
    padding: 2px 8px;
    border-radius: 5px;
}
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.3s;
}
.modal-content {
    position: relative;
    width: 90%;
    max-width: 800px;
    background: var(--color-container);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
#hint-modal-content {
    padding: 30px;
    text-align: center;
}
#hint-text-modal {
    font-size: 1.5rem;
    color: var(--color-gold);
    margin-bottom: 20px;
}
.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    background: black;
    border-radius: 10px;
}
.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
#btn-close-modal, #btn-close-hint-modal {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-accent);
    color: white;
    border: 2px solid white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
#btn-close-modal:hover, #btn-close-hint-modal:hover {
    transform: scale(1.1) rotate(90deg);
}
#results-summary {
    text-align: left;
    margin-top: 20px;
    max-height: 200px;
    overflow-y: auto;
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
}
.result-item {
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    background: rgba(255,255,255,0.05);
}
.result-item.correct {
    border-left: 5px solid var(--color-correct);
}
.result-item.incorrect {
    border-left: 5px solid var(--color-incorrect);
}
.result-item .explanation {
    font-size: 0.8rem;
    color: var(--color-borde);
    margin-top: 5px;
    font-style: italic;
}
#trophy {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounceIn 1s ease-out;
}
@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}
.results-buttons {
    display: grid;
    gap: 10px;
    margin-top: 20px;
}
.page-footer {
    text-align: center;
    margin-top: auto; /* Empuja el footer hacia abajo */
    padding-top: 15px;
    border-top: 1px solid var(--color-primary);
    font-size: 0.9em;
    color: var(--color-borde);
}
@media (min-width: 901px) {
    body { font-size: 18px; }
    .app-container { max-width: 800px; }
    h1, .main-title { font-size: 3rem; }
    .overlay-content .main-title { font-size: 4rem; }
    .overlay-content p { font-size: 1.6rem; }
    .overlay-continue-btn { padding: 15px 40px; font-size: 1.5rem; }
}
@media (min-width: 481px) and (max-width: 900px) {
    .app-container { max-width: 700px; }
    .overlay-content .main-title { font-size: 3.5rem; }
    .overlay-content p { font-size: 1.5rem; }
}
@media (max-width: 480px) {
    .app-container { padding: 15px; }
    h1, .main-title { font-size: 1.8rem; }
    .btn { padding: 12px; font-size: 1rem; }
    .level-selection, .time-selection { grid-template-columns: 1fr; }
    #pregunta-box { padding: 15px; font-size: 1.2rem; }
    .logo { width: 120px; }
    .hud-item { padding: 3px 10px; }
    .hud-item .value { font-size: 1.2rem; }
    .overlay-content .main-title { font-size: 2.5rem; }
    .overlay-content p { font-size: 1.2rem; }
    .overlay-continue-btn { padding: 10px 25px; font-size: 1.1rem; }
}