/* ============================================================
   Cardgame 査定シミュレーター (templates/simulator.php)
   フラットデザイン: 影・グラデ・transform 禁止
   ============================================================ */
.cg-sim {
    --cg-sm-main: #04384c;
    --cg-sm-success: #3cd250;
    --cg-sm-danger: #f36060;
    --cg-sm-warning: #ffa537;
    --cg-sm-info: #4a9bd6;
    --cg-sm-bg: #fff;
    --cg-sm-soft: #f6f7f8;
    --cg-sm-border: #e5e7eb;
    --cg-sm-text: #1f2937;
    --cg-sm-muted: #6b7280;
    color: var(--cg-sm-text);
    font-weight: 400;
    /* ボトムバー (60px + safe-area) 分の余白を確保 */
    padding-bottom: calc(60px + env(safe-area-inset-bottom) + 12px);
}
.cg-sim * { box-sizing: border-box; }

/* H1 相当は固定ページタイトルが出るので、紹介文ヘッダー内の見出しは h2 で表現 */
.cg-sim-h1,
.cg-sim h2.cg-sim-h1 {
    all: unset !important;
    display: block !important;
    font-size: 18px !important;
    font-weight: 500 !important;
    margin: 0 0 6px !important;
    color: var(--cg-sm-text) !important;
    line-height: 1.4 !important;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}
.cg-sim-h1::before, .cg-sim-h1::after {
    display: none !important; content: none !important; background: none !important; border: none !important;
}
.cg-sim-h2,
.cg-sim h2.cg-sim-h2 {
    all: unset !important;
    display: block !important;
    font-size: 18px !important;
    font-weight: 500 !important;
    margin: 0 0 12px !important;
    color: var(--cg-sm-text) !important;
    line-height: 1.4 !important;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}
.cg-sim-h2::before, .cg-sim-h2::after {
    display: none !important; content: none !important; background: none !important; border: none !important;
}
.cg-sim-h3,
.cg-sim h3.cg-sim-h3 {
    all: unset !important;
    display: block !important;
    margin: 0 0 8px !important;
    padding: 0 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: var(--cg-sm-text) !important;
    line-height: 1.4 !important;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}
.cg-sim-h3::before, .cg-sim-h3::after {
    display: none !important; content: none !important; background: none !important; border: none !important;
}

.cg-sim-header {
    margin: 0 0 24px;
    padding: 22px 22px 20px;
    background: var(--cg-sm-bg);
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 12px;
}
.cg-sim-lead {
    margin: 0;
    color: var(--cg-sm-muted);
    font-size: 13px;
    line-height: 1.6;
}

/* ===== カードゲーム選択 ===== */
.cg-sim-game-picker {
    margin: 0 0 24px;
    padding: 18px 20px;
    background: var(--cg-sm-bg);
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 12px;
}
.cg-sim-game-picker-label,
.cg-sim h2.cg-sim-game-picker-label {
    all: unset !important;
    display: block !important;
    margin: 0 0 10px !important;
    color: var(--cg-sm-text) !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
}
.cg-sim-game-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.cg-sim-game-option {
    min-height: 58px;
    padding: 9px 12px;
    border: 1px solid var(--cg-sm-border);
    border-radius: 8px;
    background: var(--cg-sm-bg);
    color: var(--cg-sm-text);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    text-align: left;
}
.cg-sim-game-option:hover,
.cg-sim-game-option:focus-visible {
    border-color: var(--cg-sm-main);
    outline: none;
}
.cg-sim-game-option.active {
    border-color: var(--cg-sm-main);
    background: rgba(4, 56, 76, 0.06);
    color: var(--cg-sm-main);
}
.cg-sim-game-option-main {
    display: block;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
}
.cg-sim-game-option-sub {
    display: block;
    margin-top: 2px;
    color: var(--cg-sm-muted);
    font-size: 10px;
    line-height: 1.3;
}
.cg-sim-game-current {
    margin: 9px 0 0;
    color: var(--cg-sm-muted);
    font-size: 11px;
}
.cg-sim-game-current [data-active-game-label] {
    color: var(--cg-sm-main);
    font-weight: 500;
}

/* ===== 集計エリア ===== */
.cg-sim-summary {
    margin: 0 0 24px;
    padding: 20px;
    background: var(--cg-sm-bg);
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 12px;
}
.cg-sim-summary-empty {
    margin: 8px 0 0;
    padding: 18px;
    background: var(--cg-sm-soft);
    border-radius: 8px;
    text-align: center;
    color: var(--cg-sm-muted);
    font-size: 13px;
}

