html, body {
    margin: 0;
    padding: 10px;
    padding-top: 0;
    width: 95%;
    height: 95%;
    overflow: hidden;
}

body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding-top: 50px;
    height: 100vh;
    margin: 0;
    background-color: #f0f0f0;
}

.container {
    width: 100%;
    height: 100%;
    padding: 10px;
    text-align: center;
}

input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: calc(2.5vw);
    padding: 0;
    box-sizing: border-box;
    background-color: transparent;
}
.fixed {
    font-weight: bold;
    color: var(--text-color);
}
#title {
    text-align: center;
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.5em;
    cursor: pointer;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    margin-bottom: 10px;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.congratulations {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    transform: rotate(-15deg);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    max-width: 80%;
}

.congratulations h2 {
    color: var(--primary-color);
    margin-top: 0;
}

select,
button {
    padding: 8px;
    border: none;
    border-radius: 5px;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-size: 0.9em;
}

select:hover,
button:hover {
    background-color: #2980b9;
}

#sudoku-board {
    border-collapse: collapse;
    margin: 0 auto;
    width: 100%;
    max-width: 100%;
}

#sudoku-board td {
    width: 40px;
    /* Fixed width for desktop view */
    height: 40px;
    /* Fixed height for desktop view */
    text-align: center;
    border: 1px solid var(--grid-border-color);
    font-size: 18px;
    /* Font size for desktop view */
    box-sizing: border-box;
}

#sudoku-board tr:nth-child(3n+1) td {
    border-top: 2px solid var(--grid-border-color);
}

#sudoku-board td:nth-child(3n+1) {
    border-left: 2px solid var(--grid-border-color);
}

#sudoku-board td {
    border-right: 1px solid var(--grid-border-color);
    border-bottom: 1px solid var(--grid-border-color);
}

#sudoku-board td:last-child {
    border-right: 2px solid var(--grid-border-color);
}

#sudoku-board tr:last-child td {
    border-bottom: 2px solid var(--grid-border-color);
}

#sudoku-board input {
    width: 100%;
    height: 100%;
    text-align: center;
    font-size: 18px;
    border: none;
    outline: none;
    background-color: transparent;
    color: #000;
}

#sudoku-board input.given {
    font-weight: bold;
    color: var(--primary-color);
}

#sudoku-board input.solution {
    color: #999;
    /* Light grey color */
    font-style: italic;
}

#sudoku-board input.incorrect {
    color: #e74c3c !important;
    /* Use !important to ensure this overrides other styles */
}

#sudoku-board input.hint {
    color: var(--secondary-color);
    font-style: italic;
}

#sudoku-board input.user-entered {
    color: #000;
    /* Black color for user-entered values */
}

#message {
    text-align: center;
    margin-top: 10px;
    font-weight: bold;
    color: var(--secondary-color);
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

#loading-overlay p {
    color: white;
    margin-top: 10px;
}

@media (max-width: 600px) {
    .controls {
        flex-direction: row;
    }

    .container {
        padding: 10px;
    }

    select,
    button {
        flex: 1 1 auto;
        font-size: 0.8em;
        padding: 6px;
    }

    #sudoku-board td {
        width: calc(100vw / 9);
        height: calc(100vw / 9);
        font-size: calc(4.5vw);
    }

    #sudoku-board input {
        font-size: calc(4.5vw);
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    h1 {
        font-size: 1.5em;
    }
    select,
    button {
        flex: 1 1 auto;
        font-size: 0.8em;
        padding: 6px;
    }
    #sudoku-board {
        border-collapse: collapse;
        margin: 0 auto;
        width: 100%;
        max-width: 100%;
    }
    
    #sudoku-board td {
        width: calc(100vw / 9);
        height: calc(100vw / 9);
        font-size: calc(4.5vw);
    }

    #sudoku-board input {
        font-size: calc(4.5vw);
    }
}

@media (max-width: 430px) {
    .container {
        padding: 10px;
    }

    h1 {
        font-size: 1.5em;
    }

    select, button {
        flex: 1 1 auto;
        font-size: 0.8em;
        padding: 6px;
    }

    #sudoku-board {
        width: 300px;
        height: 300px;
    }

    #sudoku-board td, #sudoku-board input {
        width: 33.33px;
        height: 33.33px;
        font-size: 1.2em;
    }

    #sudoku-board input {
        font-size: 1.2em;
    }
}
