/* 全体のフォントとリセット */
body {
    font-family: "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
    margin: 0;
    padding: 0;
    background-color: #dcdcdc; /* 背景は薄いグレー */
}

/* メインコンテナ */
.game-container {
    max-width: 800px;
    margin: 0 auto;
    border: 2px solid #000;
    background-color: #fff;
}

/* 上部：ゲーム画面エリア (緑色の部分 + 右パネル) */
.game-screen {
    display: flex;
    border-bottom: 2px solid #000;
    height: 400px;
}

/* 左側：フィールド */
/* --- フィールドエリアの基盤設定 --- */
.field-area {
    flex: 2;
    height: 100%; /* 親の400pxを継承 */
    background-image: url('/static/img/mapmap.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    border-right: 2px solid #000;
    overflow: hidden; /* はみ出しを絶対に許さない */
    display: block;
    /* display: flex; */
    /* align-items: center;
    justify-content: center; */
}

/* --- 要素1：通常時のキャラ（ピン & 右下） --- */
.map-pin {
    position: absolute;
    width: 60px;  /* 小さくする */
    height: auto;
    z-index: 20;  
    transform: translate(-50%, -100%); /* 足元を座標に合わせる */
    transition: all 1.0s ease-in-out;   /* 移動をスムーズにする */
    pointer-events: none;               /* クリックを邪魔しない */
    /* わかりやすく枠や吹き出しをつけても良い */
    border: 2px solid greenyellow; border-radius: 50%; background: rgba(255,255,255,0.5);
}
/* --- ★右下に現在のキャラステータス --- */
.big-character-display {
    position: absolute;
    bottom: 20px;
    right: 10px;
    width: 160px; /* お好みで調整 */
    height: auto;
    z-index: 10;  /* 手前に表示 */
    /* わかりやすく赤い枠や吹き出しをつけても良い */
    /* border: 0px solid greenyellow; border-radius: 0%; background: rgb(238, 141, 238); */
}

/* --- 要素2：走る演出用の中央キャラ --- */
.character-img {
    position: absolute;
    top: 30%; left: 25%;
    transform: translate(-50%, -50%);
    max-height: 70%;
    z-index: 5;
    display: none; /* 通常時は隠す */
}

/* --- 要素3：隠し画像（カットイン） --- */
.hidden-surprise-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px; /* サイズ固定 */
    height: auto;  /* 幅に合わせて自動調整 */
    z-index: 20;   /* キャラより前面 */
    display: none; /* 通常は消去 */
}

/* 応援吹き出しの基本（左側に配置） */
.surprise-bubble {
    position: absolute;
    top: 25%;       /* 少し高めの位置 */
    right: 15%;       /* 右側に配置 */
    background: #fff;
    border: 3px solid #ff4500; /* 目立つ色（オレンジなど） */
    border-radius: 15px;
    font-size: 20px;
    padding: 10px 15px;
    font-weight: bold;
    color: #ff4500;
    z-index: 110;   /* カットイン画像(100)よりさらに手前 */
    display: none;  /* 普段は隠す */
    white-space: nowrap;
}

/* 吹き出しのしっぽ（右下に出す） */
.surprise-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50px;
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: #ff4500 transparent;
}

/* --- アニメーション定義 --- */
@keyframes scrollBackground {
    from { background-position: 0 center; }
    to { background-position: -1500px center; } /* 数値は画像の横幅に合わせる */
}

@keyframes shake {
    0% { transform: translate(0,0); }
    25% { transform: translate(-3px,-3px); }
    50% { transform: translate(3px,0px); }
    75% { transform: translate(-3px,3px); }
    100% { transform: translate(0,0); }
}

/* =========================================
   状態管理用クラス（JSで切り替え）
   ========================================= */

/* 1. 走っている状態 (is-running) */
.field-area.is-running {
    /* インラインスタイルの背景を強制上書き */
    background-image: url('/static/img/speed_bg.png') !important;
    background-repeat: repeat-x !important;
    background-size: auto 100% !important;
    animation: scrollBackground 0.6s linear infinite !important;
}

/* 走行中：マップ要素を消し、中央キャラを出す */
.field-area.is-running .map-pin,
.field-area.is-running .big-character-display {
    opacity: 0 !important;
    visibility: hidden !important;
    /* display: none !important; を削除 */
    transition: opacity 0.5s ease; /* 消える時も少し滑らかに */
}
.field-area.is-running .character-img {
    display: block;
    animation: shake 0.4s infinite;
}

/* 2. カットイン状態 (show-hidden) */
.field-area.show-hidden .character-img {
    display: none !important; /* 中央キャラを消す */
}
.field-area.show-hidden {
    /* 疾走感のある背景を一時停止 */
    animation-play-state: paused !important;
}

