/**
 * ノベルゲームプラグイン フロントエンド スタイル
 *
 * @package NovelGamePlugin
 * @since 1.0.0
 */

/* =============================================================================
   WordPress レイアウト制約対応 - 特別なオーバーライド
   ============================================================================= */

/* WordPress の .is-layout-constrained による制約を回避 */
.is-layout-constrained #novel-game-modal-overlay.novel-game-modal-overlay {
    /* WordPress のレイアウト制約を完全に無効化 */
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* ビューポート全体をカバー */
    transform: none;
    /* 配置を強制 */
    inset: 0;
}

/* ブロックエディターのコンテンツ制約を回避 */
.wp-block-post-content #novel-game-modal-overlay.novel-game-modal-overlay {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    inset: 0;
}

/* 追加の WordPress テーマ制約を回避 */
.wp-site-blocks #novel-game-modal-overlay.novel-game-modal-overlay,
.wp-container #novel-game-modal-overlay.novel-game-modal-overlay,
.entry-content #novel-game-modal-overlay.novel-game-modal-overlay {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    inset: 0;
}

/* =============================================================================
   タイトル画面 スタイル（統合モーダル内）
   ============================================================================= */

/* タイトル画面 */
.novel-title-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    animation: title-screen-appear 0.4s ease-out;
}

@keyframes title-screen-appear {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* タイトル画面コンテンツ */
.novel-title-content {
    text-align: center;
    max-width: 600px;
    padding: 40px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    color: white;
}

/* タイトルテキスト */
.novel-title-main {
    font-size: 3em;
    font-weight: bold;
    margin-bottom: 20px;
    text-shadow: 
        3px 3px 6px rgba(0, 0, 0, 0.8),
        1px 1px 3px rgba(0, 0, 0, 0.9);
    line-height: 1.2;
    color: white;
}

/* サブタイトル */
.novel-title-subtitle {
    font-size: 1.3em;
    margin-bottom: 15px;
    font-weight: 300;
    text-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.8),
        1px 1px 2px rgba(0, 0, 0, 0.9);
    color: rgba(255, 255, 255, 0.95);
}

/* 説明文 */
.novel-title-description {
    font-size: 1.1em;
    margin-bottom: 40px;
    line-height: 1.6;
    text-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.8),
        1px 1px 2px rgba(0, 0, 0, 0.9);
    color: rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.2);
    padding: 15px 20px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ボタンコンテナ */
.novel-title-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

/* タイトル画面ボタン */
.novel-title-btn {
    position: relative;
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    min-width: 200px;
    overflow: hidden;
}

.novel-title-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.novel-title-btn:active {
    transform: translateY(0);
}

/* 続きからボタン */
.novel-title-continue-btn {
    background: linear-gradient(45deg, #fd7e14, #ffc107);
}

/* ボタンアニメーション効果 */
.novel-title-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

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

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .novel-title-content {
        padding: 30px 20px;
        max-width: 90%;
        background: rgba(0, 0, 0, 0.4);
    }
    
    .novel-title-main {
        font-size: 2.2em;
        text-shadow: 
            2px 2px 4px rgba(0, 0, 0, 0.9),
            1px 1px 2px rgba(0, 0, 0, 1);
    }
    
    .novel-title-subtitle {
        font-size: 1.1em;
        text-shadow: 
            1px 1px 3px rgba(0, 0, 0, 0.9),
            0 0 2px rgba(0, 0, 0, 1);
    }
    
    .novel-title-description {
        font-size: 1em;
        padding: 12px 15px;
        background: rgba(0, 0, 0, 0.3);
        text-shadow: 
            1px 1px 3px rgba(0, 0, 0, 0.9),
            0 0 2px rgba(0, 0, 0, 1);
    }
    
    .novel-title-btn {
        min-width: 100%;
        padding: 18px 25px;
        font-size: 18px;
    }
}
/* =============================================================================
   ゲーム再開ダイアログ スタイル
   ============================================================================= */

/* 再開ダイアログオーバーレイ */
.novel-resume-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2147483648;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

/* 再開ダイアログ本体 */
.novel-resume-dialog {
    background: white;
    border-radius: 10px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: resume-dialog-appear 0.3s ease-out;
}

@keyframes resume-dialog-appear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ダイアログタイトル */
.novel-resume-dialog h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 1.4em;
    font-weight: bold;
}

/* ダイアログメッセージ */
.novel-resume-dialog p {
    margin: 0 0 25px 0;
    color: #666;
    line-height: 1.6;
    font-size: 1em;
}

.novel-resume-dialog small {
    color: #999;
    font-size: 0.9em;
}

/* ボタンコンテナ */
.novel-resume-dialog > div:last-child {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ダイアログボタン */
.novel-resume-dialog button {
    border: none;
    padding: 12px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    min-width: 120px;
    transition: all 0.3s ease;
    font-weight: 500;
}

/* 再開ボタン */
.novel-resume-dialog button:first-of-type {
    background: #4CAF50;
    color: white;
}

.novel-resume-dialog button:first-of-type:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

/* 最初からボタン */
.novel-resume-dialog button:last-of-type {
    background: #f44336;
    color: white;
}

.novel-resume-dialog button:last-of-type:hover {
    background: #da190b;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
}

/* ボタン押下効果 */
.novel-resume-dialog button:active {
    transform: translateY(0);
    box-shadow: none;
}

/* モバイル対応 */
@media (max-width: 480px) {
    .novel-resume-dialog {
        padding: 20px;
        margin: 20px;
        max-width: none;
        width: calc(100% - 40px);
    }
    
    .novel-resume-dialog > div:last-child {
        flex-direction: column;
        gap: 8px;
    }
    
    .novel-resume-dialog button {
        min-width: 100%;
        padding: 15px 20px;
        font-size: 16px;
    }
}

/* =============================================================================
   広告コンテナ スタイル
   ============================================================================= */

/* 広告コンテナ */
.novel-ad-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 60px;
    max-height: 100px;
    background: rgba(240, 240, 240, 0.95);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* 広告コンテナの内容 */
.novel-ad-container > div,
.novel-ad-container > ins {
    max-width: 100%;
    max-height: 100%;
}

/* タイトル画面では広告を非表示（高い特異性で確実に非表示） */
.novel-game-modal-content #novel-title-screen.novel-title-screen ~ .novel-game-container #novel-ad-container.novel-ad-container,
.novel-game-modal-content #novel-title-screen[style*="display: flex"] ~ .novel-game-container #novel-ad-container.novel-ad-container {
    display: none;
}

