/* Sudoku PWA Styles */

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

:root {
    --primary-color: #4caf50;
    --secondary-color: #45a049;
    --error-color: #f44336;
    --bg-color: #f5f5f5;
    --text-color: #333;
    --border-color: #ccc;
    --cell-bg: #fff;
    --given-color: #000;
    --user-color: #2196f3;
    --selected-bg: #e3f2fd;
    --related-bg: #f5f5f5;
    --error-bg: #ffebee;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 1.5rem;
}

h1 {
    font-size: 2rem;
    color: var(--primary-color);
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Controls */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.difficulty-selector label {
    font-weight: 500;
}

.difficulty-selector select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: white;
    font-size: 1rem;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.3s;
}

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

.btn:active {
    transform: translateY(1px);
}

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

/* Sudoku Grid Container */
.sudoku-container {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 1px;
    background-color: #000;
    border: 3px solid #000;
    width: 100%;
    max-width: 450px;
    aspect-ratio: 1;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Cells */
.cell {
    background-color: var(--cell-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1rem, 4vw, 1.5rem);
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    aspect-ratio: 1;
}

.cell:hover {
    background-color: var(--selected-bg);
}

/* Box borders (3x3) */
.cell.box-left {
    border-left: 2px solid #000;
}

.cell.box-top {
    border-top: 2px solid #000;
}

/* Cell states */
.cell.given {
    color: var(--given-color);
    font-weight: 700;
}

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

.cell.selected {
    background-color: var(--selected-bg);
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
    z-index: 1;
}

.cell.related {
    background-color: var(--related-bg);
}

.cell.error {
    background-color: var(--error-bg);
    color: var(--error-color);
}

/* Number Pad */
.number-pad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    max-width: 450px;
    margin: 0 auto;
    width: 100%;
}

.num-btn {
    padding: 1rem;
    background-color: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    aspect-ratio: 1;
}

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

.num-btn:active {
    transform: scale(0.95);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.action-buttons .btn {
    flex: 1;
    min-width: 120px;
}

/* Footer */
footer {
    margin-top: 1rem;
    text-align: center;
}

.status-message {
    padding: 0.75rem;
    border-radius: 4px;
    font-weight: 500;
    min-height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-message.success {
    background-color: #d4edda;
    color: #155724;
}

.status-message.error {
    background-color: #f8d7da;
    color: #721c24;
}

.status-message.info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 2rem;
}

.modal-content p {
    margin: 1rem 0;
    font-size: 1.1rem;
}

#completionTime {
    font-weight: bold;
    font-size: 1.3rem;
    color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 600px) {
    .container {
        padding: 0.5rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .difficulty-selector {
        justify-content: space-between;
    }

    .number-pad {
        gap: 0.25rem;
    }

    .num-btn {
        padding: 0.75rem;
        font-size: 1rem;
    }

    .action-buttons .btn {
        min-width: 100px;
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}

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

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

    .num-btn {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
}

/* Landscape mode for mobile */
@media (max-height: 600px) and (orientation: landscape) {
    .container {
        max-width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    header {
        grid-column: 1 / -1;
    }

    main {
        grid-column: 1;
    }

    .number-pad {
        grid-column: 2;
        align-self: center;
    }

    .action-buttons {
        grid-column: 1 / -1;
    }

    footer {
        grid-column: 1 / -1;
    }
}

/* Print styles */
@media print {
    .controls,
    .number-pad,
    .action-buttons,
    footer {
        display: none;
    }

    .sudoku-grid {
        break-inside: avoid;
    }
}
