/* ==========================================
   1. 共通リセット＆ベーススタイリング
   ========================================== */
*, *::before, *::after {
    box-sizing: border-box;
    /* 💡 追加：画面上のあらゆるテキストをマウス選択・長押しできないようにします */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

body {
    margin: 0;
    padding: 0;
    background-color: #000000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100svh;
    overflow: hidden;
}



/* ==========================================
   2. 画面全体のレイアウト構造（600px × 900px）
   ========================================== */
/* 💡 新設：上部UIの黒帯エリア */
/* 上部UIの黒帯エリア */
#top-ui-panel {
    width: 100%;
    height: 50px;
    background-color: #111111;
    border-bottom: 1px solid #333333;
    display: flex;
    align-items: center;
    justify-content: space-around; /* 項目を横に均等に並べます */
    padding: 0 10px;
    gap: 8px;
}

/* 上部UIの中にあるすべてのテキストの折り返しを禁止し、文字サイズを統一 */
#top-score-text, #top-timer-text, #top-power-text, #top-stage-text {
    white-space: nowrap;
    font-size: 14px !important; 
}

/* 💡 新設：スコア表示用（中央に広がるように配置） */
#top-score-text {
    color: #ffffff;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
    flex-grow: 1; 
    text-align: center;
}

#top-stage-text {
    color: #aaaaaa;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1.5px;
}

/* ポーズボタン（縦長にして2行分をカバー） */
#pause-btn {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 0 12px;
    font-size: 11px;
    font-weight: bold;
    background-color: #113333;
    color: #99ffff;
    border: 1px solid #225555;
    border-radius: 4px;
    cursor: pointer;
    height: 38px; /* 💡 修正：2行分の高さに調整しました */
    transition: background-color 0.2s, border-color 0.2s;
}
#pause-btn:hover {
    background-color: #115555;
    border-color: #33aaaa;
}

/* 💡 新規：項目名と数値を縦に並べるためのブロック設定 */
.top-ui-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* 上段の項目名を見やすくブラッシュアップ */
.ui-label {
    font-size: 11px;           /* 文字を1段階大きくしました */
    color: #dddddd;            /* 色を白寄りに明るくして視認性を高めました */
    font-weight: bold;
    margin-bottom: 3px;        /* 下段の数値との隙間を少し広げました */
    letter-spacing: 1px;       /* 文字と文字の間隔をあけてスッキリさせました */
    white-space: nowrap;
}

/* 💡 新規：下段の数値やステージ表記 */
.ui-value {
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    /* 💡追加：数字の横幅を固定して、時間が進むたびにガクガク揺れるのを防ぎます */
    font-variant-numeric: tabular-nums;
}



/* ポーズ・ゲームオーバー画面のメニューボタン */
.menu-btn {
    padding: 12px 20px;
    margin: 8px;
    font-size: 16px;
    font-weight: bold;
    color: #ffffff;
    background-color: #444444;
    border: 2px solid #666666;
    border-radius: 6px;
    cursor: pointer;
    width: 260px;
    transition: background-color 0.2s, border-color 0.2s;
}
.menu-btn:hover:not(:disabled) {
    background-color: #666666;
    border-color: #ffffff;
}
.menu-btn:disabled {
    cursor: not-allowed;
}

#app-container {
    width: 100vw;
    /* 💡修正：画面高さから上下UI(150px)を引き、アスペクト比(2/3)を掛けて横幅を完璧に合わせます */
    max-width: min(600px, calc((100svh - 150px) * 2 / 3));
    height: 100svh;
    /* 💡修正：横幅600pxを確保できるよう、縦幅の上限を解放します */
    max-height: 1050px; 
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: #000;
    overflow: hidden;
    margin: 0 auto; /* 中央寄せ */
}

#game-container {
    width: 100%;
    flex-grow: 1; /* 上部と下部UI以外の残りの高さをすべて吸収する */
    height: 0;    /* flex-growを正しく効かせるためのおまじない */
    position: relative;
    background-color: #222222;
    touch-action: none;     /* スマホでスワイプした時に画面が動くのを完全に防ぎます */
}

