/* ==========================================
   PianoWorks Common Components (components.css)
   ========================================== */

/* --- 1. アンティーク刻印ボタン (Standard Stamp) --- */
.btn-stamp-base {
    background: transparent;
    cursor: pointer;
    font-family: var(--font-serif);
    font-weight: 900;
    color: var(--color-wood-dark);
    border: 1.5px solid var(--color-wood-dark);
    border-radius: 3px;
    text-shadow: var(--shadow-stamp);
    box-shadow: -1px -1px 1px rgba(0, 0, 0, 0.8), 
                1px 1px 0px rgba(255, 255, 255, 0.3), 
                var(--shadow-inset-soft);
    white-space: nowrap;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-stamp-base:hover {
    filter: brightness(1.3);
    background: rgba(255, 255, 255, 0.1);
}

.btn-stamp-base:active {
    transform: translateY(1px);
    box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* --- 2. アンティーク金縁ボタン (Gold Stamp) --- */
.btn-stamp-gold {
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    color: var(--color-gold-antique) !important;
    padding: 4px 14px;
    border: 1px solid rgba(80, 60, 40, 0.7);
    box-shadow: var(--shadow-inset-soft), 1px 1px 1px rgba(255, 255, 255, 0.1);
    text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    transition: all 0.3s ease;
}

.btn-stamp-gold:hover {
    color: var(--color-accent-red) !important;
    box-shadow: 0 0 8px rgba(255, 0, 100, 0.4), var(--shadow-inset-soft);
}

/* --- 3. 木目調ディスプレイ (Inset Display) --- */
.display-sunken {
    font-family: var(--font-mono);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: var(--shadow-inset-deep);
    border-radius: 2px;
    color: rgba(210, 180, 140, 0.5);
}

/* イーゼルのホバー */
.playlist-easel:hover {
    /* 少し大きくしつつ、浮き上がるような動き（cubic-bezierを活かす） */
    transform: scale(1.03) translateY(-5px);
    filter: brightness(1.05);
}

/* ホバー時の挙動を再定義 */
.playlist-easel:hover {
    /* 左側へ膨らまないよう、中心ではなく右端を軸に拡大するか、微調整する */
    transform: scale(1.05) translateY(-5px);
    filter: brightness(1.1);
}

/* ★ 初回ログイン時のみ表示される、はてなボタンを指す吹き出し */
#first-visit-help-tip {
    position: fixed;
    top: 24px;
    right: 166px; /* ヘルプボタンから40px伸ばした矢印の分、ボックスを遠ざける */
    width: 280px;  /* ★ より横長に */
    padding: 10px 16px;
    background: rgba(20, 20, 20, 0.95);
    border: 2px solid var(--brass-color);
    border-radius: 8px;
    color: #f0e6d2;
    font-family: 'Kiwi Maru', 'Hiragino Mincho ProN', serif;
    font-size: 13px;
    line-height: 1.5;
    white-space: nowrap; /* 横長なので基本1行で収める */
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
    z-index: 300;
    opacity: 0;
    pointer-events: none;
}

/* ★ 右向きの矢印（はてなボタンの方向を指す。40px伸ばした） */
#first-visit-help-tip::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -50px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 0 8px 50px;
    border-color: transparent transparent transparent var(--brass-color);
}

