#sudoku-grid {
    display: grid;

    grid-template-columns: repeat(9, 50px);
    grid-template-rows: repeat(9, 50px);

    width: fit-content;

    margin: 10px auto;
}

#sudoku-grid.paused {
    opacity: 0.4;
    pointer-events: none;
}

#sudoku-grid input {
    width: 50px;
    height: 50px;

    box-sizing: border-box;

    text-align: center;
    font-size: 24px;

    border: 1px solid black;
}

#sudoku-grid .sudoku-cell.selected {
    outline: 2px solid #2196f3;
    outline-offset: -2px;
}

#sudoku-grid input:nth-child(9n + 3),
#sudoku-grid input:nth-child(9n + 6) {
    border-right: 3px solid black;
}

#sudoku-grid input:nth-child(n + 19):nth-child(-n + 27),
#sudoku-grid input:nth-child(n + 46):nth-child(-n + 54) {
    border-bottom: 3px solid black;
}

.given {
    font-weight: bold;
    background: #eee;
}

.invalid {
    background-color: #ec8282;
}


/* Game area */

.game-container {
    width: fit-content;

    margin: 10px auto;
}


/* Timer */

.timer-container {
    display: flex;
    align-items: center;
    justify-content: flex-start;

    gap: 4px;

    margin-bottom: 4px;
}

#playPauseBtn {
    padding: 0;

    border: none;
    background: none;

    cursor: pointer;
}

#playPauseBtn svg {
    width: 22px;
    height: 22px;

    fill: black;
}

#playPauseBtn:hover {
    opacity: 0.7;
}

#timer-display {
    font-size: 18px;
}


/* Number pad */

#numpad {
    display: grid;

    grid-template-columns: repeat(5, 82px);
    grid-template-rows: repeat(2, 82px);

    gap: 10px;

    width: fit-content;

    margin: 20px auto;
}

#numpad button {
    width: 82px;
    height: 82px;

    font-size: 34px;
    font-weight: bold;

    cursor: pointer;
}

#numpad.paused {
    opacity: 0.4;
    pointer-events: none;
}


/* New game + difficulty controls */

.buttons {
    display: flex;
    justify-content: center;
    align-items: center;

    gap: 20px;
}

#new-game,
#difficulty {
    padding: 10px 15px;

    font-size: 16px;
}


/* Cell completion animation */

@keyframes blueFlash {
    0% {
        background-color: white;
    }

    15% {
        background-color: #8fdcff;
        box-shadow: inset 0 0 18px #dff6ff;
    }

    35% {
        background-color: #bcecff;
        box-shadow: inset 0 0 10px #eafaff;
    }

    100% {
        background-color: white;
        box-shadow: inset 0 0 0 transparent;
    }
}

.pulse {
    animation: blueFlash 0.35s ease-out;
}


/* Game complete overlay */

#game-complete-overlay {
    position: fixed;

    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    background-color: rgba(0, 0, 0, 0.6);

    z-index: 3000;
}

#game-complete-box {
    position: relative;

    padding: 30px 40px;

    border-radius: 15px;

    background-color: white;

    text-align: center;
}


/* Popup close button */

.close-popup {
    position: absolute;

    top: 12px;
    right: 12px;

    width: 32px;
    height: 32px;

    padding: 4px;

    border: none;
    background: none;

    cursor: pointer;

    opacity: 0.6;

    transition:
        opacity 0.15s ease,
        transform 0.15s ease;
}

.close-popup svg {
    width: 100%;
    height: 100%;

    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.close-popup:hover {
    opacity: 1;
    transform: scale(1.1);
}

.close-popup:active {
    transform: scale(0.95);
}
/* Pencil notes: a 3x3 candidate grid within each Sudoku cell */
#sudoku-grid .sudoku-cell {
    position: relative;
    width: 50px;
    height: 50px;
    box-sizing: border-box;
}
#sudoku-grid .sudoku-cell input {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: transparent;
}
#sudoku-grid .sudoku-cell.given { background: #eee; }
#sudoku-grid .sudoku-cell.invalid { background: #ec8282; }
#sudoku-grid .sudoku-cell:nth-child(9n + 3),
#sudoku-grid .sudoku-cell:nth-child(9n + 6) { border-right: 3px solid black; }
#sudoku-grid .sudoku-cell:nth-child(n + 19):nth-child(-n + 27),
#sudoku-grid .sudoku-cell:nth-child(n + 46):nth-child(-n + 54) { border-bottom: 3px solid black; }
#sudoku-grid .sudoku-cell input { border: 0; width: 100%; height: 100%; }
#sudoku-grid .cell-notes {
    position: absolute;
    inset: 2px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    pointer-events: none;
}
#sudoku-grid .cell-notes span {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #3978aa;
    line-height: 1;
}
#sudoku-grid .sudoku-cell.has-value .cell-notes {
    display: none;
}
#note-mode {
    display: block;
    margin: 12px auto 0;
    padding: 9px 18px;
    cursor: pointer;
    border: 1px solid #5799c9;
    border-radius: 8px;
    background: white;
}
#note-mode.active { background: #cbeeff; border-color: #1976b9; }

#sudoku-grid .sudoku-cell.given .cell-notes { display: none; }

#sudoku-grid .sudoku-cell { border: 1px solid black; }