/* ==========================================
   壁の証言 - 全画面テキストスタイル
   サウンドノベル風（弟切草スタイル）
   ========================================== */

/* フォント読み込み */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;500;600;700&display=swap');

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

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh; /* モバイルの動的ビューポート対応 */
    height: calc(var(--vh, 1vh) * 100); /* JS fallback */
    overflow: hidden;
    font-family: 'Noto Serif JP', 'Yu Mincho', 'Hiragino Mincho ProN', serif;
    background: #000;
    color: #e0e0e0;
    -webkit-tap-highlight-color: transparent; /* タップハイライト無効化 */
    -webkit-touch-callout: none; /* 長押しメニュー無効化 */
    touch-action: manipulation; /* ダブルタップズーム無効化 */
    user-select: none; /* テキスト選択無効化 */
    -webkit-user-select: none;
}

/* 画面コンテナ */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.screen.active {
    display: flex;
}

.screen.overlay {
    background: rgba(0, 0, 0, 0.95);
    z-index: 100;
}

/* ==========================================
   タイトル画面
   ========================================== */

#title-screen {
    background: linear-gradient(180deg, #0a0a0f 0%, #1a1a2e 50%, #0a0a0f 100%);
    position: relative;
}

/* パーティクル背景 */
#title-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.4), transparent),
        radial-gradient(2px 2px at 130px 80px, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 160px 120px, rgba(255,255,255,0.3), transparent);
    background-size: 200px 200px;
    animation: particleFloat 20s linear infinite;
    pointer-events: none;
}

@keyframes particleFloat {
    0% { transform: translateY(0); }
    100% { transform: translateY(-200px); }
}

.title-content {
    text-align: center;
    z-index: 1;
}

.series-label {
    font-size: clamp(0.7rem, 2vw, 0.95rem);
    font-weight: 400;
    letter-spacing: 0.25em;
    color: rgba(200, 180, 140, 0.7);
    margin-bottom: 1rem;
    text-transform: uppercase;
    font-family: 'Noto Sans JP', sans-serif;
}

.game-title {
    font-size: clamp(2.5rem, 8vw, 5rem);
    font-weight: 700;
    letter-spacing: 0.3em;
    margin-bottom: 1rem;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
    animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% { text-shadow: 0 0 30px rgba(255, 255, 255, 0.3); }
    50% { text-shadow: 0 0 50px rgba(255, 255, 255, 0.5), 0 0 80px rgba(200, 200, 255, 0.3); }
}

.game-subtitle {
    font-size: clamp(0.9rem, 2.5vw, 1.3rem);
    color: #888;
    letter-spacing: 0.2em;
    margin-bottom: 4rem;
}

.title-menu {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.title-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ccc;
    padding: 1rem 3rem;
    font-family: inherit;
    font-size: 1.1rem;
    letter-spacing: 0.3em;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.title-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s ease;
}

.title-btn:hover {
    border-color: rgba(255, 255, 255, 0.6);
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.title-btn:hover::before {
    left: 100%;
}

.title-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ==========================================
   ゲーム画面 - 全画面テキスト表示
   ========================================== */

#game-screen {
    flex-direction: column;
    justify-content: flex-start;
    padding: 0;
}

/* 背景レイヤー */
#background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #0a0a0f;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-color 1s ease, background-image 1s ease, opacity 0.5s ease;
    z-index: 0;
}

#background.fade {
    opacity: 0;
}

/* キャラクター立ち絵 */
.character-container {
    position: absolute;
    bottom: 15vh; /* コントロールボタンの上 */
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    display: flex !important;
    justify-content: center;
    align-items: flex-end;
    pointer-events: none;
    z-index: 10;
}

.character-sprite {
    max-height: 75vh;
    max-width: 50vw;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: bottom center;
    filter: drop-shadow(0 0 15px rgba(0, 0, 0, 0.8));
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateY(0);
    opacity: 1;
}

.character-sprite.hidden {
    opacity: 0 !important;
    transform: translateY(20px);
    pointer-events: none;
}

.character-sprite.left {
    position: absolute;
    left: 5%;
    transform: translateX(0);
}