/* ギアボタン（フローティング） */
.settings-floating-btn {
    position: fixed;
    top: var(--settings-btn-top);
    right: var(--settings-btn-right);
    width: var(--settings-btn-size);
    height: var(--settings-btn-size);
    z-index: 200!important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brass-color);
    background: radial-gradient(circle at 35% 35%, #3a3a3a, #1a1a1a);
    border: 2px solid var(--brass-color);
    border-radius: 50%;
    box-shadow: 0 4px 8px var(--brass-shadow), inset 0 0 8px rgba(0, 0, 0, 0.8);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.settings-floating-btn:hover {
    transform: rotate(90deg) scale(1.1);
    color: var(--brass-light);
    border-color: var(--brass-light);
    box-shadow: 0 0 15px rgba(181, 166, 66, 0.5), 0 6px 12px var(--brass-shadow);
}

/* ヘルプボタン（？マーク） --- ギアボタンと同デザイン、その左側に配置 */
.help-floating-btn {
    /* ギアボタン（right: var(--settings-btn-right)）の、さらにサイズ＋余白分左へ */
    right: calc(var(--settings-btn-right) + var(--settings-btn-size) + 12px);
}

.help-floating-btn .help-mark {
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: bold;
    font-size: 20px;
    line-height: 1;
}

/* ？マークは回転させると読みづらいため、ギアと違って拡大のみのホバーにする */
.help-floating-btn:hover {
    transform: scale(1.1);
}

/* 設定ボードの基本構造 */
.settings-board-container {
    min-width: 520px;
    /* 修正：100vhから少し短くして、上下の縁がブラウザ内に収まるようにする */
    height: calc(100% - 13px); 
    
    background: linear-gradient(135deg, #3d2b1f 0%, #261a12 100%);
    
    /* 修正：左右だけでなく、上下にも縁（border）を追加・統合 */
    border: 2px solid #634a35;
    
    padding: 40px;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    position: fixed;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 30px;
    box-sizing: border-box;
    animation: modalSlideDown 0.2s ease-out;

}

/* ラジオボタン（真鍮風カスタマイズ） */
.radio-group {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 40px;
    padding: 10px 0;
}

.radio-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    color: #e0cda9;
    font-size: 0.9rem;
    font-family: var(--font-serif);
    transition: all 0.2s ease;
}

.radio-label input[type="radio"] {
    cursor: pointer;
    accent-color: #bfa110; 
    width: 20px;
    height: 20px;
    margin: 0;
}

/* アニメーションの中身を定義 */
@keyframes modalSlideDown {
    from { 
        opacity: 0; 
        transform: translateY(-10px); /* 少し上から */
    }
    to { 
        opacity: 1; 
        transform: translateY(0);    /* 定位置へ */
    }
}

/* ============================================================
   5. 外部連携 (イーゼル・プレイリスト) 
   ============================================================ */

/* 1. プレイリストアイコン（本） */
.playlist-icon-wrapper {
    position: fixed;   
    bottom: 525px; /* ★ 合計25px上に移動（500px → 520px → 525px） */
    right: 50px;      /* イーゼルと重ならないよう、この数値を調整してください */
    width: 120px; 
    z-index: 10000;    
    cursor: pointer; 
    pointer-events: auto !important; 
    transition: transform 0.2s ease, filter 0.2s ease;
}

.playlist-icon-wrapper img { 
    width: 100%; 
    height: auto; 
    filter: drop-shadow(4px 4px 8px rgba(0,0,0,0.5)); 
}

.playlist-icon-wrapper:hover {
    transform: scale(1.1);
    filter: brightness(1.1);
}

/* 2. MIDIステーション・コンテナ */
.midi-station-container {
    position: absolute; 
    right: -55px;          /* 右端に固定 */
    bottom: 200px; /* ★ さらに20px下へ */
    width: 0;          /* コンテナ自体の幅を0にして干渉を防ぐ */
    height: 0; 
    z-index: 100; 
    pointer-events: none; 
    overflow: visible; /* 中身をはみ出させて表示 */
}

/* 3. イーゼル本体（label） */
.playlist-easel {
    display: block;
    position: absolute; 
    bottom: 10px;          /* コンテナの右端（画面右端）を基準にする */
    right: -75px;
    width: 250px; 
    height: 300px;     /* クリック判定の高さもしっかり確保 */
    cursor: pointer;
    pointer-events: auto; 
    transform: translateX(-50px); /* ★これで画面内に引き戻す（数値は調整してください） */
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.2s ease;
}

.playlist-easel:hover {
    /* ホバー時は translateX を維持したまま浮かせる */
    transform: translateX(-50px) scale(1.05) translateY(-5px);
    filter: brightness(1.1);
}

/* イーゼル画像 */
.playlist-easel img {
    /* ★重要：画像の透明な部分が「本」を邪魔しないよう、画像自体のイベントは切る */
    pointer-events: none; 
    width: 450px;
    display: block;
    margin-left: -200px; /* 位置の微調整 */
    filter: drop-shadow(12px 12px 25px rgba(0, 0, 0, 0.6));
}

/* ==========================================
   独立設定：設定画面 (Settings)
   ========================================== */
.settings-overlay {
    display: none; /* JSで flex に切り替え */
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000; /* 最前面 */
    justify-content: center;
    align-items: center;
    border-radius: 10px;
}

.settings-overlay .settings-board-container {
    box-sizing: border-box;
    width: 550px;      /* ★ min-widthのみだと中身次第で幅がズレるため、固定値にして設定画面・ヘルプ画面を確実に揃える */
    min-width: 550px;
    height: 98vh; /* ★画面の上から下まで */
    background: linear-gradient(135deg, #3d2b1f 0%, #261a12 100%);
    border-left: 2px solid #634a35;
    border-right: 2px solid #634a35;
    display: flex;
    flex-direction: column;
    animation: modalSlideDown 0.3s ease-out;
    border-radius: 10px;
}

/* ==========================================
   独立設定：プレイリスト (Playlist Archive)
   ========================================== */
/* --- プレイリスト内のCANCELボタンの透けを防止 --- */
#pw-board .btn-stamp-base {
    /* 透明を解除し、濃い茶色の背景を敷く */
    background: #3d2b1f !important;
    /* 質感を持たせるためのグラデーション（オプション） */
    background: linear-gradient(to bottom, #4a3526, #3d2b1f) !important;
    
    /* 枠線を少し明るくして、ボタンの輪郭をはっきりさせる */
    border-color: #634a35;
    color: #e0d0b0;
    
    /* ボタンの厚みを出すための影 */
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5), inset 1px 1px 1px rgba(255, 255, 255, 0.1);

    /* ★ 他モーダル（.settings-footer .btn-stamp-base）と寸法を統一 */
    min-width: 120px;
    height: 40px;
    font-size: 0.8rem;
    padding: 0 16px;
    box-sizing: border-box;
}

/* ホバー時は少し明るくする */
#pw-board .btn-stamp-base:hover {
    background: #523c2d !important;
    filter: brightness(1.1);
}



