* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --container-bg: white;
    --text-primary: #333;
    --text-secondary: #666;
    --info-panel-bg: #f0f0f0;
    --board-bg: #ccc;
    --cell-bg: #ddd;
    --cell-revealed-bg: #fff;
    --cell-border: #fff;
    --cell-border-revealed: #bbb;
    --instructions-bg: #f8f9fa;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

body.dark-mode {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --container-bg: #0f3460;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --info-panel-bg: #1a2332;
    --board-bg: #2a3447;
    --cell-bg: #3d4e6a;
    --cell-revealed-bg: #2a3447;
    --cell-border: #4a5f84;
    --cell-border-revealed: #3d4e6a;
    --instructions-bg: #1a2332;
    --shadow-color: rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.3s ease;
}

.container {
    background: var(--container-bg);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 40px var(--shadow-color);
    max-width: 1200px;
    transition: background 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

h1 {
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 25px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    transition: color 0.3s ease;
}

.btn-theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: 2px solid var(--text-primary);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 1.3em;
    z-index: 10;
}

.btn-theme-toggle:hover {
    transform: rotate(15deg) scale(1.1);
    background: var(--info-panel-bg);
}

.theme-icon {
    transition: transform 0.3s ease;
    font-size: 1.3em;
}

body.dark-mode .theme-icon {
    display: none;
}

body.dark-mode .btn-theme-toggle::after {
    content: '☀️';
    font-size: 1.3em;
}

.game-header {
    margin-bottom: 20px;
}

.info-panel {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.info-item {
    background: var(--info-panel-bg);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 1.1em;
    transition: background 0.3s ease;
}

.label {
    color: var(--text-secondary);
    font-weight: 500;
    transition: color 0.3s ease;
}

.value {
    color: var(--text-primary);
    font-weight: bold;
    margin-left: 5px;
    transition: color 0.3s ease;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.difficulty-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-difficulty {
    padding: 10px 20px;
    font-size: 1em;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.btn-difficulty:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.btn-difficulty.active {
    background: #667eea;
    color: white;
}

.btn-difficulty-inline {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    padding: 0 5px;
    font-size: 1em;
}

.btn-difficulty-inline:hover:not(.active) {
    color: #667eea;
    transform: translateY(-1px);
}

.btn-difficulty-inline.active {
    color: var(--text-primary);
    font-weight: 500;
    border-bottom: none;
}

.btn-reset {
    padding: 12px 30px;
    font-size: 1.1em;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

.btn-reset:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(40, 167, 69, 0.4);
}

.btn-pause {
    padding: 6px 16px;
    font-size: 0.9em;
    background: #ffc107;
    color: #333;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    margin-left: 10px;
    box-shadow: 0 2px 6px rgba(255, 193, 7, 0.3);
}

.btn-pause:hover {
    background: #ffb300;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 193, 7, 0.4);
}

.btn-pause.paused {
    background: #28a745;
    color: white;
}

.btn-pause.paused:hover {
    background: #218838;
}

.btn-pause:disabled {
    background: #ccc;
    color: #666;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-pause:disabled:hover {
    transform: none;
}

.game-board {
    display: inline-grid;
    gap: 2px;
    background: var(--board-bg);
    padding: 5px;
    border-radius: 8px;
    margin: 20px auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: background 0.3s ease;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cell {
    width: 30px;
    height: 30px;
    background: var(--cell-bg);
    border: 2px outset var(--cell-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.1em;
    transition: all 0.2s;
    user-select: none;
}

.cell:hover:not(.revealed):not(.flagged) {
    background: #e8e8e8;
    transform: scale(1.05);
}

.cell.revealed {
    background: var(--cell-revealed-bg);
    border: 1px solid var(--cell-border-revealed);
    cursor: default;
}

.cell.flagged {
    background: #ffd700;
    border: 2px outset #ffed4e;
}

.cell.flagged::before {
    content: '🚩';
    font-size: 1.2em;
}

.cell.mine {
    background: #ff4444;
}

.cell.mine::before {
    content: '💣';
    font-size: 1.2em;
}

.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-status {
    text-align: center;
    font-size: 1.5em;
    font-weight: bold;
    margin: 20px 0;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-status.win {
    color: #28a745;
    animation: pulse 1s infinite;
}

.game-status.lose {
    color: #dc3545;
    animation: shake 0.5s;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.instructions {
    background: var(--instructions-bg);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    transition: background 0.3s ease;
}

.instructions h3 {
    color: var(--text-primary);
    margin-bottom: 10px;
    transition: color 0.3s ease;
}

.instructions ul {
    list-style-position: inside;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.instructions li {
    margin: 8px 0;
    font-size: 1em;
}

@media (max-width: 768px) {
    h1 {
        font-size: 2em;
    }
    
    .cell {
        width: 25px;
        height: 25px;
        font-size: 0.9em;
    }
    
    .container {
        padding: 15px;
    }
}
