@import url('https://fonts.googleapis.com/css2?family=Shippori+Mincho:wght@400;700&display=swap');

/* ==========================================================================
   :root - 変数定義
   ========================================================================== */
:root {
    --bg-color: #1a1a2e;
    --primary-color: #e0e0e0;
    --accent-color: #f7b733;
    --accent-color-hover: #ffc966;
    --card-bg-color: #162447;
    --card-border-color: #0f3460;
    --secondary-btn-bg: #5a5a7a;
    --secondary-btn-bg-hover: #7878a3;
    --shadow-color: #00000050;
}

/* ==========================================================================
   基本スタイルとヘルパークラス
   ========================================================================== */
body {
    background-color: var(--bg-color);
    color: var(--primary-color);
    font-family: 'Shippori Mincho', serif;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}

.container {
    width: 100%;
    max-width: 800px;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   ヘッダー
   ========================================================================== */
header h1 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-shadow: 0 0 15px var(--accent-color), 0 0 5px var(--primary-color);
    margin-bottom: 0;
}

header p {
    font-size: 1.1rem;
    color: var(--primary-color);
    opacity: 0.8;
    margin-top: 5px;
}

/* ==========================================================================
   モード選択画面
   ========================================================================== */
.game-mode-selection {
    margin-top: 50px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
}

.game-mode-btn {
    background: linear-gradient(145deg, var(--card-bg-color), #1f4068);
    color: var(--primary-color);
    border: 2px solid var(--card-border-color);
    border-radius: 10px;
    padding: 25px;
    min-width: 220px;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease-in-out;
    box-shadow: 0 5px 15px var(--shadow-color);
    position: relative;
    overflow: hidden;
}

.game-mode-btn:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, var(--accent-color) 0%, rgba(247,183,51,0) 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
    opacity: 0;
}

.game-mode-btn:hover:not(:disabled) {
    border-color: var(--accent-color);
    transform: translateY(-5px);
    box-shadow: 0 10px 25px var(--shadow-color);
}

.game-mode-btn:hover:not(:disabled):before {
    width: 250%;
    height: 250%;
    opacity: 0.2;
}

.game-mode-btn .btn-title {
    font-size: 1.5rem;
    font-weight: 700;
    display: block;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.game-mode-btn .btn-description {
    font-size: 0.9rem;
    opacity: 0.8;
    display: block;
    position: relative;
    z-index: 1;
}

.game-mode-btn:disabled {
    cursor: not-allowed;
    filter: grayscale(80%);
    opacity: 0.6;
}

/* ==========================================================================
   モーダル (共通スタイル)
   ========================================================================== */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 100;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--bg-color);
    border: 2px solid var(--card-border-color);
    border-radius: 10px;
    padding: 30px 40px;
    z-index: 101;
    width: 90%;
    max-width: 700px;
    box-shadow: 0 10px 30px var(--shadow-color);
    text-align: center;
}

.modal h2 {
    font-size: 2rem;
    color: var(--accent-color);
    text-shadow: 0 0 8px var(--accent-color);
}

/* ==========================================================================
   モーダル (個別コンテンツ)
   ========================================================================== */

/* クラシックモード選択 */
.game-selection-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin: 30px 0;
}

.game-card {
    background-color: var(--card-bg-color);
    border: 1px solid var(--card-border-color);
    border-radius: 8px;
    padding: 20px;
    width: 150px;
    text-align: center;
    transition: all 0.3s ease;
}

.game-card:not(.locked) {
    cursor: pointer;
}

.game-card:not(.locked):hover {
    transform: translateY(-5px);
    border-color: var(--accent-color);
    box-shadow: 0 8px 20px var(--shadow-color);
}

.game-card h3 {
    margin: 0 0 10px 0;
    font-size: 1.5rem;
}

.game-card p {
    margin: 0;
    font-size: 0.8rem;
    opacity: 0.7;
}

.game-card.locked {
    cursor: not-allowed;
    filter: grayscale(1);
    opacity: 0.5;
}

/* ルール説明 */
.rule-list {
    text-align: left;
    display: inline-block;
    margin: 20px 0;
    padding-left: 20px;
}

.rule-list li {
    margin-bottom: 10px;
    line-height: 1.6;
}