.playlist-overlay {
    display: none; /* JSで flex に切り替え */
    position: fixed; 
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); /* 背景をしっかり暗く */
    z-index: 9999; 
    justify-content: center;
    align-items: center;
}

.playlist-overlay .pw-board-container {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;

    background: #3d2b1f !important; 
    background: linear-gradient(135deg, #3d2b1f 0%, #261a12 100%) !important;
    
    min-width: 600px;
    width: 70vw;
    height: 99vh;
    
    border: 3px solid #634a35; 
    border-radius: 12px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
    padding: 20px;
    position: relative;
    overflow: hidden;

    /* ★ 追加：モーダルのスライドダウンアニメーション */
    animation: modalSlideDown 0.3s ease-out;
}


#pw-board .settings-body {
    flex: 1;
    overflow-y: auto; 
    overflow-x: hidden;
    /* --- ここを追加：!importantで透けを止める --- */
    background: #3d2b1f !important;
    /* ------------------------------------------- */
    position: relative;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: #634a35 transparent;
}

/* プレイリスト内のテーブルスタイル */
/* テーブル全体の基本設定 */
.archive-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    color: #e0d0b0;
    table-layout: fixed;
}

/* 各列の幅指定 */
/* 1. No. (細め) */
.archive-table th:nth-child(1) { width: 60px; }

/* 2. TITLE (残り全部) */
.archive-table th:nth-child(2) { width: auto; }

/* 3. MODE (Session/Studioどちらも省略されないよう少し広げる) */
.archive-table th:nth-child(3) { width: 95px; }

/* 4. DATE (旧3列目) */
.archive-table th:nth-child(4) { width: 120px; }

/* 5, 6, 7. DEMO, FILE, SHARE (旧4,5,6列目) */
.archive-table th:nth-child(5),
.archive-table th:nth-child(6),
.archive-table th:nth-child(7),
.archive-table th:nth-child(8) { width: 100px; }

/* データ行の設定 */
.archive-table td {
    border-bottom: 1px solid #634a35;
    border-right: 1px solid #634a35;
    padding: 12px 8px;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ★ MODE列：SessionとStudioが同じ大きさで、どちらも省略されずに収まるように */
.archive-table td:nth-child(3) {
    font-size: 0.75rem;
}

.archive-table th, .archive-table td {
    border: 1px solid #634a35; /* 既存の枠線色に合わせる */
    padding: 12px 8px;
    text-align: center;
    background: rgba(0, 0, 0, 0.2); /* 少し暗くして文字を見やすく */
}

.archive-table th {
    background: rgba(99, 74, 53, 0.3); /* ヘッダーを少し強調 */
    font-size: 0.8rem;
    font-weight: bold;
}

/* テーブル内のボタン共通 */
.archive-table button {
    background: transparent;
    border: 1px solid #634a35;
    color: #e0d0b0;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.archive-table button:hover {
    background: #634a35;
    color: #fff;
}

/* 𝕏ボタンだけ少しモダンに（黒っぽく） */
.table-btn-sns {
    font-weight: bold;
    border-color: #444 !important;
}

/* --- プレイリスト内のスクロール設定 --- */
#pw-board .settings-body {
    flex: 1;
    overflow-y: auto; 
    overflow-x: hidden;
    position: relative; /* stickyの基準点 */
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: #634a35 transparent;
}

