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

body {
    font-family: 'Courier New', 'Consolas', monospace;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 50%, #e9ecef 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: background 0.3s ease;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(
            0deg,
            rgba(255, 0, 0, 0.02) 0px,
            transparent 1px,
            transparent 2px,
            rgba(255, 0, 0, 0.02) 3px
        );
    pointer-events: none;
    z-index: 0;
}

body.night-mode {
    background: linear-gradient(135deg, #000000 0%, #1a0033 50%, #0d0221 100%);
}

body.night-mode::before {
    background: 
        repeating-linear-gradient(
            0deg,
            rgba(255, 0, 255, 0.05) 0px,
            transparent 1px,
            transparent 2px,
            rgba(255, 0, 255, 0.05) 3px
        );
}

.container {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    box-shadow: 
        0 0 40px rgba(255, 0, 0, 0.2),
        0 0 80px rgba(255, 0, 0, 0.1),
        inset 0 0 60px rgba(255, 0, 0, 0.03);
    padding: 30px;
    max-width: 600px;
    width: 100%;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 0, 0, 0.2);
    position: relative;
    z-index: 1;
}

.container::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, 
        transparent 0%, 
        rgba(255, 0, 0, 0.3) 50%, 
        transparent 100%);
    border-radius: 20px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.container:hover::before {
    opacity: 0.3;
}

body.night-mode .container {
    background: rgba(13, 2, 33, 0.95);
    border-color: rgba(255, 0, 255, 0.4);
    box-shadow: 
        0 0 40px rgba(255, 0, 255, 0.3),
        0 0 80px rgba(255, 0, 255, 0.1),
        inset 0 0 60px rgba(255, 0, 255, 0.05);
}

body.night-mode .container::before {
    background: linear-gradient(45deg, 
        transparent 0%, 
        rgba(255, 0, 255, 0.5) 50%, 
        transparent 100%);
}

.header {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 20px;
}

h1 {
    text-align: center;
    color: #dc0000;
    margin: 0;
    font-size: clamp(24px, 5vw, 36px);
    transition: color 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-shadow: 
        0 0 10px rgba(255, 0, 0, 0.3),
        0 0 20px rgba(255, 0, 0, 0.2),
        0 0 30px rgba(255, 0, 0, 0.1);
    font-weight: 900;
}

body.night-mode h1 {
    color: #ff00ff;
    text-shadow: 
        0 0 10px rgba(255, 0, 255, 0.8),
        0 0 20px rgba(255, 0, 255, 0.6),
        0 0 30px rgba(255, 0, 255, 0.4);
}

.stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.stat-item {
    text-align: center;
    padding: 10px;
    background: rgba(255, 0, 0, 0.05);
    border-radius: 10px;
    flex: 1;
    min-width: 100px;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 0, 0, 0.2);
    box-shadow: inset 0 0 20px rgba(255, 0, 0, 0.05);
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 
        inset 0 0 20px rgba(255, 0, 0, 0.1),
        0 0 15px rgba(255, 0, 0, 0.2);
}

body.night-mode .stat-item {
    background: rgba(255, 0, 255, 0.1);
    border-color: rgba(255, 0, 255, 0.3);
    box-shadow: inset 0 0 20px rgba(255, 0, 255, 0.1);
}

body.night-mode .stat-item:hover {
    box-shadow: 
        inset 0 0 20px rgba(255, 0, 255, 0.2),
        0 0 15px rgba(255, 0, 255, 0.3);
}

.stat-label {
    font-size: 12px;
    color: #dc0000;
    text-transform: uppercase;
    transition: color 0.3s ease;
    letter-spacing: 2px;
    font-weight: 700;
}

body.night-mode .stat-label {
    color: #ff00ff;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #ff0000;
    transition: color 0.3s ease;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.2);
}

body.night-mode .stat-value {
    color: #ff00ff;
    text-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
}

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