/* EXボタンの省スペース化と改行・アニメーション用設定 */
#ex-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: bold;
    min-height: 70px;
    min-width: 150px;
    border-radius: 6px;
    border: none;
    background-color: #333333;
    color: #777777;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* EXゲージ関連のスタイル */
#ex-text-area {
    margin-bottom: 4px;
}

#ex-gauge-container {
    display: flex;
    gap: 2px;
    justify-content: center;
}

/* ==========================================
   EXゲージ（きりたんぽ）の重なりと徐々に満ちる演出
   ========================================== */

/* 2つの画像を重ねるための土台（枠） */
.ex-slot-wrapper {
    position: relative;
    width: 24px;
    height: 24px;
}

/* きりたんぽ画像の共通設定 */
.ex-slot {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-image: url('assets/images/items/kiritanpo.png');
    /* 💡 高さ（height）が削られても画像が縮まないよう、背景サイズを24pxに固定します */
    background-size: 100% 24px; 
    background-position: bottom center;
    background-repeat: no-repeat;
}

/* 後ろに配置する、暗いシルエット（常に高さ100%） */
.ex-slot.bg {
    height: 100%;
    filter: brightness(0);
    opacity: 0.5;
}

/* 手前に配置する、明るい部分（プログラムで高さを0%〜100%に操作する） */
.ex-slot.fill {
    transition: height 0.1s linear; /* 高さが変わる時に滑らかに動かします */
}

/* 💡 新設：EXが溜まったときに自動で付与される輝くクラス */
#ex-btn.ready {
    background-color: #ff9900;
    color: #ffffff;
    cursor: pointer;
    font-weight: 900;
    /* 枠線がブワッと広がるアニメーションをループ再生します */
    animation: ex-pulse-wave 1.5s infinite ease-out;
}

/* 💡 枠線（シャドウ）が外側に広がって消えていくアニメーション */
@keyframes ex-pulse-wave {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 153, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(255, 153, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 153, 0, 0);
    }
}

/* Matter.jsが自動生成するcanvas要素のバグ防止スタイリング */
#game-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* 下部：UI専用黒帯領域 */
#ui-panel {
    width: 100%;        /* 💡 600px 固定から画面幅いっぱいに追従するように変更します */
    height: 100px;
    flex-shrink: 0;     /* 💡 画面が狭くなっても、この下部UIが絶対に押し潰されないように固定します */
    background-color: #111111;
    border-top: 2px solid #333333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 25px;
    box-sizing: border-box;
}

/* ==========================================
   3. 下部UIパーツのスタイリング
   ========================================== */
.ui-sub-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* 左側：ステータステキスト */
#status-area {
    color: #ffffff;
    font-weight: bold;
    gap: 6px;
    text-align: left;
}

#stage-text {
    font-size: 18px;
    color: #ffd700; /* ステージ名は鮮やかな金色 */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

#character-text {
    font-size: 14px;
    color: #aaaaaa;
    letter-spacing: 0.5px;
}

/* 右側：EXボタン */
/*#ex-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    color: #ffffff;
    background-color: #555555;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s, transform 0.1s, box-shadow 0.1s;
}*/

/*#ex-btn:active:not(:disabled) {
    transform: scale(0.96);
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
}*/

/*#ex-btn:disabled {
    cursor: not-allowed;
    box-shadow: none;
}*/

/* ==========================================
   ボタン上のイベント飲み込みバグ防止用設定
   ========================================== */
#ex-btn:disabled {
    /* 無効化中はマウス判定を完全に貫通させ、後ろの画面に引っぱり解放を伝えます */
    pointer-events: none; 
}

#control-area {
    /* ボタンを貫通した先の「親の壁」で、マウスカーソルを「押せないよ」マークにします */
    cursor: not-allowed; 
}

#ex-btn.ready {
    /* EXゲージが溜まって READY クラスが付いたら、貫通を解除してボタンを押せるように戻します */
    pointer-events: auto; 
    cursor: pointer;
}

