/* --- CSS: ゲームの見た目 --- */

/* ズーム無効化とスマホでの誤操作防止 */
#bfhd-game-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: sans-serif;
    max-width: 400px;
    margin: 10px auto;
    padding: 10px;
    border: 3px solid #333;
    border-radius: 8px;
    background-color: #f5f5f5;
    box-sizing: border-box;
}

/* ズーム抑制（タップ連打での拡大防止） */
#bfhd-game-container,
#bfhd-game-container button {
    touch-action: manipulation;
}


/* 情報パネルのレイアウト */

/* 情報パネルを上下2段にする */
#bfhd-info-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 320px;
    margin-bottom: 8px;
    padding: 5px;
    border: 1px solid #ccc;
    background-color: #fff;
    font-size: 14px;
    box-sizing: border-box;
}

/* 上段：ターン＋行動 */
#bfhd-turn-row {
    margin-bottom: 4px;
    font-weight: bold;
}

/* 下段：HP（左右に配置） */
#bfhd-hp-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ハート共通スタイル */
.bfhd-hp {
    letter-spacing: 1px;      /* ハートが詰まりすぎないように調整 */
}

/* プレイヤー HP（赤） */
.bfhd-hp-player {
    color: #e74c3c;
    font-weight: bold;
}

/* ボス HP（紫） */
.bfhd-hp-boss {
    color: #6f42c1;
    font-weight: bold;
}


#bfhd-map-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    max-width: 320px;
    height: 320px;
    border: 1px solid #000;
    background-color: #eee;
    margin-bottom: 10px;
}

.bfhd-cell {
    width: 100%;
    height: 100%;
    border: 1px solid #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    box-sizing: border-box;
    /* ハイライト用アニメーションをスムーズにする */
    transition: background-color 0.1s;
}

/* プレイヤー、敵、ボスのスタイル */
.bfhd-player { background-color: #007bff; color: white; border: 2px solid #0056b3; }
.bfhd-normal-enemy { background-color: #dc3545; color: white; border: 2px solid #a71d2a; }
.bfhd-boss { background-color: #6f42c1; color: white; border: 2px solid #4a2e8c; font-size: 18px; }
.bfhd-item { background-color: #ffc107; color: #333; border: 2px solid #d39e00; }
.bfhd-empty { background-color: #e9e9e9; }

/* --- 攻撃/エフェクトのハイライトスタイル --- */

/* 敵の遠距離攻撃範囲のハイライト */
.bfhd-highlight-attack-range {
    background-color: rgba(255, 0, 0, 0.5) !important;
}

/* プレイヤーがアイテム発射時に選択した範囲のハイライト */
.bfhd-highlight-item-range {
    background-color: rgba(0, 255, 255, 0.4) !important; /* シアン系で視認性を上げる */
}

/* 敵破壊時の瞬間的なフィードバック */
.bfhd-highlight-destruction {
    background-color: #ffcc00 !important; /* 破壊の閃光 */
}

/* プレイヤー近接攻撃のハイライト */
.bfhd-highlight-player-attack {
    background-color: rgba(0, 123, 255, 0.5) !important; /* プレイヤーの色を強調 */
}

/* --- コントロールとアイテムスロット --- */

/* 1. 方向キーと攻撃ボタンのグリッド */
#bfhd-controls {
    display: grid !important;
    grid-template-areas:
        ". up ."
        "left attack right"
        ". down .";
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    width: 100%;
    max-width: 240px;
    margin-top: 10px;
    justify-items: center;    /* 各マスの中でボタンを中央寄せ */
}

/* 2. アイテムと待機ボタンのコンテナ（HTMLを修正した場合に必要） */
.bfhd-utility-controls {
    display: flex;
    justify-content: space-between; 
    width: 100%;
    max-width: 240px; 
    margin-top: 10px;
    gap: 10px;
}

/* 2-a. アイテムスロットエリアのスタイリング */
.bfhd-item-button-wrapper {
    text-align: left;
    display: flex;
    align-items: center; 
    gap: 5px;
}
#bfhd-item-slot {
    width: 40px;
    height: 40px;
    border: 2px solid #333;
    background-color: #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 18px;
    color: #333;
    box-sizing: border-box;
}
#bfhd-item-action-button {
    flex-grow: 1; /* 残りのスペースを埋める */
}

/* 2-b. 待機ボタンのスタイリング */
.bfhd-wait-button-wrapper {
    width: 40%;
}
.bfhd-wait-button-wrapper button {
    width: 100%;
    padding: 10px 0;
    font-size: 14px;
    background-color: #f1f1f1; 
    color: #333;
}


/* アイテムスロットが空の場合 */
.bfhd-slot-empty {
    background-color: #ccc;
    color: transparent;
}
/* アイテムスロットにアイテムがある場合 */
.bfhd-slot-filled {
    background-color: #ffc107;
    color: #333;
}

/* コントロールボタンの共通スタイル */
#bfhd-controls button {
    padding: 10px 0;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    border: 1px solid #333;
    border-radius: 4px;
    background-color: #fff;
    box-sizing: border-box;
}

/* この5つのボタンをマスに割り当てる */
#bfhd-controls > button {
    width: 100%;
    box-sizing: border-box;
}

#bfhd-controls > button[data-action="up"]    { grid-area: up; }
#bfhd-controls > button[data-action="down"]  { grid-area: down; }
#bfhd-controls > button[data-action="left"]  { grid-area: left; }
#bfhd-controls > button[data-action="right"] { grid-area: right; }

/* 攻撃ボタンのスタイル */
#bfhd-controls > button[data-action="attack"] {
    grid-area: attack;
    background-color: #dc3545;
    color: #fff;
}


/* --- メッセージボックスとアイテム方向選択 --- */

#bfhd-message-box {
    position: absolute;
    top: 0; bottom: 0; left: 0; right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    text-align: center;
    border-radius: 8px;
    padding: 20px;
}
#bfhd-message-box p { margin-bottom: 20px; }
#bfhd-message-box button { padding: 10px 20px; font-size: 16px; }