/* 結果表示モーダルのボタンコンテナ */
.modal-actions {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 20px;
}
.modal-actions .start-game-btn,
.modal-actions .close-modal-btn {
    margin-top: 0;
}


/* ==========================================================================
   ボタン (共通)
   ========================================================================== */

/* プライマリボタン (黄色系) */
.start-game-btn,
#answer-btn {
    background-color: var(--accent-color);
    color: var(--bg-color);
    border: none;
    border-radius: 5px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.start-game-btn {
    padding: 12px 35px;
    font-size: 1.1rem;
}

#answer-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.2rem;
}

.start-game-btn:hover,
#answer-btn:not(:disabled):hover {
    background-color: var(--accent-color-hover);
}

#answer-btn:disabled {
    background-color: var(--secondary-btn-bg);
    color: #aaa;
    cursor: not-allowed;
}

/* セカンダリボタン (グレー系) */
.close-modal-btn,
#coin-back-to-menu-btn,
#hat-back-to-menu-btn,
#back-to-menu-btn {
    background-color: var(--secondary-btn-bg);
    color: var(--primary-color);
    border: none;
    border-radius: 5px;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s;
}
.close-modal-btn {
    font-size: 1rem;
    padding: 10px 30px;
    margin-top: 20px;
}
#back-to-menu-btn,
#coin-back-to-menu-btn,
#hat-back-to-menu-btn
{
    font-size: 0.9rem;
    padding: 8px 15px;
}

.close-modal-btn:hover,
#back-to-menu-btn:hover,
#coin-back-to-menu-btn:hover,
#hat-back-to-menu-btn:hover
{
    background-color: var(--secondary-btn-bg-hover);
}


/* ヘルプボタン (特殊形状) */
#help-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: var(--bg-color);
    border: none;
    font-size: 1.8rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px var(--shadow-color);
    transition: all 0.2s;
    z-index: 200;
}

#help-btn:hover {
    transform: scale(1.1);
    background-color: var(--accent-color-hover);
}

/* ==========================================================================
   ゲームプレイ画面
   ========================================================================== */
#game-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--card-border-color);
    padding-bottom: 20px;
}

.game-header h2 {
    font-size: 2.2rem;
    color: var(--primary-color);
    margin: 0;
}

#back-to-menu-btn,
#coin-back-to-menu-btn,
#hat-back-to-menu-btn
{
    position: absolute;
    left: 0;
}

.game-board {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

/* 登場人物エリア */
.character-area {
    flex: 2;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.character-card {
    background: linear-gradient(145deg, var(--card-bg-color), #1f4068);
    border: 1px solid var(--card-border-color);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    gap: 20px;
    align-items: center;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease, border-left-color 0.3s ease;
    border-left: 5px solid transparent;
}

.character-card:hover {
    border-color: var(--primary-color);
}

.character-info {
    flex-shrink: 0;
    width: 80px;
    text-align: center;
}

.character-name {
    font-size: 3rem;
    font-weight: bold;
    color: var(--accent-color);
    display: block;
}

.status-label {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 4px;
    margin-top: 5px;
    background-color: var(--secondary-btn-bg);
    color: #fff;
    width: 50px;
}

.character-card.status-truthful {
    background: linear-gradient(145deg, #1e3a5f, #2a5288);
    border-left-color: #3498db;
}
.character-card.status-truthful .status-label {
    background-color: #3498db;
}

.character-card.status-liar {
    background: linear-gradient(145deg, #5f1e1e, #882a2a);
    border-left-color: #e74c3c;
}
.character-card.status-liar .status-label {
    background-color: #e74c3c;
}

.statements p {
    margin: 0 0 8px 0;
    line-height: 1.5;
    background-color: rgba(0,0,0,0.2);
    padding: 8px 12px;
    border-radius: 4px;
}
.statements p:last-child {
    margin-bottom: 0;
}

/* 推理・回答エリア */
.deduction-area {
    flex: 1;
    min-width: 250px;
    background-color: var(--card-bg-color);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--card-border-color);
}

.deduction-area h3 {
    text-align: center;
    margin-top: 0;
    font-size: 1.5rem;
}

.deduction-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.deduction-table th, .deduction-table td {
    border: 1px solid var(--card-border-color);
    padding: 10px;
    text-align: center;
}

.deduction-table th {
    background-color: #0f3460;
}

.deduction-table input[type="radio"] {
    transform: scale(1.5);
    cursor: pointer;
}

/* ==========================================================================
   デバッグ用スタイル (本番では非表示)
   ========================================================================== */
#debug-info {
    margin-top: 30px;
    padding: 15px;
    background-color: #111;
    border: 1px dashed #555;
    border-radius: 8px;
    color: #eee;
}

#debug-info h3 {
    margin: 0 0 10px 0;
    color: var(--accent-color);
    text-align: center;
}

#debug-info pre {
    margin: 0;
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.6;

}

/* ==========================================================================
   偽物のコインクイズ
   ========================================================================== */
   #coin-game-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

#coin-game-container .help-btn {
    position: absolute;
    right: 0;
    width: 35px;
    height: 35px;
    font-size: 1.5rem;
}