/* ==========================================
   4. ゲーム画面上に重なるオーバーレイ演出（救済版）
   ========================================== */
/* すべてのオーバーレイの共通基盤（絶対配置でキャンバスの真上に重ねる） */
.overlay {
    position: absolute;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none; /* マウスの引っ張り操作を邪魔しない */
    user-select: none;
    box-sizing: border-box;
    z-index: 10; /* キャンバスより手前に表示 */
}

/* 「YOUR TURN」などのメッセージ表示 */
#turn-overlay {
    top: 30px;
    font-size: 28px;
    color: #ffffff;
    font-weight: bold;
    letter-spacing: 2px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8), 0 0 10px rgba(255, 255, 255, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* 「GAME OVER」や「STAGE CLEAR」の全画面暗転表示 */
#result-overlay {
    top: 0;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75); /* 画面を暗くシブく隠す */
    font-size: 48px;
    font-weight: bold;
    letter-spacing: 1px;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.9);
    display: none; /* 初期状態は非表示。メインプログラムから flex に切り替わります */
}

/* ==========================================
   5. タイトル画面とUIのスタイリング
   ========================================== */
#title-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    /* 💡修正：スマホ等ではみ出した場合に縦スクロールを許可します */
    overflow-y: auto;          
    /* 💡修正：スクロールした時に一番上の要素が切れて見えなくなるバグを防ぎます */
    justify-content: flex-start;
    /*justify-content: center;*/
    z-index: 20;
    color: #ffffff;
    box-sizing: border-box;
    padding: 40px 20px;
    -ms-overflow-style: none;  /* IE, Edge用 */
    scrollbar-width: none;     /* Firefox用 */
}
#title-screen::-webkit-scrollbar {
    display: none;             /* Chrome, Safari用 */
}


#title-screen h1 {
    font-size: 32px;
    color: #ffd700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.description {
    font-size: 14px;
    color: #cccccc;
    margin-bottom: 30px;
    text-align: center;
    line-height: 1.5;
}

.selector-group {
    margin-bottom: 20px;
    text-align: center;
}

.selector-group p {
    margin: 0 0 10px 0;
    font-weight: bold;
}

.btn-group {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.char-btn, .diff-btn {
    padding: 8px 16px;
    background-color: #444444;
    color: #ffffff;
    border: 2px solid #666666;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.char-btn.selected, .diff-btn.selected {
    border-color: #ffd700;
    background-color: #665500;
}

#start-btn {
    margin-top: 20px;
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    background-color: #ff4500;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

#start-btn:disabled {
    background-color: #555555;
    cursor: not-allowed;
}

#loading-msg {
    margin-top: 10px;
    font-size: 12px;
    color: #aaaaaa;
}

/* ==========================================
   6. アニメ風カットイン演出（斜め平行四辺形・二重枠）
   ========================================== */