/* ベストミックス */
.cg-sim-bestmix {
    margin: 0 0 18px;
    padding: 16px;
    background: var(--cg-sm-soft);
    border-left: 3px solid var(--cg-sm-main);
    border-radius: 4px;
}
.cg-sim-bestmix-label {
    font-size: 12px;
    color: var(--cg-sm-muted);
    margin: 0 0 4px;
}
.cg-sim-bestmix-value {
    font-size: 24px;
    font-weight: 500;
    color: var(--cg-sm-main);
    line-height: 1.2;
    margin: 0 0 6px;
}
.cg-sim-bestmix-diff {
    font-size: 12px;
    color: var(--cg-sm-muted);
}
.cg-sim-bestmix-diff-value {
    font-weight: 500;
    color: var(--cg-sm-success);
}

/* ショップ別ランキング */
.cg-sim-shop-ranking { margin: 0 0 18px; }
.cg-sim-shop-ranking-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.cg-sim-shop-rank-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--cg-sm-bg);
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 6px;
    font-size: 13px;
}
.cg-sim-shop-rank-item--top {
    background: rgba(60, 210, 80, 0.08);
    border-color: var(--cg-sm-success);
}
.cg-sim-shop-rank-num {
    flex: 0 0 28px;
    font-size: 11px;
    font-weight: 500;
    color: var(--cg-sm-muted);
}
.cg-sim-shop-rank-item--top .cg-sim-shop-rank-num {
    color: var(--cg-sm-success);
    font-weight: 500;
}
.cg-sim-shop-rank-name { flex: 1 1 auto; min-width: 0; font-weight: 500; }
.cg-sim-shop-rank-total {
    flex: 0 0 auto;
    font-weight: 500;
    color: var(--cg-sm-text);
}

/* 合計枚数 */
.cg-sim-total-qty {
    font-size: 12px;
    color: var(--cg-sm-muted);
    text-align: right;
}
.cg-sim-total-qty-value { color: var(--cg-sm-text); font-weight: 500; }

/* ===== カードリスト ===== */
.cg-sim-cardlist {
    margin: 0 0 24px;
    padding: 20px;
    background: var(--cg-sm-bg);
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 12px;
}
.cg-sim-cardlist-empty {
    margin: 8px 0 0;
    padding: 18px;
    background: var(--cg-sm-soft);
    border-radius: 8px;
    text-align: center;
    color: var(--cg-sm-muted);
    font-size: 13px;
}
.cg-sim-rows {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.cg-sim-row {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--cg-sm-bg);
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 8px;
    align-items: flex-start;
}
.cg-sim-row-thumb {
    flex: 0 0 64px;
    width: 64px;
    height: 90px;
    background: var(--cg-sm-soft);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cg-sim-row-thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}