/* モバイル対応 */
@media (max-width: 768px) {
    .novel-ad-container {
        min-height: 50px;
        max-height: 90px;
    }
}

/* =============================================================================
   広告表示時のUI位置調整（レスポンシブ対応）
   ============================================================================= */

/* 広告表示時のみ、ゲームコンテナ全体に余白を付与して広告と重ならないようにする */

/* モバイル（767px以下）: 広告分の高さをゲームコンテナで吸収 */
@media (max-width: 767px) {
    .novel-game-container.has-ad-banner {
        padding-top: 80px;
    }
}

/* タブレット（768px〜1023px）: 広告分の高さをゲームコンテナで吸収 */
@media (min-width: 768px) and (max-width: 1023px) {
    .novel-game-container.has-ad-banner {
        padding-top: 90px;
    }
}

/* PC（1024px以上）: 広告分の高さをゲームコンテナで吸収 */
@media (min-width: 1024px) {
    .novel-game-container.has-ad-banner {
        padding-top: 100px;
    }
}

/* =============================================================================
   ベーススタイル
   ============================================================================= */

/* モーダル開放時のボディスタイル */
html.modal-open body.modal-open {
    overflow: hidden;
    height: 100vh;
    margin: 0;
    padding: 0;
}

/* モーダル開放時のHTMLスタイル */
html.modal-open {
    overflow: hidden;
    height: 100vh;
    margin: 0;
    padding: 0;
}

/* ゲーム開始ボタンコンテナ */
.novel-game-start-container {
    text-align: center;
    margin: 20px 0;
    padding: 40px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* ゲーム開始ボタン */
.novel-game-start-btn {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    padding: 20px 40px;
    border-radius: 50px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 10px 10px 0;
    display: inline-block;
}

.novel-game-start-btn:hover {
    background: linear-gradient(45deg, #ff5252, #d84315);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.6);
}

.novel-game-start-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.5);
}

/* 進捗クリアボタン */
.novel-game-clear-progress-btn {
    background: linear-gradient(45deg, #6c757d, #495057);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 10px 10px 0;
    display: inline-block;
    opacity: 0.8;
}

.novel-game-clear-progress-btn:hover {
    background: linear-gradient(45deg, #5a6268, #343a40);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.4);
    opacity: 1;
}

.novel-game-clear-progress-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(108, 117, 125, 0.3);
}

/* ボタンコンテナのレスポンシブ調整 */
.novel-game-start-container {
    text-align: center;
    margin: 20px 0;
    padding: 40px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

@media (max-width: 480px) {
    .novel-game-start-container {
        padding: 30px 15px;
    }
    
    .novel-game-start-btn,
    .novel-game-clear-progress-btn {
        display: block;
        width: 100%;
        margin: 0 0 10px 0;
        max-width: 280px;
        margin-left: auto;
        margin-right: auto;
    }
    
    .novel-game-start-btn {
        font-size: 16px;
        padding: 18px 30px;
    }
    
    .novel-game-clear-progress-btn {
        font-size: 13px;
        padding: 12px 20px;
    }
}
    font-size: 24px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.3);
    min-width: 200px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.novel-game-start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.5);
    background: linear-gradient(45deg, #ff5252, #e84118);
}

.novel-game-start-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

/* モーダルオーバーレイ - WordPress レイアウト制約を回避 */
.is-layout-constrained #novel-game-modal-overlay.novel-game-modal-overlay,
.wp-block-post-content #novel-game-modal-overlay.novel-game-modal-overlay,
body #novel-game-modal-overlay.novel-game-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2147483647; /* 最大値のz-index */
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-sizing: border-box;
    /* WordPress レイアウト制約を明示的に回避 */
    margin: 0;
    padding: 0;
    max-width: none;
    /* WordPressの管理バーよりも前面に */
    overflow: hidden;
    /* レイアウト制約をリセット */
    left: 0;
    right: 0;
    margin-left: 0;
    margin-right: 0;
}

/* WordPress管理バーを強制的に隠す */
html.modal-open body.modal-open #wpadminbar {
    display: none;
    visibility: hidden;
    opacity: 0;
}

/* モーダルが表示されている時のオーバーレイ - WordPress レイアウト制約を回避 */
.is-layout-constrained #novel-game-modal-overlay.novel-game-modal-overlay.show,
.wp-block-post-content #novel-game-modal-overlay.novel-game-modal-overlay.show,
body #novel-game-modal-overlay.novel-game-modal-overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease-out;
    /* WordPress レイアウト制約を強制的に回避 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}

/* モーダルの強制表示（JavaScript用） - WordPress レイアウト制約を回避 */
.is-layout-constrained #novel-game-modal-overlay.novel-game-modal-overlay[style*="display: flex"],
.wp-block-post-content #novel-game-modal-overlay.novel-game-modal-overlay[style*="display: flex"],
body #novel-game-modal-overlay.novel-game-modal-overlay[style*="display: flex"] {
    display: flex;
    background: rgba(0, 0, 0, 0.8);
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2147483647; /* 最大値のz-index */
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* WordPress レイアウト制約を明示的に回避 */
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    left: 0;
    right: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* モーダルコンテンツ - WordPress レイアウト制約を回避 */