#coin-game-info {
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 20px;
}
#weigh-count {
    color: var(--accent-color);
    font-size: 1.5rem;
}

#top-coins-area {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border: 2px dashed var(--card-border-color);
    border-radius: 10px;
    min-height: 50px;
}

.coin {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(45deg, #fce57f, #f7b733);
    color: #a16400;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3), inset 1px 1px 2px #fff7d6;
}

/* 天秤エリア */
#scale-area {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.pan-selection-area {
    flex: 1;
    background-color: var(--card-bg-color);
    border-radius: 8px;
    padding: 15px;
    min-width: 250px;
}
.pan-selection-area h4 {
    margin: 0 0 15px 0;
    text-align: center;
}
.selectable-coins {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.selectable-coin {
    opacity: 0.4;
    cursor: pointer;
    transition: all 0.2s ease;
}
.selectable-coin:hover {
    opacity: 0.7;
}
.selectable-coin.selected {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--accent-color);
}
.selectable-coin.disabled {
    opacity: 0.1;
    cursor: not-allowed;
}

#scale-visual-area {
    flex: 0 0 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 50px;
}

#scale-visual {
    width: 300px;
    height: 150px;
    position: relative;
    transition: transform 0.5s ease-in-out;
}
#scale-visual .scale-arm {
    width: 100%;
    height: 8px;
    background: #ccc;
    border-radius: 4px;
    position: absolute;
    top: 0;
    left: 0;
    transition: transform 0.5s ease-in-out;
}
#scale-visual .scale-pan {
    width: 80px;
    height: 80px;
    border: 4px solid #ccc;
    border-top: none;
    border-radius: 0 0 40px 40px;
    position: absolute;
    bottom: 0;
    transition: transform 0.5s ease-in-out;
}
#scale-visual .left-pan { left: 0; }
#scale-visual .right-pan { right: 0; }

/* 天秤の傾き */
#scale-visual.tilt-left .scale-arm { transform: rotate(-10deg); }
#scale-visual.tilt-left .left-pan { transform: translateY(20px); }
#scale-visual.tilt-left .right-pan { transform: translateY(-20px); }

#scale-visual.tilt-right .scale-arm { transform: rotate(10deg); }
#scale-visual.tilt-right .right-pan { transform: translateY(20px); }
#scale-visual.tilt-right .left-pan { transform: translateY(-20px); }


#weigh-btn {
    margin-top: 20px;
    padding: 10px 30px;
}

/* ログエリア */
#log-area {
    margin-top: 30px;
    padding: 15px;
    background-color: rgba(0,0,0,0.2);
    border-radius: 8px;
    min-height: 100px;
}
#log-area h4 { margin: 0 0 10px 0; }
#log-list { list-style: none; padding: 0; margin: 0; }
#log-list li { padding: 5px; border-bottom: 1px solid var(--card-border-color); }
#log-list li:last-child { border-bottom: none; }

/* 最終回答エリア */
#final-answer-area {
    margin-top: 30px;
    text-align: center;
    display: none; /* 初期状態は非表示 */
}
#final-answer-area.visible {
    display: block;
}
#answer-select {
    padding: 8px;
    font-size: 1.1rem;
    border-radius: 5px;
    margin-right: 10px;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative; /* これが重要 */
    margin-bottom: 30px;
    border-bottom: 2px solid var(--card-border-color);
    padding-bottom: 20px;
}

#coin-game-container .help-btn {
    position: absolute;
    right: 0;
    width: 35px;
    height: 35px;
    font-size: 1.5rem;
}