button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(255, 0, 0, 0.1), rgba(220, 0, 0, 0.15));
    color: #dc0000;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 2px solid rgba(255, 0, 0, 0.3);
    box-shadow: 
        0 0 10px rgba(255, 0, 0, 0.15),
        inset 0 0 10px rgba(255, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

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

button:hover::before {
    width: 300px;
    height: 300px;
}

button:hover {
    background: linear-gradient(135deg, rgba(255, 0, 0, 0.2), rgba(220, 0, 0, 0.25));
    transform: translateY(-2px);
    box-shadow: 
        0 0 20px rgba(255, 0, 0, 0.3),
        0 4px 12px rgba(255, 0, 0, 0.2),
        inset 0 0 15px rgba(255, 0, 0, 0.1);
    border-color: rgba(255, 0, 0, 0.5);
}

button:active {
    transform: translateY(0);
}

body.night-mode button {
    background: linear-gradient(135deg, rgba(255, 0, 255, 0.2), rgba(200, 0, 200, 0.3));
    color: #ff00ff;
    border-color: rgba(255, 0, 255, 0.5);
    box-shadow: 
        0 0 10px rgba(255, 0, 255, 0.3),
        inset 0 0 10px rgba(255, 0, 255, 0.1);
}

body.night-mode button::before {
    background: rgba(255, 0, 255, 0.3);
}

body.night-mode button:hover {
    background: linear-gradient(135deg, rgba(255, 0, 255, 0.3), rgba(200, 0, 200, 0.4));
    box-shadow: 
        0 0 20px rgba(255, 0, 255, 0.5),
        0 4px 12px rgba(255, 0, 255, 0.4),
        inset 0 0 15px rgba(255, 0, 255, 0.2);
    border-color: rgba(255, 0, 255, 0.8);
}

.difficulty-buttons {
    display: flex;
    gap: 5px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.difficulty-btn {
    padding: 8px 16px;
    font-size: 12px;
}

.difficulty-btn.active {
    background: linear-gradient(135deg, rgba(255, 0, 0, 0.25), rgba(220, 0, 0, 0.35));
    box-shadow: 
        0 0 20px rgba(255, 0, 0, 0.4),
        inset 0 0 20px rgba(255, 0, 0, 0.15);
}

body.night-mode .difficulty-btn.active {
    background: linear-gradient(135deg, rgba(255, 0, 255, 0.4), rgba(200, 0, 200, 0.5));
    box-shadow: 
        0 0 20px rgba(255, 0, 255, 0.6),
        inset 0 0 20px rgba(255, 0, 255, 0.2);
}

.night-mode-btn {
    position: absolute;
    right: 0;
    padding: 8px 12px;
    font-size: 20px;
    background: rgba(255, 0, 0, 0.05);
    border: 2px solid rgba(255, 0, 0, 0.3);
    transition: all 0.3s;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.15);
}

.night-mode-btn:hover {
    background: rgba(255, 0, 0, 0.15);
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 0 25px rgba(255, 0, 0, 0.3);
}

body.night-mode .night-mode-btn {
    background: rgba(255, 0, 255, 0.1);
    border-color: rgba(255, 0, 255, 0.5);
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.3);
}

body.night-mode .night-mode-btn:hover {
    background: rgba(255, 0, 255, 0.2);
    box-shadow: 0 0 25px rgba(255, 0, 255, 0.5);
}

.back-btn {
    position: absolute;
    left: 0;
    padding: 8px 12px;
    font-size: 14px;
    background: rgba(255, 0, 0, 0.05);
    border: 2px solid rgba(255, 0, 0, 0.3);
    border-radius: 8px;
    color: #dc0000;
    text-decoration: none;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.15);
    display: inline-block;
}

.back-btn:hover {
    background: rgba(255, 0, 0, 0.15);
    transform: translateX(-3px);
    box-shadow: 0 0 25px rgba(255, 0, 0, 0.3);
    border-color: rgba(255, 0, 0, 0.5);
}

body.night-mode .back-btn {
    background: rgba(255, 0, 255, 0.1);
    border-color: rgba(255, 0, 255, 0.5);
    color: #ff00ff;
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.3);
}