.is-layout-constrained #novel-game-modal-overlay .novel-game-modal-content,
.wp-block-post-content #novel-game-modal-overlay .novel-game-modal-content,
body #novel-game-modal-overlay .novel-game-modal-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: slideUp 0.4s ease-out;
    box-sizing: border-box;
    /* モーダルコンテンツは親要素のサイズを継承 */
    width: 100%;
    height: 100%;
    /* flexboxでゲームエリアを中央配置 */
    padding: 20px;
    /* WordPress レイアウト制約を回避 */
    margin: 0;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}

/* ゲームエリア（中央配置用） - WordPress レイアウト制約を回避 */
.is-layout-constrained #novel-game-modal-overlay .novel-game-modal-content .novel-game-container,
.wp-block-post-content #novel-game-modal-overlay .novel-game-modal-content .novel-game-container,
body #novel-game-modal-overlay .novel-game-modal-content .novel-game-container {
    /* レスポンシブなゲーム画面サイズ設定 */
    width: min(90vw, 1280px);
    height: min(80vh, 720px);
    /* 最大サイズを1280×720に設定 */
    max-width: 1280px;
    max-height: 720px;
    /* アスペクト比を保持しつつレスポンシブ対応 */
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    position: relative;
    /* ゲームコンテンツが確実に表示されるよう */
    min-width: 320px;
    min-height: 180px;
    /* flexbox内で中央配置 */
    flex-shrink: 0;
    /* 強制的に中央配置 */
    margin: auto;
    /* WordPress レイアウト制約を回避 */
    margin-left: auto;
    margin-right: auto;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* モバイル対応：小画面では全画面モーダル - WordPress レイアウト制約を回避 */
@media (max-width: 768px) {
    .is-layout-constrained #novel-game-modal-overlay .novel-game-modal-content .novel-game-container,
    .wp-block-post-content #novel-game-modal-overlay .novel-game-modal-content .novel-game-container,
    body #novel-game-modal-overlay .novel-game-modal-content .novel-game-container {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        min-width: auto;
        min-height: auto;
        /* WordPress レイアウト制約を回避 */
        margin: 0;
        margin-left: 0;
        margin-right: 0;
    }
    
    .is-layout-constrained #novel-game-modal-overlay .novel-game-modal-content,
    .wp-block-post-content #novel-game-modal-overlay .novel-game-modal-content,
    body #novel-game-modal-overlay .novel-game-modal-content {
        padding: 0;
        /* WordPress レイアウト制約を回避 */
        margin: 0;
        max-width: none;
        margin-left: 0;
        margin-right: 0;
    }
    
    .novel-game-start-btn {
        padding: 15px 30px;
        font-size: 20px;
        min-width: 180px;
    }
}

/* タブレット対応 - WordPress レイアウト制約を回避 */
@media (min-width: 769px) and (max-width: 1024px) {
    .is-layout-constrained #novel-game-modal-overlay .novel-game-modal-content .novel-game-container,
    .wp-block-post-content #novel-game-modal-overlay .novel-game-modal-content .novel-game-container,
    body #novel-game-modal-overlay .novel-game-modal-content .novel-game-container {
        /* タブレットサイズでも最大1280×720を維持 */
        width: min(95vw, 1280px);
        height: min(90vh, 720px);
        max-width: 1280px;
        max-height: 720px;
        /* アスペクト比を保持 */
        aspect-ratio: 16/9;
        /* WordPress レイアウト制約を回避 */
        margin: auto;
        margin-left: auto;
        margin-right: auto;
    }
}

/* 大画面対応 - WordPress レイアウト制約を回避 */
@media (min-width: 1025px) {
    .is-layout-constrained #novel-game-modal-overlay .novel-game-modal-content .novel-game-container,
    .wp-block-post-content #novel-game-modal-overlay .novel-game-modal-content .novel-game-container,
    body #novel-game-modal-overlay .novel-game-modal-content .novel-game-container {
        /* 大画面でも最大1280×720を維持 */
        width: min(80vw, 1280px);
        height: min(75vh, 720px);
        max-width: 1280px;
        max-height: 720px;
        /* アスペクト比を保持 */
        aspect-ratio: 16/9;
        /* WordPress レイアウト制約を回避 */
        margin: auto;
        margin-left: auto;
        margin-right: auto;
    }
}

/* モーダル表示時の全要素を制御 */
html.modal-open body.modal-open * {
    box-sizing: border-box;
}

/* WordPress管理バーなどの重要な要素を強制的に隠す */
html.modal-open body.modal-open #wpadminbar,
html.modal-open body.modal-open .wp-admin-bar,
html.modal-open body.modal-open header,
html.modal-open body.modal-open nav,
html.modal-open body.modal-open footer {
    display: none;
    visibility: hidden;
    opacity: 0;
    z-index: -1;
}

/* モーダル以外のページコンテンツを背景に */
html.modal-open body.modal-open #page,
html.modal-open body.modal-open #main,
html.modal-open body.modal-open .site-content,
html.modal-open body.modal-open .main-content {
    z-index: 1;
}

/* モーダル表示時のHTML/Bodyスタイル */
html.modal-open body.modal-open,
html.modal-open {
    overflow: hidden;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

/* モーダル要素のz-index確保 - WordPress レイアウト制約を回避 */
.is-layout-constrained #novel-game-modal-overlay.novel-game-modal-overlay,
.wp-block-post-content #novel-game-modal-overlay.novel-game-modal-overlay,
body #novel-game-modal-overlay.novel-game-modal-overlay {
    z-index: 2147483647; /* 最大値のz-index */
    /* WordPress レイアウト制約を強制的に回避 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}

/* 追加のオーバーレイ強制ルール - WordPress レイアウト制約を回避 */
.is-layout-constrained #novel-game-modal-overlay.novel-game-modal-overlay.show,
.wp-block-post-content #novel-game-modal-overlay.novel-game-modal-overlay.show,
body #novel-game-modal-overlay.novel-game-modal-overlay.show {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2147483647; /* 最大値のz-index */
    /* WordPress レイアウト制約を強制的に回避 */
    margin: 0;
    padding: 0;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    left: 0;
    right: 0;
}