/* スクロールバーのデザイン(Chrome, Edge, Safari用) */
#pw-board .settings-body::-webkit-scrollbar {
    width: 6px;
}
#pw-board .settings-body::-webkit-scrollbar-thumb {
    background: #634a35;
    border-radius: 10px;
}

/* --- テーブルの修正 --- */
.archive-table {
    width: 100%;
    /* 重要：collapseだとsticky時に枠線が消えるため、separateにして隙間を0にします */
    border-collapse: separate; 
    border-spacing: 0;
    margin-top: 0; /* stickyを上端に密着させるため */
    color: #e0d0b0;
    table-layout: fixed;
}

/* ヘッダーを固定する(重要) */
.archive-table thead th {
    position: sticky;
    top: 0;           /* 親要素の最上部に張り付く */
    z-index: 100;     /* データ行(td)より前面へ */
    background: #3d2b1f; /* 背景色がないと下の文字が透けます */
    padding: 12px 8px;
    font-size: 0.8rem;
    font-weight: bold;
    border-bottom: 2px solid #634a35; /* 見出しの下線をしっかり引く */
    border-right: 1px solid #634a35;
    text-align: center;
}

/* セリフ（★ 黒板の実描画範囲の左下に、専用の箱を常に表示） */
.blackboard-container {
    position: relative;
}

/* ★ セリフ専用の「雲のような」四角い箱。実測した黒板の緑の面(x:23〜354px, y:70〜367px)の
   左下に、10pxほどの余白を取って配置。テキストが無い時も箱自体は常時表示しておく。 */
.ai-mutter-box {
    position: absolute;
    /* ★★★ 修正：以前は translateY(-50%) で「中央基準」に配置していたため、
       セリフが増えて箱が大きくなると上辺も一緒に動いてしまっていた。
       上辺を固定値（現在の最小サイズ時点の見た目の上辺 184 - 88/2 = 140px）に
       する絶対位置に変更し、セリフが増えた分は下方向にだけ伸びるようにする。 */
    top: 140px;
    left: 196px;
    width: 148px;
    min-height: 88px; /* ★ 最小サイズは今までと同じ。セリフが長い時はここから伸びる */
    box-sizing: border-box;
    padding: 10px 14px;
    display: flex;
    align-items: flex-start;
    text-align: left;

    /* ★ 横長の角丸長方形。角の丸みを不揃いにし、わずかに傾けて手描き感を出す */
    background: radial-gradient(ellipse at 30% 25%, rgba(255, 255, 255, 0.20), rgba(255, 255, 255, 0.06) 75%);
    border: 2.5px solid rgba(255, 255, 255, 0.6);
    border-radius: 34px 44px 38px 46px / 42px 36px 46px 34px;
    transform: rotate(-0.8deg);

    /* ★ わずかにズラした二重線で「なぞり描き」したようなチョークの質感を追加 */
    box-shadow:
        0 0 14px rgba(255, 255, 255, 0.1) inset,
        0 0 10px rgba(255, 255, 255, 0.2),
        1.5px 2px 0 -1px rgba(255, 255, 255, 0.25);

    overflow: hidden;
    z-index: 6; /* キャラ画像より手前 */
    pointer-events: none;
}

.speech-bubble-text {
    /* 筆記体に近い日本語フォントに変更 */
    font-family: 'Kiwi Maru', serif; 
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.75); /* よりチョークらしい淡さに */
    letter-spacing: 0.08em;
    line-height: 1.5;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.3); /* ほのかな粉っぽさ */
    display: inline-block;
    white-space: pre-wrap; /* 改行を維持 */
}

/* 思考中や、独り言が消える時の演出用 */
.speech-bubble-text.thinking {
    opacity: 0.3;
}

.weather-visual-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* 画像が読み込まれた時に見えるよう、一時的にフィルタをオフに */
    filter: none; 
}

/* ★ キャラクター画像：黒板の実描画範囲(x:0〜263px, y:127〜370px)にほぼ収まる、少し小さめのサイズで表示。
   セリフ箱は z-index が上なので、画像と重なっても文字は読める。 */
