* {
    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%);
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.container {
    background: white;
    width: 100vw;
    height: 100vh;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

header {
    text-align: center;
    margin-bottom: 8px;
    flex-shrink: 0;
}

h1 {
    color: #333;
    font-size: 1.8em;
    font-weight: 700;
    letter-spacing: 1px;
    margin: 0;
}

.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
}

.difficulty-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

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

.difficulty-btn {
    padding: 8px 16px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 14px;
}

.difficulty-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.difficulty-btn.active {
    background: #667eea;
    color: white;
}

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

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.stat-label {
    color: #666;
}

.stat-value {
    color: #333;
    font-size: 1.2em;
    min-width: 50px;
    text-align: right;
    font-family: 'Courier New', monospace;
}

.reset-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.reset-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

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

.reset-btn--hidden {
    display: none;
}

.game-board-wrapper {
    flex: 1 1 auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 0;
    width: 100%;
    overflow: hidden;
    padding: 0;
    touch-action: manipulation;
}

.game-board {
    display: inline-grid;
    gap: 2px;
    background: #ccc;
    padding: 2px;
    border-radius: 8px;
    margin: 0 auto;
    user-select: none;
    flex-shrink: 0;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
    border: 3px solid #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.cell {
    width: 35px;
    height: 35px;
    min-width: 0;
    min-height: 0;
    aspect-ratio: 1;
    background: #e0e0e0;
    border: 2px outset #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.1s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.cell:hover:not(.revealed):not(.flagged) {
    background: #d0d0d0;
}

.cell.revealed {
    background: #f5f5f5;
    border: 1px solid #ccc;
    border-style: inset;
    cursor: default;
}

.cell.flagged {
    background: #ffd700;
    color: #333;
}

.cell.mine {
    background: #ff4444;
}

.cell.mine.revealed {
    background: #ff0000;
}

.cell.number-1 { color: #0000ff; }
.cell.number-2 { color: #008000; }
.cell.number-3 { color: #ff0000; }
.cell.number-4 { color: #000080; }
.cell.number-5 { color: #800000; }
.cell.number-6 { color: #008080; }
.cell.number-7 { color: #000000; }
.cell.number-8 { color: #808080; }

.game-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.game-overlay[hidden] {
    display: none;
}

.game-modal {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.game-modal-title {
    margin: 0 0 12px;
    font-size: 1.75em;
    font-weight: 700;
    color: #333;
}

.game-modal-message {
    margin: 0 0 24px;
    font-size: 1.1em;
    color: #666;
    line-height: 1.4;
}

.game-modal-btn {
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    background: #667eea;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.game-modal-btn:hover {
    background: #5568d3;
}

.game-modal-btn:active {
    transform: scale(0.98);
}

.game-overlay.win .game-modal-title {
    color: #00aa00;
}

.game-overlay.lose .game-modal-title {
    color: #d32f2f;
}

@media (max-width: 600px) {
    h1 {
        font-size: 1.5em;
    }
    
    .game-controls {
        flex-direction: column;
        align-items: center;
        margin-bottom: 6px;
    }
    
    .difficulty-row {
        justify-content: center;
    }
    
    .difficulty-selector {
        justify-content: center;
    }
    
    .container {
        padding: 8px;
    }
    
    header {
        margin-bottom: 6px;
    }
    
}
