:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --secondary: #10b981;
    --accent: #f59e0b;
    --danger: #ef4444;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    
    --p1: #e11d48;
    --p2: #2563eb;
    --p3: #059669;
    --p4: #d97706;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--bg);
    margin: 0;
    padding: 10px;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ▼ 画面切り替えの高速化 (0.6s -> 0.3s) */
.screen { display: none; }
.screen.active { display: block; animation: fadeUp 0.3s ease-out; }
.hidden { display: none; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); } /* 移動距離も短縮 */
    to { opacity: 1; transform: translateY(0); }
}

/* ▼ 遷移エフェクト (オーバーレイ) ▼ */
.transition-layer {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(17, 24, 39, 0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    color: white;
    backdrop-filter: blur(5px);
}
/* アニメーション時間を短縮 (1.5s -> 1.2s) */
.transition-layer.active { display: flex; animation: fadeInOut 1.2s forwards; }

.transition-content { text-align: center; transform: scale(0.8); animation: zoomIn 0.4s forwards; }
.trans-player-name { font-size: 2.5rem; margin: 0; color: #fff; text-shadow: 0 4px 10px rgba(0,0,0,0.5); }
.trans-divider { height: 4px; width: 50px; background: var(--secondary); margin: 15px auto; border-radius: 2px; }
.trans-turn-info { font-size: 1.2rem; color: #d1d5db; letter-spacing: 1px; }

@keyframes fadeInOut {
    0% { opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { opacity: 0; }
}
@keyframes zoomIn {
    to { transform: scale(1); }
}

/* ▼ カード・コンテナ ▼ */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 40px;
    max-width: 600px;
    margin: 40px auto;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.logo-icon { font-size: 3rem; color: var(--primary); margin-bottom: 10px; }
.subtitle { color: var(--text-light); font-weight: bold; letter-spacing: 2px; text-transform: uppercase; font-size: 0.8rem; }

/* ボタン高速化調整 */
.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    /* transitionを短縮し、transformのみに限定 */
    transition: background-color 0.2s, transform 0.1s;
    font-weight: bold;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}
.btn-primary:hover { background-color: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.3); }
/* クリック時(:active)は即座に反応させる */
.btn-primary:active { transform: translateY(0); transition: none; }

.btn-large { width: 100%; padding: 15px; font-size: 1.2rem; margin-top: 20px; }

/* ヘッダー */
header {
    background: white;
    padding: 10px 20px;
    margin-bottom: 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}
.header-left { display: flex; align-items: center; gap: 15px; }
.turn-badge { font-weight: bold; font-size: 1.1rem; }
.economy-badge { padding: 4px 10px; border-radius: 20px; font-size: 0.8rem; font-weight: bold; color: white; }
.eco-good { background: var(--p1); }   
.eco-normal { background: var(--secondary); } 
.eco-bad { background: var(--text); }   

.player-badge { font-weight: bold; color: var(--text); font-size: 1rem; }

/* ゲームレイアウト */
.game-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
    align-items: flex-start;
}

/* ステータスパネル */
.status-panel {
    background: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    flex: 1;
    min-width: 280px;
    max-width: 320px;
    border-top: 6px solid #ccc; 
}

.profile-header { display: flex; gap: 15px; margin-bottom: 20px; align-items: center; }
.avatar-circle {
    width: 64px; height: 64px;
    background: #f3f4f6;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem;
    color: var(--text);
}
.profile-info { flex: 1; }
.badges-container { display: flex; gap: 5px; margin-bottom: 5px; }
.status-badge { background: #e5e7eb; color: var(--text-light); font-size: 0.75rem; padding: 2px 8px; border-radius: 4px; font-weight: bold; }
.status-badge.outline { background: transparent; border: 1px solid #e5e7eb; }

.health-meta { font-size: 0.8rem; }
.health-label { color: var(--text-light); margin-bottom: 2px; font-size: 0.7rem; }
.health-bar-bg { background: #e5e7eb; height: 6px; border-radius: 3px; overflow: hidden; width: 100%; margin-bottom: 2px;}
.health-bar-fill { height: 100%; background: var(--secondary); transition: width 0.3s; }
.health-value { text-align: right; font-size: 0.7rem; color: var(--text-light); }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 15px; }
.stat-item { background: #f9fafb; padding: 8px; border-radius: 8px; font-size: 0.9rem; color: var(--text-light); }
.stat-item i { width: 20px; text-align: center; color: var(--primary); }
.stat-item .val { color: var(--text); font-weight: bold; margin-left: 5px; float: right; }

.finance-grid { border-top: 1px dashed var(--border); padding-top: 15px; margin-bottom: 15px; }
.stat-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 0.95rem; }
.money-val { font-weight: bold; color: var(--p4); font-size: 1.1rem; }
.cp-val { font-weight: bold; color: var(--p1); font-size: 1.1rem; }
.budget-row { text-align: right; color: var(--text-light); font-size: 0.8rem; }

.assets-section h6 { margin: 0 0 5px 0; color: var(--text-light); font-size: 0.8rem; }
.assets-list { min-height: 20px; display: flex; flex-wrap: wrap; gap: 5px; }
.asset-item {
    background: #fffbeb; border: 1px solid #fcd34d; color: #b45309;
    padding: 4px 8px; border-radius: 6px; font-size: 0.8rem;
    display: flex; align-items: center; gap: 5px;
}
/* 売却ボタン高速化 */
.btn-sell {
    background: #ef4444; color: white; border: none; border-radius: 4px;
    font-size: 0.65rem; padding: 2px 6px; cursor: pointer;
    transition: background 0.1s;
}
.btn-sell:hover { background: #dc2626; }
.btn-sell:active { transform: scale(0.95); }

.energy-area { margin-top: 15px; text-align: center; background: #f3f4f6; padding: 8px; border-radius: 8px; }
.energy-label { font-size: 0.7rem; color: var(--text-light); font-weight: bold; display: block; margin-bottom: 4px;}
.energy-dots { color: var(--accent); font-size: 1.2rem; letter-spacing: 4px; }

/* アクションパネル */
.action-panel {
    flex: 2;
    min-width: 320px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    overflow: hidden;
    display: flex; flex-direction: column;
}

.message-box {
    background: #ecfdf5; border-left: 4px solid var(--secondary);
    padding: 15px; margin: 15px; border-radius: 6px;
    color: #065f46; font-size: 0.95rem; min-height: 60px;
}

.tab-header { display: flex; background: #f9fafb; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-btn {
    flex: 1; padding: 15px 10px; border: none; background: transparent;
    color: var(--text-light); font-weight: bold; cursor: pointer;
    border-bottom: 3px solid transparent; white-space: nowrap;
    transition: color 0.2s, background 0.2s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); background: white; }
.tab-btn:hover { background: #f3f4f6; }

.tab-content { padding: 20px; background: white; flex: 1; }
.tab-pane { display: none; animation: fadeIn 0.2s ease-out; } /* フェードイン短縮 */
.tab-pane.active { display: block; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.grid-buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; }

/* アクションボタン高速化 */
.btn-action {
    background: white; border: 1px solid var(--border); border-radius: 10px;
    padding: 15px; text-align: center; cursor: pointer; 
    /* hover時のアニメーションは残しつつ、activeは別制御 */
    transition: transform 0.1s, border-color 0.1s, box-shadow 0.1s;
    position: relative; min-height: 100px; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
    /* スマホでのタップ遅延防止 */
    touch-action: manipulation;
}
.btn-action:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-3px); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }
/* active時は即座に沈む */
.btn-action:active:not(:disabled) { transform: translateY(0); box-shadow: none; transition: none; background: #f9fafb;}
.btn-action:disabled { opacity: 0.5; background: #f3f4f6; cursor: not-allowed; transform: none; }

.btn-action strong { display: block; color: var(--text); font-size: 0.95rem; margin-bottom: 5px; }
.btn-action small { color: var(--text-light); font-size: 0.75rem; line-height: 1.3; }

.badge-row { margin-top: 8px; display: flex; gap: 4px; justify-content: center; }
.cost-badge, .cost-money, .cost-health { 
    font-size: 0.65rem; padding: 2px 6px; border-radius: 10px; font-weight: bold; color: white; 
}
.cost-badge { background: var(--p2); }
.cost-money { background: var(--p4); }
.cost-health { background: var(--secondary); }

/* サイドパネル (ランキング&次へ) */
.side-panel { flex: 1; min-width: 250px; max-width: 300px; display: flex; flex-direction: column; gap: 20px; }
.ranking-box { background: white; padding: 20px; border-radius: 16px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.ranking-box h3 { margin-top: 0; font-size: 1rem; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 10px; }
#ranking-list { list-style: none; padding: 0; margin: 0; }
#ranking-list li { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 0.9rem; display: flex; justify-content: space-between; }

.btn-next {
    width: 100%; padding: 15px; background: var(--text); color: white; border: none;
    border-radius: 12px; font-size: 1.1rem; font-weight: bold; cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3); 
    transition: transform 0.1s;
}
.btn-next:hover:not(:disabled) { transform: scale(1.02); background: black; }
.btn-next:active:not(:disabled) { transform: scale(0.98); transition: none; }
.btn-next:disabled { background: #d1d5db; cursor: not-allowed; box-shadow: none; transform: none; }

/* スマホ対応 */
@media (max-width: 768px) {
    .game-container { flex-direction: column; }
    .status-panel, .action-panel, .side-panel { max-width: 100%; width: 100%; }
    .side-panel { flex-direction: column-reverse; } /* ボタンを上に */
    /* スマホでのボタンの押しやすさ調整 */
    .btn-action { min-height: 80px; padding: 10px; }
}

/* プレイヤー別カラー (JSで付与) */
.p-color-0 { border-top-color: var(--p1); }
.p-color-1 { border-top-color: var(--p2); }
.p-color-2 { border-top-color: var(--p3); }
.p-color-3 { border-top-color: var(--p4); }

/* モーダル */
.modal-overlay {
    background: rgba(0,0,0,0.6); backdrop-filter: blur(2px);
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1000; justify-content: center; align-items: center;
}
.modal-overlay.active { display: flex; animation: fadeIn 0.2s; }
.modal-content {
    background: white; padding: 30px; border-radius: 16px; width: 90%; max-width: 450px;
    text-align: center; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}
.choice-list { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.btn-choice {
    background: white; border: 2px solid var(--border); padding: 15px; border-radius: 10px;
    text-align: left; cursor: pointer; transition: background 0.1s, border 0.1s;
}
.btn-choice:hover { border-color: var(--primary); background: #f5f3ff; }
.btn-choice:active { background: #e0e7ff; transition: none; }
.btn-choice b { display: block; color: var(--text); margin-bottom: 2px; }
.btn-choice small { color: var(--text-light); }

/* 名前入力フォーム用 */
.name-inputs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.name-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.name-input-row label {
    font-weight: bold;
    min-width: 80px;
    text-align: right;
    font-size: 0.9rem;
    color: var(--text-light);
}

.name-input-row input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    outline: none;
    transition: 0.2s;
}

.name-input-row input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* 既存のCSSの最後に追加、またはbtn-choice部分を上書き */

/* 選択肢ボタンの強化 */
.btn-choice {
    background: white; border: 2px solid var(--border); padding: 15px; border-radius: 10px;
    text-align: left; cursor: pointer; transition: background 0.1s, border 0.1s;
    position: relative;
}
.btn-choice:hover:not(:disabled) { border-color: var(--primary); background: #f5f3ff; }
.btn-choice:active:not(:disabled) { background: #e0e7ff; transition: none; }

/* 無効時のスタイルを明確に */
.btn-choice:disabled {
    background-color: #f3f4f6;
    border-color: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.8;
}
.btn-choice:disabled b { color: #6b7280; } /* タイトルも薄く */

/* 条件不足のアラート表示 */
.cond-alert {
    color: var(--danger);
    font-weight: bold;
    margin-left: 5px;
    font-size: 0.85rem;
}
.btn-choice:disabled .cond-alert {
    color: #ef4444; /* 無効時も赤色は維持 */
}