/* style.css */

:root {
    --primary-color: #4a90e2;
    --primary-hover: #357abd;
    --success-color: #4caf50;
    --error-color: #f44336;
    --border-color: #333;
    --light-border: #999;
    --cell-bg: #fff;
    --given-color: #000;
    --player-color: #4a90e2;
    --highlight-bg: rgba(74, 144, 226, 0.1);
    --block-bg: #f5f5f5;
    --grid-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 25px;
}

h1 {
    color: #333;
    font-size: 2.5em;
    margin-bottom: 10px;
}

.timer {
    font-size: 1.5em;
    color: var(--primary-color);
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

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

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: #555;
}

select {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
    cursor: pointer;
    transition: border-color 0.3s;
}

select:hover {
    border-color: var(--primary-color);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    background-color: #f0f0f0;
    color: #333;
}

.btn:hover {
    background-color: #e0e0e0;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.game-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0;
    background-color: var(--border-color);
    border: 3px solid var(--border-color);
    box-shadow: var(--grid-shadow);
    width: 100%;
    max-width: 486px;
    aspect-ratio: 1;
}

.cell {
    background-color: var(--cell-bg);
    border: 1px solid var(--light-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.cell input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 1em;
    font-weight: 600;
    background: transparent;
    cursor: pointer;
    outline: none;
}

.cell.given input {
    color: var(--given-color);
    font-weight: 700;
    cursor: default;
}

.cell.player input {
    color: var(--player-color);
}

.cell.selected {
    background-color: var(--highlight-bg);
    box-shadow: inset 0 0 0 2px var(--primary-color);
}

.cell.highlighted {
    background-color: rgba(74, 144, 226, 0.05);
}

.cell.correct {
    animation: correctPulse 0.5s ease;
}

.cell.incorrect {
    background-color: rgba(244, 67, 54, 0.2);
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* 3x3 block styling with checkerboard pattern */
.cell:nth-child(9n+1),
.cell:nth-child(9n+2),
.cell:nth-child(9n+3),
.cell:nth-child(9n+10),
.cell:nth-child(9n+11),
.cell:nth-child(9n+12),
.cell:nth-child(9n+19),
.cell:nth-child(9n+20),
.cell:nth-child(9n+21) {
    background-color: var(--block-bg);
}

.cell.selected:nth-child(9n+1),
.cell.selected:nth-child(9n+2),
.cell.selected:nth-child(9n+3),
.cell.selected:nth-child(9n+10),
.cell.selected:nth-child(9n+11),
.cell.selected:nth-child(9n+12),
.cell.selected:nth-child(9n+19),
.cell.selected:nth-child(9n+20),
.cell.selected:nth-child(9n+21) {
    background-color: var(--highlight-bg);
}

/* Thick borders for 3x3 blocks */
.cell:nth-child(3n) {
    border-right: 3px solid var(--border-color);
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 3px solid var(--border-color);
}

/* Number pad */
.number-pad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 20px;
}

.num-btn {
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1.2em;
    font-weight: 600;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.num-btn:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.num-btn:active {
    transform: translateY(0);
}

/* Win message */
.win-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.win-message.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.win-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    animation: slideIn 0.5s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.win-content h2 {
    color: var(--success-color);
    font-size: 2.5em;
    margin-bottom: 15px;
}

.win-content p {
    font-size: 1.3em;
    color: #555;
    margin-bottom: 10px;
}

.win-time {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.5em !important;
}

/* Responsive design */
@media (max-width: 600px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 2em;
    }

    .timer {
        font-size: 1.2em;
    }

    .cell {
        font-size: 1.2em;
    }

    .controls {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .number-pad {
        grid-template-columns: repeat(5, 1fr);
    }

    .num-btn {
        padding: 12px;
        font-size: 1em;
    }
}

@media (max-width: 400px) {
    .cell {
        font-size: 1em;
    }

    .num-btn {
        padding: 10px;
    }
}