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

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

.container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 100%;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2em;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.stats {
    display: flex;
    gap: 30px;
    align-items: center;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1em;
    font-weight: bold;
    color: #333;
}

.difficulty-buttons {
    display: flex;
    gap: 10px;
}

.difficulty-buttons button,
#new-game-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    background: #667eea;
    color: white;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: bold;
    transition: all 0.3s ease;
}

.difficulty-buttons button:hover,
#new-game-btn:hover {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.difficulty-buttons button:active,
#new-game-btn:active {
    transform: translateY(0);
}

.game-board {
    display: grid;
    gap: 5px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 10px;
    aspect-ratio: 1 / 1;
}

.cell {
    background: #e0e0e0;
    border: 1px solid #bdbdbd;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: bold;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    padding: 0;
    color: #333;
}

.cell:hover:not(.revealed) {
    background: #f0f0f0;
    transform: scale(1.05);
}

.cell:active:not(.revealed) {
    transform: scale(0.95);
}

.cell.revealed {
    background: #fff;
    border-color: #999;
    color: #667eea;
    font-weight: bold;
}

.cell.revealed.empty {
    color: #999;
}

.cell.revealed.mine {
    background: #ff6b6b;
    color: white;
}

.cell.flagged {
    background: #ffd93d;
    color: #333;
    border-color: #ffc107;
}

.cell:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* 遊戲結束模態框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    animation: slideIn 0.3s ease;
}

.modal-content h2 {
    font-size: 1.8em;
    margin-bottom: 20px;
    color: #333;
}

.modal-content p {
    font-size: 1em;
    color: #666;
    margin-bottom: 30px;
    white-space: pre-line;
    line-height: 1.6;
}

.modal-content button {
    padding: 12px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.3s ease;
}

.modal-content button:hover {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

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

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

/* 響應式設計 */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 1.5em;
        margin-bottom: 20px;
    }
    
    .controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .stats {
        width: 100%;
        justify-content: center;
    }
    
    .difficulty-buttons {
        width: 100%;
        justify-content: center;
    }
    
    .difficulty-buttons button {
        flex: 1;
        min-width: 80px;
    }
    
    #new-game-btn {
        width: 100%;
    }
    
    .game-board {
        gap: 3px;
        padding: 10px;
    }
    
    .cell {
        font-size: 1em;
    }
}