.cutin-container-base {
    position: absolute;
    top: 30%; 
    left: 0;
    width: 80%; /* 画面幅より少し狭くして斜め枠を際立たせる */
    height: 120px; 
    /* 💡 Y軸中央寄せしつつ、-15度傾けて平行四辺形にする */
    transform: translateY(-50%) skewX(-15deg);
    pointer-events: none;
    z-index: 50; 
    overflow: hidden;

    /* 💡 黒い外枠と、キャラクターカラーの内枠（inset）の二重枠 */
    border: 4px solid #000000;
    box-shadow: inset 0 0 0 6px var(--cutin-color, #FFD700);
    background-color: #111111; /* 画像の背景は暗く渋く */
}

/* 傾けた枠の中で、画像を逆方向に傾けてまっすぐに直す */
.cutin-img {
    position: absolute;
    height: 180px; /* 💡 変更：顔をしっかり見せるため少し拡大 */
    top: 50%;
    left: 50%;
    object-fit: cover;
    /* transformは下のアニメーションで上書きされます */
}

/* 💡 味方用：左からスライドイン */
.cutin-player {
    left: -10%;
    animation: slide-in-left 1.5s cubic-bezier(0.1, 0.8, 0.1, 1) forwards;
}
.cutin-player .cutin-img {
    /* 💡 ど真ん中(50%)より少しだけ左(40%)に配置して絶妙な位置に調整 */
    left: 50%; 
    animation: img-move-left 1.5s linear forwards;
}

/* 💡 敵用：右からスライドイン */
.cutin-enemy {
    left: auto;
    right: -10%;
    animation: slide-in-right 1.5s cubic-bezier(0.1, 0.8, 0.1, 1) forwards;
}

.cutin-enemy .cutin-img {
    /* 💡 味方と完全に対称になるよう、ど真ん中(50%)より少しだけ右(60%)に配置 */
    left: 50%; 
    animation: img-move-right 1.5s linear forwards;
}

/* コンテナのアニメーション（平行四辺形のskewXを維持したまま移動） */
@keyframes slide-in-left {
    0% { transform: translateY(-50%) skewX(-15deg) translateX(-100%); opacity: 0; }
    15% { transform: translateY(-50%) skewX(-15deg) translateX(0); opacity: 1; }
    85% { transform: translateY(-50%) skewX(-15deg) translateX(10%); opacity: 1; }
    100% { transform: translateY(-50%) skewX(-15deg) translateX(-100%); opacity: 0; }
}
@keyframes slide-in-right {
    0% { transform: translateY(-50%) skewX(-15deg) translateX(100%); opacity: 0; }
    15% { transform: translateY(-50%) skewX(-15deg) translateX(0); opacity: 1; }
    85% { transform: translateY(-50%) skewX(-15deg) translateX(-10%); opacity: 1; }
    100% { transform: translateY(-50%) skewX(-15deg) translateX(100%); opacity: 0; }
}

/* 💡 画像が枠の中で動くパララックス。中央配置を保つための「translate(-50%, -50%)」を復活させます */
@keyframes img-move-left {
    0% { transform: translate(-50%, -50%) skewX(15deg) translateX(-20px); }
    100% { transform: translate(-50%, -50%) skewX(15deg) translateX(20px); }
}
@keyframes img-move-right {
    0% { transform: translate(-50%, -50%) skewX(15deg) translateX(20px); }
    100% { transform: translate(-50%, -50%) skewX(15deg) translateX(-20px); }
}


/* ==========================================
   カットイン演出：キャラカラーの動く背景ストライプ
   ========================================== */
.cutin-bg {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    /* var(--cutin-color) を使い、キャラごとの色と黒のシマシマ模様を作ります */
    background: repeating-linear-gradient(
        45deg,
        rgba(0, 0, 0, 0.8),
        rgba(0, 0, 0, 0.8) 20px,
        var(--cutin-color, #FFD700) 20px,
        var(--cutin-color, #FFD700) 40px
    );
    opacity: 0.3; /* キャラクター画像が目立つように少し薄くします */
    animation: cutin-bg-slide 1s linear infinite; /* 背景を常に流し続けるアニメーション */
    z-index: -1; /* 確実にキャラクター画像の後ろへ配置します */
    background-size: 56.56px 56.56px;
}

/* ストライプ背景を左上に向けて無限にスライドさせるアニメーションキーフレーム */
@keyframes cutin-bg-slide {
    0% { background-position: 0 0; }
    /* 斜め45度方向に模様の幅に合わせて移動させることで、途切れないループを作ります */
    100% { background-position: -56.56px 56.56px; }
}


/* ------------------------------------------
   💡 新規：タイトル画面の階層メニュー用スタイル
------------------------------------------ */
.menu-layer {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    animation: fadeIn 0.3s ease-out forwards;
    margin-top: auto;          
    margin-bottom: auto;
}

/* 縦並びメニューボタン */
.menu-item {
    background: transparent;
    border: none;
    color: #aaaaaa;
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 4px;
    padding: 10px 30px;
    margin: 5px 0;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    width: 400px;
    -webkit-appearance: none;
    appearance: none;
    flex-shrink: 0;
}


.menu-item:disabled {
    cursor: not-allowed;
    font-size: 22px !important;
    padding: 10px 30px !important;
}

/* メニュー：ホバー時の右ズレを廃止し、項目別の発光カラーを設定 */
.menu-item-main:hover { color: #ffffff; text-shadow: 0 0 10px #00ff44, 0 0 20px #00ff44; }        /* 緑 */
.menu-item-after:hover { color: #ffffff; text-shadow: 0 0 10px #ff8c00, 0 0 20px #ff8c00; }       /* 橙 */
.menu-item-extra:hover { color: #ffffff; text-shadow: 0 0 10px #ff00ff, 0 0 20px #ff00ff; }       /* 紫紅 */
.menu-item-practice:hover { color: #ffffff; text-shadow: 0 0 10px #00bfff, 0 0 20px #00bfff; }    /* 水色 */
.menu-item-howtoplay:hover { color: #ffffff; text-shadow: 0 0 10px #ffd700, 0 0 20px #ffd700; }    /* 金色 */
.menu-item-option:hover { color: #ffffff; text-shadow: 0 0 10px #aaaaaa, 0 0 20px #aaaaaa; }       /* 白銀 */
.menu-item-achievement:hover { color: #ffffff; text-shadow: 0 0 10px #da70d6, 0 0 20px #da70d6; }  /* 薄紫 */

/* GAME START ボタンのマウスホバー演出 */
#start-btn {
    transition: all 0.2s ease;
}
#start-btn:hover:not(:disabled) {
    filter: brightness(1.2);
    cursor: pointer;
}

/* 画面切り替え時のフワッと表示するアニメーション */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}


/* ------------------------------------------
   💡 新規：キャラクターごとのイメージカラー設定
------------------------------------------ */
/* ずんだもん（黄緑） ※文字が見やすいように少し暗めの文字色にしています */
#btn-zundamon.selected { background-color: #9acd32; border-color: #ffffff; color: #111111; }

/* ずん子（緑） */
#btn-zunko.selected { background-color: #228b22; border-color: #ffffff; color: #ffffff; }

/* きりたん（オレンジ） */
#btn-kiritan.selected { background-color: #ff8c00; border-color: #ffffff; color: #ffffff; }

/* イタコ（水色） ※こちらも視認性のため文字色を調整 */
#btn-itako.selected { background-color: #00bfff; border-color: #ffffff; color: #111111; }


/* ==========================================
   読み込み画面のスタイル
   ========================================== */
/* プログレスバー（進捗ゲージ）の外枠の設定です */
#loading-progress-container {
    width: 300px;
    height: 20px;
    background-color: #333333;
    border: 2px solid #ffffff;
    border-radius: 10px;
    margin: 20px auto;
    overflow: hidden; /* 中のゲージが枠からはみ出ないようにします */
}

/* 実際に伸びていく緑色のゲージ本体の設定です */
#loading-progress-bar {
    width: 0%; /* 初期状態は0%（見えない状態）にしておきます */
    height: 100%;
    background-color: #00ff44;
    transition: width 0.2s ease; /* ゲージが伸びる際にヌルッと動くアニメーションをつけます */
}

/* ゲージの下に表示する「50%」などのテキストの設定です */
#loading-progress-text {
    color: #ffffff;
    font-size: 16px;
    text-align: center;
    margin-top: 5px;
}


/* ==========================================
   キャラクター選択（カルーセルUI）のスタイル
   ========================================== */
.carousel-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
}

.nav-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 40px;
    cursor: pointer;
    transition: transform 0.2s, color 0.2s;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.nav-btn:hover {
    transform: scale(1.2);
    color: #ffd700;
}

.char-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 200px;
}

/* PCでの画像エリアを大幅に拡大（枠線をなくしてキャラを立たせるデザイン） */
#char-image-box {
    position: relative;
    width: 260px;
    height: 380px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: transparent;
    border: none;
    z-index: 1;
}

#char-select-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    
    /* 💡キャラクター自身に影を落として、背景から浮き出るような立体感を出します */
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.8));
}