.character-sprite.right {
    position: absolute;
    right: 5%;
    transform: translateX(0);
}

.character-sprite.center {
    position: relative;
}

/* 章タイトル表示 */
#chapter-title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 50;
    text-align: center;
    animation: chapterFadeIn 0.8s ease-out;
}

#chapter-title.hidden {
    display: none;
}

#chapter-text {
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 600;
    letter-spacing: 0.4em;
    color: #fff;
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.5);
}

@keyframes chapterFadeIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* 証拠獲得ポップアップ - 非表示 */
#evidence-popup {
    display: none !important;
}

#evidence-popup.hidden {
    display: none !important;
}

#evidence-text {
    display: none;
}

/* ==========================================
   全画面テキストウィンドウ
   ========================================== */

#text-window {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 8vh 8vw;
    cursor: pointer;
    z-index: 10;
}

/* 背景画像がある時は半透明に */
#text-window.with-bg {
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.85) 0%,
        rgba(0, 0, 0, 0.6) 30%,
        rgba(0, 0, 0, 0.6) 70%,
        rgba(0, 0, 0, 0.85) 100%
    );
}

/* 話者名 */
#speaker-name {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    color: #c9a227;
    margin-bottom: 2rem;
    letter-spacing: 0.2em;
    font-weight: 600;
    min-height: 1.5em;
    text-shadow: 0 0 10px rgba(201, 162, 39, 0.3);
}

/* メインテキスト - 大きく読みやすく */
#text-content {
    font-size: clamp(1.4rem, 3.5vw, 2.2rem);
    line-height: 2.2;
    letter-spacing: 0.08em;
    color: #e8e8e8;
    flex: 1;
    overflow-y: auto;
    padding-right: 1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* スクロールバースタイル */
#text-content::-webkit-scrollbar {
    width: 4px;
}

#text-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

#text-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* クリックインジケーター */
#click-indicator {
    position: absolute;
    bottom: 5vh;
    right: 8vw;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.6);
    animation: indicatorPulse 1.2s ease-in-out infinite;
    transition: opacity 0.3s ease;
}

@keyframes indicatorPulse {
    0%, 100% { opacity: 0.4; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(5px); }
}

/* ==========================================
   選択肢 - 全画面中央表示
   ========================================== */

#choices {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 20;
    width: 90%;
    max-width: 700px;
}

#choices.hidden {
    display: none;
}