/* ゲーム全体のコンテナ */
#novel-game-container {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    overflow: hidden;
    touch-action: manipulation; /* タッチ操作最適化 */
}

/* モーダル内のゲームコンテナのスタイル強化 */
body #novel-game-modal-overlay #novel-game-container {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    overflow: hidden;
}

/* ゲーム閉じるボタン */
.novel-game-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.novel-game-close-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border-color: #333;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.novel-game-close-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.novel-game-close-btn:focus {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

.close-icon {
    line-height: 1;
    font-family: Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* モバイルでの閉じるボタン調整 */
@media (max-width: 768px) {
    .novel-game-close-btn {
        top: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
}

/* ゲームタイトル */
.novel-game-title {
    text-align: center;
    font-size: clamp(18px, 4vw, 24px); /* レスポンシブフォントサイズ */
    font-weight: bold;
    margin-bottom: 20px;
    color: #333;
    padding: 10px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 5px;
    line-height: 1.4;
}

/* キャラクター画像 */
#novel-character,
.novel-character {
    position: absolute;
    bottom: 20%;
    max-height: 40%;
    max-width: 70%;
    z-index: 2;
    object-fit: contain;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

/* 3体キャラクター個別配置 */
.novel-character-left {
    left: 5%;
    transform: none;
    -webkit-transform: none;
    -moz-transform: none;
    -ms-transform: none;
    max-width: 25%;
}

.novel-character-center {
    left: 50%;
    transform: translateX(-50%);
    -webkit-transform: translateX(-50%);
    -moz-transform: translateX(-50%);
    -ms-transform: translateX(-50%);
    max-width: 30%;
}

.novel-character-right {
    right: 5%;
    transform: none;
    -webkit-transform: none;
    -moz-transform: none;
    -ms-transform: none;
    max-width: 25%;
}

/* 話者によるキャラクター強調 */
.novel-character.speaking {
    opacity: 1;
    filter: brightness(1.1);
}

.novel-character.not-speaking {
    opacity: 0.5;
    filter: brightness(0.8);
}

/* セリフごとのキャラクター切り替えアニメーション */
.novel-character.novel-character-transitioning {
    transition: opacity 0.3s ease-in-out;
}

/* 後方互換性のための旧スタイル */
#novel-character:not(.novel-character-left):not(.novel-character-center):not(.novel-character-right) {
    left: 50%;
    transform: translateX(-50%);
    -webkit-transform: translateX(-50%);
    -moz-transform: translateX(-50%);
    -ms-transform: translateX(-50%);
}

/* セリフボックス */
#novel-dialogue-box,
.novel-dialogue-box {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 20px;
    font-size: clamp(14px, 3vw, 18px); /* レスポンシブフォントサイズ */
    line-height: 1.6;
    z-index: 3;
    box-sizing: border-box;
    height: 140px; /* 固定高さ設定 - ノベルゲームの標準的な表示 */
    display: flex;
    flex-direction: column;
}

/* モーダル内のセリフボックススタイル強化 */
body #novel-game-modal-overlay #novel-dialogue-box,
body #novel-game-modal-overlay .novel-dialogue-box {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    z-index: 3;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* 話者名表示 */
.novel-speaker-name {
    position: absolute;
    bottom: 100px; /* ダイアログボックスに半分重ねる位置 */
    left: 20px;
    font-weight: bold;
    color: #ffd700;
    font-size: 0.9em;
    opacity: 0.9;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 12px;
    border-radius: 4px;
    display: block;
    width: fit-content;
    min-width: 80px;
    min-height: 20px; /* 空欄時でも高さを維持 */
    text-align: center;
    z-index: 4;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* セリフテキストコンテナ */
.novel-dialogue-text-container {
    flex: 1;
    display: flex;
    align-items: center;
}

/* セリフテキストの詳細スタイル */
#novel-dialogue-text {
    white-space: pre-wrap;
    word-break: break-all;
    font-family: 'Hiragino Kaku Gothic ProN', 'ヒラギノ角ゴ ProN W3', 'Meiryo', 'メイリオ', sans-serif;
    letter-spacing: 0.05em;
    overflow-wrap: break-word;
    max-height: calc(1.6em * 3); /* 3行分の高さ */
    overflow: hidden;
    width: 100%;
}

/* 継続インジケーター */
.novel-dialogue-continue {
    position: absolute;
    bottom: 5px;
    right: 15px;
    z-index: 1;
}

.continue-indicator {
    font-size: 16px;
    color: #ffd700;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* 選択肢コンテナ */
#novel-choices,
.novel-choices {
    position: absolute;
    bottom: 5%;
    left: 5%;
    width: 90%;
    z-index: 4;
    display: none;
}

/* 選択肢リスト */
#novel-choices .choice-list,
.novel-choices .choice-list {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 20px;
    border-radius: 5px;
    font-family: 'Hiragino Kaku Gothic ProN', 'ヒラギノ角ゴ ProN W3', 'Meiryo', 'メイリオ', sans-serif;
    font-size: clamp(14px, 3vw, 18px);
    line-height: 1.6;
    max-width: 100%;
    box-sizing: border-box;
}

/* 選択肢アイテム */
#novel-choices .choice-item,
.novel-choices .choice-item {
    display: block;
    padding: 12px 20px;
    margin: 8px 0;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -ms-transition: all 0.3s ease;
    min-height: 44px; /* タッチ対応最小サイズ */
    box-sizing: border-box;
    white-space: pre-wrap;
    word-break: break-word;
    text-align: left;
}

/* 選択肢アイテムの選択状態 */
#novel-choices .choice-item.selected,
.novel-choices .choice-item.selected {
    background: rgba(255, 255, 255, 0.3);
    border-color: #fff;
    color: #fff;
}

/* 選択肢アイテムのホバー状態 */
#novel-choices .choice-item:hover,
.novel-choices .choice-item:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

/* 選択肢アイテムのフォーカス状態 */
#novel-choices .choice-item:focus,
.novel-choices .choice-item:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* 選択肢アイテムのアクティブ状態 */
#novel-choices .choice-item:active,
.novel-choices .choice-item:active {
    transform: scale(0.98);
    -webkit-transform: scale(0.98);
    -moz-transform: scale(0.98);
    -ms-transform: scale(0.98);
}

/* 選択肢の三角表示 */
#novel-choices .choice-item::before,
.novel-choices .choice-item::before {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid transparent;
    margin-right: 8px;
    vertical-align: middle;
    transition: all 0.3s ease;
}

#novel-choices .choice-item.selected::before,
.novel-choices .choice-item.selected::before {
    border-left: 8px solid #fff;
    border-right: 0;
    border-bottom: 4px solid transparent;
    border-top: 4px solid transparent;
}

#novel-choices .choice-list,
.novel-choices .choice-list {
    /* Remove counter reset since we're not using counters anymore */
}

/* 古いボタンスタイル（後方互換性のため残す） */
#novel-choices button:not(.game-nav-button),
.novel-choices button:not(.game-nav-button),
.novel-choice-button {
    display: none; /* 新しいスタイルを使用する場合は非表示 */
}

/* ゲーム終了メッセージ */
.game-end-message {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 40px;
    border-radius: 10px;
    text-align: center;
    font-size: clamp(24px, 6vw, 36px);
    font-weight: bold;
    border: 2px solid #ffd700;
    margin: 20px 0;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Game Over メッセージ */
.game-over-message {
    background: rgba(139, 0, 0, 0.9);
    color: #fff;
    padding: 40px;
    border-radius: 10px;
    text-align: center;
    font-size: clamp(24px, 6vw, 36px);
    font-weight: bold;
    border: 2px solid #ff4444;
    margin: 20px 0;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    box-shadow: 0 4px 15px rgba(139, 0, 0, 0.3);
}

/* ゲームナビゲーションボタン */
.game-navigation {
    margin-top: 20px;
    text-align: center;
}

.game-nav-button {
    display: inline-block;
    padding: 15px 30px;
    margin: 0 10px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: clamp(16px, 3vw, 20px);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    min-height: 50px;
    min-width: 150px;
    box-sizing: border-box;
}

.game-nav-button:hover {
    background: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

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

.game-nav-button.close-button {
    background: #666;
}

.game-nav-button.close-button:hover {
    background: #555;
}


.game-nav-button.title-return-button {
    background: #2196F3;
}

.game-nav-button.title-return-button:hover {
    background: #1976D2;
}

/* 古いゲーム終了メッセージのスタイル調整 */
.game-end-message:hover {
    background: rgba(0, 0, 0, 0.9);
    border-color: #fff;
    transform: none; /* ナビゲーションボタンがある場合は変形しない */
}

.game-end-message:active {
    transform: none; /* ナビゲーションボタンがある場合は変形しない */
}

/* Game Over メッセージのホバー・アクティブ状態 */
.game-over-message:hover {
    background: rgba(139, 0, 0, 1);
    border-color: #fff;
    transform: none;
    box-shadow: 0 6px 20px rgba(139, 0, 0, 0.4);
}

.game-over-message:active {
    transform: none;
}

/* タッチデバイス用のゲーム終了メッセージ */
@media (hover: none) and (pointer: coarse) {
    .game-end-message {
        padding: 50px;
        font-size: clamp(28px, 8vw, 42px);
        min-height: 100px;
    }
    
    .game-over-message {
        padding: 50px;
        font-size: clamp(28px, 8vw, 42px);
        min-height: 100px;
    }
    
    .game-nav-button {
        padding: 20px 40px;
        font-size: clamp(18px, 4vw, 24px);
        min-height: 60px;
        min-width: 200px;
        margin: 10px;
    }
}

/* 小画面での調整 */
@media (max-width: 480px) {
    .game-end-message {
        padding: 30px;
        font-size: clamp(20px, 5vw, 28px);
        min-height: 60px;
    }
    
    .game-over-message {
        padding: 30px;
        font-size: clamp(20px, 5vw, 28px);
        min-height: 60px;
    }
    
    .game-nav-button {
        padding: 15px 25px;
        font-size: clamp(14px, 3vw, 18px);
        min-height: 50px;
        min-width: 120px;
        margin: 5px;
        display: block;
        width: 100%;
    }
    
    .game-navigation {
        margin-top: 15px;
    }
}

/* スクリーンリーダー専用テキスト */
.screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    word-wrap: normal !important;
}

/* =============================================================================
   アーカイブページのスタイル
   ============================================================================= */

.novel-game-archive-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.archive-header {
    text-align: center;
    margin-bottom: 40px;
}

.archive-title {
    font-size: clamp(1.8em, 5vw, 2.5em); /* レスポンシブフォントサイズ */
    color: #333;
    margin-bottom: 10px;
    line-height: 1.2;
}

.archive-description {
    font-size: clamp(1em, 2.5vw, 1.2em); /* レスポンシブフォントサイズ */
    color: #666;
    margin: 0;
    line-height: 1.4;
}

.novel-games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.novel-game-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-height: 200px; /* 最小高さ設定 */
}

.novel-game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
}

.game-thumbnail {
    width: 100%;
    height: 180px;
    overflow: hidden;
    position: relative;
    background: #f0f0f0;
}

.game-bg-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    color: #666;
}

.game-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.game-info {
    flex: 1;
}

.game-title {
    font-size: clamp(1.1em, 2.5vw, 1.4em);
    font-weight: bold;
    margin: 0 0 5px 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    line-height: 1.2;
}

.scene-count {
    font-size: clamp(0.8em, 1.5vw, 0.9em);
    color: #ccc;
    margin: 0;
}

.play-button {
    background: #ff6b6b;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    text-align: center;
    font-weight: bold;
    transition: background-color 0.3s ease;
    font-size: clamp(0.8em, 1.5vw, 0.9em);
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.novel-game-card:hover .play-button,
.novel-game-card.hovered .play-button {
    background: #ff5252;
}

.no-games-message {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: clamp(1em, 2vw, 1.2em);
}

.no-games-message .button {
    display: inline-block;
    margin-top: 20px;
    padding: 12px 24px;
    background: #0073aa;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s ease;
    font-size: clamp(0.9em, 1.5vw, 1em);
    min-height: 44px;
    min-width: 44px;
    box-sizing: border-box;
}

.no-games-message .button:hover {
    background: #005a87;
}

/* =============================================================================
   アクセシビリティ対応
   ============================================================================= */

/* 高コントラストモード対応 */
@media (prefers-contrast: high) {
    #novel-choices .choice-item,
    .novel-choices .choice-item {
        border-width: 3px;
    }

    #novel-choices .choice-item.selected,
    .novel-choices .choice-item.selected {
        border-color: #fff;
        background: rgba(255, 255, 255, 0.5);
    }

    .novel-game-title {
        background: rgba(255, 255, 255, 1);
        border: 2px solid #000;
    }

    #novel-dialogue-box,
    .novel-dialogue-box {
        background: rgba(0, 0, 0, 1);
        border: 2px solid #fff;
    }

    #novel-choices .choice-list,
    .novel-choices .choice-list {
        background: rgba(0, 0, 0, 1);
        border: 2px solid #fff;
    }
}

/* 動きを減らす設定への対応 */
@media (prefers-reduced-motion: reduce) {
    #novel-choices .choice-item,
    .novel-choices .choice-item {
        transition: none;
        -webkit-transition: none;
        -moz-transition: none;
        -ms-transition: none;
    }

    #novel-choices .choice-item:hover,
    .novel-choices .choice-item:hover {
        transform: none;
        -webkit-transform: none;
        -moz-transform: none;
        -ms-transform: none;
    }

    #novel-choices .choice-item:active,
    .novel-choices .choice-item:active {
        transform: none;
        -webkit-transform: none;
        -moz-transform: none;
        -ms-transform: none;
    }

    .novel-game-card:hover {
        transform: none;
    }
}

/* =============================================================================
   レスポンシブデザイン - モバイルファースト
   ============================================================================= */

/* タブレット以上（768px以上） */
@media (min-width: 768px) {
    .novel-game-archive-container {
        padding: 30px;
    }

    .archive-header {
        margin-bottom: 50px;
    }

    .novel-games-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 25px;
    }

    .game-thumbnail {
        height: 200px;
    }

    .novel-character-left {
        max-width: 28%;
    }

    .novel-character-center {
        max-width: 32%;
    }

    .novel-character-right {
        max-width: 28%;
    }

    #novel-character,
    .novel-character {
        bottom: 15%;
        max-height: 45%;
    }

    #novel-dialogue-box,
    .novel-dialogue-box {
        padding: 25px;
        height: 160px; /* 固定高さ - タブレット以上 */
    }
    
    .novel-speaker-name {
        bottom: 120px; /* タブレット以上での位置調整 */
        font-size: 1em;
        padding: 8px 16px;
        min-height: 24px; /* 空欄時でも高さを維持 */
    }
    
    .novel-dialogue-text-container {
        flex: 1;
        display: flex;
        align-items: center;
    }
    
    #novel-dialogue-text {
        max-height: calc(1.6em * 3);
        font-size: clamp(16px, 2.5vw, 20px);
    }

    #novel-choices .choice-item,
    .novel-choices .choice-item {
        padding: 15px 25px;
        margin: 8px 0;
    }
}

