:root {
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --container-bg: white;
    --container-shadow: rgba(0, 0, 0, 0.3);
    --text-primary: #333;
    --text-secondary: #666;
    --info-bg: #f5f5f5;
    --cell-bg: #e0e0e0;
    --cell-revealed: #f5f5f5;
    --cell-flagged: #ffd54f;
    --board-bg: #ddd;
    --button-primary: #667eea;
    --button-primary-shadow: rgba(102, 126, 234, 0.3);
    --diff-btn-border: #ddd;
    --diff-btn-bg: white;
    --diff-btn-text: #666;
}

[data-theme="dark"] {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --container-bg: #1e1e2e;
    --container-shadow: rgba(0, 0, 0, 0.5);
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --info-bg: #2a2a3e;
    --cell-bg: #3a3a4e;
    --cell-revealed: #2a2a3e;
    --cell-flagged: #8b6914;
    --board-bg: #2a2a3e;
    --button-primary: #667eea;
    --button-primary-shadow: rgba(102, 126, 234, 0.4);
    --diff-btn-border: #4a4a5e;
    --diff-btn-bg: #2a2a3e;
    --diff-btn-text: #b0b0b0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    touch-action: manipulation;
    transition: background 0.3s ease;
}

.container {
    background: var(--container-bg);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 60px var(--container-shadow);
    width: 100%;
    max-width: 500px;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

.header h1 {
    color: var(--text-primary);
    font-size: 32px;
    margin-bottom: 15px;
    font-weight: 700;
    transition: color 0.3s ease;
}

.game-info {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--info-bg);
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 15px;
    transition: background 0.3s ease;
    gap: 10px;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    transition: color 0.3s ease;
}

#bombs-count,
#timer {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
}

.theme-toggle {
    background: var(--button-primary);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 10px var(--button-primary-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:active {
    transform: scale(0.9);
    box-shadow: 0 2px 5px var(--button-primary-shadow);
}

.reset-btn {
    background: var(--button-primary);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 10px var(--button-primary-shadow);
}

.reset-btn:active {
    transform: scale(0.9);
    box-shadow: 0 2px 5px var(--button-primary-shadow);
}

.difficulty-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.diff-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--diff-btn-border);
    background: var(--diff-btn-bg);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--diff-btn-text);
    cursor: pointer;
    transition: all 0.3s;
}

.diff-btn.active {
    background: var(--button-primary);
    color: white;
    border-color: var(--button-primary);
}

.diff-btn:active {
    transform: scale(0.95);
}

.game-board {
    display: grid;
    gap: 2px;
    background: var(--board-bg);
    padding: 2px;
    border-radius: 10px;
    margin: 0 auto;
    max-width: 100%;
    overflow: hidden;
    transition: background 0.3s ease;
}

.cell {
    aspect-ratio: 1;
    background: var(--cell-bg);
    border: none;
    border-radius: 4px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    touch-action: manipulation;
    -webkit-touch-callout: none;
}

.cell:active {
    transform: scale(0.95);
}

.cell.revealed {
    background: var(--cell-revealed);
    cursor: default;
}

.cell.flagged {
    background: var(--cell-flagged);
}

.cell.mine {
    background: #f44336;
    color: white;
}

.cell.mine-revealed {
    background: #d32f2f;
    color: white;
}

.cell.number-1 { color: #1976d2; }
.cell.number-2 { color: #388e3c; }
.cell.number-3 { color: #d32f2f; }
.cell.number-4 { color: #7b1fa2; }
.cell.number-5 { color: #f57c00; }
.cell.number-6 { color: #0288d1; }
.cell.number-7 { color: #000000; }
.cell.number-8 { color: #616161; }

[data-theme="dark"] .cell.number-7 { color: #ffffff; }
[data-theme="dark"] .cell.number-8 { color: #cccccc; }

.game-status {
    margin-top: 20px;
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    min-height: 30px;
    padding: 10px;
    border-radius: 10px;
}

.game-status.win {
    background: #4caf50;
    color: white;
}

.game-status.lose {
    background: #f44336;
    color: white;
}

/* Адаптация для маленьких экранов - используем 100% ширины */
@media (max-width: 480px) {
    body {
        padding: 0;
        align-items: flex-start;
    }
    
    .container {
        max-width: 100%;
        width: 100%;
        border-radius: 0;
        min-height: 100vh;
        padding: 15px;
    }
    
    .header h1 {
        font-size: 24px;
    }
    
    #bombs-count,
    #timer {
        font-size: 20px;
    }
    
    .cell {
        font-size: 16px;
    }
}

/* Адаптация для очень маленьких экранов */
@media (max-width: 360px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 22px;
    }
    
    #bombs-count,
    #timer {
        font-size: 18px;
    }
    
    .cell {
        font-size: 14px;
    }
}

/* Оптимизация для больших экранов */
@media (min-width: 500px) {
    .container {
        padding: 30px;
    }
    
    .cell {
        font-size: 20px;
    }
}
