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

body {
    background: #c0c0c0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: manipulation;
}

.game-wrapper {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    padding-bottom: 30px;
}

.game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.game-title {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 2px;
}

.back-btn {
    background: linear-gradient(145deg, #505050, #3a3a3a);
    border: 1px solid #2a2a2a;
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.back-btn:active {
    transform: scale(0.95);
    background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
}

.game-info-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: #c0c0c0;
    border-radius: 8px;
    border: 2px solid #808080;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.info-label {
    font-size: 12px;
    color: #808080;
}

.info-value {
    font-size: 18px;
    font-weight: 700;
    color: #000;
    margin-top: 4px;
}

.difficulty-wrapper {
    position: relative;
}

.difficulty-btn {
    padding: 5px 15px;
    background: linear-gradient(145deg, #e0e0e0, #c0c0c0);
    border: 2px solid #808080;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    min-width: 60px;
    text-align: center;
}

.difficulty-btn:active {
    background: linear-gradient(145deg, #d0d0d0, #b0b0b0);
}

.difficulty-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 2px solid #808080;
    border-radius: 4px;
    z-index: 10;
    min-width: 80px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.difficulty-dropdown.show {
    display: block;
}

.difficulty-option {
    padding: 8px 15px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.difficulty-option:hover {
    background: #0078d4;
    color: #fff;
}

.difficulty-option:first-child {
    border-radius: 2px 2px 0 0;
}

.difficulty-option:last-child {
    border-radius: 0 0 2px 2px;
}

.game-area {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    overflow: auto;
    max-width: 100%;
    flex: 1;
    min-height: 0;
}

.minefield {
    display: grid;
    background: #c0c0c0;
    border: 3px solid #808080;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.cell {
    width: 100%;
    height: 100%;
    min-width: 20px;
    min-height: 20px;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #808080 #808080 #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    box-shadow: inset 1px 1px 0 #dfdfdf, inset -1px -1px 0 #0a0a0a;
}

.cell:active {
    border-color: #808080;
}

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

.cell.revealed {
    background: #d0d0d0;
    border-width: 1px;
    border-color: #808080;
    cursor: default;
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.cell.mine {
    background: #ff0000;
}

.mine-graphic {
    width: 16px;
    height: 16px;
    background: radial-gradient(circle at 35% 35%, #4a4a4a, #1a1a1a);
    border-radius: 50%;
    position: relative;
    box-shadow: 
        inset -2px -2px 4px rgba(0, 0, 0, 0.5),
        inset 2px 2px 4px rgba(100, 100, 100, 0.3);
}

.mine-graphic::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: 
        linear-gradient(0deg, transparent 45%, #1a1a1a 45%, #1a1a1a 55%, transparent 55%),
        linear-gradient(90deg, transparent 45%, #1a1a1a 45%, #1a1a1a 55%, transparent 55%),
        linear-gradient(45deg, transparent 45%, #1a1a1a 45%, #1a1a1a 55%, transparent 55%),
        linear-gradient(-45deg, transparent 45%, #1a1a1a 45%, #1a1a1a 55%, transparent 55%);
}

.mine-graphic::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 3px;
    width: 4px;
    height: 3px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
}

.cell.flagged {
    background: #c0c0c0;
}

.cell.flagged::before {
    content: '';
    position: absolute;
    width: 2px;
    height: 14px;
    background: linear-gradient(180deg, #5d4037, #3e2723);
    left: 50%;
    transform: translateX(-50%);
    top: 50%;
    margin-top: -7px;
    border-radius: 1px;
}

.cell.flagged::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 7px;
    background: linear-gradient(135deg, #ff5252, #d32f2f);
    left: 50%;
    top: 50%;
    margin-top: -7px;
    margin-left: -1px;
    clip-path: polygon(0 0, 100% 25%, 100% 75%, 0 100%);
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.cell.question {
    background: #c0c0c0;
}

.cell.question::after {
    content: '?';
    font-size: 14px;
    font-weight: 700;
    color: #000;
}

.cell[data-count="1"] { color: #0000ff; font-size: 18px; font-weight: 800; }
.cell[data-count="2"] { color: #008000; font-size: 18px; font-weight: 800; }
.cell[data-count="3"] { color: #ff0000; font-size: 18px; font-weight: 800; }
.cell[data-count="4"] { color: #000080; font-size: 18px; font-weight: 800; }
.cell[data-count="5"] { color: #800000; font-size: 18px; font-weight: 800; }
.cell[data-count="6"] { color: #008080; font-size: 18px; font-weight: 800; }
.cell[data-count="7"] { color: #000000; font-size: 18px; font-weight: 800; }
.cell[data-count="8"] { color: #808080; font-size: 18px; font-weight: 800; }

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.mode-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.toggle-track {
    width: 50px;
    height: 26px;
    background: linear-gradient(145deg, #a0a0a0, #808080);
    border: 2px solid #606060;
    border-radius: 13px;
    position: relative;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-slider {
    width: 20px;
    height: 20px;
    background: linear-gradient(145deg, #e0e0e0, #c0c0c0);
    border: 2px solid #808080;
    border-radius: 50%;
    position: absolute;
    top: 1px;
    left: 2px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-slider.flag-mode {
    left: calc(100% - 22px);
    background: linear-gradient(145deg, #ff6b6b, #ee5a5a);
    border-color: #cc4444;
}

.toggle-label {
    font-size: 12px;
    font-weight: 600;
    color: #808080;
    min-width: 30px;
    transition: color 0.3s ease;
}

.toggle-label.active {
    color: #000;
}

.control-btn {
    background: linear-gradient(145deg, #e0e0e0, #c0c0c0);
    border: 2px solid #808080;
    color: #000;
    padding: 10px 25px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.control-btn:active {
    transform: scale(0.95);
    background: linear-gradient(145deg, #d0d0d0, #c0c0c0);
}

.game-over-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.game-over-overlay.show {
    display: flex;
}

.game-over-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 25px 35px;
    background: #c0c0c0;
    border-radius: 8px;
    border: 2px solid #808080;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.game-over-title {
    font-size: 24px;
    font-weight: 700;
    color: #000;
}

.game-over-buttons {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.back-to-start-btn {
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: #000;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-to-start-btn:active {
    transform: scale(0.95);
    background: rgba(0, 0, 0, 0.15);
}

.retry-btn {
    background: linear-gradient(145deg, #0078d4, #00a000);
    border: none;
    color: #fff;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 120, 212, 0.3);
    transition: all 0.2s ease;
}

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