@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@400;700&display=swap');

body { margin: 0; background: #050510; color: #fff; font-family: 'M PLUS Rounded 1c', sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; overflow: hidden; }

#game-container { position: relative; width: 100%; max-width: 600px; height: 100%; max-height: 800px; background: radial-gradient(circle, #1a1a3a 0%, #050510 100%); border: 2px solid #336699; box-shadow: 0 0 20px rgba(100, 100, 255, 0.3); overflow: hidden; border-radius: 10px; }

canvas { width: 100%; height: 100%; display: block; cursor: crosshair; position: absolute; top:0; left:0; z-index: 5; }

.screen { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); display: none; flex-direction: column; justify-content: center; align-items: center; z-index: 20; text-align: center; padding: 20px; box-sizing: border-box; }
.screen.active { display: flex; }

h1 { font-size: 40px; color: #ccffff; text-shadow: 0 0 15px #66ccff, 0 0 5px #fff; margin-bottom: 5px; }
h2 { font-size: 24px; color: #e6e6fa; text-shadow: 0 0 10px #aaaaff; margin-bottom: 20px; }
.input-group { background: rgba(50,50,100,0.5); padding: 15px; border-radius: 10px; border: 1px solid #6699ff; margin: 20px 0; }
input { background: none; border: none; color: #fff; font-size: 18px; outline: none; text-align: center; font-family: inherit; }

button { background: #333366; color: white; border: 2px solid #666699; padding: 12px 24px; font-size: 16px; border-radius: 30px; cursor: pointer; transition: 0.3s; margin: 5px; font-weight: bold; }
button:hover:not(:disabled) { background: #555599; box-shadow: 0 0 15px #8888ff; transform: scale(1.05); }
button:disabled { background: #333; border-color: #555; color: #888; cursor: not-allowed; }

/* 🌟 ルール説明 */
.rules-box { margin-top: 20px; background: rgba(0,0,0,0.6); padding: 15px 30px; border-radius: 10px; border: 1px solid #558; text-align: left; font-size: 14px; line-height: 1.5; }
.rules-box h3 { margin-top: 0; color: #ffccff; text-align: center; }

/* 🌟 プロフ画面デザイン */
.prof-container { display: flex; flex-direction: column; gap: 15px; width: 100%; max-width: 500px; }
.prof-card { background: rgba(255,255,255,0.1); border: 2px solid #8888ff; border-radius: 10px; padding: 15px; text-align: left; box-shadow: 0 0 10px rgba(100,100,255,0.2); }
.prof-role { font-size: 14px; color: #ffccff; font-weight: bold; margin-bottom: 10px; border-bottom: 1px solid #558; padding-bottom: 5px; }
.prof-card-inner { display: flex; align-items: center; gap: 15px; }
.prof-card img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; flex-shrink: 0; }
.prof-info h3 { margin: 0 0 5px 0; color: #ccffff; font-size: 20px; }
.prof-info p { margin: 2px 0; font-size: 13px; line-height: 1.5; }

/* UIデザイン */
#game-ui { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; display: flex; flex-direction: column; justify-content: space-between; }
#top-bar { display: flex; justify-content: space-between; padding: 10px 20px; background: rgba(0,0,0,0.6); border-bottom: 1px solid #558; }
.gauge-container { display: flex; align-items: center; gap: 10px; width: 50%; }
.gauge-bg { width: 100%; height: 15px; background: #222; border-radius: 10px; overflow: hidden; border: 1px solid #555; }
.gauge-fill { height: 100%; transition: width 0.3s; }
.hp-fill { background: linear-gradient(90deg, #ff3333, #ff9999); }
.skill-fill { background: linear-gradient(90deg, #00ffff, #ffffff); }
#skill-container { pointer-events: auto; position: absolute; right: 20px; top: 60px; text-align: center; width: 100px; }
#skill-btn { padding: 10px; width: 100%; font-size: 14px; margin-bottom: 5px; }

#dialogue-area { display: flex; justify-content: space-between; align-items: flex-end; padding: 10px; background: rgba(0,0,0,0.8); border-top: 2px solid #558; }
.chara-box img { width: 65px; height: 65px; border-radius: 50%; border: 2px solid #88f; object-fit: cover; }
.balloon { flex-grow: 1; margin: 0 10px; padding: 12px; background: rgba(255,255,255,0.95); color: #000; border-radius: 10px; font-weight: bold; font-size: 14px; position: relative; }
#speaker-name { color: #3333ff; }
.result-dialogue { background: rgba(255,255,255,0.9); color: #111; padding: 20px; border-radius: 10px; margin: 20px; font-weight: bold; width: 80%; }

/* クラスバッジ */
.class-badge { background: #558; color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 12px; margin-left: 10px; }

/* 🌟 ステージ3専用：豚骨スープ背景（JSで切り替え） */
.soup-bg { background: radial-gradient(circle, #8a733a 0%, #3d3215 100%) !important; }

/* お邪魔テキスト */
.decoy-text { font-size: 30px; font-weight: bold; opacity: 0.6; pointer-events: none; }

/* ミニゲーム中の演出 */
.breakthrough-flash { animation: flash 0.5s infinite alternate; }
@keyframes flash { from { box-shadow: inset 0 0 20px #fff; } to { box-shadow: inset 0 0 100px #fff; } }

/* 🌟 ステージ選択画面をスクロール可能に修正！ */
#stage-select-screen {
    justify-content: flex-start; /* 上から並べる */
    overflow-y: auto;            /* 縦スクロールを許可 */
    padding-top: 40px;           /* 上に少し余白 */
    padding-bottom: 40px;
}

/* スクロールバーのデザイン（Webkit系） */
#stage-select-screen::-webkit-scrollbar {
    width: 8px;
}
#stage-select-screen::-webkit-scrollbar-thumb {
    background: #555599;
    border-radius: 4px;
}
/* 🌟 強制的に非表示にするための重要ルール */
.hidden {
    display: none !important;
}

/* 各スクリーンが全画面を覆うように設定 */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 15, 0.95); /* 背景を濃くして後ろを遮断 */
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100; /* ゲームUI(z-index:10)より上にする */
    padding: 20px;
    box-sizing: border-box;
}

.screen.active {
    display: flex;
}

/* ゲームUI（HPバーやセリフ枠）の配置 */
#game-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* 下のボタンが押せるように */
    z-index: 50;
}

#top-bar, #dialogue-area, #skill-container {
    pointer-events: auto; /* UIのボタンだけは触れるように */
}

/* 🌟 退出ボタンを小さく */
#quit-btn {
    padding: 4px 10px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    margin-left: 10px;
    color: #ccc;
}
#quit-btn:hover { background: rgba(200, 0, 0, 0.5); color: #fff; }

/* クラスバッジ等の微調整 */
.class-badge { background: #448; padding: 2px 6px; border-radius: 4px; font-size: 10px; vertical-align: middle; }
/* 🌟 ホームへ戻るリンクボタン */
.home-link-area {
    margin-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
    width: 80%;
}

.home-link-btn {
    text-decoration: none;
    color: #8888aa;
    font-size: 14px;
    font-weight: bold;
    transition: 0.3s;
    display: inline-block;
}

.home-link-btn:hover {
    color: #ccffff;
    text-shadow: 0 0 10px #66ccff;
    transform: translateY(-2px);
}

.home-link-btn i {
    margin-right: 5px;
}

/* UIデザイン */
#game-ui { 
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; 
    pointer-events: none; /* 🌟 下にあるキャンバスのクリックを邪魔しない */
    z-index: 50; 
    display: flex; flex-direction: column; justify-content: space-between; 
}

/* 🌟 トップバー全体をクリック可能にする */
#top-bar { 
    display: flex; justify-content: space-between; padding: 10px 20px; 
    background: rgba(0,0,0,0.6); border-bottom: 1px solid #558; 
    pointer-events: auto; /* 🌟 ここ重要！ボタンが押せるようにする */
}

/* 🌟 サウンド＆退出ボタンのコンテナ */
#ui-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* 音量ボタンのデザイン */
#sound-toggle-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    padding: 0 5px;
    margin: 0;
    cursor: pointer;
}
#sound-toggle-btn:hover { color: #0ff; transform: scale(1.1); }

/* 退出ボタンを小さく */
#quit-btn {
    padding: 4px 10px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    margin: 0;
    color: #ccc;
    cursor: pointer;
}
#quit-btn:hover { background: rgba(200, 0, 0, 0.5); color: #fff; }

.gauge-container { display: flex; align-items: center; gap: 10px; width: 40%; }
.gauge-bg { width: 100%; height: 15px; background: #222; border-radius: 10px; overflow: hidden; border: 1px solid #555; }
.gauge-fill { height: 100%; transition: width 0.3s; }
.hp-fill { background: linear-gradient(90deg, #ff3333, #ff9999); }
.skill-fill { background: linear-gradient(90deg, #00ffff, #ffffff); }

/* 🌟 スキルボタンもクリック可能に */
#skill-container { 
    pointer-events: auto; /* 🌟 ここ重要！ */
    position: absolute; right: 20px; top: 60px; text-align: center; width: 100px; 
}
#skill-btn { padding: 10px; width: 100%; font-size: 14px; margin-bottom: 5px; cursor: pointer; }

/* 🌟 ダイアログエリアもクリック可能に */
#dialogue-area { 
    pointer-events: auto; /* 🌟 ここ重要！ */
    display: flex; justify-content: space-between; align-items: flex-end; 
    padding: 10px; background: rgba(0,0,0,0.8); border-top: 2px solid #558; 
}
/* 🌟 トップバーとUIコントロールの配置修正 */
#top-bar {
    position: relative; /* 絶対配置の基準にする */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(0,0,0,0.8);
    border-bottom: 1px solid #558;
    pointer-events: auto; /* ボタンを押せるようにする */
    z-index: 1000; /* キャンバス(z-index: 5)より圧倒的に上にする！ */
}

/* 音量ボタンと退出ボタンを横に並べる */
#ui-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* 音量ボタンのデザイン（はみ出さないように） */
#sound-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 18px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    padding: 0;
    margin: 0;
    transition: 0.2s;
}

#sound-toggle-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    border-color: #0ff;
    color: #0ff;
    transform: scale(1.1);
}

/* 退出ボタンのデザイン */
#quit-btn {
    padding: 6px 12px;
    font-size: 12px;
    background: rgba(255, 0, 0, 0.2);
    border: 1px solid rgba(255, 0, 0, 0.5);
    border-radius: 15px;
    color: #fff;
    cursor: pointer;
    margin: 0;
    transition: 0.2s;
}

#quit-btn:hover {
    background: rgba(255, 0, 0, 0.6);
}
/* 🌟 スマホ（レスポンシブ）対応 */
@media (max-width: 600px) {
    #game-container {
        width: 100vw;
        height: 100vh;
        border: none;
        border-radius: 0;
    }
    
    h1 { font-size: 28px; }
    h2 { font-size: 20px; }
    
    /* ステージ選択を1列にしてタップしやすく */
    .grid-container {
        grid-template-columns: 1fr;
    }
    
    /* プロフ画面のカードを縦並びに */
    .prof-container {
        flex-direction: column;
    }
    
    /* ゲームUIの文字サイズを調整 */
    .balloon {
        font-size: 12px;
        padding: 8px;
    }
    .chara-box img {
        width: 40px;
        height: 40px;
    }
}
