/* リセット・基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background-color: #000;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ゲームコンテナ - 画面全体を覆う */
#gameContainer {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
}

/* ゲームキャンバス - 9:16比率を維持 */
#gameCanvas {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: calc(100vh * 9 / 16);
    max-width: calc(100dvh * 9 / 16);
    max-height: calc(100vw * 16 / 9);
    aspect-ratio: 9 / 16;
    background-color: #1a1a2e;
    overflow: hidden;
}

/* 背景 */
#background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #2d3a4a;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* キャラクター */
#character {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

/* テキストウィンドウ */
#textWindow {
    position: absolute;
    bottom: 2%;
    left: 3%;
    width: 94%;
    height: 28%;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.85) 0%, rgba(20, 20, 40, 0.95) 100%);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 2%;
    padding: 4%;
    display: flex;
    align-items: flex-start;
}

#textContent {
    width: 100%;
    height: 100%;
    color: #fff;
    font-size: 4.5cqw;
    line-height: 1.8;
    overflow: hidden;
    word-wrap: break-word;
}

/* 選択肢コンテナ */
#choicesContainer {
    position: absolute;
    bottom: 32%;
    left: 10%;
    width: 80%;
    display: none;
    flex-direction: column;
    gap: 3%;
    z-index: 10;
}

#choicesContainer.active {
    display: flex;
}

/* 選択肢ボタン */
.choiceButton {
    width: 100%;
    padding: 4% 5%;
    background: linear-gradient(180deg, rgba(60, 60, 100, 0.95) 0%, rgba(40, 40, 70, 0.95) 100%);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    color: #fff;
    font-size: 4cqw;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: none;
}

.choiceButton.active {
    display: block;
}

.choiceButton:active {
    background: linear-gradient(180deg, rgba(100, 100, 160, 0.95) 0%, rgba(70, 70, 120, 0.95) 100%);
    transform: scale(0.98);
}

/* タップ領域 */
#tapArea {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 70%;
    cursor: pointer;
    z-index: 1;
}

/* Container Query対応 */
@supports (container-type: inline-size) {
    #gameCanvas {
        container-type: inline-size;
    }
}

/* Container Query非対応のフォールバック */
@supports not (container-type: inline-size) {
    #textContent {
        font-size: calc(min(100vw, 56.25vh) * 0.045);
    }

    .choiceButton {
        font-size: calc(min(100vw, 56.25vh) * 0.04);
    }
}
