body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 10px;
    box-sizing: border-box;
}

.worksheet-container {
    background-color: white;
    width: 100%;
    max-width: 800px;
    border: 1px solid #ccc;
    padding: 20px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

/* --- Encabezado y Título --- */

.header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.header input[type="text"] {
    border: none;
    border-bottom: 1px solid black;
    width: 150px;
    padding: 2px 5px;
    font-size: 1em;
}

h1 {
    text-align: center;
    font-size: 2.5em;
    margin-bottom: 5px;
    border-bottom: 2px solid black;
    display: inline-block;
    padding-bottom: 5px;
    margin-left: 50%;
    transform: translateX(-50%);
    font-weight: bold; 
}

.instructions {
    text-align: left;
    margin-top: 10px;
    margin-bottom: 15px;
    font-size: 1.1em;
}

/* --- Cuadrícula de Problemas --- */

.problems-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border-top: 1px solid black;
    border-left: 1px solid black;
}

.problem-cell {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-right: 1px solid black;
    border-bottom: 1px solid black;
    font-size: 1.3em;
}

.problem-text {
    flex-grow: 1;
}

.problem-input {
    width: 60px;
    height: 30px;
    font-size: 1.1em;
    text-align: center;
    border: 1px solid #ccc;
    margin-left: 10px;
}

/* --- Botones de Control (Agrupados) --- */

.control-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    margin-bottom: 10px;
}

#checkAnswersBtn, #regenerateBtn { 
    display: inline-block;
    margin: 0;
    padding: 10px 20px;
    font-size: 1em; 
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-weight: normal;
}

#checkAnswersBtn {
    background-color: #4CAF50;
}

#checkAnswersBtn:hover {
    background-color: #45a049;
}

#regenerateBtn {
    background-color: #007bff;
}

#regenerateBtn:hover {
    background-color: #0056b3;
}

/* --- Resultados --- */

#results {
    text-align: center;
    font-size: 1.1em;
    margin-top: 5px;
    margin-bottom: 15px;
    font-weight: bold;
}

.correct {
    color: green;
}

.incorrect {
    color: red;
}

/* --- Sección de Compra (Call to Action) --- */

.buy-section {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background-color: #f5f5f5; 
    border: 1px dashed #999; 
    border-radius: 5px;
}

.buy-section p {
    font-family: Arial, sans-serif;
    font-size: 1em;
    margin-bottom: 10px;
    font-weight: normal;
    color: #333;
}

.buy-btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 1.1em;
    font-weight: bold; 
    text-decoration: none; 
    color: white;
    background-color: #ff5722; 
    border: none;
    border-radius: 5px; 
    box-shadow: 2px 2px 0px #d84315; 
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

.buy-btn:hover {
    background-color: #d84315;
    transform: translateY(-1px);
}

/* ============================================== */
/* === Adaptación para Pantallas Pequeñas (Media Query) === */
/* ============================================== */

/* Para dispositivos con un ancho máximo de 480px a 768px (rango común para móviles grandes y tabletas) */
@media (max-width: 768px) {

    /* Reducir el padding general del contenedor */
    .worksheet-container {
        padding: 10px;
    }

    /* Reducir el tamaño de fuente base para todo */
    body {
        font-size: 0.9em; 
    }

    /* Reducir el encabezado */
    h1 {
        font-size: 2em; /* Título más pequeño */
        margin-bottom: 0px;
        padding-bottom: 3px;
    }
    
    .header {
        font-size: 1em;
        margin-bottom: 10px;
    }

    /* Ajustar la rejilla de problemas */
    .problem-cell {
        padding: 8px; /* Reducir padding interno */
        font-size: 1.1em; /* Reducir tamaño de texto de los problemas */
    }

    .problem-input {
        width: 50px; /* Reducir ancho del campo de entrada */
        height: 25px; /* Reducir altura del campo de entrada */
        font-size: 1em; 
        margin-left: 5px;
    }

    /* Ajustar botones */
    #checkAnswersBtn, #regenerateBtn {
        padding: 8px 15px; /* Botones más pequeños */
        font-size: 0.9em;
    }

    /* Ajustar Call to Action */
    .buy-section {
        padding: 10px;
        margin-top: 15px;
    }
    
    .buy-section p {
        font-size: 0.9em;
    }

    .buy-btn {
        padding: 8px 15px;
        font-size: 1em;
    }
}