#char-select-name {
    margin: 0 0 10px 0;
    font-size: 24px;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    transition: color 0.3s;
    
    /* 💡修正：PC版でも文字数が多くなった場合は、はみ出さずに「...」で美しく省略します */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px; /* キャラクター情報エリアの横幅に合わせた上限値 */
    text-align: center;
}

/* 説明文を乗せる広いスペース */
#char-desc-box {
    width: 80%;
    height: 100px;
    background-color: rgba(0, 0, 0, 0.5);
    border: 1px solid #444444;
    border-radius: 8px;
    margin-top: 20px;
    padding: 15px;
    color: #cccccc;
    font-size: 14px;
    line-height: 1.6;
    text-align: left;
}


/* ==========================================
   キャラクター選択：レスポンシブ・レイアウト
   ========================================== */
.char-select-layout {
    display: flex;
    /* 💡変更：PC版でも横並び(row)を廃止し、最初から縦並びに統一します */
    flex-direction: column; 
    /* 💡変更：縦並びになるため、要素をしっかり中央寄せにします */
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
    max-width: 550px;
}

.char-visual-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-shrink: 0;
}

/* 全身画像が映える縦長の枠に変更 */
.char-visual-area .tall-box {
    width: 160px;
    height: 240px; 
    background-color: #222222;
    border: 3px solid #666666;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.char-info-area {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    flex-grow: 1;
    /* テキストとボックスを中央に揃えます */
    align-items: center; 
    text-align: center;
    width: 100%;
    min-width: 0;
}

