* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    overflow-x: hidden;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 100%;
}

h1 {
    text-align: center;
    color: #1a1a2e;
    margin-bottom: 15px;
    font-size: 1.8rem;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.difficulty-select {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.diff-btn, .action-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
}

.diff-btn {
    background: #e0e0e0;
    color: #333;
}

.diff-btn.active {
    background: #4CAF50;
    color: white;
    transform: scale(1.05);
}

.action-btn {
    background: #2196F3;
    color: white;
    width: 100%;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

#flagModeBtn {
    background: #FF9800;
}

#flagModeBtn.active {
    background: #f44336;
    animation: pulse 1s infinite;
}

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

.reset-btn {
    background: #9C27B0;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    padding: 10px 20px;
    background: #f0f0f0;
    border-radius: 10px;
    margin-bottom: 15px;
}

.status-item {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
    display: flex;
    align-items: center;
    gap: 5px;
}

.board {
    display: grid;
    gap: 2px;
    background: #bdbdbd;
    padding: 5px;
    border-radius: 10px;
    margin: 0 auto;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.cell {
    width: 36px;
    height: 36px;
    background: linear-gradient(145deg, #e0e0e0, #c0c0c0);
    border: none;
    border-radius: 4px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    box-shadow: inset -2px -2px 4px rgba(0,0,0,0.2), inset 2px 2px 4px rgba(255,255,255,0.7);
}

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

.cell.revealed {
    background: #f5f5f5;
    box-shadow: none;
    border: 1px solid #ddd;
}

.cell.mine {
    background: #ff5252;
}

.cell.flagged {
    color: #f44336;
}

.cell[data-number="1"] { color: #2196F3; }
.cell[data-number="2"] { color: #4CAF50; }
.cell[data-number="3"] { color: #f44336; }
.cell[data-number="4"] { color: #9C27B0; }
.cell[data-number="5"] { color: #FF9800; }
.cell[data-number="6"] { color: #00BCD4; }
.cell[data-number="7"] { color: #333; }
.cell[data-number="8"] { color: #888; }

.message {
    text-align: center;
    padding: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    min-height: 50px;
}

.message.win {
    color: #4CAF50;
}

.message.lose {
    color: #f44336;
}

@media (max-width: 400px) {
    .cell {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .diff-btn, .action-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}