/* デスクトップ（1024px以上） */
@media (min-width: 1024px) {
    .novel-game-archive-container {
        padding: 40px;
    }

    .novel-games-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        gap: 30px;
    }

    .game-thumbnail {
        height: 220px;
    }

    .novel-character-left {
        max-width: 30%;
    }

    .novel-character-center {
        max-width: 35%;
    }

    .novel-character-right {
        max-width: 30%;
    }

    #novel-character,
    .novel-character {
        bottom: 20%;
        max-height: 50%;
    }

    #novel-dialogue-box,
    .novel-dialogue-box {
        padding: 30px;
        height: 180px; /* 固定高さ - デスクトップ */
    }
    
    .novel-speaker-name {
        bottom: 140px; /* デスクトップでの位置調整 */
        font-size: 1.1em;
        padding: 10px 20px;
        min-height: 28px; /* 空欄時でも高さを維持 */
    }
    
    .novel-dialogue-text-container {
        flex: 1;
        display: flex;
        align-items: center;
    }
    
    #novel-dialogue-text {
        max-height: calc(1.6em * 3);
        font-size: clamp(18px, 2vw, 22px);
    }
}

/* 大画面（1200px以上） */
@media (min-width: 1200px) {
    .novel-games-grid {
        grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    }

    .game-thumbnail {
        height: 250px;
    }
}