/* ★ キャラクター画像：実物の blackboard.png(692x632)を元に実測した、
   黒板の緑の面の範囲（コンテナ380x440内で x:23〜354px, y:70〜367px, 幅331x高さ298）に配置。
   中心(188,218)から右に50px・上に20px寄せた位置が実際にちょうど良かったため、その値を使用。 */
.weather-visual-box {
    position: absolute; /* 他の要素を無視して配置 */
    top: 85px;
    left: 24px;

    display: flex;
    justify-content: center;
    align-items: center;
    width: 225px;
    height: 212px;
    z-index: 5;         /* セリフより背後、または手前に調整（必要に応じて） */
    
    transition: opacity 0.8s ease-in-out;
    background-color: transparent !important; /* 背景は完全に透明 */
    pointer-events: none; /* アイコンがクリックの邪魔をしないように */
}

#weather-image {
    width: 100%;  
    height: 100%;
    object-fit: contain;
    display: block;
}

/* ==========================================
   独立設定：ミニモーダル（ダウンロード成功画面）
   プレイリスト画面 (#pw-board) との整合性を維持
   ========================================== */

#toast-modal .mini-modal {
    /* 外枠：プレイリストの 3px solid #634a35 に統一 */
    border: 3px solid #634a35 !important;
    /* 背景：プレイリストと同じ重厚なグラデーション */
    background: linear-gradient(135deg, #3d2b1f 0%, #261a12 100%) !important;
    /* 形状：プレイリストの 12px に合わせる */
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
    width: 450px !important;
    min-height: 250px;

    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ヘッダー：プレイリストのテーブルヘッダー色に統一 */
#toast-modal .mini-modal .settings-header {
    background: rgba(99, 74, 53, 0.3) !important; 
    color: #e0d0b0 !important;
    padding: 12px 15px;
    /* 仕切り線：プレイリストの枠線色 #634a35 */
    border-bottom: 2px solid #634a35 !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ボディ：背景の透けを防止しつつメッセージを中央配置 */
#toast-modal .mini-modal .settings-body {
    background: transparent !important; 
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px !important;
}

/* メッセージテキスト */
#toast-message {
    color: #e0d0b0 !important;
    font-family: 'Kiwi Maru', serif;
    font-size: 1.15rem;
    font-weight: 400;
    text-align: center;
    line-height: 1.6;
    margin: 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
}

/* フッター：右寄せ設定と仕切り線の色を統一 */
#toast-modal .mini-modal .settings-footer {
    display: flex !important;
    justify-content: flex-end !important;
    padding: 15px 20px !important;
    /* 背景：少し暗くしてフッター感を出す */
    background-color: rgba(0, 0, 0, 0.2) !important; 
    /* 仕切り線：プレイリストの枠線色 #634a35 */
    border-top: 1px solid #634a35 !important;
}

/* フッター内のOKボタン（干渉防止のため詳細度を高めて再定義） */
#toast-modal .mini-modal .btn-stamp-base {
    margin-left: auto; 
    min-width: 100px;
    height: 36px;
    background: linear-gradient(to bottom, #4a3526, #3d2b1f) !important;
    border: 1.5px solid #634a35 !important;
    color: #e0d0b0 !important;
    position: static !important;
    transform: none !important;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5), inset 1px 1px 1px rgba(255, 255, 255, 0.1) !important;
}

#toast-modal .mini-modal .btn-stamp-base:hover {
    background: #523c2d !important;
    filter: brightness(1.2) !important;
}

#toast-modal.playlist-overlay {
    background: rgba(0, 0, 0, 0.75) !important;
    backdrop-filter: blur(2px);
    border: none !important;
    
    /* 追加：親(プレイリスト)の枠線を強制的に無視して画面全体に広げる */
    position: fixed;
    top: -5px;    /* 枠線の太さ分、わずかに外側へ広げる */
    left: -5px;
    width: calc(100% + 10px);
    height: calc(100% + 10px);
    
    /* 修正：スタック文脈を強制的にリセットする */
    z-index: 10000 !important; 
}

/* --- 選択モーダルの背景 --- */
#pw-select-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.55);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 99999;
}

