/* Sudoku Specific Styles */

.public-ranking-entry {
    flex-shrink: 0;
    min-height: 44px;
    margin-bottom: 6px;
    padding: 8px 12px;
    font-size: 14px;
}

:root {
    --sudoku-grid-border: 2px solid var(--text-primary);
    --sudoku-cell-size: clamp(35px, 10vw, 50px);
    --sudoku-complete-green: rgba(34, 197, 94, 0.18);
    --sudoku-complete-blue: rgba(14, 165, 233, 0.18);
    --sudoku-complete-amber: rgba(245, 158, 11, 0.18);
}

/* Level Select Style */
.stat-select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    -webkit-appearance: none;
    text-align: center;
    text-align-last: center;
}

.stat-select:hover {
    background: var(--bg-secondary);
}

/* Puzzle Board Layout */
.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, var(--sudoku-cell-size));
    grid-template-rows: repeat(9, var(--sudoku-cell-size));
    gap: 1px;
    background-color: var(--border-color);
    border: var(--sudoku-grid-border);
    margin: 0 auto;
    user-select: none;
    touch-action: manipulation;
}

.cell {
    background-color: var(--panel-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    position: relative;
    transition: background-color 0.1s;
}

/* 3x3 Box Borders */
.cell:nth-child(3n) { border-right: 1px solid var(--text-primary); }
.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: 1px solid var(--text-primary);
}

.cell.fixed {
    color: var(--text-secondary);
    background-color: var(--bg-secondary);
    font-weight: 400;
}

.cell.selected {
    background-color: var(--game-accent-soft) !important;
    outline: 2px solid var(--game-accent);
    z-index: 1;
}

/* Improved Highlights */
.cell.highlighted {
    background-color: rgba(108, 92, 231, 0.25);
}

.cell.highlight-unit {
    background-color: rgba(0, 0, 0, 0.05);
}

[data-theme='dark'] .cell.highlight-unit {
    background-color: rgba(255, 255, 255, 0.05);
}

.cell.error,
.cell .cell-value.error {
    color: var(--error-color, #ef4444) !important;
}

@keyframes auto-fill-pop {
    0% {
        transform: scale(0.85);
        box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    }
    60% {
        transform: scale(1.05);
        box-shadow: 0 0 12px rgba(99, 102, 241, 0.25);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    }
}

.cell.auto-fill {
    animation: auto-fill-pop 0.35s ease-out;
}

@keyframes unit-flash-row {
    0% { background-color: transparent; }
    40% { background-color: var(--sudoku-complete-green); }
    100% { background-color: transparent; }
}

@keyframes unit-flash-col {
    0% { background-color: transparent; }
    40% { background-color: var(--sudoku-complete-blue); }
    100% { background-color: transparent; }
}

@keyframes unit-flash-box {
    0% { background-color: transparent; }
    40% { background-color: var(--sudoku-complete-amber); }
    100% { background-color: transparent; }
}

.cell.flash-row {
    animation: unit-flash-row 0.8s ease-out;
}

.cell.flash-col {
    animation: unit-flash-col 0.8s ease-out;
}

.cell.flash-box {
    animation: unit-flash-box 0.8s ease-out;
}

/* Note Mode inside Cell */
.cell.note-mode {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 2px;
}

.cell.note-mode span {
    font-size: 9px;
    color: var(--text-secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
}

/* Paused Blur */
.paused-blur {
    filter: blur(8px);
    pointer-events: none;
    opacity: 0.6;
}

/* Number Pad */
.number-pad {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 4px;
    margin: 12px 0;
}

.numpad-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 0.85;
    border: 1px solid var(--border-color);
    background: var(--panel-bg);
    color: var(--text-primary);
    border-radius: var(--border-radius-sm);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 0;
}

.remaining-count {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: -2px;
}

.numpad-btn:active:not(:disabled) {
    background: var(--bg-secondary);
}

.numpad-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

/* Modal Header Fix */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

/* Toggle Button Style */
.action-btn.active {
    background-color: var(--bg-secondary);
    color: var(--game-accent);
    border-color: var(--game-accent);
}

/* Mini Grid in Completion Modal */
.mini-grid-container {
    display: grid;
    grid-template-columns: repeat(9, 15px);
    grid-template-rows: repeat(9, 15px);
    gap: 1px;
    border: 1px solid var(--text-primary);
    background: var(--border-color);
    margin: 10px auto;
    width: fit-content;
}

.mini-cell {
    background: var(--panel-bg);
    font-size: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mini-cell.fixed {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

@media (max-width: 420px) {
    :root {
        /* 44px reserves side padding, gaps, and board borders. */
        --sudoku-cell-size: min(38px, calc((100vw - 44px) / 9));
    }
    .cell { font-size: 18px; }
    .cell.note-mode span { font-size: 8px; }
    .number-pad { gap: 2px; }
    .numpad-btn { font-size: 16px; }
}