/* =============================================================================
   モバイル縦画面特化（Portrait）
   ============================================================================= */

@media (max-width: 767px) and (orientation: portrait) {
    #novel-game-container {
        height: 100vh;
        height: 100dvh; /* 動的ビューポート対応 */
    }

    .novel-game-title {
        font-size: 16px;
        margin-bottom: 10px;
        padding: 8px;
    }

    .novel-character-left {
        left: 2%;
        max-width: 25%;
        max-height: 35%;
    }

    .novel-character-center {
        max-width: 30%;
        max-height: 35%;
    }

    .novel-character-right {
        right: 2%;
        max-width: 25%;
        max-height: 35%;
    }

    #novel-character,
    .novel-character {
        bottom: 25%;
        max-height: 35%;
    }

    #novel-dialogue-box,
    .novel-dialogue-box {
        padding: 15px;
        height: 100px; /* 固定高さ - モバイル縦画面 */
        font-size: 14px;
    }
    
    .novel-speaker-name {
        bottom: 85px; /* モバイル縦画面での位置調整 */
        font-size: 12px;
        padding: 4px 8px;
        min-height: 16px; /* 空欄時でも高さを維持 */
    }
    
    .novel-dialogue-text-container {
        flex: 1;
        display: flex;
        align-items: center;
    }
    
    #novel-dialogue-text {
        max-height: calc(1.5em * 3);
        font-size: 14px;
        line-height: 1.5;
    }

    #novel-choices,
    .novel-choices {
        bottom: 10%;
        left: 10%;
        width: 80%;
    }

    #novel-choices .choice-list,
    .novel-choices .choice-list {
        padding: 15px;
        font-size: 14px;
    }

    #novel-choices .choice-item,
    .novel-choices .choice-item {
        padding: 15px;
        margin: 10px 0;
        font-size: 14px;
        min-height: 48px; /* タッチ対応 */
    }

    /* アーカイブページ */
    .novel-game-archive-container {
        padding: 15px;
    }

    .archive-header {
        margin-bottom: 20px;
    }

    .novel-games-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .game-thumbnail {
        height: 160px;
    }

    .game-overlay {
        padding: 10px;
    }

    .play-button {
        padding: 6px 12px;
        border-radius: 15px;
    }
}

