@charset "UTF-8";

/* =========================================
   0. Poem Page
   ========================================= */
#page-poem {
    /* グラデーション設定 */
    background: linear-gradient(135deg, #fceb55 0%, #ff6633 50%, #ee0979 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
}

#page-poem .player-title {
    position: relative; 
    top: auto;
    margin-top: 5svh;   
    margin-bottom: 20px;
}

#page-poem .video-container {
    position: relative;
    z-index: 5;
    flex-shrink: 0;
}

#page-poem .player-clock-container {
    position: relative;
    top: auto;
    right: auto;
    transform: none;
    margin: 30px auto 20px auto;
    width: 30vmin;
    height: 30vmin;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
}

/* 横画面（landscape）時のみ右側に配置する */
@media (orientation: landscape) {
    #page-poem {
        display: grid;
        /* タイトル、ビデオ、時計、スロットを統合管理するグリッドを定義 */
        grid-template-areas: 
            "title title"
            "video clock"
            "slots slots";
        grid-template-columns: 1fr auto;
        grid-template-rows: auto 1fr auto;
        align-items: center; /* これによりビデオと時計の中心線が強制的に一致する */
        justify-items: center;
        height: 100%;
        padding: 10px 5%;
    }

    #page-poem .player-title {
        grid-area: title;
        position: static;
        margin: 0 0 10px 0;
    }

    #page-poem .video-container {
        grid-area: video;
        width: 100%;
        max-width: 70vh; /* 縦幅に合わせる */
        margin: 0;
    }

    #page-poem .player-clock-container {
        grid-area: clock;
        position: static;
        transform: none;
        width: 35vmin;
        height: 35vmin;
        margin-left: 20px;
        z-index: 10;
    }

    #page-poem .list-section {
        grid-area: slots;
        width: 100%;
        margin-top: 10px;
    }
}

#page-poem .clock-ui {
    border: 2px solid #ffffff !important; /* 枠線を黒から白に変更 */
}

/* ポエムページの時計円盤 */
#page-poem .clock-face {
    background-image: url('assets/ui/poemclock.png');
}

/* グリッドエリアの横幅を確保 */
#page-poem .list-section {
    width: 100%;
}

/* ポエムスロットの枠線設定 */
.poem-slot {
    border-width: 2px !important;
    border-style: solid !important;
}

.poem-red    { border-color: #ff4444 !important; }
.poem-blue   { border-color: #4444ff !important; }
.poem-yellow { border-color: #ffff44 !important; }
.poem-green  { border-color: #44ff44 !important; }

/* =========================================
   1. Player Page (再生画面)
   ========================================= */
#page-player {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    position: relative;
}

/* タイトル中央揃え (エラー修正: 01 play) */
.player-title {
    position: absolute;
    top: 10%; /* 上部配置 */
    width: 100%;
    text-align: center;
    font-size: 1.5rem;
    color: var(--text-main);
    z-index: 2;
    pointer-events: none;
}

.video-container {
    width: 80%;
    max-width: 800px;
    aspect-ratio: 16 / 9;
    background: #000;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    margin: 0 auto;
}

video { width: 100%; height: 100%; object-fit: cover; }

/* Playページ用 Empty表示 */
.video-placeholder {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: #1a2a3a;
    display: flex; justify-content: center; align-items: center;
    border: 2px dashed rgba(255,255,255,0.2);
    z-index: 1;
}
.video-placeholder .slot-label {
    font-size: 2rem;
    color: #666;
    letter-spacing: 4px;
    text-transform: uppercase;
}

/* 再生/停止オーバーレイ */
.video-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
    background: rgba(0,0,0,0.3);
    opacity: 0; transition: opacity 0.3s;
    pointer-events: none;
}
.video-overlay.paused { opacity: 1; }
.play-icon {
    font-size: 3rem; color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

/* プレイヤー時計の位置修正 (エラー修正: landscapeでの中心ズレ) */
.player-clock-container {
    position: absolute;
    right: 5%;
    top: 50%;
    transform: translateY(-50%);
    width: 30vmin;
    height: 30vmin;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;     
    z-index: 10;
}

/* =========================================
   2. storyboard Page
   ========================================= */
.page-content h2 {
    text-align: center;
    width: 100%;
}

.story-header {
    width: 100%;
    text-align: center;
    margin-bottom: 20px;
}

.story-header .sub-text {
    color: var(--text-sub);
    font-size: 0.9rem;
}

/* =========================================
   3. Editor Page (編集画面 - 核心部)
   ========================================= */
/* 上下2段構成のレイアウト定義 */
.editor-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: flex-start;
    gap: 10px;
    padding: 15px 0;
}

/* A. 上段: 素材ライブラリ */
.editor-library-section {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(40, 160, 220, 0.3); /* 青っぽい枠 */
}

/* B. 中央: 矢印 (オレンジ) */
.editor-arrow {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 30px;
}
.arrow-icon {
    color: var(--accent-orange); /* エラー修正: オレンジ色 */
    font-size: 1.5rem;
    animation: bounce 2s infinite;
}
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(5px); }
}

