/* --- 1. 変数定義 --- */
:root {
    --primary-color: #27ae60;    /* 芝グリーン */
    --primary-light: #eafaf1;
    --secondary-color: #2c3e50;  /* 信頼ネイビー */
    --main-color: #ff8e72;      /* 少しピンクがかった、優しくて明るいオレンジ */
    --accent-color: #ffc107;    /* 期待値を表す、キラキラしたゴールドイエロー */
    --bg-color: #fff9f8;        /* ほんのり温かみのある白背景 */
    --text-color: #4a4a4a;      /* 柔らかいダークグレー */
    --card-bg: #ffffff;
    --surface-color: #ffffff;    /* 白背景 */
    --text-light: #7f8c8d;
    --border-color: #e0e0e0;
    --danger-color: #e63946;     /* 強調・期待値用 */
    --font-main: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
}

/* --- 2. ベース（リセット後の再定義） --- */
* { box-sizing: border-box; }

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* --- 3. ヘッダー・フッター --- */
header {
    background-color: #fff;
    border-bottom: 3px solid var(--main-color);
    padding: 15px 0;
}

header h1 {
    color: var(--main-color);
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 1px;
}

/* 診断ボタン（決定的なアクション） */
.primary-btn, .primary-re-btn {
    background: linear-gradient(135deg, var(--main-color), #ff6b6b);
    border: none;
    border-radius: 50px; /* 角を丸くしてポップに */
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(255, 142, 114, 0.3);
    transition: transform 0.2s ease;
}

.primary-btn:active {
    transform: scale(0.98);
}

.main-header {
    background-color: var(--surface-color);
    border-bottom: 3px solid var(--primary-color);
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo { font-size: 24px; font-weight: 900; text-decoration: none; }
.logo-main { color: var(--secondary-color); }
.logo-sub {
    color: var(--primary-color);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 2px;
}

.main-footer {
    background-color: var(--secondary-color);
    color: #ecf0f1;
    padding: 30px 0;
    margin-top: 60px;
    text-align: center;
}

/* --- 4. メインコンテナ --- */
.container {
    max-width: 800px;
    margin: 40px auto;
    padding: 40px;
    background: var(--surface-color);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

h1 {
    font-size: 24px;
    margin-bottom: 30px;
    text-align: center;
    color: var(--secondary-color);
    font-weight: 900;
}

section { margin-bottom: 40px; }

.hero-copy {
    margin: 20px auto 30px;
    padding: 0 15px;
}

.hero-inner {
    background: linear-gradient(135deg, #fffaf0 0%, #ffffff 100%); /* 柔らかなクリーム系のグラデーション */
    padding: 30px 20px;
    border-radius: 20px;
    border: 2px solid #ffedcc; /* 優しいオレンジの枠線 */
    text-align: center;
    box-shadow: 0 8px 20px rgba(0,0,0,0.05);
    position: relative;
    overflow: hidden;
}

/* 装飾用の擬似要素：キラキラした多幸感を演出 */

.main-copy {
    font-size: 22px;
    font-weight: 900;
    color: #d35400; /* 落ち着いたオレンジ */
    margin-bottom: 15px;
    letter-spacing: 0.05em;
}

.main-copy .highlight {
    color: #e67e22;
    font-size: 28px;
    font-weight: 900;
    text-shadow: 2px 2px 0px #fff, 4px 4px 0px rgba(230,126,34,0.1);
    display: inline-block;
    white-space: nowrap; 
}

.sub-copy {
    font-size: 14px;
    line-height: 1.8;
    color: #5d6d7e;
    font-weight: 600;
}

.sub-copy span {
    display: inline-block;
    background: linear-gradient(transparent 60%, #fff2cc 60%); /* 重要な箇所にマーカー風の線 */
    color: #2c3e50;
    font-weight: 800;
    padding: 0 2px;
}

.section-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 10px;
}

.step-number {
    background: var(--secondary-color);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 12px;
    font-size: 12px;
}

.analysis-summary {
    text-align: center;
    margin: 25px 0;
    padding: 15px;
    background: #f8f9fa; /* 軽いグレーの背景で区切る */
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.summary-label {
    display: block;
    font-size: 13px;
    color: #7f8c8d;
    margin-bottom: 5px;
    font-weight: bold;
    letter-spacing: 0.05em;
}

.summary-value {
    font-size: 32px; /* 数字を大きく強調 */
    font-weight: 800;
    color: #2c3e50;
    font-family: 'Helvetica Neue', Arial, sans-serif; /* 数字が綺麗に見えるフォント */
}

.summary-unit {
    font-size: 14px;
    color: #2c3e50;
    margin-left: 4px;
    font-weight: bold;
}

h3 { margin: 0; font-size: 18px; color: var(--secondary-color); }

/* 必須ラベル（赤） */
.required-badge {
    color: #e74c3c;
    font-size: 0.7em;
    font-weight: normal;
    margin-left: 8px;
    vertical-align: middle;
}

/* 任意ラベル（紺） */
.optional-badge {
    color: #2c3e50;    /* 落ち着いたネイビー */
    font-size: 0.7em;
    font-weight: normal; /* 任意なので太字にせず、少し控えめに */
    margin-left: 8px;
    vertical-align: middle;
}

/* --- 5. 選択グリッド（入力用） --- */
.selection-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.selection-item input { 
    position: absolute; 
    opacity: 0; 
}

.selection-item label {
    display: block;
    background: #fff;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1); /* 動きをより滑らかに */
    font-size: 14px; 
    padding: 10px 5px;
    position: relative;
    top: 0; /* 位置制御用 */
}

.selection-item label span {
    font-size: 10px;
    margin-left: 2px;
}

/* --- 改善点1：マウスホバーで浮き上がる --- */
.selection-item label:hover {
    border-color: var(--primary-color); /* 枠線を先に色づかせる */
    transform: translateY(-2px); /* 上に4px浮かせる */
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.05); /* 浮いた時の影 */
    background: #f9fdfb; /* ほんの少しだけ背景を明るく */
}

/* --- 改善点2：クリックした瞬間（アクティブ）の凹み --- */
.selection-item label:active {
    transform: translateY(0px); /* 押し込んだように見せる */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.selection-item input:checked + label {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.15);
    transform: translateY(-1px); /* 選択中も少し浮いた状態を維持して「選ばれてる感」を出す */
}

/* --- 改善点3：選択中にホバーしても沈まないように調整 --- */
.selection-item input:checked + label:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(39, 174, 96, 0.2);
}

/* --- 6. 診断結果表示用パーツ（追加） --- */

/* カード全体の基本構造 */
.result-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* 左側の馬券種ラベル（単勝・複勝など） */
.result-label {
    font-weight: bold;
    color: var(--secondary-color);
    font-size: 16px;
}

/* 右側の数値グループ */
.result-values {
    text-align: right;
}

/* 的中率・中央値のグループ（横並びで控えめに） */
.sub-value-group {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 6px;
}

.sub-value {
    font-size: 14px;      /* 指定の14px */
    color: #95a5a6;      /* 薄いグレー */
    white-space: nowrap;
}

/* 的中率・中央値の「数字」だけ少し色を濃く */
.sub-value span {
    color: #7f8c8d;
    font-weight: bold;
}

/* 【主役】回収率の行 */
.main-return {
    display: block;
    font-size: 14px;      /* 「回収率」の文字も14px */
    color: #7f8c8d;
}

/* 回収率の「数字」部分（ここを最大化） */
.main-return span {
    font-size: 32px;      /* 数字は引き続き大きくしてインパクトを維持 */
    font-weight: bold;
    color: #2c3e50;
    margin-left: 6px;
    line-height: 1;
    vertical-align: baseline;
}

/* 回収率の「%」を小さく */
.main-return span::after {
    content: '%';
    font-size: 16px;
    font-weight: normal;
    margin-left: 2px;
    color: #7f8c8d;
}

/* 条件バッジ（診断された条件をきれいに並べる） */
.condition-badge-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
}

.badge-jiku { background: var(--secondary-color); color: #fff; }
.badge-filter { background: #fff; border: 1px solid var(--border-color); color: var(--text-color); }

/* --- 7. フィルタ・フォーム --- */
.filter-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 25px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.input-group { display: flex; flex-direction: column; }
.input-group label {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 6px;
    color: var(--text-light);
}

.full-width { grid-column: span 2; }

select {
    padding: 10px;
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}

/* 詳細フィルタのアコーディオン設定 */
.detail-filters {
    margin-top: 20px;
    border-top: 1px dashed var(--border-color);
    padding-top: 15px;
}

.detail-summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    color: var(--primary-color);
    text-align: center;
    list-style: none; /* デフォルトの矢印を消す */
    outline: none;
}

.detail-summary::-webkit-details-marker {
    display: none; /* Safari用の矢印消し */
}

.detail-summary:after {
    content: ' ＋'; /* 閉じている時の記号 */
}

details[open] .detail-summary:after {
    content: ' －'; /* 開いている時の記号 */
}

.detail-grid {
    margin-top: 15px;
    padding: 15px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* --- 8. ボタン --- */
button#submit-btn, .btn-back {
    width: 100%;
    padding: 18px;
    font-size: 16px;
    font-weight: bold;
    color: white;
    background: linear-gradient(135deg, var(--primary-color), #2ecc71);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.2);
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
    display: block;
}

.logic-disclaimer {
    margin-top: 15px; /* ボタンとの間隔 */
    padding: 0 10px;
    font-size: 12px; /* 小さくさりげなく */
    color: #95a5a6;  /* 目立ちすぎないグレー */
    line-height: 1.5;
    text-align: left; /* 左揃えで箇条書き感を出す */
}

.logic-disclaimer p {
    margin-bottom: 4px;
    text-indent: -1em; /* 2行目以降をインデントして「・」を際立たせる */
    padding-left: 1em;
}

.sticky-action-area {
    position: -webkit-sticky; /* Safari用 */
    position: sticky;
    bottom: 20px; /* 画面下部との余白 */
    width: 100%;
    max-width: 500px; /* ボタンの最大幅に合わせる */
    margin: 40px auto 20px; /* 上下に余白を持たせる */
    padding: 0 20px;
    z-index: 100;
}

.primary-re-btn {
    display: block;
    background: #e67e22;
    color: #fff;
    text-align: center;
    padding: 18px;
    border-radius: 50px;
    font-size: 18px;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 10px 20px rgba(230, 126, 34, 0.3); /* 影を少し柔らかく */
    transition: transform 0.2s, box-shadow 0.2s;
}

.primary-re-btn:active {
    transform: scale(0.95); /* 押した時に少し凹む演出 */
}

.container {
    padding-bottom: 20px; 
}

.btn-back {
    background: var(--text-light);
    margin-top: 20px;
    box-shadow: none;
}

.result-card:has(.error-message[style*="display: block"]) {
    background-color: #fcfcfc;
    border-color: #eee;
    opacity: 0.8;
}

.value-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* --- 9. レスポンシブ --- */
@media screen and (max-width: 768px) {
    h1 { margin-bottom: 0 !important; }
    .result-section { margin-top: 30px; }
    .container { padding: 20px; margin: 15px 10px; }
    .selection-grid { grid-template-columns: repeat(3, 1fr); }
    .filter-grid { grid-template-columns: 1fr; }
    .full-width { grid-column: span 1; }
    .header-inner { flex-direction: column; text-align: center; }
}

/* スマホ向けの微調整 */
@media (max-width: 480px) {
    .main-copy {
        font-size: 18px; /* 全体を少し小さくして */
    }
    .main-copy .highlight {
        font-size: 24px; /* プラスの部分もバランス調整 */
    }
    .hero-inner {
        padding: 20px 10px; /* 余白を削って横幅を確保 */
    }
}