/* =============================================================================
   モバイル横画面特化（Landscape）
   ============================================================================= */

@media (max-width: 767px) and (orientation: landscape) {
    #novel-game-container {
        height: 100vh;
        height: 100dvh; /* 動的ビューポート対応 */
    }

    .novel-game-title {
        font-size: 14px;
        margin-bottom: 5px;
        padding: 5px;
    }

    .novel-character-left {
        left: 2%;
        bottom: 15%;
        max-width: 20%;
        max-height: 40%;
    }

    .novel-character-center {
        left: 40%;
        bottom: 15%;
        max-width: 20%;
        max-height: 40%;
    }

    .novel-character-right {
        right: 2%;
        bottom: 15%;
        max-width: 20%;
        max-height: 40%;
    }

    #novel-character,
    .novel-character {
        bottom: 20%;
        max-height: 40%;
    }

    #novel-dialogue-box,
    .novel-dialogue-box {
        padding: 10px;
        height: 80px; /* 固定高さ - モバイル横画面 */
        font-size: 12px;
        left: 0;
        width: 55%;
    }
    
    .novel-speaker-name {
        bottom: 65px; /* モバイル横画面での位置調整 */
        font-size: 10px;
        padding: 3px 6px;
        min-height: 14px; /* 空欄時でも高さを維持 */
    }
    
    .novel-dialogue-text-container {
        flex: 1;
        display: flex;
        align-items: center;
    }
    
    #novel-dialogue-text {
        max-height: calc(1.4em * 3);
        font-size: 12px;
        line-height: 1.4;
    }

    #novel-choices,
    .novel-choices {
        bottom: 5%;
        left: 5%;
        width: 50%;
    }

    #novel-choices .choice-list,
    .novel-choices .choice-list {
        padding: 10px;
        font-size: 12px;
    }

    #novel-choices .choice-item,
    .novel-choices .choice-item {
        font-size: 12px;
        padding: 8px 12px;
        margin: 3px 0;
        min-height: 36px;
    }

    /* アーカイブページ */
    .novel-games-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 10px;
    }

    .game-thumbnail {
        height: 120px;
    }

    .archive-header {
        margin-bottom: 15px;
    }
}

/* =============================================================================
   小画面デバイス（480px以下）
   ============================================================================= */

@media (max-width: 480px) {
    .novel-game-title {
        font-size: 15px;
        padding: 6px;
    }

    #novel-dialogue-box,
    .novel-dialogue-box {
        padding: 12px;
        font-size: 13px;
        height: 90px; /* 固定高さ - 小画面 */
    }
    
    .novel-speaker-name {
        bottom: 75px; /* 小画面での位置調整 */
        font-size: 11px;
        padding: 3px 6px;
        min-height: 15px; /* 空欄時でも高さを維持 */
    }
    
    .novel-dialogue-text-container {
        flex: 1;
        display: flex;
        align-items: center;
    }
    
    #novel-dialogue-text {
        max-height: calc(1.5em * 3);
        font-size: 13px;
        line-height: 1.5;
    }
    
    #novel-dialogue-text {
        max-height: calc(1.5em * 3);
        font-size: 13px;
        line-height: 1.5;
    }

    #novel-choices .choice-item,
    .novel-choices .choice-item {
        font-size: 13px;
        padding: 12px;
        min-height: 44px;
    }

    .novel-game-archive-container {
        padding: 10px;
    }

    .archive-header {
        margin-bottom: 15px;
    }

    .novel-games-grid {
        gap: 10px;
    }

    .game-thumbnail {
        height: 140px;
    }

    .game-overlay {
        padding: 8px;
    }

    .play-button {
        padding: 4px 8px;
        font-size: 0.8em;
    }
}

/* =============================================================================
   タッチ対応スタイル
   ============================================================================= */

/* タッチフィードバック */
.touch-active {
    opacity: 0.7;
}

#novel-game-container.touch-active {
    filter: brightness(0.9);
}

