/* ==========================================
   1. 共通リセット＆ベーススタイリング
   ========================================== */
body {
    margin: 0;
    padding: 0;
    background-color: #f0f0f0;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

/* ==========================================
   2. 画面全体のレイアウト構造（600px × 900px）
   ========================================== */
#app-container {
    width: 600px;
    height: 900px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    overflow: hidden;
    background-color: #222222;
}

/* 上部：ゲームプレイ領域（600px × 800px） */
#game-container {
    width: 600px;
    height: 800px;
    position: relative;
    background-color: #222222;
}

/* Matter.jsが自動生成するcanvas要素のバグ防止スタイリング */
#game-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* 下部：UI専用黒帯領域（600px × 100px） */
#ui-panel {
    width: 600px;
    height: 100px;
    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;
}

/* ==========================================
   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;
    justify-content: center;
    z-index: 20;
    color: #ffffff;
    box-sizing: border-box;
    padding: 20px;
}

#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;
}

#back-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 5px 10px;
    font-size: 12px;
    z-index: 15;
    display: none;
}