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

body {
    font-family: 'Noto Sans JP', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* 画面管理 */
.screen {
    display: none;
    height: 100vh;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.screen.active {
    display: block;
}

/* メインメニュー */
.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: 2rem;
}

.game-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1.2;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    margin-top: 2rem;
}

.instruction-text {
    color: white;
    font-size: 1.1rem;
    text-align: center;
    opacity: 0.9;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.menu-btn {
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 500;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
    font-family: inherit;
}

.menu-btn.primary {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    box-shadow: 0 4px 15px rgba(238, 90, 82, 0.4);
}

.menu-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(238, 90, 82, 0.6);
}

.menu-btn.secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.menu-btn.secondary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.menu-btn:not(.primary):not(.secondary) {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.menu-btn:not(.primary):not(.secondary):hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* キャラクター選択画面 */
.character-select-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.character-select-container h2 {
    text-align: center;
    font-size: 2rem;
    color: #333;
    margin-bottom: 2rem;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
    max-width: 1200px;
    width: 100%;
}

.character-card {
    background: transparent;
    border-radius: 20px;
    padding: 0;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    aspect-ratio: 976/1280;
    max-width: 400px;
    margin: 0 auto;
}

.character-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
}

.character-card.active {
    border-color: #667eea;
    border-width: 4px;
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.4);
}

.character-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.menu-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* ゲーム画面 */
.game-wrapper {
    width: 100%;
    height: 100vh;
    margin: 0;
    background: transparent;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.game-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 0.5rem 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border-bottom: 3px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.header-info {
    display: flex;
    gap: 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    justify-content: center;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    margin: 0 1rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.info-text {
    font-weight: 500;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
}











.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}

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

.label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.counter {
    font-size: 1.5rem;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    background: #000;
    color: #ff0000;
    padding: 5px 15px;
    border-radius: 5px;
    min-width: 70px;
    text-align: center;
}

.reset-button {
    background: linear-gradient(135deg, #ffeaa7, #fab1a0);
    border: none;
    font-size: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.reset-button:hover {
    transform: scale(1.1);
}

.reset-button:active {
    transform: scale(0.95);
}

.reset-button.dead {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
}

.reset-button.win {
    background: linear-gradient(135deg, #00b894, #55a3ff);
}

.stage-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
}

.progress-bar {
    width: 200px;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00b894, #55a3ff);
    width: 33%;
    transition: width 0.5s ease;
}

/* ゲームメイン */
.game-main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.25rem 0;
    margin: 0;
    overflow: hidden;
    min-height: 0;
}

.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
}

.board-container {
    position: relative;
    width: min(95vw, 90vh * 976/1280);
    height: min(95vw * 1280/976, 90vh);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.character-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.character-background img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    filter: brightness(0.7);
}

.game-board {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(12, 1fr);
    gap: 0;
    z-index: 2;
    border: 2px solid rgba(255, 255, 255, 0.3);
    min-height: 0;
    min-width: 0;
}


.cell {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(24px, 5vw, 72px);
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    position: relative;
    z-index: 4;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 1);
    background-size: 800% 1200%;
    background-repeat: no-repeat;
    box-sizing: border-box;
}



.cell.close {
    position: relative;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}



.cell.close .cell-content {
    position: relative;
    z-index: 2;
}

.cell.open {
    cursor: default;
    font-weight: bold;
    color: #fff;
    font-size: clamp(28px, 6vw, 96px);
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 1), -2px -2px 4px rgba(0, 0, 0, 0.8), 0 0 8px rgba(0, 0, 0, 0.6);
    position: relative;
    box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.2);
}



.cell.revealed {
    cursor: default;
    color: #333;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
    font-weight: bold;
}

.cell.mine {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    animation: explosion 0.5s ease;
    box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.2);
}

.cell.mine::before {
    display: none;
}