body.night-mode .back-btn:hover {
    background: rgba(255, 0, 255, 0.2);
    box-shadow: 0 0 25px rgba(255, 0, 255, 0.5);
}

.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0;
    margin: 0 auto 20px;
    border: 3px solid rgba(255, 0, 0, 0.4);
    width: 100%;
    max-width: 450px;
    aspect-ratio: 1;
    box-shadow: 
        0 0 30px rgba(255, 0, 0, 0.2),
        inset 0 0 30px rgba(255, 0, 0, 0.05);
    position: relative;
}

body.night-mode .sudoku-board {
    border-color: rgba(255, 0, 255, 0.6);
    box-shadow: 
        0 0 30px rgba(255, 0, 255, 0.4),
        inset 0 0 30px rgba(255, 0, 255, 0.1);
}

.cell {
    aspect-ratio: 1;
    border: 1px solid rgba(255, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(16px, 3vw, 24px);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.9);
    color: #dc0000;
    text-shadow: 0 0 3px rgba(255, 0, 0, 0.2);
    position: relative;
}

.cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(255, 0, 0, 0.05) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
}

.cell:hover::before {
    opacity: 1;
}

body.night-mode .cell {
    background: rgba(20, 0, 40, 0.6);
    border-color: rgba(255, 0, 255, 0.2);
    color: #ff00ff;
    text-shadow: 0 0 5px rgba(255, 0, 255, 0.5);
}

body.night-mode .cell::before {
    background: radial-gradient(circle at center, rgba(255, 0, 255, 0.1) 0%, transparent 70%);
}

.cell:hover:not(.fixed) {
    background: rgba(255, 0, 0, 0.1);
    box-shadow: 
        0 0 15px rgba(255, 0, 0, 0.2),
        inset 0 0 15px rgba(255, 0, 0, 0.1);
}

body.night-mode .cell:hover:not(.fixed) {
    background: rgba(255, 0, 255, 0.2);
    box-shadow: 
        0 0 15px rgba(255, 0, 255, 0.4),
        inset 0 0 15px rgba(255, 0, 255, 0.2);
}

.cell.fixed {
    background: rgba(255, 240, 240, 0.95);
    color: #8b0000;
    cursor: default;
    text-shadow: 0 0 5px rgba(255, 0, 0, 0.3);
}

body.night-mode .cell.fixed {
    background: rgba(100, 0, 100, 0.3);
    color: #cc00cc;
    text-shadow: 0 0 8px rgba(255, 0, 255, 0.6);
}

.cell.selected {
    background: rgba(255, 0, 0, 0.2) !important;
    box-shadow: 
        0 0 20px rgba(255, 0, 0, 0.4),
        inset 0 0 20px rgba(255, 0, 0, 0.15) !important;
    border-color: rgba(255, 0, 0, 0.5) !important;
}

body.night-mode .cell.selected {
    background: rgba(255, 0, 255, 0.3) !important;
    box-shadow: 
        0 0 20px rgba(255, 0, 255, 0.6),
        inset 0 0 20px rgba(255, 0, 255, 0.3) !important;
    border-color: rgba(255, 0, 255, 0.8) !important;
}

.cell.highlighted {
    background: rgba(255, 0, 0, 0.05);
    border-color: rgba(255, 0, 0, 0.2);
}

body.night-mode .cell.highlighted {
    background: rgba(255, 0, 255, 0.1);
    border-color: rgba(255, 0, 255, 0.3);
}

.cell.error {
    background: rgba(255, 0, 0, 0.3) !important;
    color: #ff3333;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.8);
    animation: error-pulse 0.5s ease-in-out;
}

@keyframes error-pulse {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 0, 0, 0.5); }
    50% { box-shadow: 0 0 25px rgba(255, 0, 0, 0.8); }
}

.cell.correct {
    color: #ff0000;
    text-shadow: 0 0 5px rgba(255, 0, 0, 0.3);
}