.choice-btn {
    background: rgba(20, 20, 30, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #e0e0e0;
    padding: 1.5rem 2rem;
    font-family: inherit;
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.choice-btn::before {
    content: '▶';
    position: absolute;
    left: -30px;
    opacity: 0;
    transition: all 0.3s ease;
    color: #c9a227;
}

.choice-btn:hover {
    background: rgba(40, 40, 60, 0.95);
    border-color: rgba(201, 162, 39, 0.6);
    color: #fff;
    padding-left: 3rem;
    box-shadow: 0 0 20px rgba(201, 162, 39, 0.2);
}

.choice-btn:hover::before {
    left: 1rem;
    opacity: 1;
}

/* ==========================================
   コントロールボタン
   ========================================== */

#controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.8rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    z-index: 30;
}

.control-btn {
    background: rgba(30, 30, 40, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.6rem 1rem;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.05em;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    min-width: 50px;
}

.btn-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.btn-label {
    font-size: 0.65rem;
    opacity: 0.8;
}

.control-btn:hover {
    background: rgba(50, 50, 70, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

.control-btn.active {
    background: rgba(139, 90, 43, 0.8);
    border-color: #c9a227;
    color: #fff;
}

/* ==========================================
   オーバーレイ画面共通
   ========================================== */

.overlay-content {
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    background: rgba(15, 15, 25, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    overflow: hidden;
}

.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
}

.overlay-title {
    font-size: 1.3rem;
    letter-spacing: 0.2em;
    color: #c9a227;
}

.close-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #888;
    width: 36px;
    height: 36px;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    border-color: rgba(255, 255, 255, 0.5);
    color: #fff;
}

.overlay-body {
    padding: 1.5rem;
    max-height: 65vh;
    overflow-y: auto;
}

.overlay-body::-webkit-scrollbar {
    width: 6px;
}

.overlay-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.overlay-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* ==========================================
   バックログ
   ========================================== */

.log-entry {
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-speaker {
    color: #c9a227;
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
    letter-spacing: 0.1em;
}

.log-text {
    color: #bbb;
    line-height: 1.8;
    font-size: 1rem;
}

/* ==========================================
   セーブ・ロード
   ========================================== */

.save-slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.save-slot {
    background: rgba(30, 30, 45, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.save-slot:hover {
    background: rgba(50, 50, 70, 0.8);
    border-color: rgba(201, 162, 39, 0.5);
}

.save-slot-title {
    color: #c9a227;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    letter-spacing: 0.1em;
}

.save-slot-info {
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.save-slot-preview {
    color: #aaa;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==========================================
   設定画面
   ========================================== */

.settings-group {
    margin-bottom: 2rem;
}

.settings-group:last-child {
    margin-bottom: 0;
}

.settings-label {
    display: block;
    color: #ccc;
    margin-bottom: 0.8rem;
    font-size: 1rem;
    letter-spacing: 0.1em;
}

.settings-slider {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.settings-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #c9a227;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease;
}

.settings-slider::-webkit-slider-thumb:hover {
    background: #ddb52f;
}

.settings-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #c9a227;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

/* ==========================================
   証拠画面
   ========================================== */

.evidence-item {
    background: rgba(30, 30, 45, 0.6);
    border: 1px solid rgba(201, 162, 39, 0.3);
    padding: 1.2rem;
    margin-bottom: 1rem;
}

.evidence-item:last-child {
    margin-bottom: 0;
}

.evidence-item-title {
    color: #c9a227;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    letter-spacing: 0.1em;
}

.evidence-item-desc {
    color: #aaa;
    line-height: 1.7;
    font-size: 0.95rem;
}

.no-evidence {
    text-align: center;
    color: #666;
    padding: 3rem;
    font-size: 1.1rem;
}

/* ==========================================
   エンディングギャラリー
   ========================================== */

.ending-container {
    background: rgba(10, 10, 15, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 2rem;
    max-width: 600px;
    width: 95%;
    max-height: 85vh;
    overflow-y: auto;
}

.ending-subtitle {
    text-align: center;
    color: #888;
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.ending-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.ending-item {
    background: rgba(30, 30, 40, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1.2rem;
    text-align: center;
    transition: all 0.3s ease;
}

.ending-item.unlocked {
    border-color: rgba(200, 50, 50, 0.5);
    background: rgba(50, 20, 20, 0.6);
}

.ending-item.unlocked:hover {
    border-color: rgba(200, 50, 50, 0.8);
    transform: translateY(-2px);
}

.ending-item.locked {
    opacity: 0.5;
}

.ending-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.ending-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #ddd;
    margin-bottom: 0.3rem;
}

.ending-desc {
    font-size: 0.8rem;
    color: #999;
    line-height: 1.4;
}

/* エンディングギャラリーの閉じるボタン */
.ending-container .close-btn {
    display: block;
    width: 100%;
    max-width: 200px;
    margin: 1.5rem auto 0;
    padding: 0.9rem 2rem;
    height: auto;
    background: linear-gradient(135deg, rgba(80, 30, 30, 0.8), rgba(40, 15, 15, 0.9));
    border: 2px solid rgba(200, 50, 50, 0.5);
    border-radius: 8px;
    color: #e8e8e8;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.ending-container .close-btn:hover {
    background: linear-gradient(135deg, rgba(120, 40, 40, 0.9), rgba(60, 20, 20, 0.95));
    border-color: rgba(200, 50, 50, 0.8);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(150, 50, 50, 0.3);
}

.ending-container .close-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

/* タイトル画面のエンディングカウンター */
.ending-counter-display {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.9rem;
    letter-spacing: 0.1em;
}

#ending-counter {
    color: rgba(200, 50, 50, 0.7);
    font-weight: 600;
}

/* ==========================================
   レスポンシブ対応 - スマホ最適化
   ========================================== */

/* タブレット (768px以下) */
@media (max-width: 768px) {
    /* タイトル */
    .game-title {
        letter-spacing: 0.15em;
    }
    
    .game-subtitle {
        margin-bottom: 3rem;
    }
    
    .title-btn {
        padding: 0.9rem 2rem;
        font-size: 1rem;
        width: 80vw;
        max-width: 300px;
    }
    
    /* テキストウィンドウ */
    #text-window {
        padding: 4vh 5vw;
        padding-bottom: 15vh;
    }
    
    #speaker-name {
        margin-bottom: 1.5rem;
    }
    
    #text-content {
        line-height: 2;
    }
    
    #click-indicator {
        bottom: 16vh;
        right: 5vw;
    }
    
    /* 選択肢 */
    #choices {
        width: 95%;
        gap: 1rem;
    }
    
    .choice-btn {
        padding: 1.2rem 1.5rem;
    }
    
    /* コントロール - スマホ最適化 */
    #controls {
        flex-wrap: nowrap;
        gap: 0.3rem;
        padding: 0.6rem 0.5rem;
        padding-bottom: calc(0.6rem + env(safe-area-inset-bottom));
        justify-content: space-around;
    }
    
    .control-btn {
        padding: 0.5rem 0.6rem;
        min-width: 48px;
        flex: 1;
        max-width: 60px;
    }
    
    .btn-icon {
        font-size: 1rem;
    }
    
    .btn-label {
        font-size: 0.55rem;
    }
    
    /* オーバーレイ */
    .overlay-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .overlay-body {
        max-height: 70vh;
    }
    
    .save-slots {
        grid-template-columns: 1fr;
    }
    
    /* キャラクター立ち絵 - タブレット用調整 */
    .character-sprite {
        max-height: 70vh;
        max-width: 50vw;
    }
    
    .character-container {
        bottom: 12vh;
    }
    
    /* エンディングギャラリー - タブレット */
    .ending-container {
        padding: 1.5rem;
    }
    
    .ending-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }
    
    .ending-counter-display {
        bottom: 1.5rem;
        right: 1.5rem;
        font-size: 0.85rem;
    }
}

/* スマートフォン (480px以下) */
@media (max-width: 480px) {
    /* タイトル画面 - スマホ専用最適化 */
    .title-content {
        padding: 2rem;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        min-height: 100dvh;
    }
    
    .game-title {
        font-size: 2.5rem;
        letter-spacing: 0.15em;
        margin-bottom: 0.8rem;
        line-height: 1.3;
    }
    
    /* キャラクター - スマホで1.2倍サイズ */
    .character-sprite {
        max-height: 78vh !important;
        max-width: 72vw !important;
        transform: scale(1.2) !important;
        transform-origin: bottom center !important;
    }
    
    .game-subtitle {
        font-size: 1rem;
        margin-bottom: 3rem;
        letter-spacing: 0.15em;
    }
    
    .title-menu {
        gap: 1.2rem;
        width: 100%;
        max-width: 280px;
    }
    
    .title-btn {
        padding: 1.2rem 2rem;
        font-size: 1.1rem;
        letter-spacing: 0.2em;
        width: 100%;
        border-radius: 4px;
    }
    
    /* エンディングギャラリー - スマホ */
    .ending-container {
        padding: 1.2rem;
        max-height: 90vh;
    }
    
    .ending-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }
    
    .ending-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }
    
    .ending-item {
        padding: 0.8rem;
    }
    
    .ending-icon {
        font-size: 1.5rem;
    }
    
    .ending-name {
        font-size: 0.85rem;
    }
    
    .ending-desc {
        font-size: 0.7rem;
    }
    
    .ending-counter-display {
        bottom: 1rem;
        right: 1rem;
        font-size: 0.8rem;
    }
    
    /* エンディングギャラリー閉じるボタン - スマホ */
    .ending-container .close-btn {
        max-width: 180px;
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
        margin-top: 1rem;
    }
    
    /* テキストウィンドウ - スマホ最適化 */
    #text-window {
        padding: 3vh 4vw;
        padding-bottom: 16vh;
    }
    
    #speaker-name {
        font-size: 1.8rem;
        margin-bottom: 1rem;
    }
    
    #text-content {
        font-size: 2rem;
        line-height: 1.8;
        letter-spacing: 0.03em;
    }
    
    #click-indicator {
        bottom: 17vh;
        right: 4vw;
        font-size: 1.1rem;
    }
    
    /* 選択肢 - スマホ用 */
    #choices {
        width: 98%;
        gap: 0.7rem;
        padding: 0 2vw;
    }
    
    .choice-btn {
        padding: 1.2rem;
        font-size: 1.8rem;
        letter-spacing: 0.03em;
    }
    
    .choice-btn:hover {
        padding-left: 1.5rem;
    }
    
    .choice-btn::before {
        font-size: 0.8rem;
    }
    
    .choice-btn:hover::before {
        left: 0.5rem;
    }
    
    /* コントロールボタン - スマホ用コンパクト化 */
    #controls {
        gap: 0.2rem;
        padding: 0.5rem 0.3rem;
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }
    
    .control-btn {
        padding: 0.4rem 0.5rem;
        min-width: 44px;
    }
    
    .btn-icon {
        font-size: 0.95rem;
    }
    
    .btn-label {
        font-size: 0.5rem;
    }
    
    /* 章タイトル - スマホで2倍大きく */
    #chapter-text {
        font-size: 3rem;
        letter-spacing: 0.3em;
    }
    
    /* オーバーレイ */
    .overlay-content {
        width: 98%;
        border-radius: 2px;
    }
    
    .overlay-header {
        padding: 1rem;
    }
    
    .overlay-title {
        font-size: 1.1rem;
        letter-spacing: 0.1em;
    }
    
    .close-btn {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
    
    .overlay-body {
        padding: 1rem;
        max-height: 65vh;
    }
    
    /* バックログ */
    .log-entry {
        padding: 0.8rem 0;
    }
    
    .log-speaker {
        font-size: 0.85rem;
    }
    
    .log-text {
        font-size: 0.9rem;
        line-height: 1.7;
    }
    
    /* セーブスロット */
    .save-slot {
        padding: 1rem;
    }
    
    .save-slot-title {
        font-size: 0.9rem;
    }
    
    .save-slot-info, .save-slot-preview {
        font-size: 0.8rem;
    }
    
    /* 設定 */
    .settings-label {
        font-size: 0.9rem;
    }
    
    .settings-slider {
        height: 12px;
    }
    
    .settings-slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }
    
    /* 証拠リスト */
    .evidence-item {
        padding: 1rem;
    }
    
    .evidence-item-title {
        font-size: 1rem;
    }
    
    .evidence-item-desc {
        font-size: 0.85rem;
    }
    
    /* キャラクター立ち絵 - スマホ用（大きく表示） */
    .character-container {
        bottom: 13vh;
        left: auto;
        right: 2vw;
        width: auto;
        justify-content: flex-end;
        z-index: 10;
    }
    
    .character-sprite {
        max-height: 78vh !important;
        max-width: 72vw !important;
        transform: scale(1.2) !important;
        transform-origin: bottom center !important;
    }
    
    .character-sprite:not(.hidden) {
        opacity: 1 !important;
        display: block !important;
    }
    
    .character-container {
        bottom: 10vh !important;
    }
}

