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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.header {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.header h1 {
    color: #4a5568;
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-info {
    display: flex;
    gap: 30px;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 600;
}

.timer {
    background: #667eea;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.difficulty select {
    padding: 8px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    background: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.difficulty select:hover {
    border-color: #667eea;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 30px;
    flex: 1;
    align-items: start;
}

.game-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-self: center;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #4a5568;
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
    background: white;
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-1px);
}

.sudoku-board {
    display: flex;
    justify-content: center;
    align-items: center;
}

.grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0;
    background: white;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    position: relative;
}

.grid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 3px solid #333;
    border-radius: 15px;
    pointer-events: none;
}

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

.cell:hover {
    background: #aabae5;
}

.cell.selected {
    background: #7c3aed !important;
    color: white !important;
    transform: scale(1.05);
    border: 2px solid #6081da !important;
    z-index: 20;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.cell.given {
    background: #f8f9fa;
    color: #333;
    font-weight: 700;
    cursor: default;
}

.cell.given:hover {
    transform: none;
    background: #f8f9fa;
}

.cell.given.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.cell.given.clickable:hover {
    background: #e2e8f0;
    transform: scale(1.05);
}

.cell.highlight-row {
    background: #e6f3ff !important;
}

.cell.highlight-col {
    background: #e6f3ff !important;
}

.cell.highlight-box {
    background: #e6f3ff !important;
}

.cell.highlight-row.col-highlight {
    background: #e6f3ff !important;
}

.cell.highlight-col.row-highlight {
    background: #e6f3ff !important;
}

.cell.highlight-box.row-highlight.col-highlight {
    background: #e6f3ff !important;
}

.cell.same-number {
    background: #73a3ea !important;
    border: 2px solid #73a3ea;
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(192, 132, 252, 0.4);
}

.cell.completed {
    background: #d4edda !important;
    border-color: #28a745 !important;
    color: #155724 !important;
    font-weight: 700;
}

.cell.completed.given {
    background: #d4edda !important;
}

.cell.error {
    background: #fed7d7;
    color: #c53030;
}

.cell.hint {
    background: #fef5e7;
    color: #d69e2e;
    animation: hint-pulse 1s ease-in-out;
}

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

.cell.conflict {
    background: #fed7d7;
    animation: conflict-shake 0.5s ease-in-out;
}

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

/* 3x3 区块边界 */
.cell:nth-child(3n) {
    border-right: 3px solid #333;
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 3px solid #333;
}

.number-pad {
    display: flex;
    align-items: center;
    justify-content: center;
}

.number-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    align-items: center;
}

.number-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 220px;
}

.number-btn {
    width: 60px;
    height: 60px;
    border: 2px solid #e2e8f0;
    border-radius: 15px;
    background: white;
    font-size: 1.4rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.number-btn:hover {
    border-color: #667eea;
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.number-btn:active {
    transform: translateY(0);
}

.number-btn.completed {
    background: #d4edda !important;
    border-color: #28a745 !important;
    color: #155724 !important;
}

.number-btn.completed:hover {
    background: #c3e6cb !important;
    border-color: #1e7e34 !important;
    color: #0f3917 !important;
    transform: none;
}

.number-btn:disabled {
    background: #f8f9fa !important;
    border-color: #dee2e6 !important;
    color: #6c757d !important;
    cursor: not-allowed;
    opacity: 0.6;
}

.number-btn:disabled:hover {
    transform: none;
    box-shadow: none;
    background: #f8f9fa !important;
    border-color: #dee2e6 !important;
    color: #6c757d !important;
}

.clear-btn {
    width: 100%;
    max-width: 220px;
    background: #fed7d7;
    color: #c53030;
    border-color: #feb2b2;
}

.clear-btn:hover {
    background: #fc8181;
    color: white;
    border-color: #fc8181;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    margin: 15% auto;
    padding: 40px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modal-appear 0.3s ease-out;
}

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

.modal-content h2 {
    color: #4a5568;
    font-size: 2rem;
    margin-bottom: 20px;
}

.modal-content p {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #666;
}

.footer {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    margin-top: 30px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .game-info {
        gap: 20px;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .game-controls {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .cell {
        width: 35px;
        height: 35px;
        font-size: 1.2rem;
    }
    
    .grid {
        padding: 15px;
    }
    
    .number-buttons {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
        padding: 15px;
    }
    
    .number-btn {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }
    
    .number-grid {
        max-width: 150px;
    }
    
    .clear-btn {
        max-width: 150px;
    }
}

@media (max-width: 480px) {
    .cell {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }
    
    .number-btn {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
}