/* --- ESTILOS GENERALES Y FUENTES --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --background-color: #f0f2f5;
    --board-background: #ffffff;
    --given-number-bg: #e9ecef;
    --selected-cell-bg: #cce5ff;
    --error-color: #dc3545;
    --correct-color: #28a745;
    --font-color: #333;
    --border-light: #ccc;
    --border-dark: #343a40;
}

body {
    font-family: 'Poppins', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-color: var(--background-color);
    color: var(--font-color);
}

* {
    box-sizing: border-box;
}

/* --- PANTALLA DE SELECCIÓN DE NIVEL --- */
#level-selection-screen {
    text-align: center;
    background-color: var(--board-background);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

#level-selection-screen h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

#level-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 20px;
}

.level-btn, button {
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    background-color: var(--primary-color);
    color: white;
    transition: background-color 0.3s, transform 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.level-btn:hover, button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

/* --- PANTALLA DE JUEGO --- */
#game-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
}

.info-box {
    background-color: var(--board-background);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    min-width: 140px;
    text-align: center;
}

#errors-display {
    color: var(--error-color);
}

.game-main {
    display: flex;
    justify-content: center;
}

/* --- TABLERO DE SUDOKU --- */
#sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    width: 500px;
    height: 500px;
    border: 3px solid var(--border-dark);
    border-radius: 8px;
    background-color: var(--board-background);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.cell {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: 600;
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.cell:nth-child(3n) { border-right: 2px solid var(--border-dark); }
.cell:nth-child(9n) { border-right: none; }
.row-border .cell { border-bottom: 2px solid var(--border-dark); }

.cell.given-number {
    font-weight: 700;
    color: #000;
    background-color: var(--given-number-bg);
    cursor: not-allowed;
}

.cell.selected { background-color: var(--selected-cell-bg); }
.cell.incorrect {
    color: white;
    background-color: var(--error-color);
    animation: shake 0.3s;
}

/* Estilos para mostrar la solución al perder */
.cell.correct-on-loss {
    color: var(--correct-color);
    font-weight: 700;
}
.cell .user-incorrect-on-loss {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 12px;
    color: var(--error-color);
    text-decoration: line-through;
}

/* --- PALETA DE NÚMEROS ABAJO --- */
#number-palette {
    display: flex;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 500px;
}

.number-btn {
    width: 45px;
    height: 45px;
    font-size: 24px;
    font-weight: 700;
    border-radius: 8px;
    background-color: #f8f9fa;
    color: var(--primary-color);
    border: 2px solid #dee2e6;
    cursor: grab;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.number-btn:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.number-btn:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.erase-btn {
    background-color: #6c757d;
    color: white;
    border: 2px solid #6c757d;
}
.erase-btn:hover {
    background-color: #5a6268;
    border-color: #5a6268;
}

/* --- CONTROLES Y MODAL --- */
.game-controls {
    display: flex;
    gap: 20px;
}

#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 30px 40px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.modal-content button {
    margin: 10px;
    min-width: 150px;
}

/* --- ANIMACIÓN --- */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
