/* ---- Radio Cards ---- */
.radio-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.radio-card input {
    display: none;
}

.radio-card-inner {
    padding: 16px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-input);
}

.radio-card-inner:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
}

.radio-card input:checked + .radio-card-inner {
    border-color: var(--primary-light);
    background: rgba(108, 92, 231, 0.15);
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.15);
}

.radio-card input:checked + .radio-card-inner.normal {
    border-color: #2ecc71;
    background: rgba(46, 204, 113, 0.1);
    box-shadow: 0 0 20px rgba(46, 204, 113, 0.1);
}

.radio-card input:checked + .radio-card-inner.gokigen {
    border-color: #f1c40f;
    background: rgba(241, 196, 15, 0.1);
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.1);
}

.radio-card input:checked + .radio-card-inner.suki {
    border-color: var(--suki-color);
    background: rgba(253, 121, 168, 0.1);
    box-shadow: 0 0 20px rgba(253, 121, 168, 0.1);
}

/* ななめ：選択時の色（標準スタイル） */
.radio-card input:checked + .radio-card-inner.naname {
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.1);
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.1);
}

/* さいあく：選択時の色（標準スタイルに修正） */
.radio-card input:checked + .radio-card-inner.saiaku {
    border-color: #9b59b6;
    background: rgba(155, 89, 182, 0.1);
    box-shadow: 0 0 20px rgba(155, 89, 182, 0.1);
}

.radio-card input:checked + .radio-card-inner.card-special {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.08);
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.08);
}