/* show-hidden クラスがついた時だけ表示 */
.field-area.show-hidden .hidden-surprise-img {
    display: block !important;
    animation: shake 0.5s infinite;
}
.field-area.show-hidden .surprise-bubble {
    display: block !important;
}

/* ========= */

/* 吹き出し
.speech-bubble {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #fff;
    border-radius: 50%;
    padding: 20px;
    border: 2px solid #000;
    text-align: center;
    font-size: 14px;
    width: 120px;
}
.speech-bubble:after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 20px;
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: #fff transparent;
    display: block;
    width: 0;
} */

/* 右側：コントロールパネル */
.control-panel {
    flex: 1;
    background-color: #d0e0ff; /* 薄い青紫っぽい色 */
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ステータスボックス (ベージュ色) */
.status-box {
    background-color: #ffecd1;
    border: 2px solid #000;
    padding: 5px 10px;
    font-weight: bold;
    margin-bottom: 5px;
}

/* アクションボタンの共通設定 */
.action-btn {
    display: flex;           /* 内容を中央に寄せる */
    align-items: center;     
    justify-content: center; 
    width: 100%;             
    height: 60px;            /* 高さを固定 */
    box-sizing: border-box;  
    
    /* ↓ ここを追加・修正：ブラウザの初期設定を上書き ↓ */
    margin: 0;               /* 外側の余白を消す */
    padding: 0;              /* 内側の余白をゼロにする（heightで高さを決めるため） */
    font-family: inherit;    /* フォントをbodyに合わせる */
    line-height: 1;          /* 行の高さをリセット */
    /* ------------------------------------------ */

    background-color: #e0e0e0;
    border: 2px solid #000;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 2px 2px 0px #000;
    text-decoration: none;   
    color: #000;
    overflow: hidden;        /* はみ出しを隠す */
    white-space: nowrap;     /* 改行させない */             
}
.action-btn:active {
    box-shadow: none;
    transform: translate(2px, 2px);
}
/* ボタンを包むエリアの設定 */
.action-buttons {
    display: grid;               /* グリッドレイアウトを有効化 */
    grid-template-columns: 1fr 1fr; /* 横に同じ幅で2列並べる (1fr = 1比率) */
    gap: 10px;                   /* ボタン同士の隙間 */
    margin-top: 10px;
}
/* 体力ゲージの外枠 */
.hp-bar-container {
    display: flex;
    align-items: center;
    background-color: rgba(255, 236, 209, 0.8); /* 少し透けさせるとゲーム風になります */
    border: 2px solid #000;
    padding: 3px 10px;
}
/* ゲージの中身の高さ調整 */
.hp-bar {
    flex-grow: 1;
    height: 15px;      /* 少しスリムに */
    background-color: #000;
    margin-left: 8px;
    display: flex;
}
.hp-current {
    background-color: red;
    height: 100%;
}
/* 体力ゲージのコンテナを緑枠内の中央下端に固定 */
#hp-gauge-container {
    position: absolute;
    bottom: 5px;       /* 下端ギリギリ (0〜5pxで調整) */
    left: 50%;         /* 一旦、左端を中央に持ってくる */
    transform: translateX(-50%); /* 自分の幅の半分だけ左に戻す（これで完全中央） */
    width: 80%;        /* 親要素(緑枠)に対して80%の幅 */
    z-index: 10;
    min-height: 30px;  /* ← 読み込み前でも場所を確保するために追加 */
}

/* 中段：情報バー */
.info-bar {
    background-color: #f0f0f0;
    border-bottom: 2px solid #000;
    /* border-left: 5px solid #00f; 青いバー */
    padding: 10px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
}

/* 下部：ログ・フードエリア */
.data-section {
    padding: 10px;
    border-bottom: 2px solid #000;
}
.section-title {
    font-weight: bold;
    border-left: 5px solid #00f; /* 青いバー */
    padding-left: 10px;
    margin-bottom: 10px;
}

/* ログ一覧のスクロールコンテナ */
#log-history-container {
    background-color: #ffffff;
}

/* スクロールバーのデザイン（Chrome系ブラウザ用） */
#log-history-container::-webkit-scrollbar {
    width: 8px;
}
#log-history-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}
#log-history-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}
#log-history-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* モーダルの背景 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

/* モーダルの中身 */
.modal-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.food-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.food-item:hover { background: #f9f9f9; }

/* 料理演出のコンテナ */
#food-animation-container {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 150; /* ピンよりも手前に表示 */
    pointer-events: none;
}

/* 料理画像のスタイルとアニメーション */
.food-pop-img {
    width: 320px;
    height: auto;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
    animation: foodPop 1.5s ease-out forwards;
}

@keyframes foodPop {
    0% { transform: scale(0) rotate(-20deg); opacity: 0; }
    70% { transform: scale(1.2) rotate(10deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}