/* --- モーダル本体（他の設定画面・Archiveと同じ木目デザインに統一） --- */
.pw-select-container {
    box-sizing: border-box;
    width: 420px;
    min-height: 33vh;
    background: #3d2b1f;
    background: linear-gradient(135deg, #3d2b1f 0%, #261a12 100%);
    border: 3px solid #634a35;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;

    /* ★ 追加：スライドダウンアニメーション */
    animation: modalSlideDown 0.3s ease-out;
}

/* ヘッダー（タイトル + 閉じるX）は他モーダルと共通の .settings-header をそのまま使用 */
.pw-select-container .settings-header {
    margin-bottom: 15px;
}

/* --- ボタンを縦に並べる --- */
.pw-select-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
    flex-grow: 1;
    padding: 10px 0;
}

/* --- Session / Studio Archive ボタン（他モーダルのボタンと同じ配色） --- */
.pw-select-btn {
    width: 100%;
    padding: 14px 0;
    font-size: 18px;
    letter-spacing: 1px;
    background: #3d2b1f;
    background: linear-gradient(to bottom, #4a3526, #3d2b1f);
    border-color: #634a35;
    color: #e0d0b0;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5),
                inset 1px 1px 1px rgba(255, 255, 255, 0.1);
}

.pw-select-btn:hover {
    background: #523c2d;
    filter: brightness(1.1);
}

/* CANCEL ボタンを右寄せ、フッターも他モーダルと同じ区切り線・余白に */
.pw-select-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 15px;
    border-top: 1px solid rgba(191, 161, 16, 0.2);
    margin-top: auto;
}

.pw-select-footer button {
    background: #3d2b1f;
    background: linear-gradient(to bottom, #4a3526, #3d2b1f);
    border-color: #634a35;
    color: #e0d0b0;
    /* ★ 他モーダル（.settings-footer .btn-stamp-base）と寸法を統一 */
    min-width: 120px;
    height: 40px;
    font-size: 0.8rem;
    padding: 0 16px;
    box-sizing: border-box;
}

.pw-select-footer button:hover {
    background: #523c2d;
    filter: brightness(1.1);
}

/* --- MIDI重複確認モーダルだけ高さを内容に合わせる --- */
#duplicate-confirm-modal .pw-select-container {
    min-height: 0;
}

#duplicate-confirm-modal .pw-select-body {
    flex-grow: 0;
}

/* --- 設定画面・ヘルプ画面（CANCEL / APPLY OK）も、Archiveと同じ木目ボタンに統一 --- */
#settings-modal-overlay .settings-footer button,
#help-modal-overlay .settings-footer button {
    background: #3d2b1f;
    background: linear-gradient(to bottom, #4a3526, #3d2b1f);
    border: 1px solid #634a35;
    color: #e0d0b0 !important;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5),
                inset 1px 1px 1px rgba(255, 255, 255, 0.1);
    text-shadow: none;
}

#settings-modal-overlay .settings-footer button:hover,
#help-modal-overlay .settings-footer button:hover {
    background: #523c2d;
    filter: brightness(1.1);
    color: #e0d0b0 !important;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5),
                inset 1px 1px 1px rgba(255, 255, 255, 0.1);
}

/* --- GAME ON背景設定の Customize / Default ボタンも同じ配色・寸法に統一。
   以前は透明地に暗い刻印文字の標準スタイルのままで、暗い背景の上で
   見えづらくなっていた。寸法も他のボタン（CANCEL等）と揃える。 --- */
#bg-customize-btn,
#bg-default-btn {
    background: #3d2b1f;
    background: linear-gradient(to bottom, #4a3526, #3d2b1f);
    border: 1px solid #634a35;
    color: #e0d0b0 !important;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5),
                inset 1px 1px 1px rgba(255, 255, 255, 0.1);
    text-shadow: none;
    /* ★ 他のボタン（CANCEL / APPLY OK等）と同じ寸法に統一 */
    min-width: 120px;
    height: 40px;
    font-size: 0.8rem;
    padding: 0 16px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

#bg-customize-btn:hover,
#bg-default-btn:hover {
    background: #523c2d;
    filter: brightness(1.1);
    color: #e0d0b0 !important;
}

/* --- オーバーレイ濃さスライダー：ボリュームスライダー(#master-volume)と同じデザイン --- */
#game-overlay-opacity-slider {
    -webkit-appearance: none;
    background: transparent;
    cursor: pointer;
}
#game-overlay-opacity-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: #1a1a1a;
    border-radius: 3px;
}
#game-overlay-opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 24px;
    width: 12px;
    background: linear-gradient(145deg, var(--color-gold-bright), #8b5a2b);
    border-radius: 2px;
    margin-top: -9px;
    border: 1px solid var(--color-wood-frame);
}