/* 横向きスマホ対応 */
@media (max-height: 500px) and (orientation: landscape) {
    #text-window {
        padding: 2vh 5vw;
        padding-bottom: 12vh;
    }
    
    #speaker-name {
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
    }
    
    #text-content {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    #click-indicator {
        bottom: 13vh;
    }
    
    #controls {
        padding: 0.4rem;
    }
    
    .control-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.65rem;
    }
    
    .game-subtitle {
        margin-bottom: 1.5rem;
    }
    
    .title-menu {
        gap: 0.6rem;
    }
    
    .title-btn {
        padding: 0.5rem 1.5rem;
        font-size: 0.85rem;
    }
    
    .choice-btn {
        padding: 0.8rem;
        font-size: 0.9rem;
    }
    
    #choices {
        gap: 0.5rem;
    }
    
    /* 横向きスマホ - キャラクター */
    .character-sprite {
        max-height: 70vh;
        max-width: 35vw;
    }
}

/* スマホ縦向き専用 (portrait) */
@media (max-width: 480px) and (orientation: portrait) {
    /* タイトル画面 - 縦向きスマホ専用 */
    .title-content {
        padding: 3rem 1.5rem;
        padding-top: max(3rem, env(safe-area-inset-top));
        padding-bottom: max(3rem, env(safe-area-inset-bottom));
    }
    
    .game-title {
        font-size: 2.8rem;
        letter-spacing: 0.2em;
        margin-bottom: 1rem;
    }
    
    .game-subtitle {
        font-size: 1.1rem;
        margin-bottom: 4rem;
    }
    
    .title-menu {
        gap: 1.5rem;
        max-width: 300px;
    }
    
    .title-btn {
        padding: 1.4rem 2.5rem;
        font-size: 1.2rem;
        letter-spacing: 0.25em;
    }
    
    .character-container {
        position: fixed !important;
        bottom: 13vh !important;
        right: 0 !important;
        left: auto !important;
        width: auto !important;
        z-index: 10 !important;
    }
    
    .character-sprite {
        max-height: 72vh !important;
        max-width: 66vw !important;
        transform: scale(1.2) !important;
        transform-origin: bottom center !important;
    }
    
    .character-sprite:not(.hidden) {
        opacity: 1 !important;
        display: block !important;
        visibility: visible !important;
    }
    
    .character-container {
        bottom: 10vh !important;
    }
    
    /* 章タイトル - スマホ縦向きでも大きく */
    #chapter-text {
        font-size: 2.5rem;
        letter-spacing: 0.25em;
    }
}

