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

body {
    font-family: 'Yu Gothic', 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    height: -webkit-fill-available;
    position: relative;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 0;
    background-color: #000;
}

/* コンテナ（縦位置固定） */
#app-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 100vh;
    overflow: hidden;
}

/* 背景画像 */
.background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center 20%;
    background-color: #000;
    z-index: 1;
}

/* フェード用オーバーレイ */
.fade-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 10;
    pointer-events: none;
    opacity: 1;
    transition: opacity 2s ease-in-out;
}

.fade-overlay.fade-out {
    opacity: 0;
}

.fade-overlay.fade-in {
    opacity: 1;
}

/* テキストウィンドウ */
.text-window {
    position: absolute;
    bottom: env(safe-area-inset-bottom, 0);
    left: 0;
    width: 100%;
    height: 30%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 15;
    padding: 20px 40px;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    /* center → flex-start（上寄せ） */
    gap: 20px;
    opacity: 0;
    pointer-events: none;
}

/* セリフがある状態 */
.text-window.active {
    opacity: 1;
    pointer-events: auto;
}

/* セリフがない状態（kkj.jpg表示中など） */
.text-window.empty {
    opacity: 0;
    pointer-events: none;
}

.text-window.empty .face-icon,
.text-window.empty .name-display,
.text-window.empty .text-content {
    display: none;
}

/* 顔アイコン */
.face-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

/* テキストエリア */
.text-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* 名前表示 */
.name-display {
    display: none;
}

/* テキスト内容 */
.text-content {
    font-size: 18px;
    line-height: 1.8;
    color: #ffffff;
    padding-top: 10px;
}

/* 進行可能マーク */
.continue-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    color: #ffffff;
    opacity: 0;
    pointer-events: none;
}

.continue-icon.show {
    opacity: 1;
    animation: blink 1s ease-in-out infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

/* タイトル画面 */
.title-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 40vh;
    z-index: 20;
    opacity: 1;
    transition: opacity 1s ease-in-out;
}

.title-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.title-text {
    color: #fff;
    font-size: 48px;
    font-weight: 300;
    letter-spacing: 4px;
    text-align: center;
}

/* 常時表示クローズボタン */
.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 30;
    font-size: 32px;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: color 0.2s ease;
    line-height: 1;
    user-select: none;
}

.close-btn:hover {
    color: #fff;
}

/* エンド画面 */
.replay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 40vh;
    z-index: 15;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease-in-out;
}

.replay-screen.show {
    opacity: 1;
    pointer-events: auto;
}

.replay-button {
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: opacity 0.2s ease;
}

.replay-button:hover {
    opacity: 0.7;
}

/* グローバルミュートボタン */
.mute-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    background: transparent;
    border: none;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.mute-btn svg {
    fill: rgba(255, 255, 255, 0.5);
    width: 28px;
    height: 28px;
    transition: fill 0.2s ease, transform 0.3s ease;
    display: block;
}

.mute-btn:hover svg {
    fill: #ffffff;
}

/* レスポンシブ対応 */

/* モバイル */
@media (max-width: 768px) {
    body {
        align-items: flex-start;
        padding-top: 10vh;
    }

    #app-container {
        height: 90vh;
    }

    .title-screen {
        padding-top: 30vh;
    }

    .text-window {
        height: 35%;
        padding: 15px 20px;
        padding-bottom: max(15px, env(safe-area-inset-bottom, 15px));
        gap: 15px;
    }

    .face-icon {
        width: 70px;
        height: 70px;
        border-width: 2px;
    }

    .name-display {
        font-size: 16px;
    }

    .text-content {
        font-size: 14px;
    }

    .continue-icon {
        font-size: 20px;
        right: 15px;
    }

    .title-text {
        font-size: 36px;
    }

    .replay-button {
        font-size: 20px;
    }
}