/* ================================== */
/* ====== CONFIGURAÇÕES PÁGINA ====== */
/* ================================== */

body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f4f4f9;
    color: #333;
}

main {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ====== CABEÇALHO PRINCIPAL ====== */
.cabecalho-principal {
    position: relative;
    width: 90%;
    max-width: 600px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 10px;
}

.cabecalho-principal h1 {
    width: 100%;
    text-align: center;
    font-size: 1.5em;
}

#modo-escuro-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%); 
    font-size: 1.2em; 
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

#modo-escuro-btn:hover {
    color: #007bff;
}

#barra-numeros, #status-jogo {
    display: none;
}

.area-jogo {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#tabuleiro-sudoku {
    display: grid;
    grid-template-columns: repeat(9, 50px);
    grid-template-rows: repeat(9, 50px);
    border: 3px solid #333;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    margin-top: 10px;
}

/* ====== CÉLULAS DO TABULEIRO ====== */

.celula {
    width: 50px;
    height: 50px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    position: relative;
}

#tabuleiro-sudoku > .celula:nth-child(-n+9) {
    border-top: 1px solid #ccc;
}

.celula:not(:nth-child(3n)) {
    border-right: 1px solid #ccc;
}

.celula:nth-child(3n):not(:nth-child(9n)) {
    border-right: 3px solid #333;
}

.celula:not(:nth-of-type(n+19):nth-of-type(-n+27)):not(:nth-of-type(n+46):nth-of-type(-n+54)):not(:nth-of-type(n+73)) {
    border-bottom: 1px solid #ccc;
}

#tabuleiro-sudoku > .celula:nth-child(n + 19):nth-child(-n + 27),
#tabuleiro-sudoku > .celula:nth-child(n + 46):nth-child(-n + 54) {
    border-bottom: 3px solid #333;
}


.celula-dada {
    background-color: #e9ecef;
}

.celula-entrada {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 24px;
    background-color: #fff;
    color: #007bff;
}

.celula-entrada:focus {
    outline: none;
    background-color: #e6f0ff;
}

.celula-entrada::-webkit-outer-spin-button,
.celula-entrada::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ====== CONTROLES ====== */

.controles {
    width: 450px;   
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.controle-dificuldade {
    display: flex;
    align-items: center;
    gap: 5px;
}

.controles button {
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    background-color: #e9ecef;
    color: #333;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.controles button:hover {
    background-color: #d1d5db;
}

.controles button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.controles select {
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ccc;
}

/* ====== ESTILOS DE CÉLULAS ====== */
.correto {
    color: #28a745 !important; 
    font-weight: bold;
}
.incorreto {
    color: #dc3545 !important; 
    font-weight: bold;
}

#status-jogo {
    width: 100%;
    text-align: center;
    margin-top: 15px;
    font-style: italic;
    color: #555;
    height: 20px;
}


/* ========================= */
/* ========= TIMER ========= */
/* ========================= */

#timer {
    text-align: center;
    font-size: 2.5em;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
    font-family: 'Courier New', Courier, monospace;
}


/* ================================== */
/* ======= BARRA DE NÚMEROS ========= */
/* ================================== */

#barra-numeros {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
}

.numero-btn {
    width: 50px;
    height: 60px;
    border: 2px solid #ccc;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s;
}

.numero-btn:hover {
    background-color: #e9ecef;
}

.numero-texto {
    font-size: 28px;
    font-weight: bold;
}

.contador-numero {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 12px;
    font-weight: normal;
    color: #555;
}

.numero-completo {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: #f0f0f0;
}


/* ================================== */
/* =========== MODO LÁPIS =========== */
/* ================================== */

.lapis-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.lapis-numero {
    font-size: 11px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
}

.lapis-numero.ativo {
    visibility: visible;
}

#modo-lapis-btn.ativo {
    background-color: #007bff;
    color: white;
}

#modo-lapis-btn.ativo:hover {
    background-color: #0056b3;
}