/* タッチデバイス専用スタイル */
@media (hover: none) and (pointer: coarse) {
    #novel-choices .choice-item,
    .novel-choices .choice-item {
        padding: 16px 24px;
        font-size: 16px;
        min-height: 48px;
    }
    
    .play-button {
        padding: 10px 16px;
        min-height: 40px;
    }
    
    .no-games-message .button {
        padding: 16px 32px;
        min-height: 48px;
    }
}

/* =============================================================================
   ショートコード用スタイル
   ============================================================================= */

/* ショートコード内のプレイボタン */
.noveltool-play-button {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    text-decoration: none;
    display: inline-block;
    min-width: 120px;
    text-align: center;
}

.noveltool-play-button:hover {
    background: linear-gradient(45deg, #5a67d8, #6b46c1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    color: white;
    text-decoration: none;
}

.noveltool-play-button:active {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

/* ゲーム一覧グリッド */
.noveltool-game-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.noveltool-game-list-item {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.noveltool-game-list-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.noveltool-game-thumbnail {
    width: 100%;
    height: 200px;
    overflow: hidden;
}

.noveltool-game-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.noveltool-game-list-item:hover .noveltool-game-thumbnail img {
    transform: scale(1.05);
}

.noveltool-game-content {
    padding: 20px;
}

.noveltool-game-title {
    margin: 0 0 10px 0;
    font-size: 1.3em;
    font-weight: bold;
    color: #333;
}

.noveltool-game-title a {
    color: #333;
    text-decoration: none;
}

.noveltool-game-title a:hover {
    color: #667eea;
}

.noveltool-game-description {
    margin: 0 0 10px 0;
    color: #666;
    line-height: 1.5;
    font-size: 0.95em;
}

.noveltool-game-count {
    margin: 0 0 15px 0;
    color: #888;
    font-size: 0.9em;
}

.noveltool-game-actions {
    text-align: center;
}

/* レスポンシブ対応：ショートコード */
@media (max-width: 768px) {
    .noveltool-game-list-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .noveltool-game-thumbnail {
        height: 180px;
    }
    
    .noveltool-game-content {
        padding: 15px;
    }
    
    .noveltool-play-button {
        padding: 10px 20px;
        font-size: 14px;
        min-width: 100px;
    }
}

@media (max-width: 480px) {
    .noveltool-game-thumbnail {
        height: 160px;
    }
    
    .noveltool-game-content {
        padding: 12px;
    }
    
    .noveltool-game-title {
        font-size: 1.1em;
    }
}

/* =============================================================================
   設定ボタン・設定モーダル スタイル
   ============================================================================= */

/* タイトル画面の設定ボタン（右下に配置） */
.novel-title-settings-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 15;
    padding: 0;
}

.novel-title-settings-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
    color: white;
    transform: rotate(30deg);
}

.novel-title-settings-btn:focus {
    outline: 3px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

.novel-title-settings-btn svg {
    width: 22px;
    height: 22px;
}

/* 設定モーダルオーバーレイ */
/* フォールバック: body に append される場合（通常ケース） */
.novel-settings-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999; /* 過度に高い値は避ける */
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* ゲームオーバーレイ内に append されるケース: overlay 内で前面に表示 */
#novel-game-modal-overlay .novel-settings-modal-overlay {
    z-index: 10001; /* overlay 内で最前面に表示するために調整 */
}

/* 設定モーダル本体 */
.novel-settings-modal {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: novel-settings-modal-appear 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

@keyframes novel-settings-modal-appear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 設定モーダルヘッダー */
.novel-settings-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.novel-settings-modal-title {
    margin: 0;
    font-size: 1.3em;
    font-weight: bold;
    color: #333;
}

.novel-settings-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    line-height: 1;
}

.novel-settings-modal-close:hover {
    background: #eee;
    color: #333;
}

/* 設定モーダルコンテンツ */
.novel-settings-modal-content {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

/* データなしメッセージ */
.novel-settings-no-data {
    text-align: center;
    color: #666;
    padding: 30px 0;
    font-size: 1em;
}

/* データリスト */
.novel-settings-data-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* データ項目 */
.novel-settings-data-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.novel-settings-data-item:last-child {
    margin-bottom: 0;
}

.novel-settings-data-item:hover {
    background: #f1f3f4;
    border-color: #dee2e6;
}

/* データ情報 */
.novel-settings-data-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.novel-settings-data-label {
    font-weight: 600;
    color: #333;
    font-size: 1em;
}

.novel-settings-data-meta {
    font-size: 0.85em;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 削除ボタン */
.novel-settings-delete-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 15px;
    flex-shrink: 0;
}

.novel-settings-delete-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.3);
}

.novel-settings-delete-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* アクションエリア */
.novel-settings-actions {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    text-align: center;
}

/* 全データクリアボタン */
.novel-settings-clear-all-btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.novel-settings-clear-all-btn:hover {
    background: linear-gradient(135deg, #ff5252, #d84315);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.novel-settings-clear-all-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(255, 107, 107, 0.3);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .novel-title-settings-btn {
        bottom: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
    }
    
    .novel-title-settings-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .novel-settings-modal {
        width: 95%;
        max-height: 85vh;
    }
    
    .novel-settings-modal-header {
        padding: 15px 20px;
    }
    
    .novel-settings-modal-title {
        font-size: 1.1em;
    }
    
    .novel-settings-modal-content {
        padding: 20px;
    }
    
    .novel-settings-data-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .novel-settings-delete-btn {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .novel-title-settings-btn {
        bottom: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
    }
    
    .novel-title-settings-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .novel-settings-modal-header {
        padding: 12px 15px;
    }
    
    .novel-settings-modal-content {
        padding: 15px;
    }
    
    .novel-settings-data-item {
        padding: 12px;
    }
    
    .novel-settings-data-label {
        font-size: 0.95em;
    }
    
    .novel-settings-data-meta {
        font-size: 0.8em;
    }
    
    .novel-settings-clear-all-btn {
        padding: 10px 25px;
        font-size: 0.95em;
    }
}