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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(-45deg, #667eea, #764ba2, #f093fb, #f5576c);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #333;
    overflow-x: hidden;
    position: relative;
}

/* Floating particles background */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: float 20s infinite linear;
}

@keyframes float {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    25% { background-position: 100% 50%; }
    50% { background-position: 0% 100%; }
    75% { background-position: 100% 0%; }
}

/* Enhanced Preloader */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(-45deg, #667eea, #764ba2, #f093fb, #f5576c);
    background-size: 400% 400%;
    animation: gradientShift 3s ease infinite;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

.preloader.hidden {
    opacity: 0;
    visibility: hidden;
}

.spinner-container {
    position: relative;
    margin-bottom: 20px;
}

.spinner {
    width: 80px;
    height: 80px;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top: 5px solid white;
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

.spinner-inner {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-bottom: 3px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite reverse;
}

.loading-text {
    color: white;
    font-size: 20px;
    font-weight: 300;
    letter-spacing: 3px;
    animation: pulse 2s ease-in-out infinite;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.loading-dots {
    color: white;
    font-size: 24px;
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

/* Main content with enhanced animations */
.main-content {
    opacity: 0;
    transition: opacity 1s ease;
    width: 100%;
    max-width: 650px;
    padding: 20px;
    z-index: 10;
    position: relative;
}

.main-content.visible {
    opacity: 1;
}

.header {
    text-align: center;
    margin-bottom: 30px;
    animation: slideDown 1s ease;
}

.header h1 {
    font-size: 3.5rem;
    font-weight: 800;
    background: linear-gradient(45deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3, #a8e6cf);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientText 4s ease infinite, textFloat 6s ease-in-out infinite;
    margin-bottom: 15px;
    text-shadow: 0 8px 16px rgba(0,0,0,0.3);
    position: relative;
}

.header h1::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.3), transparent);
    transform: translateX(-100%);
    animation: shine 3s infinite;
}

@keyframes gradientText {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes textFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

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

.game-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    padding: 35px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.15), 
                inset 0 1px 0 rgba(255,255,255,0.3);
    animation: slideUp 1s ease 0.3s both;
    position: relative;
    overflow: hidden;
}

.game-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.05), transparent);
    animation: containerShine 8s linear infinite;
    pointer-events: none;
}

@keyframes containerShine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

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

.options-section {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 0px;
    flex-wrap: wrap;
}

.option-group {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 15px 25px;
    border-radius: 30px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.option-group::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transition: width 0.6s, height 0.6s;
    transform: translate(-50%, -50%);
}

.option-group:hover::before {
    width: 300px;
    height: 300px;
}

.option-group:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.6);
}

.option-group:active {
    transform: translateY(-1px) scale(0.98);
}

select {
    background: transparent;
    border: none;
    color: white;
    outline: none;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

select option {
    background: #667eea;
    color: white;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: white;
    cursor: pointer;
}

.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 3px;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    padding: 8px;
    border-radius: 20px;
    margin: 0 auto 30px;
    max-width: 500px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.3),
                inset 0 2px 4px rgba(255,255,255,0.1);
    position: relative;
}

.sudoku-grid::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 20px;
    box-shadow: inset 0 0 20px rgba(255,255,255,0.1);
    pointer-events: none;
}

.cell {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #ffffff, #f8f9fa);
    border: none;
    font-size: 22px;
    font-weight: 700;
    color: #2c3e50;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 8px;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.5), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cell:hover:not(.filled)::before {
    opacity: 1;
}

.cell:hover:not(.filled) {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    transform: scale(1.08) translateZ(0);
    box-shadow: 0 8px 20px rgba(33, 150, 243, 0.4);
    z-index: 10;
}

.cell.selected {
    background: linear-gradient(135deg, #2196f3, #1976d2) !important;
    color: white !important;
    transform: scale(1.15) translateZ(0);
    z-index: 20;
    box-shadow: 0 10px 25px rgba(33, 150, 243, 0.6);
    animation: cellPulse 2s ease-in-out infinite;
}

@keyframes cellPulse {
    0%, 100% { box-shadow: 0 10px 25px rgba(33, 150, 243, 0.6); }
    50% { box-shadow: 0 15px 35px rgba(33, 150, 243, 0.8); }
}

.cell.filled {
    background: linear-gradient(135deg, #e8f5e8, #c8e6c9);
    cursor: default;
    font-weight: 800;
    color: #2e7d32;
}

.cell.conflict {
    background: linear-gradient(135deg, #ffebee, #ffcdd2) !important;
    color: #d32f2f !important;
    animation: conflictShake 0.6s ease, conflictGlow 2s ease infinite;
}

@keyframes conflictShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

@keyframes conflictGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(211, 47, 47, 0.5); }
    50% { box-shadow: 0 0 20px rgba(211, 47, 47, 0.8); }
}

/* Enhanced 3x3 grid borders */
.cell:nth-child(3n):not(:nth-child(9n)) {
    border-right: 4px solid #2c3e50;
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 4px solid #2c3e50;
}
.restart{margin-top: 30px;}

.timer {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, rgba(255,255,255,0.2), rgba(255,255,255,0.1));
    backdrop-filter: blur(10px);
    color: white;
    margin-bottom: 25px;
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}

.timer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: timerShine 3s infinite;
}

@keyframes timerShine {
    0% { left: -100%; }
    100% { left: 100%; }
}

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

.btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.4);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transition: width 0.6s, height 0.6s;
    transform: translate(-50%, -50%);
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 15px 35px rgba(255, 107, 107, 0.6);
}

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

.help-section {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(15px);
    padding: 15px;
    border-radius: 20px;
    margin-top: 20px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.help-section h3 {
    color: white;
    margin-bottom: 15px;
    font-size: 20px;
    font-weight: 600;
}

.help-section p {
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
    margin-bottom: 12px;
}

.keyboard-shortcuts {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
}

/* Enhanced Success animation */
.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.95), rgba(139, 195, 74, 0.95));
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(10px);
}

.success-message {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 50px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0,0,0,0.3);
    animation: successBounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
    overflow: hidden;
}

.success-message::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(76, 175, 80, 0.1), transparent);
    animation: successShine 2s linear infinite;
}

.success-message h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #4caf50, #8bc34a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: successTextGlow 2s ease-in-out infinite;
}

@keyframes successBounce {
    0% {
        transform: scale(0.3) rotate(-10deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    70% {
        transform: scale(0.9) rotate(-2deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes successShine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

@keyframes successTextGlow {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(76, 175, 80, 0.5)); }
    50% { filter: drop-shadow(0 0 20px rgba(76, 175, 80, 0.8)); }
}

/* Responsive design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2.8rem;
    }
    
    .game-container {
        margin: 10px;
        padding: 25px;
    }
    
    .options-section {
        flex-direction: column;
        align-items: center;
    }
    
    .cell {
        font-size: 20px;
    }

    .actions {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 200px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 2.2rem;
    }

    .sudoku-grid {
        max-width: 350px;
    }

    .cell {
        font-size: 18px;
    }
}