/* ==========================================
   Scoring モーダル（Playlist と同じデザイン）
   ========================================== */

/* 背景は playlist-overlay と同じ */
#pw-score-board {
    display: none; /* JSで flex に切り替え */
    position: fixed; 
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

/* モーダル本体（プレイリストと同じサイズ・質感） */
#pw-score-board .pw-board-container {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;

    background: #3d2b1f !important;
    background: linear-gradient(135deg, #3d2b1f 0%, #261a12 100%) !important;

    min-width: 600px;
    width: 70vw;
    height: 99vh;

    border: 3px solid #634a35;
    border-radius: 12px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
    padding: 20px;
    position: relative;
    overflow: hidden;

    /* ★ 追加：スライドダウンアニメーション */
    animation: modalSlideDown 0.3s ease-out;
}

/* 中身スクロール領域（プレイリストと同じ） */
#pw-score-board .settings-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #3d2b1f !important;
    position: relative;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: #634a35 transparent;
}

/* CANCEL ボタン（プレイリストと同じ） */
#pw-score-board .btn-stamp-base {
    background: #3d2b1f !important;
    background: linear-gradient(to bottom, #4a3526, #3d2b1f) !important;
    border-color: #634a35;
    color: #e0d0b0;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5),
                inset 1px 1px 1px rgba(255, 255, 255, 0.1);

    /* ★ 他モーダル（.settings-footer .btn-stamp-base）と寸法を統一 */
    min-width: 120px;
    height: 40px;
    font-size: 0.8rem;
    padding: 0 16px;
    box-sizing: border-box;
}

#pw-score-board .btn-stamp-base:hover {
    background: #523c2d !important;
    filter: brightness(1.1);
}

/* ★ Jukeboxモーダルのボタン（IMPORT MIDI・CANCEL）も他モーダルと同じデザインに統一 */

/* ============================================================
   簡易チュートリアル（Web版限定・スライド形式）
   ============================================================ */
.tutorial-container {
    min-width: 460px;
    max-width: 520px;
}

#tutorial-slide-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 36px;
    min-height: 260px;
}

.tutorial-slide-icon {
    font-size: 3.2rem;
    margin-bottom: 18px;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
    animation: tutorialIconIn 0.4s ease-out;
}

.tutorial-slide-title {
    font-family: var(--font-serif);
    color: #d2b48c;
    font-size: 1.15rem;
    font-weight: 900;
    letter-spacing: 1px;
    margin-bottom: 16px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.tutorial-slide-text {
    color: #e0cda9;
    font-family: 'Times New Roman', Times, serif;
    font-size: 0.95rem;
    line-height: 1.9;
}

.tutorial-footer {
    justify-content: space-between !important;
}

.tutorial-dots {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tutorial-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(210, 180, 140, 0.3);
    transition: background 0.2s ease, transform 0.2s ease;
}

.tutorial-dot.active {
    background: #d4af37;
    transform: scale(1.3);
}

.tutorial-nav-buttons {
    display: flex;
    gap: 12px;
}

@keyframes tutorialIconIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

#pw-jukebox-board .btn-stamp-base {
    background: #3d2b1f !important;
    background: linear-gradient(to bottom, #4a3526, #3d2b1f) !important;
    border-color: #634a35;
    color: #e0d0b0;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5),
                inset 1px 1px 1px rgba(255, 255, 255, 0.1);

    /* ★ 他モーダル（.settings-footer .btn-stamp-base）と寸法を統一 */
    min-width: 120px;
    height: 40px;
    font-size: 0.8rem;
    padding: 0 16px;
    box-sizing: border-box;
}

#pw-jukebox-board .btn-stamp-base:hover {
    background: #523c2d !important;
    filter: brightness(1.1);
}

/* ★ チュートリアルモーダルのボタン（戻る・次へ・×）も他モーダルと同じデザインに統一 */
#tutorial-modal-overlay .btn-stamp-base {
    background: #3d2b1f !important;
    background: linear-gradient(to bottom, #4a3526, #3d2b1f) !important;
    border-color: #634a35;
    color: #e0d0b0;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5),
                inset 1px 1px 1px rgba(255, 255, 255, 0.1);

    min-width: 120px;
    height: 40px;
    font-size: 0.8rem;
    padding: 0 16px;
    box-sizing: border-box;
}

#tutorial-modal-overlay .btn-stamp-base:hover {
    background: #523c2d !important;
    filter: brightness(1.1);
}

