/* Global Styles */
body {
    font-family: Arial, sans-serif;
    text-align: center;
    background-color: #fafafa;
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%; /* Prevent font scaling */
}

h1 {
    margin-top: 20px;
    font-size: 2em;
}

#controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px;
    flex-wrap: wrap;
}

#controls label,
#controls select,
#controls button,
#controls #timer {
    margin: 5px;
    font-size: 1em;
}

#timer {
    font-size: 1em;
}

/* Sudoku Grid Styles */
#sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 2px;
    width: 90%;
    max-width: 500px;
    margin: 20px auto;
    border: 3px solid #333;
    background-color: #fff;
}

.cell {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* Maintain a square aspect ratio */
    border: 1px solid #ccc;
    box-sizing: border-box; /* Include border in width and height calculations */
}

/* Input Styles */
.cell input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-size: 1.6rem; /* Ensure font size is at least 16px to prevent zoom on mobile */
    font-weight: bold; /* Make the numbers bold */
    color: #000; /* Solid black color for good contrast */
    text-align: center;
    border: none;
    outline: none;
    background: none;
    display: flex; /* Use Flexbox to center content */
    align-items: center; /* Vertical centering */
    justify-content: center; /* Horizontal centering */
    box-sizing: border-box;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    font-family: 'Arial', sans-serif; /* Ensure a readable font on mobile devices */
}

.cell input:disabled {
    background-color: #e9e9e9;
}

.fixed input {
    background-color: #e9e9e9;
}

.hinted input {
    background-color: #d9edf7;
}

/* Action Buttons */
#action-buttons {
    margin-bottom: 20px;
}

#action-buttons button {
    padding: 15px 25px;
    font-size: 1.1em;
    margin: 10px;
    min-width: 120px;
    cursor: pointer;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

#action-buttons button:active {
    background-color: #ccc;
}

/* Disable Text Selection and Tap Highlight */
body,
button,
input {
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* IE 10+ */
    user-select: none; /* Standard syntax */
}

button,
input {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0); /* Mobile Safari */
}

/* Responsive Design */
@media (max-width: 600px) {
    h1 {
        font-size: 1.5em;
    }

    #controls label,
    #controls select,
    #controls button,
    #controls #timer {
        font-size: 0.9em;
    }

    #sudoku-grid {
        width: 100%;
    }

    #action-buttons button {
        width: auto;
        font-size: 0.9em;
        padding: 12px 20px;
    }

    .cell input {
        font-size: 1.4rem;
    }
}

/* Thick Borders for Subgrids */
.cell:nth-child(9n) {
    border-right: none;
}

.cell:nth-child(n+73) {
    border-bottom: none;
}

.cell:nth-child(3n) {
    border-right: 2px solid #333;
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54),
.cell:nth-child(n+73):nth-child(-n+81) {
    border-bottom: 2px solid #333;
}