/* 超Sエンカウント：角を丸く保ったまま虹色の枠線にする修正 */
.radio-card input:checked + .radio-card-inner.card-super {
    border: 2px solid transparent;
    background: linear-gradient(var(--bg-input), var(--bg-input)) padding-box, 
                linear-gradient(135deg, #ff7675, #fdcb6e, #55efc4, #74b9ff, #a29bfe) border-box;
    box-shadow: 0 0 20px rgba(255, 118, 117, 0.15);
}
.radio-icon {
    font-size: 1.6rem;
    margin-bottom: 6px;
}

.normal .radio-icon { color: var(--normal-color); }
.gokigen .radio-icon { color: var(--gokigen-color); }
.suki .radio-icon { color: var(--suki-color); }
.card-normal .radio-icon { color: var(--card-normal-color); }
.card-special .radio-icon { color: var(--card-special-color); }
.card-super .radio-icon { color: var(--card-super-color); }

.radio-label {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap; /* ★これだけ追加：一行に強制する */
}

.radio-range {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---- Coin Selector ---- */
.coin-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.coin-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease;
}

.coin-item i.fa-coins {
    color: var(--warning);
}

.coin-item select {
    padding: 4px 8px;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.coin-item select:focus {
    outline: none;
    border-color: var(--primary-light);
}

.coin-remove {
    background: none;
    border: none;
    color: var(--text-muted); /* var(--danger) から変更！ */
    cursor: pointer;
    font-size: 1.1rem;
    padding: 2px 6px;
    transition: var(--transition);
}

.coin-remove:hover {
    color: #000; /* マウスを乗せた時は真っ黒に */
    transform: scale(1.2);
}

.coin-remove:hover {
    transform: scale(1.2);
}

/* ============ RESULTS ============ */
.result-placeholder {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}

.result-placeholder i {
    font-size: 2.5rem;
    margin-bottom: 16px;
    display: block;
    opacity: 0.5;
}

.result-placeholder p {
    font-size: 0.95rem;
}

.result-loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Result Summary ---- */
.result-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
}

.summary-card-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-card-value {
    font-size: 1.5rem;
    font-weight: 800;
}

.summary-card-value.highlight {
    color: var(--accent);
}

.summary-card-sub {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 2px;
}

/* ---- Result Chart ---- */
.result-chart {
    margin-bottom: 0; /* ← 24pxから0に変更して、かつて表があった場所の余白を完全に消す */
}

/* 一番下（25%）の棒グラフの下のわずかな隙間も消すための追記 */
.chart-bar-row:last-child {
    margin-bottom: 0;
}

.chart-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.chart-label {
    width: 60px;
    text-align: right;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.chart-bar-wrap {
    flex: 1;
    height: 28px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.chart-bar {
    height: 100%;
    border-radius: 4px;
    min-width: 2px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.chart-bar.zero {
    min-width: 0;
}

.chart-value {
    width: 70px;
    text-align: left;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    flex-shrink: 0;
}

/* ---- Result Table ---- */
.result-table-wrap {
    overflow-x: auto;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.result-table th {
    background: var(--bg-input);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.result-table tr:hover td {
    background: rgba(108, 92, 231, 0.05);
}

.result-table .pct-cell {
    font-weight: 700;
}

.result-table .prob-cell {
    font-weight: 600;
}

.result-table .cum-cell {
    color: var(--text-muted);
}

.prob-zero {
    color: var(--text-dim) !important;
    opacity: 0.5;
}

/* ---- 状態・カードのアイコン色 ---- */
.card-super .radio-icon i {
    background: linear-gradient(135deg, #ff7675, #fdcb6e, #55efc4, #74b9ff, #a29bfe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}
.card-special .radio-icon i { color: #e74c3c; }
.normal .radio-icon i { color: #2ecc71; }
.gokigen .radio-icon i { color: #f1c40f; }
.suki .radio-icon i { color: var(--suki-color); }
.naname .radio-icon i { color: #3498db; }
.saiaku .radio-icon i { color: #9b59b6; }

/* ---- グラフの累計ツールチップ ---- */
.chart-bar-wrap { position: relative; cursor: help; }
.cum-tooltip {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}
.chart-bar-row:hover .cum-tooltip,
.chart-bar-row:active .cum-tooltip { opacity: 1; }

/* ---- アイテム入力行のデザイン ---- */
.item-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    background: var(--bg-card-hover, #f8f9fa);
    padding: 8px 15px;
    border-radius: 8px;
    border: 1px solid var(--border, #e2e8f0);
}
.item-icon { font-size: 1.4rem; width: 30px; text-align: center; }
.support-item-input {
    width: 60px;
    padding: 6px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    text-align: center;
    font-size: 1rem;
    font-weight: bold;
}

/* EX用レスポンシブ（スマホ画面の調整） */
@media (max-width: 768px) {
    /* 1. キャラ状態・エンカウント（3列を維持） */
    .radio-group { 
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    
    .radio-card-inner {
        padding: 10px 4px;
    }
    
    .radio-icon {
        font-size: 1.2rem;
    }
    
    .radio-label {
        font-size: 0.8rem;
        white-space: nowrap; /* 「ト」が落ちるのを防ぐ */
    }

    /* 2. アイテムリストを「2列」にしてコンパクトにする */
    #item-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr); /* 2列に並べる */
        gap: 8px; /* アイテム同士の隙間 */
        width: 100%;
    }

    .item-row {
        gap: 6px; /* アイコン、選択、削除ボタンの隙間を詰める */
        padding: 6px 8px; /* 内側の余白を削ってスリムに */
        margin-bottom: 0; /* Gridのgapを使うのでマージンは0に */
        justify-content: space-between;
    }

    .item-icon {
        font-size: 1.1rem;
        width: 24px;
    }

    /* セレクトボックスの幅を調整 */
    .chara-item-select, .support-item-input {
        padding: 4px !important;
        font-size: 0.85rem !important;
        min-width: 0; /* 幅が広がりすぎないように固定 */
    }

    /* 削除ボタンを少し小さく */
    .item-row button {
        font-size: 1rem !important;
        padding: 0 4px !important;
    }

    /* 3. 計算結果のサマリー（3列） */
    .result-summary { 
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
    }
    
    .summary-card {
        padding: 8px 2px;
    }
    
    .summary-card-value {
        font-size: 1rem;
    }
}