#coin-help-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: var(--bg-color);
    border: none;
    font-size: 1.8rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px var(--shadow-color);
    transition: all 0.2s;
    z-index: 200;
}

#coin-help-btn:hover {
    transform: scale(1.1);
    background-color: var(--accent-color-hover);
}

/* ==========================================================================
   帽子の色あてクイズ
   ========================================================================== */
   #hat-puzzle-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

#hat-pool-display {
    text-align: center;
    margin-bottom: 25px;
}
#hat-pool-display h4 {
    margin: 0 0 10px 0;
}
.hat-pool-items {
    display: flex;
    justify-content: center;
    gap: 10px;
}
.hat-item {
    width: 30px;
    height: 30px;
    border-radius: 5px;
}

#player-display {
    display: flex;
    justify-content: space-around;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap; /* スマホ対応 */
}

.player-card {
    background-color: var(--card-bg-color);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    width: 120px;
    border-bottom: 5px solid var(--card-border-color);
}
.player-card.is-user {
    border-bottom-color: var(--accent-color);
}
.player-name {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 10px;
}
.hat-display {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}
.hat-red {
    background-color: #e74c3c;
    box-shadow: inset 0 -5px 0 rgba(0,0,0,0.2);
}
.hat-blue {
    background-color: #3498db;
    box-shadow: inset 0 -5px 0 rgba(0,0,0,0.2);
}
.hat-unknown {
    background-color: #7f8c8d;
    box-shadow: inset 0 -5px 0 rgba(0,0,0,0.2);
}


#log-area-hat {
    margin-top: 20px;
    padding: 15px;
    background-color: rgba(0,0,0,0.2);
    border-radius: 8px;
    min-height: 100px; /* 空の状態でも最低限の高さを確保 */
    /* heightとoverflow-yの指定を削除 */
}
#log-area-hat h4 { margin: 0 0 10px 0; }
#log-list-hat p {
    margin: 0 0 8px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--card-border-color);
}
#log-list-hat p:last-child {
    border-bottom: none;
}

#user-action-area {
    margin-top: 25px;
    text-align: center;
    padding: 20px;
    background-color: var(--card-bg-color);
    border-radius: 8px;
}
#user-action-area h4 { margin: 0 0 15px 0; }
.user-choice-btn {
    padding: 12px 25px;
    font-size: 1rem;
    margin: 0 5px;
}

#result-area-hat {
    margin-top: 25px;
    padding: 25px;
    border: 2px dashed var(--accent-color);
    border-radius: 8px;
    text-align: center;
}
#result-title-hat {
    font-size: 2rem;
    margin: 0 0 15px 0;
}
#result-explanation-hat {
    line-height: 1.8;
    text-align: left;
    display: inline-block;
    margin-bottom: 20px;
}
/* ==========================================================================
   タイムアタックモード
   ========================================================================== */
   #time-attack-hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 25px;
    box-sizing: border-box;
    z-index: 50; /* モーダルよりは下、ゲーム画面よりは上 */
    font-size: 1.2rem;
    font-weight: bold;
}

.hud-item {
    min-width: 150px;
}

#time-attack-timer {
    color: var(--accent-color);
    font-size: 1.5rem;
}

#time-attack-score {
    color: var(--accent-color);
    font-size: 1.5rem;
}

#time-attack-quit-btn {
    background-color: var(--secondary-btn-bg);
    color: var(--primary-color);
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
}
#time-attack-quit-btn:hover {
    background-color: var(--secondary-btn-bg-hover);
}

#final-score-display {
    font-size: 4rem;
    font-weight: bold;
    color: var(--accent-color);
    margin: 20px 0;
    text-shadow: 0 0 15px var(--accent-color);
}
/* ==========================================================================
   タイムアタック用フィードバック
   ========================================================================== */
   #feedback-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 30px 60px;
    border-radius: 15px;
    color: white;
    font-size: 2.5rem;
    font-weight: bold;
    z-index: 200; /* 最前面に表示 */
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    pointer-events: none; /* クリックを透過させる */
}
#feedback-modal.correct {
    background-color: rgba(52, 152, 219, 0.85); /* 青色 */
}
#feedback-modal.incorrect {
    background-color: rgba(231, 76, 60, 0.85); /* 赤色 */
}

.hidden{
    display: none;
}