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

:root {
    --primary: #6366f1;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --dark: #1e1b4b;
    --light: #f8fafc;
    --error: #ef4444;
    --success: #10b981;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    min-height: 100vh;
    padding: 1rem;
}

.container {
    max-width: 600px;
    margin: 0 auto;
}

.header {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}

.back-btn {
    position: absolute;
    left: 0;
    top: 0;
    background: white;
    color: var(--primary);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    border: 2px solid var(--primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 48px;
}

.back-btn:hover {
    transform: translateX(-5px);
    background: var(--primary);
    color: white;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.back-btn:active {
    transform: translateX(-3px) scale(0.98);
}

.brand h1 {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.brand-text {
    color: rgba(255,255,255,0.9);
    font-size: 0.9rem;
}

.game-container {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.controls {
    margin-bottom: 1.5rem;
}

.game-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    border-radius: 10px;
    font-weight: 600;
}

.level-display {
    color: var(--primary);
    font-size: 1.1rem;
}

.high-score {
    color: var(--secondary);
    font-size: 1.1rem;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.action-btn {
    padding: 0.75rem;
    border: 2px solid var(--primary);
    background: white;
    color: var(--primary);
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.action-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.hint-btn {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    border-color: #f59e0b;
}

.hint-btn:hover {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.new-game-btn {
    grid-column: span 2;
}

.difficulty-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.diff-btn {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--primary);
    background: white;
    color: var(--primary);
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.diff-btn:hover {
    transform: translateY(-2px);
}

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

.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.new-game-btn {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.new-game-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 5px 20px rgba(99, 102, 241, 0.4);
}

.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0;
    margin-bottom: 1.5rem;
    border: 3px solid var(--dark);
    border-radius: 10px;
    overflow: hidden;
}

.cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.cell:hover:not(.fixed) {
    background: #f1f5f9;
}

.cell.selected {
    background: #dbeafe !important;
    border-color: var(--primary);
}

.cell.fixed {
    background: #f8fafc;
    color: var(--dark);
    cursor: default;
}

.cell.error {
    background: #fee2e2;
    color: var(--error);
    animation: shake 0.3s;
}

.cell.hint-cell {
    background: #fef3c7;
    color: #f59e0b;
    animation: pulse 0.5s;
}

.cell:nth-child(3n):not(:nth-child(9n)) {
    border-right: 2px solid var(--dark);
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid var(--dark);
}

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

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

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

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

.erase-btn {
    grid-column: span 2;
    background: var(--error);
    color: white;
    border-color: var(--error);
}

.erase-btn:hover {
    background: #dc2626;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    animation: scaleIn 0.3s;
}

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

.win-time {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 1rem 0;
    color: var(--secondary);
}

.modal-btn {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@media (max-width: 600px) {
    .header {
        margin-bottom: 1.5rem;
    }
    
    .back-btn {
        position: relative;
        left: auto;
        top: auto;
        margin-bottom: 1rem;
        width: 100%;
        justify-content: center;
        padding: 1rem;
        font-size: 1.1rem;
    }
    
    .brand {
        text-align: center;
    }
    
    .brand h1 {
        font-size: 2rem;
    }
    
    .game-container {
        padding: 1rem;
    }
    
    .cell {
        font-size: 1.2rem;
    }
    
    .num-btn {
        padding: 0.75rem;
        font-size: 1rem;
    }
}
