/* 基本スタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans CJK JP', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    touch-action: manipulation;
    user-select: none;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    background: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

/* タイトル画像（メインコンテンツ内） */
.title-image {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
}

.main-title-img {
    max-width: 90%;
    max-height: 150px;
    width: auto;
    height: auto;
    object-fit: contain;
}


/* 画面管理 */
.screen {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.screen.hidden {
    display: none;
}

/* ゲーム開始画面 */
.start-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex: 1;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.start-content .img-btn {
    max-width: 80vw;
    margin: 0 auto;
}

/* モードボタンレイアウト */
.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    align-items: center;
}

.start-content p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 1rem;
    font-size: 1rem;
}

/* ボタンスタイル */
.start-btn, .control-btn, .modal-btn, .story-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 1rem;
    background: #4a90e2;
    color: white;
}

/* 画像ボタン用スタイル */
.img-btn {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
    flex-shrink: 1;
}

.btn-img {
    width: 100%;
    height: auto;
    max-width: 100%;
    display: block;
    object-fit: contain;
    transition: all 0.3s ease;
}

/* ゲーム開始ボタンの特別スタイル */
.game-start-btn {
    max-width: 90vw;
    max-height: 15vh;
    width: auto;
    height: auto;
}

.img-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.img-btn:active {
    transform: translateY(0) scale(0.98);
}

/* 従来のテキストボタンスタイル（フォールバック用） */
.start-btn:not(.img-btn) {
    background: #4a90e2;
    color: white;
}

.start-btn:not(.img-btn):hover {
    background: #357abd;
    transform: translateY(-2px);
}

.control-btn:not(.img-btn) {
    background: #6c757d;
    color: white;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

.control-btn:not(.img-btn):hover {
    background: #5a6268;
}


/* ゲームコントロール */
.game-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
    padding: 1rem;
    flex-wrap: wrap;
}

.game-controls .img-btn {
    max-width: 25vw;
    min-width: 80px;
    flex: 0 1 auto;
}

/* ゲームプレイエリア（ヒント+パズルの一体化ブロック） */
.game-play-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 80vw;
    max-height: 80vh;
    margin: 0 auto;
    padding: 0.5rem;
}

/* ヒント画像コンテナ */
.hint-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 0.3rem;
    padding: 0;
}

.hint-label {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.hint-image {
    width: 120px;
    height: 120px;
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hint-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.modal:not(.hidden) {
    opacity: 1;
}


.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    max-width: 90%;
    max-height: 80%;
    width: 100%;
    max-width: 400px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-content h2 {
    color: #4a90e2;
    margin: 0;
}

/* 完成画像表示 */
.completed-image {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    max-width: 90vw;
    max-height: 70vh;
    overflow: hidden;
    gap: 0.5rem;
}

/* タイトル画像とhajimariボタンを一つのブロックとして扱う */
.completed-image img:first-child {
    flex: 1;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 85%;
    object-fit: contain;
    border-radius: 8px;
}

.completed-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* はじまりボタンスタイル */
.hajimari-button {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    height: 15%;
}

.hajimari-img {
    width: auto;
    height: 100%;
    max-width: 30vw;
    object-fit: contain;
    border-radius: 8px;
    opacity: 0.9;
}



.modal-actions {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.modal-actions .img-btn {
    max-width: 25vw;
    min-width: 80px;
    flex: 0 1 auto;
}

.modal-btn:not(.img-btn) {
    background: #28a745;
    color: white;
}

.modal-btn:not(.img-btn):hover {
    background: #218838;
}

/* ローディング画面 */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e9ecef;
    border-top: 4px solid #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* レスポンシブデザイン追加 */
@media (max-width: 480px) {
    .btn-img {
        max-height: 35px;
    }
    
    .game-start-btn {
        max-height: 12vh;
    }
    
    .game-controls {
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .game-controls .img-btn {
        max-width: 35vw;
        min-width: 70px;
    }
    
    .modal-actions .img-btn {
        max-width: 35vw;
        min-width: 70px;
    }
    
    .start-content .img-btn {
        max-width: 90vw;
    }
    
    /* ゲームプレイエリアのモバイル調整 */
    .game-play-area {
        max-width: 95vw;
        max-height: 85vh;
        padding: 0.25rem;
    }
    
    .hint-image {
        width: 80px;
        height: 80px;
    }
    
    .hint-label {
        font-size: 0.7rem;
    }
    
    .hint-container {
        margin-bottom: 0.2rem;
    }
    
    /* はじまりボタンのモバイル調整 */
    .hajimari-img {
        max-width: 25vw;
    }
}

@media (max-width: 320px) {
    .game-controls .img-btn {
        max-width: 40vw;
        min-width: 60px;
    }
    
    .modal-actions .img-btn {
        max-width: 40vw;
        min-width: 60px;
    }
    
    /* ゲームプレイエリアの極小画面調整 */
    .game-play-area {
        max-width: 98vw;
        max-height: 90vh;
        padding: 0.1rem;
    }
    
    .hint-image {
        width: 60px;
        height: 60px;
    }
    
    .hint-container {
        margin-bottom: 0.15rem;
    }
    
    /* はじまりボタンの極小画面調整 */
    .hajimari-img {
        max-width: 20vw;
    }
}

/* ユーティリティクラス */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-1 { margin-bottom: 1rem; }
.mt-1 { margin-top: 1rem; }