* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f5f5f5;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.container {
    max-width: 600px;
    width: 100%;
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
}

button, select {
    padding: 8px 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

select {
    background-color: #2196F3;
}

button:hover, select:hover {
    opacity: 0.9;
}

#sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 1px;
    background-color: #333;
    border: 2px solid #333;
    margin-bottom: 20px;
    width: 100%;
    max-width: 450px;
    aspect-ratio: 1 / 1;
}

.cell {
    background-color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    cursor: pointer;
    position: relative;
}

.cell input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 20px;
    background: transparent;
    cursor: pointer;
}

.cell input:focus {
    outline: 2px solid #4CAF50;
}

.cell.prefilled {
    font-weight: bold;
    color: #333;
}

.cell.prefilled input {
    font-weight: bold;
    color: #333;
    cursor: not-allowed;
}

/* Add borders to separate 3x3 boxes */
.cell:nth-child(3n) {
    border-right: 2px solid #333;
}

.cell:nth-child(9n) {
    border-right: none;
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid #333;
}

#message {
    margin: 20px 0;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
    min-height: 40px;
}

.success-message {
    background-color: #dff0d8;
    color: #3c763d;
    border: 1px solid #d6e9c6;
}

.error-message {
    background-color: #f2dede;
    color: #a94442;
    border: 1px solid #ebccd1;
}

#check-btn {
    margin-top: 10px;
    background-color: #2196F3;
}

/* Highlight cells with the same value on hover */
.highlight {
    background-color: #f0f8ff;
}

/* Highlight cells with errors */
.error {
    color: #a94442;
}

@media (max-width: 500px) {
    .cell input {
        font-size: 16px;
    }
    
    .game-controls {
        flex-direction: column;
        align-items: center;
    }
    
    button, select {
        width: 100%;
    }
}
