/* 基本設定 */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding-top: 140px; /* ヘッダーの高さに合わせて調整 */
    background-color: #f4f7f6;
    color: #333;
    line-height: 1.6;
}

/* ヘッダー */
.fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #2c3e50;
    color: white;
    padding: 10px 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    text-align: center;
}

.fixed-header h1 {
    margin: 0;
    font-size: 1.5em;
    padding-bottom: 10px;
}

/* アコーディオンと検索フィルター */
.search-accordion-container {
    background-color: #34495e;
    padding: 0 15px;
}

.accordion-header {
    background-color: #34495e;
    color: white;
    cursor: pointer;
    padding: 10px 15px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 1em;
    transition: background-color 0.3s ease;
    border-bottom: 1px solid #4a6681;
}

.accordion-header:hover {
    background-color: #4a6681;
}

.accordion-content {
    padding: 0 15px;
    background-color: #34495e;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;

    /* ★ここを変更しました★ */
    overflow-y: auto; /* コンテンツがmax-heightを超えた場合に縦スクロールを有効にする */
    -webkit-overflow-scrolling: touch; /* iOSで滑らかなスクロールを有効にする */
}

/* アコーディオンが開いた時のmax-heightを調整 */
.accordion-content.active {
    max-height: 250px; /* スマホでスクロールバーが見えるように、適切な高さに調整 */
    padding: 15px;
}

.search-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 5px;
}

.filter-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
    color: #ecf0f1;
}

.filter-group select,
.filter-group input[type="text"] {
    width: calc(100% - 20px);
    padding: 8px 10px;
    border: 1px solid #7f8c8d;
    border-radius: 4px;
    background-color: #ecf0f1;
    color: #333;
    font-size: 0.9em;
}

/* チェックボックス用グリッドレイアウト */
.checkbox-grid {
    display: grid;
    /* 各アイテムの幅を調整し、列数を自動で決定 */
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); /* スマホで押しやすいサイズに調整 */
    gap: 8px 10px;
    color: #ecf0f1;
    font-size: 0.85em;
    padding-top: 5px;
}

/* 個々のチェックボックスアイテム（ラベルとチェックボックスのセット） */
.checkbox-grid > div {
    /* 押下領域を広げるためのスタイル */
    padding: 8px 5px; /* 上下左右のパディングを追加 */
    border-radius: 4px;
    transition: background-color 0.2s ease;
    cursor: pointer; /* ポインター表示 */
    box-sizing: border-box; /* パディングを幅に含める */
    display: flex; /* チェックボックスとラベルを横並びにする */
    align-items: center; /* 垂直方向中央揃え */
    justify-content: flex-start; /* 左寄せ */
}

.checkbox-grid > div:hover {
    background-color: rgba(255, 255, 255, 0.1); /* ホバー時の背景色 */
}

.checkbox-grid label {
    margin-bottom: 0; /* 親要素のmargin-bottomを打ち消す */
    flex-grow: 1; /* ラベルが利用可能なスペースを全て占めるようにする */
    margin-left: 5px; /* チェックボックスとの間に少しスペースを空ける */
    cursor: inherit; /* 親のカーソル設定を継承 */
}

.checkbox-grid input[type="checkbox"] {
    /* チェックボックス自体のスタイルは小さめにするが、タップ領域はラベルと合わせて広げる */
    min-width: 16px; /* 最小幅を確保 */
    min-height: 16px; /* 最小高さを確保 */
    margin: 0; /* デフォルトマージンをリセット */
    cursor: pointer; /* ポインター表示 */
    flex-shrink: 0; /* 縮小しない */
}


/* カードリスト */
#card-list-container {
    padding: 20px 15px;
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* スマホ向けに調整 */
}

.card-item {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 15px;
    transition: transform 0.2s ease-in-out;
}

.card-item:hover {
    transform: translateY(-5px);
}

.card-item h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #2c3e50;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-item p {
    font-size: 0.9em;
    color: #555;
    margin-bottom: 5px;
}

.card-rank {
    font-size: 0.8em;
    padding: 3px 8px;
    border-radius: 4px;
    color: white;
    font-weight: bold;
    white-space: nowrap; /* 改行防止 */
}

/* カードランクの色分け */
.rank-一般 { background-color: #ccc; } /* 白系統 */
.rank-高級 { background-color: #27ae60; } /* 緑 */
.rank-希少 { background-color: #3498db; } /* 青 */
.rank-英雄 { background-color: #8e44ad; } /* 紫 */
.rank-古代 { background-color: #f39c12; } /* 黄 */

/* レスポンシブデザイン */
@media (max-width: 600px) {
    body {
        padding-top: 200px; /* スマホ向けにヘッダーの高さ再調整 (ステータスが増えた分) */
    }

    .fixed-header h1 {
        font-size: 1.3em;
    }

    .search-section {
        padding-top: 0;
    }

    .filter-group select,
    .filter-group input[type="text"] {
        width: 100%;
    }

    #card-list-container {
        grid-template-columns: 1fr; /* スマホでは1列表示 */
        padding: 15px;
    }

    .checkbox-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); /* スマホではさらに項目を詰める */
        font-size: 0.8em; /* フォントサイズも少し小さく */
    }
}