@keyframes explosion {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.cell.flagged {
    background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
    color: #d63031;
    font-size: clamp(22px, 4.5vw, 56px);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.cell.number-1 { color: #ffffff; font-size: clamp(26px, 5.5vw, 80px); }
.cell.number-2 { color: #ffffff; font-size: clamp(26px, 5.5vw, 80px); }
.cell.number-3 { color: #ffffff; font-size: clamp(26px, 5.5vw, 80px); }
.cell.number-4 { color: #ffffff; font-size: clamp(26px, 5.5vw, 80px); }
.cell.number-5 { color: #ffffff; font-size: clamp(26px, 5.5vw, 80px); }
.cell.number-6 { color: #ffffff; font-size: clamp(26px, 5.5vw, 80px); }
.cell.number-7 { color: #ffffff; font-size: clamp(26px, 5.5vw, 80px); }
.cell.number-8 { color: #ffffff; font-size: clamp(26px, 5.5vw, 80px); }



/* 難易度選択 */
.difficulty-selection {
    text-align: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 15px;
    margin: 1rem;
}

.difficulty-selection h4 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.difficulty-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.difficulty-btn {
    padding: 12px 24px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    font-family: inherit;
}

.difficulty-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.difficulty-btn.active {
    background: #667eea;
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* ゲームメッセージ */
.game-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 15px;
    padding: 2rem;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: messageSlide 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1000;
    min-width: 300px;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.game-message.win {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border: 2px solid #28a745;
    color: #155724;
}

.game-message.lose {
    background: linear-gradient(135deg, #f8d7da, #f1c2c7);
    border: 2px solid #dc3545;
    color: #721c24;
}

.game-over-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.game-over-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.retry-btn {
    background: linear-gradient(135deg, #00b894, #55a3ff);
    color: white;
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 184, 148, 0.4);
}





.hidden {
    display: none;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
        margin-bottom: 2rem;
    }
    
    .menu-btn {
        min-width: 180px;
        padding: 12px 30px;
        font-size: 1rem;
    }
    
    .game-main {
        padding: 0.25rem;
    }
    
    .board-container {
        max-width: 95vw;
        max-height: 85vh;
    }
    
    .header-info {
        gap: 1rem;
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
        margin: 0 0.5rem;
    }
    
    .character-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .character-card {
        max-width: 350px;
    }
    
    .header-info {
        gap: 0.5rem;
        font-size: 0.8rem;
    }
    
    .game-header {
        padding: 0.75rem 0;
    }
    
    .header-info {
        gap: 1rem;
        font-size: 1rem;
        padding: 0.75rem 1rem;
        margin: 0 0.5rem;
    }
    
    /* モバイルでのフォントサイズ調整 */
    .cell {
        font-size: clamp(22px, 4.5vw, 56px);
    }
    
    .cell.open {
        font-size: clamp(24px, 5vw, 64px);
    }
    
    .cell.flagged {
        font-size: clamp(20px, 4vw, 44px);
    }
    
    .cell.number-1, .cell.number-2, .cell.number-3, .cell.number-4,
    .cell.number-5, .cell.number-6, .cell.number-7, .cell.number-8 {
        font-size: clamp(22px, 4.5vw, 56px);
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 1.5rem;
    }
    
    .board-container {
        max-width: 95vw;
        max-height: 80vh;
    }
    
    .header-info {
        gap: 0.5rem;
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
        margin: 0 0.3rem;
    }
    
    .info-text {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }
    
    /* 小さい画面でのフォントサイズ調整 */
    .cell {
        font-size: clamp(20px, 4vw, 48px);
    }
    
    .cell.open {
        font-size: clamp(22px, 4.5vw, 56px);
    }
    
    .cell.flagged {
        font-size: clamp(18px, 3.5vw, 36px);
    }
    
    .cell.number-1, .cell.number-2, .cell.number-3, .cell.number-4,
    .cell.number-5, .cell.number-6, .cell.number-7, .cell.number-8 {
        font-size: clamp(20px, 4vw, 48px);
    }
}

/* ステージクリア画面 */
.stage-clear-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.stage-clear-screen.hidden {
    display: none;
}

.stage-clear-container {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
}

.stage-clear-title {
    color: white;
    font-size: 2rem;
    margin-bottom: 1.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.stage-image-container {
    margin: 1.5rem 0;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

#stage-clear-image {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 15px;
}

.stage-clear-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.stage-btn {
    padding: 12px 24px;
    font-size: 1.1rem;
    font-weight: 500;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    min-width: 120px;
}



.next-btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    box-shadow: 0 4px 15px rgba(238, 90, 82, 0.4);
    display: block !important; /* 初期状態で表示（!importantで強制） */
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 1001 !important;
}

.next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(238, 90, 82, 0.6);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .stage-clear-container {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .stage-clear-title {
        font-size: 1.5rem;
    }
    
    .stage-clear-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .stage-btn {
        width: 100%;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .stage-clear-container {
        padding: 1rem;
        margin: 0.5rem;
    }
    
    .stage-clear-title {
        font-size: 1.3rem;
    }
}