.cg-sim-row-body { flex: 1 1 auto; min-width: 0; }
.cg-sim-row-title {
    display: block;
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 500;
    color: var(--cg-sm-text) !important;
    text-decoration: none !important;
    line-height: 1.4;
}
.cg-sim-row-title:hover { text-decoration: underline !important; }
.cg-sim-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 10px;
    font-size: 11px;
    color: var(--cg-sm-muted);
}
.cg-sim-row-game {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(4, 56, 76, 0.08);
    color: var(--cg-sm-main);
    font-weight: 500;
}
.cg-sim-row-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* 数量 ± */
.cg-sim-qty {
    display: inline-flex;
    align-items: center;
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--cg-sm-bg);
}
.cg-sim-qty-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--cg-sm-soft);
    color: var(--cg-sm-text);
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
}
.cg-sim-qty-btn:hover { background: var(--cg-sm-border); }
.cg-sim-qty-input {
    width: 56px;
    height: 44px;
    border: none;
    border-left: 0.5px solid var(--cg-sm-border);
    border-right: 0.5px solid var(--cg-sm-border);
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--cg-sm-text);
    background: var(--cg-sm-bg);
    -moz-appearance: textfield;
}
.cg-sim-qty-input::-webkit-outer-spin-button,
.cg-sim-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* 状態 */
.cg-sim-cond-select {
    height: 44px;
    padding: 0 28px 0 12px;
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 6px;
    background: var(--cg-sm-bg);
    color: var(--cg-sm-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.cg-sim-cond-select:focus { outline: none; border-color: var(--cg-sm-main); }

/* 削除 */
.cg-sim-row-remove {
    height: 44px;
    padding: 0 12px;
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 6px;
    background: var(--cg-sm-bg);
    color: var(--cg-sm-danger);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}
.cg-sim-row-remove:hover { border-color: var(--cg-sm-danger); }

/* ===== アクション ===== */
.cg-sim-actions {
    margin: 16px 0 0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.cg-sim-btn {
    flex: 1 1 auto;
    height: 44px;
    padding: 0 16px;
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 6px;
    background: var(--cg-sm-bg);
    color: var(--cg-sm-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.cg-sim-btn:hover { border-color: var(--cg-sm-main); }
.cg-sim-btn-share { background: var(--cg-sm-main); color: #fff; border-color: var(--cg-sm-main); }
.cg-sim-btn-share:hover { opacity: .9; }
.cg-sim-btn-clear { color: var(--cg-sm-muted); }

/* ===== 通知 ===== */
.cg-sim-notice {
    margin: 0 0 16px;
    padding: 12px 14px;
    background: rgba(255, 165, 55, 0.08);
    border: 0.5px solid var(--cg-sm-warning);
    border-radius: 8px;
    color: var(--cg-sm-warning);
    font-size: 12px;
}

/* ===== ボトムバー (旧 FAB を下全幅化) ===== */
/* 旧仕様: 右下に丸ボタン
   新仕様: 画面下部に全幅で固定バー、押しやすさと視認性を優先
   archive ページでも同パターンを共通利用予定 (Phase 3) */
.cg-sim-fab {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    height: 60px;
    padding: 0 16px;
    border: none;
    border-top: 0.5px solid var(--cg-sm-border);
    border-radius: 0;
    background: var(--cg-sm-main);
    color: #fff;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    /* iOS の home indicator 余白対応 */
    padding-bottom: max(0px, env(safe-area-inset-bottom));
    height: calc(60px + env(safe-area-inset-bottom));
}
.cg-sim-fab:hover { opacity: .92; }
.cg-sim-fab:active { background: #032936; }
.cg-sim-fab-plus { font-size: 22px; line-height: 1; }
.cg-sim-fab-text { line-height: 1; }

/* ===== ボトムシート ===== */
.cg-sim-sheet {
    position: fixed;
    inset: 0;
    z-index: 99999; /* SWELL 固定ヘッダーより上 */
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.cg-sim-sheet[hidden] { display: none; }
.cg-sim-sheet-overlay {
    position: absolute;
    inset: 0;
    background: rgba(31, 41, 55, 0.55);
}
.cg-sim-sheet-panel {
    position: relative;
    width: 100%;
    max-width: 560px;
    /* SWELL の固定ヘッダー（80px 程度）を完全に避けて、シート上端を視認可能に */
    max-height: calc(100vh - 80px);
    background: var(--cg-sm-bg);
    border-radius: 14px 14px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* スワイプダウン時のトランジション */
    transition: transform 0.18s ease;
}
.cg-sim-sheet-panel.cg-sim-sheet-panel--dragging { transition: none; }

/* ドラッグハンドル（視覚的に「下に引いて閉じられる」と示す） */
.cg-sim-sheet-handle {
    flex: 0 0 auto;
    padding: 8px 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
}
.cg-sim-sheet-handle span {
    display: block;
    width: 40px;
    height: 4px;
    background: var(--cg-sm-border);
    border-radius: 999px;
}
.cg-sim-sheet-handle:active { cursor: grabbing; }

/* ヘッダー: sticky で常時閉じるボタンが見える */
.cg-sim-sheet-head {
    position: sticky;
    top: 0;
    z-index: 2;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px 12px;
    background: var(--cg-sm-bg);
    border-bottom: 0.5px solid var(--cg-sm-border);
}
.cg-sim-sheet-title,
.cg-sim-sheet h2.cg-sim-sheet-title {
    all: unset !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    color: var(--cg-sm-text) !important;
    line-height: 1.35 !important;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}
.cg-sim-sheet-title::before, .cg-sim-sheet-title::after {
    display: none !important; content: none !important; background: none !important; border: none !important;
}

/* 閉じるボタン: 44x44 丸ボタン（指で押しやすい） */
.cg-sim-sheet-close {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--cg-sm-soft);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: var(--cg-sm-text);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    touch-action: manipulation;
}
.cg-sim-sheet-close:hover { background: var(--cg-sm-border); }
.cg-sim-sheet-close:active { background: #d5d5d5; }

.cg-sim-sheet-body {
    padding: 14px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1 1 auto;
    min-height: 0;
}
.cg-sim-search-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 8px;
    background: var(--cg-sm-bg);
    color: var(--cg-sm-text);
    font-size: 14px;
}
.cg-sim-search-input:focus { outline: none; border-color: var(--cg-sm-main); }
.cg-sim-search-results {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 80px;
}
.cg-sim-search-hint {
    margin: 0;
    padding: 24px 0;
    text-align: center;
    color: var(--cg-sm-muted);
    font-size: 12px;
}
.cg-sim-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: var(--cg-sm-bg);
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    width: 100%;
}
.cg-sim-result:hover { border-color: var(--cg-sm-main); }
.cg-sim-result-thumb {
    flex: 0 0 48px;
    width: 48px;
    height: 68px;
    background: var(--cg-sm-soft);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cg-sim-result-thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}
.cg-sim-result-body { flex: 1 1 auto; min-width: 0; }
.cg-sim-result-title {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--cg-sm-text);
    line-height: 1.35;
    margin: 0 0 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cg-sim-result-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--cg-sm-muted);
}

/* ===== シート内タブ ===== */
.cg-sim-sheet-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 12px 0;
    background: var(--cg-sm-bg);
    border-bottom: 0.5px solid var(--cg-sm-border);
}
.cg-sim-sheet-tab {
    flex: 1 1 auto;
    padding: 8px 10px;
    border: 0.5px solid var(--cg-sm-border);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    background: var(--cg-sm-soft);
    color: var(--cg-sm-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}
.cg-sim-sheet-tab.active {
    background: var(--cg-sm-bg);
    color: var(--cg-sm-main);
    border-color: var(--cg-sm-border);
}
.cg-sim-sheet-panel-body { display: none; }
.cg-sim-sheet-panel-body.active { display: flex; flex-direction: column; gap: 12px; }

/* ===== 検索ヒント例（B） ===== */
.cg-sim-search-examples {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--cg-sm-muted);
}
.cg-sim-search-examples-label { font-size: 11px; color: var(--cg-sm-muted); }
.cg-sim-search-example {
    padding: 4px 10px;
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 999px;
    background: var(--cg-sm-bg);
    color: var(--cg-sm-text);
    font-size: 11px;
    cursor: pointer;
}
.cg-sim-search-example:hover { border-color: var(--cg-sm-main); color: var(--cg-sm-main); }

/* ===== レアリティチップ（D） ===== */
.cg-sim-rarity-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.cg-sim-rarity-filter-label { font-size: 11px; color: var(--cg-sm-muted); }
.cg-sim-rarity-chip {
    padding: 4px 10px;
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 999px;
    background: var(--cg-sm-bg);
    color: var(--cg-sm-text);
    font-size: 11px;
    cursor: pointer;
}
.cg-sim-rarity-chip.active {
    background: var(--cg-sm-main);
    color: #fff;
    border-color: var(--cg-sm-main);
}
.cg-sim-rarity-chip:hover:not(.active) { border-color: var(--cg-sm-main); }

/* ===== 検索履歴（C） ===== */
.cg-sim-history { display: flex; flex-direction: column; gap: 4px; }
.cg-sim-history-label { font-size: 11px; color: var(--cg-sm-muted); }
.cg-sim-history-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cg-sim-history-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px 4px 10px;
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 999px;
    background: var(--cg-sm-soft);
    color: var(--cg-sm-text);
    font-size: 11px;
    cursor: pointer;
}
.cg-sim-history-chip:hover { border-color: var(--cg-sm-main); }
.cg-sim-history-chip-x {
    width: 16px; height: 16px;
    border: none; background: transparent;
    color: var(--cg-sm-muted);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.cg-sim-history-chip-x:hover { color: var(--cg-sm-danger); }

/* ===== 空状態サジェスト（A） ===== */
.cg-sim-suggestions { display: flex; flex-direction: column; gap: 6px; }
.cg-sim-suggestions-list { min-height: 60px; }

/* ===== パックブラウザ ===== */
.cg-sim-pack-browser { display: flex; flex-direction: column; gap: 12px; }
.cg-sim-pack-search { margin-bottom: 12px; }
.cg-sim-pack-cats { display: flex; flex-direction: column; gap: 18px; }
.cg-sim-pack-cat-section {
    margin: 0;
    padding: 12px;
    background: var(--cg-sm-bg);
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 8px;
}
.cg-sim-pack-cat-h4 {
    margin: 0 0 10px;
    padding: 0 0 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--cg-sm-text);
    border-bottom: 0.5px solid var(--cg-sm-border);
}
/* もっと見るボタン */
.cg-sim-pack-cat-more-wrap { margin: 10px 0 0; text-align: center; }
.cg-sim-pack-cat-more {
    padding: 6px 14px;
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 6px;
    background: var(--cg-sm-bg);
    color: var(--cg-sm-main);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
}
.cg-sim-pack-cat-more:hover { border-color: var(--cg-sm-main); }
.cg-sim-pack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
}
.cg-sim-pack-tile {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 6px;
    background: var(--cg-sm-bg);
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
}
.cg-sim-pack-tile:hover { border-color: var(--cg-sm-main); }
/* 初期非表示の余剰タイル。展開時に表示（順序が重要: .cg-sim-pack-tile より後で打ち消す） */
.cg-sim-pack-tile--extra { display: none; }
.cg-sim-pack-cat-section--expanded .cg-sim-pack-tile--extra { display: flex; }
.cg-sim-pack-tile-image {
    display: block;
    aspect-ratio: 11 / 20;
    background: var(--cg-sm-soft);
    border-radius: 4px;
    overflow: hidden;
}
.cg-sim-pack-tile-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}
.cg-sim-pack-tile-name {
    font-size: 10px;
    font-weight: 500;
    color: var(--cg-sm-text);
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.cg-sim-pack-back {
    align-self: flex-start;
    padding: 6px 10px;
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 6px;
    background: var(--cg-sm-bg);
    color: var(--cg-sm-text);
    font-size: 12px;
    cursor: pointer;
}
.cg-sim-pack-back:hover { border-color: var(--cg-sm-main); }

/* ===== 送料トグル ===== */
.cg-sim-shipping-toggle {
    margin: 0 0 12px;
    padding: 8px 12px;
    background: var(--cg-sm-soft);
    border-radius: 6px;
    font-size: 12px;
}
.cg-sim-shipping-toggle-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.cg-sim-shipping-toggle-row input { width: 16px; height: 16px; }

/* ===== ベストミックス内訳 ===== */
.cg-sim-bestmix-detail-btn {
    margin-top: 10px;
    padding: 0;
    border: none;
    background: none;
    color: var(--cg-sm-main);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}
.cg-sim-bestmix-detail-btn:hover { text-decoration: underline; }
.cg-sim-bestmix-detail {
    margin: 12px 0 0;
    padding: 12px;
    background: var(--cg-sm-bg);
    border: 0.5px solid var(--cg-sm-border);
    border-radius: 6px;
}
.cg-sim-bestmix-detail-list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: bm;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cg-sim-bestmix-detail-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--cg-sm-soft);
    border-radius: 4px;
    font-size: 12px;
}
.cg-sim-bestmix-detail-card {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cg-sim-bestmix-detail-name {
    font-weight: 500;
    color: var(--cg-sm-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cg-sim-bestmix-detail-shop {
    font-size: 11px;
    color: var(--cg-sm-success);
    font-weight: 500;
}
.cg-sim-bestmix-detail-price {
    flex: 0 0 auto;
    text-align: right;
    font-weight: 500;
    color: var(--cg-sm-text);
}
.cg-sim-bestmix-detail-price-unit {
    display: block;
    font-size: 10px;
    color: var(--cg-sm-muted);
    font-weight: 400;
}

/* ===== ショップランキングのメタ情報展開 ===== */
.cg-sim-shop-rank-meta {
    margin: 4px 0 0;
    padding: 6px 10px;
    background: var(--cg-sm-soft);
    border-radius: 4px;
    font-size: 10px;
    color: var(--cg-sm-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.cg-sim-shop-rank-meta-item { display: inline-flex; gap: 3px; }

/* ===== モバイル ===== */
@media (max-width: 600px) {
    .cg-sim-header { padding: 18px 16px 16px; }
    .cg-sim-game-picker { padding: 14px; }
    .cg-sim-game-option { min-height: 64px; padding: 8px 10px; }
    .cg-sim-game-option-main { font-size: 12px; }
    .cg-sim-h1 { font-size: 18px !important; }
    .cg-sim-summary,
    .cg-sim-cardlist { padding: 14px; }
    .cg-sim-bestmix-value { font-size: 20px; }
    .cg-sim-row { padding: 10px; gap: 10px; }
    .cg-sim-row-thumb { flex: 0 0 56px; width: 56px; height: 78px; }
    .cg-sim-row-controls { gap: 6px; }
    .cg-sim-cond-select { padding: 0 22px 0 10px; font-size: 12px; }
    .cg-sim-row-remove { padding: 0 10px; font-size: 11px; }
    /* ボトムバーはモバイルでもデスクトップと同じ下全幅、上書き不要 */
    /* モバイル: SWELL のモバイルヘッダー（60px 程度）を避ける */
    .cg-sim-sheet-panel { max-height: calc(100vh - 60px); max-height: calc(100dvh - 60px); }
    .cg-sim-pack-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   「使い方を見る」アコーディオン（ヘッダー直下）
   ============================================================ */
.cg-sim .cg-sim-how-to {
    margin: 16px 0 24px;
    padding: 12px 16px;
    background: #f9fafb;
    border: 0.5px solid #e5e7eb;
    border-radius: 8px;
}
.cg-sim .cg-sim-how-to-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #04384c;
    text-align: left;
}
.cg-sim .cg-sim-how-to-icon {
    transition: transform 0.2s;
    display: inline-block;
    font-size: 12px;
    line-height: 1;
}
.cg-sim .cg-sim-how-to-toggle[aria-expanded="true"] .cg-sim-how-to-icon {
    transform: rotate(180deg);
}
.cg-sim .cg-sim-how-to-content {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 0.5px solid #e5e7eb;
    font-size: 13px;
    line-height: 1.7;
    color: #1f2937;
    white-space: pre-line;
}
.cg-sim .cg-sim-how-to-content[hidden] {
    display: none;
}

/* hidden 属性をコンポーネント側の display 指定より優先する。 */
.cg-sim-suggestions[hidden],
.cg-sim-search-results[hidden] {
    display: none !important;
}

/* ============================================================
   CARD VALUE visual refresh 2026-08
   機能を変えず、情報の優先順位とゲーム横断査定を視覚化する。
   ============================================================ */
.cg-sim {
    --cg-sm-main: #0b2b58;
    --cg-sm-main-2: #123f78;
    --cg-sm-accent: #08b77b;
    --cg-sm-success: #07996a;
    --cg-sm-danger: #d94b5a;
    --cg-sm-warning: #d78b22;
    --cg-sm-bg: #ffffff;
    --cg-sm-soft: #f3f6fa;
    --cg-sm-border: #dce4ee;
    --cg-sm-text: #10213a;
    --cg-sm-muted: #65748a;
    font-feature-settings: "palt" 1;
}

.cg-sim-header {
    position: relative;
    overflow: hidden;
    margin-bottom: 18px;
    padding: 32px 34px 30px;
    border: 0;
    border-radius: 20px;
    background: linear-gradient(135deg, #071a3a 0%, #0d3568 62%, #0b6f66 145%);
    box-shadow: 0 18px 44px rgba(10, 35, 72, .16);
}
.cg-sim-header::after {
    content: "";
    position: absolute;
    right: -54px;
    top: -94px;
    width: 220px;
    height: 220px;
    border: 34px solid rgba(255,255,255,.045);
    border-radius: 50%;
    pointer-events: none;
}
.cg-sim-h1,
.cg-sim h2.cg-sim-h1 {
    position: relative !important;
    z-index: 1 !important;
    margin-bottom: 10px !important;
    color: #fff !important;
    font-size: clamp(23px, 3vw, 34px) !important;
    font-weight: 700 !important;
    letter-spacing: -.035em !important;
}
.cg-sim-lead {
    position: relative;
    z-index: 1;
    max-width: 680px;
    color: rgba(255,255,255,.74);
    font-size: 14px;
    line-height: 1.85;
}

.cg-sim-game-picker,
.cg-sim-summary,
.cg-sim-cardlist {
    border: 1px solid rgba(17, 53, 94, .10);
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(15, 42, 76, .07);
}
.cg-sim-game-picker {
    padding: 20px;
    margin-bottom: 14px;
}
.cg-sim-game-picker-label,
.cg-sim h2.cg-sim-game-picker-label {
    margin-bottom: 12px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    letter-spacing: .08em !important;
    text-transform: uppercase !important;
    color: #53657d !important;
}
.cg-sim-game-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.cg-sim-game-option {
    position: relative;
    min-height: 70px;
    padding: 13px 14px 12px;
    overflow: hidden;
    border: 1px solid #dce4ee;
    border-radius: 12px;
    background: #fff;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.cg-sim-game-option::before {
    display: block;
    margin-bottom: 5px;
    color: #8290a3;
    font: 700 9px/1.1 ui-monospace, monospace;
    letter-spacing: .12em;
}
.cg-sim-game-option[data-game-switch="pokemon"]::before { content: "POKÉMON"; }
.cg-sim-game-option[data-game-switch="onepiece"]::before { content: "ONE PIECE"; }
.cg-sim-game-option[data-game-switch="yugioh"]::before { content: "YU-GI-OH!"; }
.cg-sim-game-option::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: #9aa8b8;
}
.cg-sim-game-option[data-game-switch="pokemon"]::after { background: #d5a514; }
.cg-sim-game-option[data-game-switch="onepiece"]::after { background: #d24a43; }
.cg-sim-game-option[data-game-switch="yugioh"]::after { background: #7056b8; }
.cg-sim-game-option:hover,
.cg-sim-game-option:focus-visible {
    transform: translateY(-1px);
    border-color: #8ba4c2;
    box-shadow: 0 8px 20px rgba(15, 42, 76, .08);
}
.cg-sim-game-option.active {
    color: #0b2b58;
    border-color: #174b83;
    background: #f1f7ff;
    box-shadow: inset 0 0 0 1px rgba(23,75,131,.08), 0 7px 18px rgba(15,42,76,.08);
}
.cg-sim-game-option-main { font-size: 13px; font-weight: 700; }
.cg-sim-game-current {
    display: inline-flex;
    margin-top: 12px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #f1f5f9;
}

.cg-sim .cg-sim-how-to {
    margin: 0 0 18px;
    padding: 10px 16px;
    border: 1px solid rgba(17,53,94,.09);
    border-radius: 12px;
    background: rgba(255,255,255,.78);
}
.cg-sim .cg-sim-how-to-toggle { color: #26476f; font-size: 13px; }

.cg-sim-summary,
.cg-sim-cardlist { padding: 22px; }
.cg-sim-h2,
.cg-sim h2.cg-sim-h2 {
    margin-bottom: 16px !important;
    color: #10213a !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    letter-spacing: -.02em !important;
}
.cg-sim-shipping-toggle {
    margin-bottom: 14px;
    padding: 9px 11px;
    border: 1px solid #e1e8f0;
    background: #f7f9fc;
}
.cg-sim-strategy-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}
.cg-sim-one-shop,
.cg-sim-bestmix {
    min-width: 0;
    margin: 0;
    padding: 16px;
    border-radius: 13px;
}
.cg-sim-one-shop {
    border: 1px solid #dbe5ef;
    background: #f6f9fc;
}
.cg-sim-bestmix {
    border: 1px solid rgba(8,183,123,.4);
    border-left: 1px solid rgba(8,183,123,.4);
    background: linear-gradient(145deg, #082750, #0b4160);
    color: #fff;
}
.cg-sim-strategy-kicker {
    margin-bottom: 7px;
    color: #718198;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .12em;
}
.cg-sim-bestmix .cg-sim-strategy-kicker { color: #76e5bd; }
.cg-sim-strategy-label,
.cg-sim-bestmix-label {
    min-height: 36px;
    color: #53657d;
    font-size: 11px;
    line-height: 1.55;
}
.cg-sim-bestmix-label { color: rgba(255,255,255,.7); }
.cg-sim-one-shop-name {
    overflow: hidden;
    color: #15395f;
    font-size: 15px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cg-sim-one-shop-value,
.cg-sim-bestmix-value {
    margin: 3px 0 6px;
    color: #102e52;
    font: 700 24px/1.2 ui-monospace, "SFMono-Regular", monospace;
    letter-spacing: -.04em;
}
.cg-sim-bestmix-value { color: #fff; }
.cg-sim-strategy-note,
.cg-sim-bestmix-diff { color: #728198; font-size: 10px; line-height: 1.5; }
.cg-sim-bestmix-diff { color: rgba(255,255,255,.64); }
.cg-sim-bestmix-diff-value { color: #76e5bd; }
.cg-sim-bestmix-detail-btn {
    margin-top: 8px;
    color: #8df0ca;
    font-weight: 700;
}
.cg-sim-bestmix-detail {
    margin: 0 0 16px;
    padding: 13px;
    border: 1px solid #dfe7ef;
    background: #f8fafc;
}
.cg-sim-bestmix-detail-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    color: #18395e;
    font-size: 12px;
}
.cg-sim-bestmix-detail-head span { color: #7c899b; font-size: 9px; text-align: right; }
.cg-sim-bestmix-detail-item { border: 1px solid transparent; background: #fff; }
.cg-sim-bestmix-detail-item--gain { border-color: rgba(8,183,123,.25); background: #f0fbf7; }
.cg-sim-bestmix-detail-shop { color: #67778d; font-weight: 400; }
.cg-sim-bestmix-detail-gain,
.cg-sim-bestmix-detail-same {
    flex: 0 0 auto;
    padding: 4px 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}
.cg-sim-bestmix-detail-gain { background: #d9f6eb; color: #087a58; }
.cg-sim-bestmix-detail-same { background: #edf1f5; color: #6b7889; }

.cg-sim-shop-ranking { margin-top: 18px; }
.cg-sim-shop-rank-item {
    min-height: 48px;
    border-color: #e1e7ee;
    border-radius: 9px;
    background: #fff;
}
.cg-sim-shop-rank-item--top {
    border-color: rgba(8,153,106,.35);
    background: linear-gradient(90deg, #effbf6, #fff);
}
.cg-sim-shop-rank-total { font-family: ui-monospace, "SFMono-Regular", monospace; }

.cg-sim-row {
    border-color: #e0e7ef;
    border-radius: 12px;
    transition: border-color .18s ease, box-shadow .18s ease;
}
.cg-sim-row:hover { border-color: #b8c9da; box-shadow: 0 8px 20px rgba(15,42,76,.06); }
.cg-sim-row-thumb { border-radius: 7px; box-shadow: 0 4px 10px rgba(16,33,58,.12); }
.cg-sim-row-title { color: #102e52 !important; font-weight: 700; }
.cg-sim-row-game { background: #eaf2fb; color: #174b83; }
.cg-sim-qty,
.cg-sim-cond-select,
.cg-sim-row-remove { border-color: #d9e2ec; border-radius: 8px; }
.cg-sim-btn { border-radius: 9px; font-weight: 700; }
.cg-sim-btn-share { background: #0b2b58; border-color: #0b2b58; }

.cg-sim-fab {
    left: auto;
    right: 24px;
    bottom: 22px;
    width: auto;
    min-width: 190px;
    height: 54px;
    padding: 0 24px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    background: linear-gradient(135deg, #0b2b58, #0b6d64);
    box-shadow: 0 14px 32px rgba(7,26,58,.25);
    font-weight: 700;
}
.cg-sim-fab:hover { opacity: 1; box-shadow: 0 17px 36px rgba(7,26,58,.32); }
.cg-sim-sheet-overlay { background: rgba(5,19,40,.66); backdrop-filter: blur(3px); }
.cg-sim-sheet-panel {
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -18px 50px rgba(5,19,40,.18);
}
.cg-sim-search-input { height: 48px; border-width: 1px; }
.cg-sim-search-input:focus { border-color: #27639f; box-shadow: 0 0 0 3px rgba(39,99,159,.10); }

@media (min-width: 900px) {
    .cg-sim {
        display: grid;
        grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
        gap: 18px;
        align-items: start;
    }
    .cg-sim-header,
    .cg-sim-game-picker,
    .cg-sim-how-to,
    .cg-sim-notice { grid-column: 1 / -1; }
    .cg-sim-header { margin-bottom: 0; }
    .cg-sim-game-picker { margin-bottom: 0; }
    .cg-sim-how-to { margin-bottom: 0 !important; }
    .cg-sim-summary { grid-column: 1; margin-bottom: 0; position: sticky; top: 82px; }
    .cg-sim-cardlist { grid-column: 2; margin-bottom: 0; }
}

@media (max-width: 600px) {
    .cg-sim { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
    .cg-sim-header { padding: 24px 20px 22px; border-radius: 16px; }
    .cg-sim-header::after { right: -10px; top: -10px; font-size: 125px; }
    .cg-sim-h1,
    .cg-sim h2.cg-sim-h1 { font-size: 23px !important; }
    .cg-sim-lead { font-size: 12px; }
    .cg-sim-game-picker,
    .cg-sim-summary,
    .cg-sim-cardlist { padding: 16px; border-radius: 14px; }
    .cg-sim-game-options { grid-template-columns: 1fr; }
    .cg-sim-game-option { min-height: 60px; }
    .cg-sim-strategy-grid { grid-template-columns: 1fr; }
    .cg-sim-strategy-label,
    .cg-sim-bestmix-label { min-height: 0; }
    .cg-sim-bestmix-detail-head { align-items: flex-start; flex-direction: column; }
    .cg-sim-bestmix-detail-head span { text-align: left; }
    .cg-sim-bestmix-detail-item { align-items: flex-start; flex-direction: column; }
    .cg-sim-bestmix-detail-gain,
    .cg-sim-bestmix-detail-same { align-self: flex-start; }
    .cg-sim-rarity-filter {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 0 0 6px;
        scrollbar-width: thin;
        overscroll-behavior-inline: contain;
    }
    .cg-sim-rarity-filter-label,
    .cg-sim-rarity-chip { flex: 0 0 auto; }
    .cg-sim-fab {
        left: 12px;
        right: 12px;
        bottom: max(10px, env(safe-area-inset-bottom));
        width: auto;
        min-width: 0;
        height: 54px;
        border-radius: 14px;
    }
}
