* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 25px;
}

header {
    grid-column: 1 / -1;
    text-align: center;
    padding: 25px;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    margin-bottom: 10px;
}

h1 {
    font-size: 2.4rem;
    margin-bottom: 8px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

.sidebar {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    height: fit-content;
    position: sticky;
    top: 20px;
}

.control-group {
    margin-bottom: 22px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: #444;
    font-size: 1rem;
}

select, input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e1e5eb;
    border-radius: 8px;
    font-size: 15px;
    background-color: #f9fbfd;
    transition: all 0.3s;
}

select:focus, input:focus {
    outline: none;
    border-color: #6a11cb;
    box-shadow: 0 0 0 3px rgba(106, 17, 203, 0.15);
    background-color: white;
}

.buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 25px;
}

button {
    padding: 14px 20px;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(106, 17, 203, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(106, 17, 203, 0.35);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #b0b7c3;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.preview-area {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    min-height: 600px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eaeef2;
}

.preview-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #444;
}

#status {
    font-size: 0.95rem;
    color: #6a11cb;
    font-weight: 500;
    background: #f0f4ff;
    padding: 6px 12px;
    border-radius: 20px;
}

.sudoku-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.sudoku-item {
    background: #f9fbfd;
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s, box-shadow 0.3s;
}

.sudoku-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.sudoku-header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #e1e5eb;
}

.sudoku-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #555;
}

.sudoku-grid {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid #333;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    margin: 0 auto;
    background: white;
}

.sudoku-cell {
    border: 1px solid #aaa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 500;
    background-color: white;
    transition: background-color 0.2s;
}

.sudoku-cell:nth-child(3n) {
    border-right: 2px solid #333;
}

.sudoku-cell:nth-child(9n) {
    border-right: 1px solid #aaa;
}

.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid #333;
}

.given {
    font-weight: 700;
    color: #1a1a1a;
}

.empty {
    color: transparent;
}

.loading {
    text-align: center;
    padding: 60px 20px;
    font-size: 18px;
    color: #666;
    grid-column: 1 / -1;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #6a11cb;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 25px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

footer {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    color: #666;
    font-size: 0.9rem;
    border-top: 1px solid #eaeef2;
}

.info-text {
    font-size: 0.85rem;
    color: #777;
    margin-top: 8px;
    line-height: 1.4;
}

@media (max-width: 1100px) {
    .container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: static;
    }
    
    .sudoku-container {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 600px) {
    body {
        padding: 15px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .sudoku-container {
        grid-template-columns: 1fr;
    }
}