/* ============================================================
   ヘルプ画面：説明文中に実物と同じデザインのミニチュアボタンを表示する
   ============================================================ */
.help-btn-preview-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0;
}

.help-btn-preview {
    /* ★ 実際のボタンと全く同じクラスを流用しているため見た目はそのまま。
       ここではヘルプ内でのプレビュー用に、位置指定だけ無効化する。 */
    position: static !important;
    flex-shrink: 0;
    pointer-events: none; /* ヘルプ内では非操作（説明用の見本） */
    transform: none !important;
}

.help-btn-preview-desc {
    color: #e0cda9;
    font-size: 0.85rem;
    line-height: 1.6;
}

.help-easel-preview {
    width: 70px;
    height: auto;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}


/* --- アニメーション定義 --- */
@keyframes modalSlideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   GAME ON中にカスタム背景URLが有効な場合の透過演出
   （Sessionモードの .session-active と同じパターン）
   ============================================================ */

/* メインUI層（各種ボタン等）を透明化 */
.game-bg-active #ui-layer,
.game-bg-active #control-panel-wrapper,
.game-bg-active #midi-search-bar,
.game-bg-active .studio-seek-container {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 1.0s ease-in-out !important;
}

/* 鍵盤は消さず、半透明グラフィックにして背景を透けさせる */
.game-bg-active #view-piano {
    opacity: 0.5 !important;
    transition: opacity 1.0s ease-in-out !important;
}

/* 通常時に戻る時のリバースアニメーション用 */
#ui-layer,
#view-piano,
#control-panel-wrapper,
#midi-search-bar,
.studio-seek-container {
    transition: opacity 1.0s ease-in-out;
}

/* ============================================================
   カスタム背景表示中、画面左上に退避させるPLAY/STOPボタン
   ============================================================ */
#floating-transport-controls {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 300000; /* 暗幕・背景より確実に手前 */
    display: flex;
    gap: 10px;
    pointer-events: auto;
    /* ★ 他のUI（#ui-layer等）が透過し終わる1秒後から、
       うっすら・ゆっくり浮かび上がるように出す */
    opacity: 0;
    animation: floatingControlsIn 1.2s ease-out 0.9s forwards;
}

#floating-transport-controls .play-stamp,
#floating-transport-controls .stop-stamp {
    /* ボタン自身の位置指定(absolute/top/left)を打ち消し、
       このコンテナ内で横並びにする */
    position: static !important;
}

@keyframes floatingControlsIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 0.85; transform: translateY(0); }
}

#floating-transport-controls:hover {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* --- MIDI検索ボタン：他のボタンと同じ木目デザインに統一 --- */
#midi-search-btn {
    background: #3d2b1f;
    background: linear-gradient(to bottom, #4a3526, #3d2b1f);
    border: 1px solid #634a35;
    color: #e0d0b0 !important;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5),
                inset 1px 1px 1px rgba(255, 255, 255, 0.1);
    text-shadow: none;
}

#midi-search-btn:hover {
    background: #523c2d;
    filter: brightness(1.1);
    color: #e0d0b0 !important;
}

/* ★ プレースホルダーの文字色を明るくする */
#midi-search-input::placeholder {
    color: #d8c9a8;
    opacity: 0.9;
}

/* ==========================================
   Web(体験)版限定：有料版限定機能のツールチップ
   ========================================== */
.paid-feature-tooltip {
    position: fixed;
    z-index: 999999;
    background: rgba(20, 20, 20, 0.97);
    border: 1px solid #b87333;
    border-radius: 6px;
    padding: 12px 16px;
    color: #eee;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
    width: 260px;
    box-sizing: border-box;
    animation: paidFeatureTooltipIn 0.15s ease-out;
}

.paid-feature-tooltip-close {
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 16px;
    line-height: 1;
    color: #aaa;
    cursor: pointer;
}

.paid-feature-tooltip-close:hover {
    color: #fff;
}

.paid-feature-tooltip-text {
    font-weight: bold;
    margin-bottom: 8px;
    padding-right: 16px; /* 閉じるボタンと重ならないように */
    color: #fff;
}

.paid-feature-tooltip-link {
    display: inline-block;
    color: #ffcc80;
    text-decoration: underline;
    word-break: break-word;
}

.paid-feature-tooltip-link:hover {
    color: #ffe0b2;
}

@keyframes paidFeatureTooltipIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
