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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
}

h1 {
    color: #333;
    margin-bottom: 20px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.difficulty-buttons {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.difficulty-btn {
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: #667eea;
    color: white;
    transition: all 0.3s ease;
    font-weight: bold;
}

.difficulty-btn:hover {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.difficulty-btn.active {
    background: #764ba2;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.game-info {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
}

.info-box {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    padding: 10px 20px;
    background: #f0f0f0;
    border-radius: 10px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-label {
    font-size: 18px;
    color: #666;
}

.info-value {
    font-size: 24px;
    color: #333;
    min-width: 60px;
    text-align: center;
}

.mine-counter .info-value {
    transition: all 0.3s ease;
}

.mine-counter.warning .info-value {
    color: #ff9800;
    font-weight: bold;
    transform: scale(1.1);
}

.mine-counter.danger .info-value {
    color: #f44336;
    font-weight: bold;
    transform: scale(1.2);
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0) scale(1.2); }
    25% { transform: translateX(-5px) scale(1.2); }
    75% { transform: translateX(5px) scale(1.2); }
}

.grid-container {
    display: inline-block;
    background: #ddd;
    padding: 10px;
    border-radius: 10px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}

.grid {
    display: grid;
    gap: 2px;
    background: #999;
}

.cell {
    width: 30px;
    height: 30px;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #808080 #808080 #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    transition: all 0.1s ease;
    user-select: none;
    position: relative;
}

.cell.focused {
    outline: 3px solid #667eea;
    outline-offset: -3px;
    z-index: 10;
}

.cell:hover:not(.opened):not(.game-over) {
    background: #d0d0d0;
    transform: scale(1.05);
}

.cell:active:not(.opened) {
    border-color: #808080 #fff #fff #808080;
    transform: scale(0.95);
}

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

.cell.mine {
    background: #ff4444;
    color: #000;
}

.cell.flag {
    background: #ffd700;
    position: relative;
    animation: flagPlant 0.3s ease;
}

.cell.flag::after {
    content: '🚩';
    font-size: 20px;
}

@keyframes flagPlant {
    0% { transform: scale(0) rotate(0deg); }
    50% { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* 数字の色分け */
.cell.num-1 { color: #0000ff; }
.cell.num-2 { color: #008000; }
.cell.num-3 { color: #ff0000; }
.cell.num-4 { color: #000080; }
.cell.num-5 { color: #800000; }
.cell.num-6 { color: #008080; }
.cell.num-7 { color: #000000; }
.cell.num-8 { color: #808080; }

.game-btn {
    margin-top: 20px;
    padding: 15px 30px;
    font-size: 18px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.game-btn:active {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

@keyframes explode {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); background: #ff6666; }
    100% { transform: scale(1); }
}

.cell.exploded {
    animation: explode 0.5s ease;
}

.message {
    margin-top: 20px;
    font-size: 24px;
    font-weight: bold;
    height: 30px;
}

.message.win {
    color: #4CAF50;
    animation: pulse 1s infinite;
}

.message.lose {
    color: #f44336;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.stats-container {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.stats-container h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-item {
    background: #f8f8f8;
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.stat-label {
    display: block;
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 20px;
    font-weight: bold;
    color: #333;
}

.reset-stats-btn {
    padding: 8px 16px;
    font-size: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: #e0e0e0;
    color: #333;
    transition: all 0.3s ease;
}

.reset-stats-btn:hover {
    background: #d0d0d0;
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .game-container {
        padding: 20px;
        width: 95%;
        max-width: 100%;
    }
    
    .settings-row {
        flex-direction: column;
        gap: 15px;
    }
    
    h1 {
        font-size: 2em;
    }
    
    .difficulty-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .difficulty-btn {
        width: 100%;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .info-box {
        width: 100%;
        justify-content: center;
    }
    
    .cell {
        width: 25px;
        height: 25px;
        font-size: 14px;
    }
    
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

.settings-row {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.sound-toggle label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 16px;
    color: var(--info-text, #666);
}

.sound-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.theme-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    color: var(--info-text, #666);
}

.theme-selector select {
    padding: 6px 12px;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: var(--info-bg, #f0f0f0);
    color: var(--text-color, #333);
    cursor: pointer;
}

.keyboard-help {
    margin-top: 15px;
    text-align: center;
}

.help-btn {
    padding: 8px 16px;
    font-size: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: var(--info-bg, #e0e0e0);
    color: var(--text-color, #333);
    transition: all 0.3s ease;
}

.help-btn:hover {
    background: var(--cell-hover, #d0d0d0);
    transform: translateY(-1px);
}

/* モーダルスタイル */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--container-bg, #fff);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    position: relative;
    animation: slideIn 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: var(--info-text, #666);
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-close:hover {
    color: var(--text-color, #333);
    transform: scale(1.2);
}

.modal h2 {
    margin-bottom: 20px;
    text-align: center;
    color: var(--text-color, #333);
}

.help-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.help-section h3 {
    margin-bottom: 10px;
    color: var(--text-color, #333);
    font-size: 1.2em;
}

.key-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.key {
    display: inline-block;
    padding: 6px 12px;
    background: var(--info-bg, #f0f0f0);
    border: 2px solid var(--cell-border-dark, #ccc);
    border-radius: 6px;
    font-family: monospace;
    font-weight: bold;
    font-size: 14px;
    color: var(--text-color, #333);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 35px;
    text-align: center;
}

.key.wide {
    min-width: 60px;
}

.key-desc {
    color: var(--info-text, #666);
    font-size: 16px;
    margin-left: 10px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}