body.night-mode .cell.correct {
    color: #ff00ff;
    text-shadow: 0 0 8px rgba(255, 0, 255, 0.6);
}

/* Thicker borders for 3x3 boxes */
.cell:nth-child(3n) {
    border-right: 2px solid rgba(255, 0, 0, 0.3);
}

body.night-mode .cell:nth-child(3n) {
    border-right: 2px solid rgba(255, 0, 255, 0.5);
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid rgba(255, 0, 0, 0.3);
}

body.night-mode .cell:nth-child(n+19):nth-child(-n+27),
body.night-mode .cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid rgba(255, 0, 255, 0.5);
}

.number-pad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    max-width: 450px;
    margin: 0 auto 20px;
}

.number-btn {
    aspect-ratio: 1;
    font-size: 18px;
    padding: 0;
}

.message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    text-align: center;
    padding: 20px 40px;
    border-radius: 15px;
    font-weight: 700;
    display: none;
    text-transform: uppercase;
    letter-spacing: 2px;
    min-width: 300px;
    max-width: 90%;
    animation: messageSlideDown 0.3s ease-out;
}

@keyframes messageSlideDown {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%);
        opacity: 1;
    }
}

.message.success {
    background: linear-gradient(135deg, rgba(0, 255, 100, 0.98), rgba(0, 200, 80, 0.98));
    color: #ffffff;
    display: block;
    border: 3px solid rgba(255, 255, 255, 0.6);
    box-shadow: 
        0 8px 32px rgba(0, 255, 100, 0.5),
        0 0 40px rgba(0, 255, 100, 0.4),
        inset 0 0 30px rgba(0, 255, 100, 0.3);
    text-shadow: 
        0 0 10px rgba(0, 255, 100, 0.8),
        0 2px 4px rgba(0, 0, 0, 0.5);
    animation: messageSlideDown 0.3s ease-out, success-glow 1s ease-in-out infinite;
}

@keyframes success-glow {
    0%, 100% { 
        box-shadow: 
            0 8px 32px rgba(0, 255, 100, 0.5),
            0 0 40px rgba(0, 255, 100, 0.4), 
            inset 0 0 30px rgba(0, 255, 100, 0.3); 
    }
    50% { 
        box-shadow: 
            0 8px 32px rgba(0, 255, 100, 0.6),
            0 0 60px rgba(0, 255, 100, 0.6), 
            inset 0 0 40px rgba(0, 255, 100, 0.4); 
    }
}

.message.info {
    background: linear-gradient(135deg, rgba(255, 200, 0, 0.98), rgba(255, 150, 0, 0.98));
    color: #ffffff;
    display: block;
    border: 3px solid rgba(255, 255, 255, 0.6);
    box-shadow: 
        0 8px 32px rgba(255, 200, 0, 0.5),
        0 0 40px rgba(255, 200, 0, 0.4),
        inset 0 0 30px rgba(255, 200, 0, 0.2);
    text-shadow: 
        0 0 10px rgba(255, 200, 0, 0.8),
        0 2px 4px rgba(0, 0, 0, 0.5);
}

.stats-panel {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 0, 0, 0.03);
    border-radius: 10px;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 0, 0, 0.15);
    box-shadow: inset 0 0 30px rgba(255, 0, 0, 0.03);
}

body.night-mode .stats-panel {
    background: rgba(255, 0, 255, 0.05);
    border-color: rgba(255, 0, 255, 0.2);
    box-shadow: inset 0 0 30px rgba(255, 0, 255, 0.05);
}

.stats-panel h3 {
    color: #dc0000;
    margin-bottom: 10px;
    font-size: 18px;
    transition: color 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.2);
}

body.night-mode .stats-panel h3 {
    color: #ff00ff;
    text-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    .stats {
        gap: 5px;
    }

    .stat-item {
        padding: 8px;
        min-width: 80px;
    }

    .stat-value {
        font-size: 20px;
    }

    .number-pad {
        gap: 5px;
    }

    .number-btn {
        font-size: 16px;
    }
}