/* C. 下段: 絵コンテ */
.editor-board-section {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 68, 0.3); /* 黄色っぽい枠 */
}

/* 見出し (起承転結ラベル) */
.paging-label {
    margin: 0;
    padding: 0;
    font-size: 0.9rem;
    font-weight: bold;
    text-align: center;
    line-height: 1;
}

/* =========================================
   4. Slot Grid & Highlight (スロット)
   ========================================= */
.slot-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 常に4列 */
    gap: 8px;
    width: 100%;
}

.slot {
    aspect-ratio: 16 / 9;
    background-color: #1a2a3a; /* 画像がない時に見えるベース色を少し暗く */
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    position: relative; 
    cursor: pointer;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s;
}

/* サムネイル画像を枠いっぱいに敷き詰める */
.slot-thumbnail {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1; /* 画像は背面 */
    display: block;
}

/* テキスト類を画像の上に浮かせて読みやすくする */
.slot .asset-id, 
.slot .asset-price, 
.slot .slot-label, 
.slot .slot-number {
    position: relative;
    z-index: 2; /* テキストは前面 */
    text-shadow: 0 1px 3px rgba(0,0,0,0.8); /* 画像の上でも文字を読みやすく */
}

.slot:active { transform: scale(0.95); }

/* 状態別のスタイル */
.slot.owned { background-color: #2a4a6a; border-color: var(--accent-cyan); }
.slot.empty { background-color: #1a2a3a; opacity: 0.5; border-style: dashed; }
.slot.store { background-color: #3a2a4a; border-color: #d8bfd8; }

/* 選択中のハイライト (白く光る - 仕様厳守) */
.selected-glow {
    box-shadow: 0 0 15px #ffffff, inset 0 0 5px #ffffff;
    border-color: #ffffff !important;
    z-index: 10;
    animation: pulse-glow 1.5s infinite alternate;
}
@keyframes pulse-glow {
    from { box-shadow: 0 0 10px #ffffff; }
    to { box-shadow: 0 0 20px #ffffff; }
}

/* 鍵マークオーバーレイ (仕様 に基づく) */
.slot-lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 鍵マーク画像自体のスタイル */
.slot-lock-overlay img {
    width: 33%;
    height: auto;
    opacity: 0.9;
}

/* テキスト表示 */
.asset-id { font-size: 0.7rem; color: #fff; }
.asset-price { font-size: 0.7rem; color: #ffd700; margin-top: 2px; }
.slot-label { font-size: 0.8rem; color: #666; }
.slot-number { 
    position: absolute; top: 2px; left: 4px; 
    font-size: 0.6rem; color: rgba(255,255,255,0.7); 
}

/* =========================================
   5. Paging Buttons (RGBY - 核心部)
   ========================================= */
.paging-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

/* A. Assets & Store ページ：画面中央・最前面に固定するレイアウト */
#page-asset .paging-controls,
#page-store .paging-controls {
    position: fixed;
    top: 50%;
    left: 0;
    width: 100%;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 5vmin;
    z-index: 50;
    pointer-events: none;
}

/* B. Editor ページ：各セクション内の上部に配置するレイアウト */
#page-editor .paging-controls {
    position: static;
    display: flex;
    justify-content: space-between;
    align-items: center; 
    width: 100%;
    margin-bottom: 0;    
    pointer-events: auto;
}

.paging-btn {
    pointer-events: auto;
    width: 8vmin; 
    min-width: 40px;
    height: 6vmin;
    min-height: 30px;
    border: none; border-radius: 4px;
    color: #fff; font-weight: bold;
    cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    transition: transform 0.1s, box-shadow 0.1s, filter 0.1s;
}
.paging-btn:active {
    transform: scale(1.1);
    filter: brightness(1.2);
}

/* 各色ごとのクリック時の発光（グロー効果）の設定 */
.btn-red:active    { box-shadow: 0 0 15px #ff6b6b; }
.btn-blue:active   { box-shadow: 0 0 15px #54a0ff; }
.btn-green:active  { box-shadow: 0 0 15px #2ecc71; }
.btn-yellow:active { box-shadow: 0 0 15px #f1c40f; }

/* 色定義 (UIUX仕様厳守) */
.btn-red    { background: linear-gradient(to bottom, #ff6b6b, #c0392b); }
.btn-blue   { background: linear-gradient(to bottom, #54a0ff, #2980b9); }
.btn-green  { background: linear-gradient(to bottom, #2ecc71, #27ae60); }
.btn-yellow { background: linear-gradient(to bottom, #f1c40f, #f39c12); color: #333; }

/* =========================================
   6. Clock UI (時計)
   ========================================= */
.clock-ui {
    width: 100%; height: 100%;
    position: relative;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.2);
}
.clock-face {
    width: 100%; height: 100%;
    position: relative;
    background-image: url('assets/ui/clock.jpg'); 
    background-size: cover;     /* 枠いっぱいに表示 */
    background-position: center; /* 中央合わせ */
    border-radius: 50%;         /* ロゴを円形に切り抜き */
}
.clock-hand {
    position: absolute;
    top: 50%; left: 50%;
    width: 50%; height: 2px;
    background-color: var(--accent-orange);
    transform-origin: 0% 50%; 
    transform: rotate(-90deg);
}
/* ドラッグ中の拡大 */
.clock-ui.dragging { transform: scale(1.1); border-color: var(--accent-orange); }

/* =========================================
   7. Preview Overlay (ボタン制御)
   ========================================= */
.preview-actions {
    position: absolute;
    top: 15px;
    left: 15px;
    display: flex;
    gap: 10px;
    z-index: 102;
}

#preview-title {
    text-align: center;
    margin: 0;
    padding: 0 60px; /* 左右のボタン（GET/削除とバツ印）との重なりを防止 */
    font-size: 1.1rem;
    line-height: 32px; /* ボタンの高さに合わせて垂直方向を整列 */
}
.action-btn {
    padding: 10px 25px;
    border: none; border-radius: 20px;
    font-weight: bold; cursor: pointer;
    color: #fff;
}

/* 共通ダイアログのOKボタンの視認性改善 (指示 対応) */
#btn-dialog-ok {
    background-color: #fff;
    color: #000;
}

.btn-get { background: var(--accent-orange); }
.btn-delete { background: #e74c3c; }

/* コンテキスト制御用: hiddenクラスは style_base.css にある想定だが念のため */
.hidden { display: none !important; }

/* =========================================
   8. Responsive (Landscape/Portrait)
   ========================================= */
/* Landscape (横画面) デフォルト */
/* 1. .center-content (アセット/ストア/ポエム)
   2. .editor-container (エディタ)
   3. #page-storyboard .page-content (ストーリーボード)
   これら全てのメインコンテナに対して幅制限を適用します。
*/
.center-content,
.editor-container,
#page-storyboard .page-content {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: 100%;
    gap: 10px;
    padding: 15px 10px;
    /* --- PC/横画面での幅制限と中央寄せ --- */
    width: 80%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Portrait (縦画面)  */
@media (orientation: portrait) {
    /* --- 修正: 縦画面ではすべてのコンテナの横幅を100%に戻す --- */
    .center-content,
    .editor-container,
    #page-storyboard .page-content {
        width: 100%;
    }

    .slot-grid { grid-template-columns: repeat(2, 1fr); } /* 2列にする */
    
    /* shot_0000 (slot-big) を横2列・縦2列分に拡大 */
    .slot.slot-big {
        grid-column: span 2;
        grid-row: span 2;
    }

    /* 17個のスロットが表示された際、最下部がフッターに隠れないよう余白を追加 */
    .list-section {
        padding-bottom: 80px;
    }

    .video-container { width: 95%; margin-top: 20px; }
    .player-clock-container {
        position: relative; right: auto; top: auto;
        transform: none; margin: 20px auto;
    }
}

/* =========================================
   9. Settings Modal (Tab Style)
   ========================================= */
.settings-modal {
    background: #0f1f33; /* 暗い背景 */
    border: 1px solid #2c3e50;
    width: 90%; max-width: 500px;
    padding: 0; /* タブのためにパディング調整 */
    overflow: hidden;
}

/* 横画面（landscape）時の上書き設定を追加 */
@media (orientation: landscape) {
    .settings-modal {
        width: 55vw;         /* デバイス幅 */
        max-width: 800px;    
        max-height: 80dvh;   /* 画面内に収まるよう高さを制限 */
        overflow-y: auto;    /* 内部がはみ出す場合に備えてスクロールを許可 */
    }
}

/* タブヘッダー */
.settings-tabs {
    display: flex;
    border-bottom: 1px solid #2c3e50;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #8899aa;
    padding: 15px 0;
    cursor: pointer;
    font-size: 1rem;
    position: relative;
    transition: color 0.3s;
}

.tab-btn.active {
    color: #28a0dc; /* シアン系の青 */
}

/* 選択中のタブの下線 */
.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; width: 100%;
    height: 3px;
    background-color: #28a0dc;
}

/* コンテンツエリア */
.tab-content {
    display: none; /* デフォルト非表示 */
    padding: 0 20px 30px 20px;
    text-align: center; /* 中央揃え (UIUX指摘対応) */
}
.tab-content.active {
    display: block; /* 選択中のみ表示 */
    animation: fadeIn 0.3s;
}

/* 閉じるボタン専用 */
.settings-header-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height); 
    display: flex;
    justify-content: flex-end;   
    align-items: center;
    padding: 0 15px;
    pointer-events: none;
}

.settings-close-btn {
    pointer-events: auto;
    z-index: 10;
}

/* 各要素のスタイル */
.settings-label { 
    color: #fff; 
    margin-bottom: 1.5rem; /* 指示に基づき1行分のスペース(1.5rem)を確保 */
    font-size: 0.9rem; 
}
.coin-value { font-size: 1.5rem; font-weight: bold; margin: 10px 0 20px 0; }

/* ボタンデザインの統一 */
.btn-charge, .btn-export, .btn-restore, .btn-apply-start, .btn-upload-start, .btn-pay-start {
    background-color: #28a0dc !important;
    color: #ffffff !important;
    width: 100%;
    padding: 12px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    border: none;
}

.price-info { color: #fff; font-size: 0.8rem; margin-top: 1.5rem; }

.restore-desc {
    text-align: left;
    font-size: 0.9rem;
    color: #fff;
    line-height: 1.6;
    margin-bottom: 20px;
}

#recovery-email {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box; /* 枠からはみ出し防止 */
}

.restore-note {
    font-size: 0.8rem;
    color: #fff;
    margin-top: 15px;
    text-align: left;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   10. Store Page (Actor Selection)
   ========================================= */
/* ストア上部の見出しとボタンの配置コンテナ */
.store-header-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(10px, 5vw, 30px);
    padding: 20px 10px;
}

/* ニコニコマークボタン：レスポンシブな正円維持 */
.actor-btn {
    width: 12vmin !important; /* 小さい方の画面幅に対して12% */
    height: 12vmin !important;
    min-width: 50px !important;
    min-height: 50px !important;
    max-width: 80px;
    max-height: 80px;
    
    aspect-ratio: 1 / 1 !important; /* 強制的に正方形を維持 */
    border-radius: 50% !important; /* 完璧な正円に切り抜き */
    flex-shrink: 0; /* 親の圧縮に抵抗して形を守る */
    
    display: flex !important;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 0 !important;
    border: none !important;
}

/* ボタン内画像のフィッティング */
.actor-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 比率を維持して中央で切り抜き */
}

/* ドロップダウンメニューのラップ（絶対配置） */
#actor-dropdown-wrapper {
    transition: opacity 0.2s, transform 0.2s;
}
#actor-dropdown-wrapper.hidden {
    display: none !important;
}

/* --- アクター選択用：グリッド列数の個別設定 --- */
#actor-select-overlay .slot-grid {
    grid-template-columns: repeat(6, 1fr); 
}

@media (orientation: portrait) {
    #actor-select-overlay .slot-grid {
        grid-template-columns: repeat(3, 1fr); 
    }
}

/* --- アクター選択用：正方形タイル設定 --- */
.actor-select-slot {
    aspect-ratio: 1 / 1 !important; /* 強制的に正方形を維持 */
    background-color: #28a0dc;
    border: 2px solid #fff !important;
    position: relative;
    overflow: hidden;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column;
    justify-content: flex-end; /* テキストを下部に配置 */
}

/* スロット内のサムネイル画像 */
.actor-select-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 比率を維持して中央で切り抜き */
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* テキスト（Actor 0001等）を画像の上に重ねる */
.actor-select-slot .asset-id {
    position: relative;
    z-index: 2;
    background: rgba(0, 0, 0, 0.6); /* 視認性を高める背景 */
    width: 100%;
    text-align: center;
    padding: 2px 0;
}

/* =========================================
   10-2. Store Sort Navigation (並び順切替)
   ========================================= */
.store-sort-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 20px;
    width: 100%;
}

.sort-tab {
    font-size: 1.2rem;
    font-weight: bold;
    color: #8899aa; /* 非選択時はグレー */
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 5px 15px;
}

/* 選択中のスタイル (並び順.png の発光を再現) */
.sort-tab.active {
    color: #ffffff;
    text-shadow: 0 0 10px #ffffff, 0 0 20px var(--accent-cyan);
}

.sort-tab:hover {
    color: #ffffff;
    filter: brightness(1.2);
}

/* =========================================
   11. AB Preview Page
   ========================================= */
#page-abpreview {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    gap: 10px;
}

.ab-header {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 5px;
}

.ab-title {
    font-size: 1.4rem;
    margin: 0;
    color: var(--text-main);
}

.ab-audio-toggle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.ab-audio-toggle img {
    height: 30px;
    width: auto;
}

.ab-video-area {
    width: 85vw;          
    max-width: 800px;     
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.ab-video-container {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ab-video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain; /* 16:9枠内に収める */
}

.ab-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    z-index: 1;
}

.ab-controls {
    width: 90vw;          
    max-width: 800px;     
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 15px 0;
    margin-top: auto;
}

.ab-control-btn {
    width: 16vw;
    height: 16vw;
    max-width: 100px;
    max-height: 100px;
    border-radius: 15px;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: transform 0.1s;
}

.ab-control-btn:active {
    transform: scale(0.9);
}

.ab-control-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ボタン色指定 (画像に基づき再現) */
.btn-ab-upload { background-color: #d63384; } /* ピンク */
.btn-ab-play   { background-color: #ffc107; } /* 黄色 */
.btn-ab-reset  { background-color: #ffc107; } /* 黄色 */
.btn-ab-audio  { background-color: #d63384; } /* ピンク（旧カメラボタンから継承） */

/* Landscape (横画面) 時のみ動画を左右に並べ、ボタンを縮小する */
@media (orientation: landscape) {
    .ab-video-area {
        flex-direction: row; 
        width: 90vw;         /* 画面幅の95%まで拡大 */
        max-width: 1200px;   /* 上限を1200pxに引き上げ */
        margin: 0 auto;
        gap: 15px;
        align-items: center;
    }
    .ab-video-container {
        flex: 1;            
    }
    .ab-controls {
        width: 100%;
        justify-content: center;
        align-items: center;  /* ★追加：ボタンが縦に伸びるのを防ぐ */
        gap: 5vw;             /* ★修正：dvhからvwに変更して適切な間隔にする */
        padding: 0;
        margin-top: 5px;
    }
    .ab-control-btn {
        width: 7vw;         
        height: 7vw;       
        max-width: 120px;    
        max-height: 120px;   
        border-radius: 12px; /* サイズに合わせて角丸を調整 */
    }
}

/* =========================================
   12. ABプレビュー画面　Video A Selection Modal (動画A選択)
   ========================================= */
#video-a-select-grid {
    width: 100%;
    max-height: 70vh; /* モーダル内でスクロール可能にするための高さ制限 */
    overflow-y: auto;
    padding-right: 5px; /* スクロールバーとの干渉防止 */
}

/* ストーリボードと同じセクションヘッダーの維持 */
#video-a-select-grid .story-section-header {
    display: flex;
    align-items: baseline;
    border-left: 5px solid transparent; /* 色はJSで動的に付与 */
    padding-left: 10px;
    margin: 20px 0 10px 0;
}

/* モーダル内のグリッド余白調整 */
#video-a-select-grid .slot-grid {
    margin-bottom: 20px;
}

/* =========================================
   13. 16マス Preview Placement Grid (プレビュー内配置機能)
   ========================================= */
.preview-placement-area {
    margin-top: 15px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.p-grid-label-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 65vw;
}

.p-grid-label {
    font-size: 0.8rem;
    color: var(--text-sub);
    width: 1.5rem;
    text-align: center;
    font-weight: bold;
}

.p-slot-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    flex: 1;
}

.p-slot-btn {
    aspect-ratio: 1 / 1;
    border-radius: 4px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    font-size: 1.0rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

/* 起承転結カラー (TableAct参考: 半透明背景 + 強めの枠線) */
/* 未配置時（通常）は枠線のみ色を薄く付ける */
.p-slot-red    { border-color: rgba(255, 68, 68, 0.4); }
.p-slot-blue   { border-color: rgba(68, 68, 255, 0.4); }
.p-slot-green  { border-color: rgba(68, 255, 68, 0.4); }
.p-slot-yellow { border-color: rgba(255, 255, 68, 0.4); }
.p-slot-pink   { border-color: rgba(255, 59, 100, 0.4); } 

/* 配置済み (光っている状態) */
.p-slot-btn.active {
    border-width: 2px;
    border-style: solid;
    box-shadow: 0 0 12px currentColor;
    transform: scale(1.05);
}

.p-slot-red.active    { background: rgba(255, 68, 68, 0.5); border-color: #ff4444; color: #fff; }
.p-slot-blue.active   { background: rgba(68, 68, 255, 0.5); border-color: #4444ff; color: #fff; }
.p-slot-green.active  { background: rgba(68, 255, 68, 0.5); border-color: #44ff44; color: #fff; }
.p-slot-yellow.active { background: rgba(255, 255, 68, 0.5); border-color: #ffff44; color: #333; }
.p-slot-pink.active   { background: rgba(255, 59, 100, 0.5); border-color: #FF3CA0; color: #fff; } 
/* クリック時のフィードバック (一瞬小さくなる) */
.p-slot-btn:active {
    transform: scale(0.9);
}