/* ================================== */
/* ========= MODO ESCURO ============ */
/* ================================== */

body.modo-escuro {
    background-color: #1a202c; 
    color: #cbd5e0;           
}

body.modo-escuro #modo-escuro-btn {
    color: #cbd5e0; 
}

body.modo-escuro #tabuleiro-sudoku {
    border-color: #cbd5e0;
    border-left: 3px solid #cbd5e0;
    border-top: 3px solid #cbd5e0;
}

body.modo-escuro .celula {
    border-color: #4a5568; 
    border-right: 1px solid #4a5568;
    border-bottom: 1px solid #4a5568;
}

body.modo-escuro #tabuleiro-sudoku > .celula:nth-child(-n+9) {
    border-top: 1px solid #4a5568;
}

body.modo-escuro .celula:not(:nth-child(3n)) {
    border-right: 1px solid #4a5568;
}

body.modo-escuro .celula:nth-child(3n):not(:nth-child(9n)) {
    border-right: 3px solid #cbd5e0;
}

body.modo-escuro .celula:not(:nth-of-type(n+19):nth-of-type(-n+27)):not(:nth-of-type(n+46):nth-of-type(-n+54)):not(:nth-of-type(n+73)) {
    border-bottom: 1px solid #4a5568;
}

body.modo-escuro #tabuleiro-sudoku > .celula:nth-child(n + 19):nth-child(-n + 27),
body.modo-escuro #tabuleiro-sudoku > .celula:nth-child(n + 46):nth-of-type(-n+54) {
    border-bottom: 3px solid #cbd5e0;
}

body.modo-escuro .celula-dada {
    background-color: #2d3748; 
}

body.modo-escuro .celula-entrada {
    background-color: #1a202c; 
    color: #63b3ed;           
}

body.modo-escuro .controles button {
    background-color: #2d3748;
    color: #cbd5e0;
}

body.modo-escuro .controles button:hover {
    background-color: #4a5568;
}

body.modo-escuro #status-jogo {
    color: #a0aec0;
}

body.modo-escuro .correto {
    color: #48bb78 !important; 
}

body.modo-escuro .incorreto {
    color: #f56565 !important; 
}

body.modo-escuro #timer {
    color: #cbd5e0;
}

body.modo-escuro .numero-btn {
    border-color: #4a5568;
}

body.modo-escuro .numero-btn:hover {
    background-color: #2d3748;
}

body.modo-escuro .contador-numero {
    color: #a0aec0;
}

body.modo-escuro .numero-completo {
    background-color: #1a202c;
}

body.modo-escuro .lapis-numero {
    color: #a0aec0;
}

body.modo-escuro #modo-lapis-btn.ativo {
    background-color: #63b3ed;
    color: #1a202c;
}


/* ================================== */
/* ========= RESPONSIVIDADE ========= */
/* ================================== */
@media (max-width: 600px) {
    main {
        width: 100%;
    }

    .cabecalho-principal h1 {
        font-size: 1.3em;
    }

    .celula {
        width: 10.8vw;
        height: 10.8vw;
        font-size: 5.2vw;
    }

    #tabuleiro-sudoku {
        grid-template-columns: repeat(9, 10.8vw);
        grid-template-rows: repeat(9, 10.8vw);
        width: auto;
        height: auto;
    }

    .lapis-numero {
        font-size: 2.6vw;
    }

    .area-jogo {
        width: 100%;
    }
    
    .controles {
        width: 97.2vw;
    }

    #barra-numeros {
        width: 98vw;
        gap: 0.8vw;
    }

    .numero-btn {
        width: 9vw;
        height: 12vw;
    }
    .numero-texto {
        font-size: 5vw;
    }
    .contador-numero {
        font-size: 2.5vw;
    }

    #timer {
        font-size: 2.2em;
    }
    
    #status-jogo {
        margin-top: 10px;
    }
}