body, h1, p, button, input {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
}

body {
    background: linear-gradient(135deg, #e0e7ff 0%, #f8fafc 100%);
    min-height: 100vh;
    color: #222;
    display: flex;
    flex-direction: column;
}

body.dark-mode {
    background: linear-gradient(135deg, #0f0f12 0%, #18181b 100%);
    color: #f3f4f6;
}

header {
    background: #6366f1;
    color: #fff;
    padding: 1.2rem 0;
    text-align: center;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.08);
    position: relative;
}

body.dark-mode header {
    background: #1e1b4b;
    box-shadow: 0 2px 8px rgba(129, 140, 248, 0.12);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.mode-toggle {
    position: absolute;
    top: 50%;
    right: 2rem;
    transform: translateY(-50%);
    width: 3rem;
    height: 1.5rem;
    background: #fff;
    border: 2px solid #6366f1;
    border-radius: 1rem;
    cursor: pointer;
    padding: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    transition: all 0.3s ease;
    z-index: 20;
    font-size: 0.8rem;
}

body.dark-mode .mode-toggle {
    background: #1e1b4b;
    border-color: #818cf8;
    justify-content: flex-end;
}

.mode-toggle::before {
    content: '';
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: #6366f1;
    transition: all 0.3s ease;
}

body.dark-mode .mode-toggle::before {
    background: #818cf8;
}

main {
    flex: 1;
    overflow: hidden;
}

.main-layout {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    padding: 1.5rem;
    height: 100%;
    max-height: calc(100vh - 200px);
}



.features, .rules {
    list-style: disc inside;
    margin-bottom: 1.5rem;
    font-size: 1.05rem;
    line-height: 1.7;
    padding-left: 0.5rem;
}

.container {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 4px 24px rgba(99, 102, 241, 0.12);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

body.dark-mode .container {
    background: #23232a;
    box-shadow: 0 4px 24px rgba(129, 140, 248, 0.16);
    border: 1px solid #818cf8;
}

.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 50px);
    grid-template-rows: repeat(9, 50px);
    gap: 2px;
    background: #e0e7ff;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.12);
    transition: all 0.3s;
    margin-bottom: 1rem;
    border: 2px solid #6366f1;
}

body.dark-mode .sudoku-grid {
    background: #1e1b4b;
    border-color: #818cf8;
    box-shadow: 0 6px 24px rgba(129, 140, 248, 0.16);
}

.cell {
    width: 50px;
    height: 50px;
    text-align: center;
    font-size: 1.4rem;
    border: none;
    outline: none;
    background: #f3f4f6;
    color: #222;
    border-radius: 4px;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(99, 102, 241, 0.04);
    caret-color: #6366f1;
    font-weight: 500;
}

body.dark-mode .cell {
    background: #18181b;
    color: #f3f4f6;
    caret-color: #818cf8;
    border: 1px solid #818cf8;
}

.cell::placeholder {
    color: #b4b4b4;
    opacity: 1;
    font-size: 1rem;
}

body.dark-mode .cell::placeholder {
    color: #818cf8;
}

.cell:focus {
    background: #e0e7ff;
    box-shadow: 0 0 0 2px #6366f1;
    border: 2px solid #818cf8;
}

body.dark-mode .cell:focus {
    background: #2a2750;
    box-shadow: 0 0 0 2px #818cf8;
    border: 2px solid #818cf8;
}

.cell:hover {
    background: #e0e7ff;
    box-shadow: 0 0 0 2px #818cf8;
    border: 2px solid #6366f1;
    z-index: 1;
}

body.dark-mode .cell:hover {
    background: #2a2750;
    box-shadow: 0 0 0 2px #818cf8;
    border: 2px solid #818cf8;
}

.sudoku-grid input:nth-child(3n+1) {
    border-left: 2px solid #6366f1;
}
.sudoku-grid input:nth-child(n+1):nth-child(-n+9),
.sudoku-grid input:nth-child(n+28):nth-child(-n+36),
.sudoku-grid input:nth-child(n+55):nth-child(-n+63) {
    border-top: 2px solid #6366f1;
}
.sudoku-grid input:nth-child(9n) {
    border-right: 2px solid #6366f1;
}
.sudoku-grid input:nth-child(n+73) {
    border-bottom: 2px solid #6366f1;
}
body.dark-mode .sudoku-grid input:nth-child(3n+1),
body.dark-mode .sudoku-grid input:nth-child(n+1):nth-child(-n+9),
body.dark-mode .sudoku-grid input:nth-child(n+28):nth-child(-n+36),
body.dark-mode .sudoku-grid input:nth-child(n+55):nth-child(-n+63),
body.dark-mode .sudoku-grid input:nth-child(9n),
body.dark-mode .sudoku-grid input:nth-child(n+73) {
    border-color: #818cf8;
}

.controls {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 0;
}

.btn {
    background: linear-gradient(90deg, #6366f1 0%, #818cf8 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.6rem 1.3rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.12);
    transition: all 0.2s;
}

body.dark-mode .btn {
    background: linear-gradient(90deg, #818cf8 0%, #6366f1 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(129, 140, 248, 0.16);
}

.btn:hover, .btn:focus {
    background: linear-gradient(90deg, #818cf8 0%, #6366f1 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

footer {
    text-align: center;
    padding: 1rem 0;
    background: #f3f4f6;
    color: #6366f1;
    font-size: 0.95rem;
    border-top: 1px solid #e0e7ff;
    margin-top: auto;
}

body.dark-mode footer {
    background: #1e1b4b;
    color: #818cf8;
    border-top: 1px solid #818cf8;
}

.rules-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(99, 102, 241, 0.10);
    padding: 2rem 1.5rem;
    min-width: 260px;
    max-width: 320px;
    color: #222;
    margin: 2rem 2rem 2rem 2rem;
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
body.dark-mode .rules-card {
    background: #23232a;
    color: #f3f4f6;
    box-shadow: 0 4px 24px rgba(99, 102, 241, 0.18);
}

.rules-card h2 {
    font-size: 1.3rem;
    margin-bottom: 0.7rem;
    color: #6366f1;
}
body.dark-mode .rules-card h2 {
    color: #818cf8;
}

.user-input {
    background: #e5e7eb !important;
    color: #888 !important;
    font-weight: 600;
}

body.dark-mode .user-input {
    background: #18181b !important;
    color: #a5b4fc !important;
}

@media (max-width: 1024px) {
    .main-layout {
        flex-direction: column;
        gap: 1rem;
    }
    .container {
        padding: 1rem;
    }
    .sudoku-grid {
        margin-bottom: 0.8rem;
    }
    .rules-card {
        min-width: 220px;
        max-width: 95vw;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.6rem;
    }
    .sudoku-grid {
        grid-template-columns: repeat(9, 40px);
        grid-template-rows: repeat(9, 40px);
    }
    .cell {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    .rules-card {
        font-size: 0.9rem;
    }
}