/* 超小型スマホ (360px以下) */
@media (max-width: 360px) {
    /* タイトル画面 - 超小型スマホ */
    .game-title {
        font-size: 2rem;
        letter-spacing: 0.1em;
    }
    
    .game-subtitle {
        font-size: 0.9rem;
        margin-bottom: 2.5rem;
    }
    
    .title-menu {
        max-width: 250px;
        gap: 1rem;
    }
    
    .title-btn {
        padding: 1rem 1.5rem;
        font-size: 1rem;
        letter-spacing: 0.15em;
    }
    
    .character-container {
        bottom: 13vh !important;
        right: 0 !important;
    }
    
    .character-sprite {
        max-height: 66vh !important;
        max-width: 60vw !important;
        transform: scale(1.2) !important;
        transform-origin: bottom center !important;
    }
    
    .character-container {
        bottom: 10vh !important;
    }
    
    /* 章タイトル */
    #chapter-text {
        font-size: 2rem;
        letter-spacing: 0.2em;
    }
    
    #text-content {
        font-size: 0.95rem;
        line-height: 1.75;
    }
    
    .control-btn {
        padding: 0.3rem 0.4rem;
        min-width: 40px;
    }
    
    .btn-icon {
        font-size: 0.85rem;
    }
    
    .btn-label {
        font-size: 0.45rem;
    }
}

/* タッチデバイス用 - ホバーエフェクト無効化・タップ最適化 */
@media (hover: none) {
    .title-btn:hover::before,
    .choice-btn:hover::before {
        left: -30px;
        opacity: 0;
    }
    
    .choice-btn:hover {
        padding-left: 1rem;
    }
    
    /* タップ時のハイライト */
    .title-btn:active,
    .choice-btn:active {
        background: rgba(201, 162, 39, 0.3);
        transform: scale(0.98);
    }
    
    .control-btn:active {
        background: rgba(139, 90, 43, 0.8);
        transform: scale(0.95);
    }
    
    /* タップ可能領域を広く */
    .control-btn {
        min-height: 44px;
    }
    
    .choice-btn {
        min-height: 48px;
    }
    
    .title-btn {
        min-height: 48px;
    }
    
    /* テキストウィンドウのタップ反応 */
    #text-window:active {
        background: rgba(0, 0, 0, 0.75);
    }
}

/* ==========================================
   アニメーション・エフェクト
   ========================================== */

/* フェードイン */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* テキスト表示アニメーション */
.text-fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* 画面遷移 */
.screen-transition {
    animation: fadeIn 0.5s ease-out;
}