#char-select-name {
    margin: 0 0 10px 0;
    font-size: 24px; /* 💡 26pxから少しだけ小さくして余裕を持たせます */
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    white-space: nowrap; /* 💡 追加：絶対に改行させない設定です */
}

/* 概要テキストボックス */
#char-desc-box, #char-ex-box {
    background-color: rgba(0, 0, 0, 0.5);
    border: 1px solid #444444;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    color: #cccccc;
    font-size: 14px;
    line-height: 1.5;
    /* ボックスを横幅いっぱいに広げます */
    width: 100%; 
    box-sizing: border-box;
}

/* PC・スマホ共通で、設定画面のボタン群を縦並び（上が決定、下が戻る）にします ↓↓ */
.menu-layer div[style*="display: flex"] {
    flex-direction: column-reverse !important;
    align-items: center !important;
    gap: 12px !important;
    width: 100%;
}

/* PC・スマホ共通で、すべてのメニューボタンの横幅とサイズを統一します ↓↓ */
.menu-btn, #start-btn {
    width: 280px !important;
    max-width: 100% !important;
    font-size: 16px !important;
    padding: 12px !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
}

#char-shadow-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    /* 画面外に飛ばした元画像を隠すための設定 */
    overflow: hidden; 
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: -1;
    opacity: 0; /* 最初は見えない状態 */
}

#char-select-shadow {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* CSSの魔法：画像を1000px左へ飛ばす（影だけを元の位置に落とします） */
    transform: translateX(-1000px);
}



/* メイン画像（下から上）と同じ軌道でスッと上がるように動きを修正 */
@keyframes shadowSlide {
    0% { opacity: 0; transform: translate(15px, 30px) scale(1.0); }
    100% { opacity: 0.6; transform: translate(15px, 10px) scale(1.05); } 
}


/* 画面幅が480px以下（スマホ縦画面）になった時の自動切り替え */
@media (max-width: 480px) {
    .char-select-layout {
        flex-direction: column; /* 縦並びに変更 */
        align-items: center;
    }
    
    #char-image-box {
        width: 220px;
        height: 280px; /* 💡スマホではスクロールしすぎない程度の高さに縮めます */
    }
    
    .char-info-area {
        width: 95%;
    }
}


/* ==========================================
   全体のレイアウトとUIの自動最適化（修正版v2）
   ========================================== */

