/* 基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Hiragino Sans', 'Yu Gothic', Arial, sans-serif;
    background-color: #f0f0f0;
    overflow: hidden;
}

/* ゲームコンテナ：画面全体を使用 */
#gameContainer {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #333;
}

/* 上部：画像表示エリア（約2/3） */
#imageArea {
    flex: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #222;
    overflow: hidden;
}

#sceneImage {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease-in-out;
}

/* 下部：テキストボックスエリア（約1/3） */
#textArea {
    flex: 1;
    background-color: #1a1a1a;
    border-top: 2px solid #555;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 10px 60px 10px;
}

/* テキストボックス */
#textBox {
    flex: 1;
    background-color: #2a2a2a;
    border: 2px solid #555;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    overflow-y: auto;
    width: 100%;
    max-width: 800px;
}

#storyText {
    color: #fff;
    font-size: 16px;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* ボタンエリア */
#buttonArea {
    min-height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 800px;
    position: relative;
    z-index: 10;
}

.button-container {
    display: none;
    gap: 15px;
    width: 100%;
    justify-content: center;
    align-items: center;
}

/* ナビゲーションボタンコンテナのみ特別に配置 */
#navigationButtons.button-container {
    justify-content: space-between;
}

.button-container.active {
    display: flex;
}

/* ボタン共通スタイル */
button {
    background: linear-gradient(45deg, #4a90e2, #357abd);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

button:hover {
    background: linear-gradient(45deg, #357abd, #2c6ba0);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

button:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ナビゲーションボタン */
.nav-button {
    min-width: 80px;
}

/* ナビゲーションボタンの配置 */
#navigationButtons {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 戻るボタンを左に配置 */
#prevButton {
    margin-right: auto;
}

/* 次へボタンを右に配置 */
#nextButton {
    margin-left: auto;
}

/* ゲームボタン（スタート、最初から） */
.game-button {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    font-size: 18px;
    padding: 15px 30px;
}

.game-button:hover {
    background: linear-gradient(45deg, #c0392b, #a93226);
}

/* スタートボタンの特別な配置 */
#startButtonContainer {
    position: fixed;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    justify-content: center;
    align-items: center;
    display: none;
}

/* スタートボタンが確実に表示されるように */
#startButtonContainer.active {
    display: flex !important;
}

/* ゲーム開始後はスタートボタンを完全に非表示 */
#startButtonContainer.hidden {
    display: none !important;
}

/* スタート画面でのスタートボタン表示 */
#gameContainer.start-mode #startButtonContainer.active {
    display: flex !important;
}

/* スタート画面でのテキストエリア非表示対応 */
#gameContainer.start-mode #textArea {
    background: transparent;
    border: none;
}

#gameContainer.start-mode #textBox {
    display: none !important;
}

#gameContainer.start-mode #buttonArea {
    background: transparent;
}

/* 選択肢ボタン */
.choice-button {
    background: linear-gradient(45deg, #27ae60, #229954);
    margin: 5px;
    padding: 15px 20px;
    text-align: left;
    white-space: pre-wrap;
    flex: 1;
    min-width: 200px;
}

.choice-button:hover {
    background: linear-gradient(45deg, #229954, #1e8449);
}

/* レスポンシブデザイン：スマートフォン対応 */
@media screen and (max-width: 768px) {
    #textArea {
        padding: 8px 8px 80px 8px;
    }

    #textBox {
        padding: 10px;
        margin-bottom: 15px;
    }

    #storyText {
        font-size: 14px;
    }

    button {
        font-size: 14px;
        padding: 10px 16px;
    }

    .game-button {
        font-size: 16px;
        padding: 12px 24px;
    }

    .choice-button {
        padding: 12px 16px;
        font-size: 14px;
        min-width: 150px;
    }

    .button-container {
        flex-wrap: wrap;
        gap: 10px;
    }

    #buttonArea {
        min-height: 70px;
        position: fixed;
        bottom: 10px;
        left: 0;
        right: 0;
        z-index: 100;
        background-color: #1a1a1a;
        padding: 10px;
    }

    /* スマートフォンでのナビゲーションボタン */
    #navigationButtons {
        padding: 15px 10px !important;
        display: flex !important;
        justify-content: space-between !important;
        width: 100% !important;
        max-width: 100% !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    #navigationButtons.active {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .nav-button {
        min-width: 70px !important;
        font-size: 14px !important;
        padding: 10px 16px !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    #prevButton, #nextButton {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

@media screen and (max-width: 480px) {
    #textArea {
        padding: 6px 6px 90px 6px;
    }

    #textBox {
        padding: 8px;
        margin-bottom: 20px;
    }

    #storyText {
        font-size: 13px;
    }

    button {
        font-size: 13px;
        padding: 8px 12px;
    }

    .game-button {
        font-size: 15px;
        padding: 10px 20px;
    }

    .choice-button {
        padding: 10px 12px;
        font-size: 13px;
        min-width: 120px;
    }

    .button-container {
        gap: 8px;
    }

    #buttonArea {
        min-height: 80px;
        position: fixed;
        bottom: 5px;
        left: 0;
        right: 0;
        z-index: 100;
        background-color: #1a1a1a;
        padding: 15px 10px;
    }

    /* 小さいスマートフォンでのナビゲーションボタン */
    #navigationButtons {
        padding: 12px 8px !important;
        display: flex !important;
        justify-content: space-between !important;
        width: 100% !important;
        max-width: 100% !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    #navigationButtons.active {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .nav-button {
        min-width: 60px !important;
        font-size: 13px !important;
        padding: 8px 12px !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    #prevButton, #nextButton {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* 横向きスマートフォン対応 */
@media screen and (max-height: 480px) and (orientation: landscape) {
    #imageArea {
        flex: 3;
    }

    #textArea {
        flex: 2;
    }

    #textBox {
        padding: 8px;
    }

    #storyText {
        font-size: 12px;
        line-height: 1.4;
    }

    button {
        font-size: 12px;
        padding: 6px 10px;
    }

    .game-button {
        font-size: 14px;
        padding: 8px 16px;
    }

    .choice-button {
        padding: 8px 10px;
        font-size: 12px;
    }
}