* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.game-container {
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    text-align: center;
}

h1 {
    color: #333;
    margin-bottom: 40px;
    font-size: 36px;
}

.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 10px;
}

.toggle-mode-btn {
    display: flex;
    align-items: center;
    border-radius: 15px;
    font-size: 20px;
    padding: 3px;
}

.toggle-btn-before, .toggle-btn-after{
    background-color: #c6ffad;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    width: 40px;
    height: 25px;
    border-radius: 10px;
}
.toggle-btn-after{background-color: #ffadad;}


#difficulty {
    padding: 10px;
    font-size: 24px;
    border: 2px solid #ddd;
    border-radius: 6px;
}

#reset-btn {
    padding: 10px 30px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 24px;
}

#reset-btn:hover {
    background-color: #45a049;
}

.game-info {
    display: flex;
    gap: 40px;
    font-size: 24px;
    font-weight: bold;
}

.mine-counter, .timer {
    background-color: #333;
    color: #ff0000;
    padding: 10px 20px;
    border-radius: 6px;
    min-width: 200px;
}

.game-grid {
    display: grid;
    gap: 2px;
    margin: 20px auto;
    border: 3px solid #999;
    background-color: #999;
    padding: 5px;
    border-radius: 5px;
}

.cell {
    width: 30px;
    height: 30px;
    background-color: #c0c0c0;
    border: 2px outset #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
}

.cell:hover {
    background-color: #d0d0d0;
}

.cell.revealed {
    background-color: #e0e0e0;
    border: 1px solid #999;
    cursor: default;
}

.cell.mine {
    background-color: #ff0000;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.cell.flagged {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23f00" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 22h16a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v14a2 2 0 0 1-2 2z"/><path d="M14 2v8"/><path d="M10 2v8"/><path d="M6 6v14"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.cell.one { color: #0000ff; }
.cell.two { color: #008000; }
.cell.three { color: #ff0000; }
.cell.four { color: #000080; }
.cell.five { color: #800000; }
.cell.six { color: #008080; }
.cell.seven { color: #000000; }
.cell.eight { color: #808080; }

.game-status {
    margin-top: 40px;
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #4CAF50;
    margin-bottom: 20px;
    font-size: 24px;
}

.modal-content p {
    font-size: 18px;
    margin-bottom: 30px;
    color: #333;
}

#close-modal {
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

#close-modal:hover {
    background-color: #45a049;
}

@media (max-width: 768px) {
    .cell {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }
    
    .game-controls {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
        padding: 15px;
        margin-bottom: 30px;
    }
    
    .game-info {
        justify-content: center;
    }
    
    .game-container {
        padding: 15px;
        width: 100%;
        max-width: 100%;
        margin: 0 10px;
    }
    
    .game-grid {
        max-width: 100%;
        overflow-x: auto;
        padding: 3px;
    }
    
    h1 {
        font-size: 28px;
        margin-bottom: 30px;
    }
    
    .game-info {
        gap: 20px;
        font-size: 20px;
    }
    
    .mine-counter, .timer {
        min-width: 120px;
        padding: 8px 15px;
    }
    
    #difficulty {
        font-size: 20px;
        padding: 8px;
    }
    
    #reset-btn {
        font-size: 20px;
        padding: 8px 25px;
    }
    
    .game-status {
        font-size: 20px;
        margin-top: 30px;
    }
}

@media (max-width: 480px) {
    .cell {
        width: 18px;
        height: 18px;
        font-size: 10px;
    }
    
    .game-container {
        padding: 10px;
    }
    
    .game-controls {
        margin-bottom: 20px;
        padding: 10px;
    }
    
    .mine-counter, .timer {
        min-width: 100px;
        padding: 6px 12px;
    }
    
    .game-status {
        font-size: 18px;
        margin-top: 20px;
    }
}