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

/* ズーム無効化とスマホでの誤操作防止 */
#bfhd-game-container {
    position: relative;
    /* 選択無効化 */
    user-select: none;
    -webkit-user-select: none;
    /* ハイライト無効化 */
    -webkit-tap-highlight-color: transparent;
    /* ボタンのダブルタップ拡大を抑制する効果を期待 */

    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-info-panel {
    display: flex;
    justify-content: space-between;
    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-display { width: 30%; text-align: left; }
#bfhd-hp-display { width: 40%; text-align: center; font-weight: bold; }
/* ハートアイコン表示エリアは、ひとまず非表示に近い形で残す */
#bfhd-player-heart-display {
    width: 30%;
    text-align: right;
    visibility: hidden; /* 見た目上は隠すが、領域は残す */
    line-height: 1;
}

#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;
    /* 上下左右と中央の攻撃ボタンのみ */
    grid-template-areas:
        ". up ."
        "left attack right"
        ". down .";
    grid-template-columns: 1fr 1fr 1fr;
    gap: 5px;
    width: 100%;
    max-width: 240px;
    margin-top: 10px;
}

/* 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;
}

#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: white;
}


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

#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; }

#bfhd-item-direction-controls {
    display: none;
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #333;
    padding: 15px;
    border-radius: 5px;
    z-index: 100;
}
#bfhd-item-direction-controls button {
    margin: 5px;
    padding: 8px 15px;
}