/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #333;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    padding: 30px;
    max-width: 800px;
    width: 100%;
    animation: slideIn 0.8s ease-out;
}

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

/* Header styles */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(102, 126, 234, 0.1);
    padding: 10px 15px;
    border-radius: 12px;
    font-weight: 500;
}

.stat-icon {
    font-size: 1.2rem;
}

.stat-value {
    font-weight: 700;
    color: #667eea;
    min-width: 30px;
    text-align: center;
}

/* Difficulty selector */
.difficulty-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    overflow: hidden;
}

.difficulty-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    border-radius: 8px;
    margin: 4px;
}

.difficulty-btn:hover {
    background: rgba(102, 126, 234, 0.1);
}

.difficulty-btn.active {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* Restart button */
.restart-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.restart-icon {
    font-size: 1.1rem;
    animation: rotate 2s linear infinite paused;
}

.restart-btn:hover .restart-icon {
    animation-play-state: running;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Game area */
.game-area {
    text-align: center;
}

.game-status {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.game-status.playing {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.game-status.won {
    background: rgba(46, 204, 113, 0.1);
    color: #27ae60;
}

.game-status.lost {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

/* Game board */
.game-board {
    display: grid;
    gap: 2px;
    background: #ddd;
    padding: 10px;
    border-radius: 12px;
    margin: 0 auto;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.1);
}

.game-board.easy {
    grid-template-columns: repeat(9, 1fr);
    max-width: 400px;
}

.game-board.medium {
    grid-template-columns: repeat(16, 1fr);
    max-width: 600px;
}

.game-board.hard {
    grid-template-columns: repeat(30, 1fr);
    max-width: 800px;
}

/* Game cells */
.cell {
    width: 100%;
    aspect-ratio: 1;
    border: none;
    background: linear-gradient(145deg, #f0f0f0, #e6e6e6);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cell:hover:not(.revealed):not(.flagged) {
    background: linear-gradient(145deg, #e8e8e8, #d4d4d4);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.cell.revealed {
    background: #fff;
    cursor: default;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cell.flagged {
    background: linear-gradient(145deg, #ff6b6b, #ee5a24);
    color: white;
    animation: pulse 1s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

.cell.mine {
    background: linear-gradient(145deg, #e74c3c, #c0392b);
    color: white;
    animation: explode 0.5s ease-out;
}

@keyframes explode {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Number colors */
.cell.number-1 { color: #2980b9; }
.cell.number-2 { color: #27ae60; }
.cell.number-3 { color: #e74c3c; }
.cell.number-4 { color: #8e44ad; }
.cell.number-5 { color: #d35400; }
.cell.number-6 { color: #16a085; }
.cell.number-7 { color: #2c3e50; }
.cell.number-8 { color: #7f8c8d; }

/* Footer */
.footer {
    margin-top: 30px;
    text-align: center;
}

.instructions {
    background: rgba(102, 126, 234, 0.05);
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid #667eea;
}

.instructions p {
    margin: 5px 0;
    line-height: 1.5;
}

.instructions strong {
    color: #667eea;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

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

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.4s ease-out;
}

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

.modal-title {
    font-size: 2rem;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-message {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: #666;
}

.modal-stats {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
    padding: 15px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 12px;
}

.modal-stat {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.modal-stat span:first-child {
    font-size: 0.9rem;
    color: #666;
}

.modal-stat span:last-child {
    font-weight: 700;
    color: #667eea;
}

.modal-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.modal-btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.modal-btn.primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

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

.modal-btn.secondary {
    background: rgba(0, 0, 0, 0.05);
    color: #666;
}

.modal-btn.secondary:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    
    .title {
        font-size: 2rem;
    }
    
    .controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .stats {
        order: 2;
    }
    
    .difficulty-selector {
        order: 1;
    }
    
    .restart-btn {
        order: 3;
    }
    
    .game-board.medium {
        grid-template-columns: repeat(12, 1fr);
        max-width: 400px;
    }
    
    .game-board.hard {
        grid-template-columns: repeat(16, 1fr);
        max-width: 500px;
    }
    
    .cell {
        font-size: 0.8rem;
    }
}