/* 3. PC版の謎の壁（アリーナ横幅ズレ）を解消 */
#game-container {
    width: 100%;
    flex-grow: 1;
    
    /* 💡変更：余白（レターボックス）を黒色にして、アリーナとの境界をハッキリさせます */
    background-color: #000000; 
    
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

#game-container canvas {
    /* 💡変更：画面に合わせて拡大縮小しつつ、物理空間（2:3）の比率を絶対に崩さない設定 */
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    aspect-ratio: 2 / 3 !important;
    
    /* 実際のプレイアリーナ（壁の内側）をグレーにして境界を可視化します */
    background-color: #222222; 
    
    object-fit: contain !important;

    /* ↓↓ 追加：ブラウザの計算バグを強制的に上書きして中央に寄せます ↓↓ */
    margin: 0 auto !important;
}

/* 画面幅が480px以下（スマホ縦画面）になった時のUI自動切り替え */
@media (max-width: 480px) {
    
    /* 1. 上部UIのレイアウト崩れを防ぐため、グリッド(マス目)で強固に配置します */
    #top-ui-panel {
        height: auto !important; 
        min-height: 50px;
        padding: 8px 4px !important;
        display: grid !important;
        grid-template-columns: auto 1fr 1fr !important; /* ポーズボタン + 右に2列 */
        gap: 8px 4px !important; /* 縦横の隙間 */
    }
    
    #pause-btn {
        grid-row: 1 / 3; /* 💡ポーズボタンを縦2行分ぶち抜いて配置します */
        height: 100% !important;
        margin: 0 !important;
    }

    .top-ui-block {
        margin: 0 !important;
        align-items: center !important;
    }
    
    /* 2. カットイン画像のスマホ向け最適化 */
    .cutin-container-base {
        width: 95% !important; /* スマホでは枠を画面いっぱいに広げる */
        height: 90px !important; /* 枠の縦幅を少しスリムに */
    }
    .cutin-img {
        height: 140px !important; /* スマホサイズに合わせて画像を少し縮小 */
        width: auto !important;   /* アスペクト比を崩さない */
    }
    
    /* 3. スマホ版ポーズ・ゲームオーバー画面のボタンの隙間を復活 */
    #pause-overlay, 
    #gameover-overlay {
        gap: 16px !important;
    }
    
    
    .menu-btn {
        width: 260px !important; 
        max-width: 100% !important;
        font-size: 16px !important;
        padding: 12px !important;
        margin: 0 auto !important;
        box-sizing: border-box !important;
    }
}


/* ==========================================
   ボタンサイズの完全統一と余白の共通化（修正版）
   ========================================== */

/* 1. すべての枠（コンテナ）の隙間を16pxに統一する */
.menu-layer div[style*="display: flex"],
#pause-overlay, 
#gameover-overlay {
    gap: 16px !important;
}

/* 2. ボタン自身のサイズを統一（外側の余白はゼロに戻す） */
.menu-btn, #start-btn {
    width: 280px !important;
    height: 52px !important; 
    max-width: 100% !important;
    font-size: 16px !important;
    padding: 0 !important;   
    box-sizing: border-box !important;
    
    /* 枠が隙間(gap)を管理するため、ボタン自身の外側余白は0にします */
    margin: 0 auto !important; 
    
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

/* 3. スマホ画面の時は、両方同時に同じサイズへ縮小させる */
@media (max-width: 480px) {
    .menu-btn, #start-btn {
        width: 260px !important; 
    }
}

/* ↓↓ 追加：ロックされているボタンのカーソルを禁止マークにします ↓↓ */
button:disabled {
    cursor: not-allowed !important;
}




/* ==========================================
   ロード画面のぐるぐるアイコン
   ========================================== */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 5px solid #333333; /* 暗いグレーの枠 */
    border-top: 5px solid #4CAF50; /* ずんだカラーのアクセント */
    border-radius: 50%; /* 完全な円にする */
    animation: spin 1s linear infinite; /* 1秒かけて一定速度で無限に回転 */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}