/* リセット & ベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Helvetica Neue', 'Noto Sans JP', sans-serif;
    background-color: #0f0f0f;
    color: #e0e0e0;
    line-height: 1.6;
    letter-spacing: 0.3px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ヘッダー */
.header {
    margin-bottom: 15px;
    padding: 15px 0 10px 0;
    border-bottom: 1px solid #2a2a2a;
}

.header h1 {
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: #ffffff;
    margin-bottom: 8px;
    text-align: center;
}

.subtitle-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 20px;
}

.subtitle {
    font-size: 0.75rem;
    color: #888888;
    font-weight: 300;
    letter-spacing: 0.5px;
    margin: 0;
    flex: 1;
}

.header-links {
    font-size: 0.8rem;
    display: flex;
    gap: 8px;
}

.header-link-label {
    color: #888888;
    font-size: 0.8rem;
}

.header-link {
    color: #22c55e;
    text-decoration: none;
    transition: color 0.2s ease;
    padding: 0 4px;
    font-weight: 600;
}

.header-link:hover {
    color: #4ade80;
    text-decoration: underline;
}

/* トップバー */
.topbar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

.topbar-left {
    flex: 1;
}

.search-wrappers {
    display: flex;
    gap: 10px;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
}

#search-card,
#search-effect {
    width: 100%;
    padding: 10px 12px;
    padding-right: 36px;
    background-color: #262626;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    font-size: 16px;
}

#search-card:focus,
#search-effect:focus {
    outline: none;
    border-color: #555555;
    background-color: #2a2a2a;
}

.clear-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: #666666;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 6px;
    transition: color 0.2s ease;
    display: none;
}

.clear-btn:hover {
    color: #e0e0e0;
}

#search-card:not(:placeholder-shown)~.clear-btn,
#search-effect:not(:placeholder-shown)~.clear-btn {
    display: block;
}

#search-card::placeholder,
#search-effect::placeholder {
    color: #666666;
}

.topbar-right {
    display: flex;
    gap: 10px;
    align-items: center;
    white-space: nowrap;
}

.filter-btn {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background-color: #333333;
    border-color: #555555;
    color: #ffffff;
}

.filter-btn:active {
    background-color: #252525;
}

.card-count {
    font-size: 0.85rem;
    color: #888888;
    font-weight: 600;
}

/* フィルターポップアップ */
.filter-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background-color: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    z-index: 1000;
    max-height: 80vh;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    max-width: 90%;
    width: 400px;
}

.filter-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.filter-popup-content {
    padding: 20px;
}

.filter-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #2a2a2a;
    padding-bottom: 12px;
}

.filter-popup-header h3 {
    font-size: 1rem;
    color: #ffffff;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: #888888;
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #ffffff;
}

.filter-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.filter-category {
    border-bottom: 1px solid #2a2a2a;
    padding-bottom: 12px;
}

.filter-category:last-child {
    border-bottom: none;
}

.filter-category h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* チェックボックスグループ */
.checkbox-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    user-select: none;
    font-size: 0.85rem;
}

.checkbox-label:hover {
    background-color: #252525;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
    accent-color: #ffffff;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #262626;
    border: 2px solid #555555;
    border-radius: 3px;
    flex-shrink: 0;
    background-image: none;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

.checkbox-label input[type="checkbox"]:checked {
    background-color: #ffffff;
    border-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23000000'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd'/%3E%3C/svg%3E");
}

.checkbox-label input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

/* フィルターアクション */
.filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #2a2a2a;
}

.reset-btn {
    flex: 1;
    background-color: #262626;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    background-color: #2a2a2a;
    border-color: #555555;
    color: #ffffff;
}

.apply-btn {
    flex: 1;
    background-color: #333333;
    color: #ffffff;
    border: 1px solid #555555;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.apply-btn:hover {
    background-color: #3a3a3a;
    border-color: #666666;
}

/* オーバーレイ */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.overlay.active {
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 1;
    visibility: visible;
}

/* テーブルラッパー */
.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #2a2a2a;
    background-color: #1a1a1a;
}

/* テーブル */
#cards-table {
    width: 100%;
    border-collapse: collapse;
}

#cards-table thead {
    background-color: #1a1a1a;
    border-bottom: 2px solid #333333;
    position: sticky;
    top: 0;
    z-index: 10;
}

#cards-table th {
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    color: #ffffff;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

#cards-table tbody tr {
    border-bottom: 1px solid #2a2a2a;
    transition: background-color 0.2s ease;
}

#cards-table tbody tr:hover {
    background-color: #242424;
}

#cards-table td {
    padding: 14px 12px;
    font-size: 0.9rem;
    color: #f0f0f0;
}

/* 種類列のスタイル */
#cards-table td:first-child {
    font-weight: 600;
    white-space: nowrap;
}

/* PC版：種類は完全表示 */
.type-short {
    display: none;
}

.type-full {
    display: inline;
}

/* カード名列 */
#cards-table td:nth-child(2) {
    max-width: 150px;
    word-break: break-word;
}

/* グレード列のカラーコーディング */
#cards-table td:nth-child(4),
#cards-table td.grade-cell {
    font-weight: 600;
    white-space: nowrap;
}

.grade-common {}

.grade-rare {}

.grade-legend {}

.grade-myth {}

/* AP列 */
#cards-table th.ap-header,
#cards-table td:nth-child(7) {
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
}

/* カオス列（PC版で表示） */
#cards-table th.chaos-header {
    text-align: center;
}

#cards-table td.chaos-cell {
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
}

/* 職業列 */
#cards-table th:nth-child(6),
#cards-table td:nth-child(6) {
    text-align: center;
}

/* PC版：職業は省略なし */
.job-short {
    display: none;
}

.job-full {
    white-space: normal;
    word-break: break-word;
    font-size: 0.85rem;
}

/* ヘッダーの表示/非表示制御 */
.header-short {
    display: none;
}

.header-full {
    display: inline;
}

/* 画像列（PC版） */
#cards-table th.image-header {
    text-align: center;
    width: 150px;
}

#cards-table td.image-cell {
    text-align: center;
    padding: 8px !important;
}

#cards-table td.image-cell img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
}

/* 種列のヘッダー */
#cards-table th.type-header {}

/* AP列のヘッダー */
#cards-table th.ap-header {}

/* カード名列 */
#cards-table td.card-name-cell {
    max-width: 150px;
}

/* PC版：カード名と画像の組み合わせ */
.card-name-with-image {
    display: contents;
}

.card-name-text {
    display: inline;
}

.card-image-sp {
    display: none;
}

/* 効果列 */
#cards-table td:last-child {
    max-width: 400px;
    word-break: break-word;
    color: #f0f0f0;
    line-height: 1.5;
}

/* PC版：効果は通常表示、SP版の表示は非表示 */
.effect-pc {
    display: inline;
}

.effect-sp {
    display: none;
}

/* スマートフォン対応 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header {
        margin-bottom: 12px;
        padding: 10px 0 8px 0;
    }

    .header h1 {
        font-size: 1.1rem;
        margin-bottom: 2px;
    }

    .subtitle {
        font-size: 0.65rem;
    }

    .topbar {
        flex-direction: column;
        gap: 8px;
        margin-bottom: 10px;
    }

    .topbar-left {
        width: 100%;
    }

    #search-card,
    #search-effect {
        font-size: 0.85rem;
        padding: 8px 10px;
    }

    .topbar-right {
        width: 100%;
        gap: 8px;
    }

    .filter-btn {
        flex: 1;
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .card-count {
        flex: 0 0 auto;
        padding: 8px 10px;
        background-color: #262626;
        border: 1px solid #3a3a3a;
        border-radius: 6px;
        font-size: 0.8rem;
    }

    .filter-popup {
        width: 95%;
        max-width: 95%;
    }

    .filter-popup-content {
        padding: 15px;
    }

    #cards-table th,
    #cards-table td {
        padding: 8px 4px;
        font-size: 0.75rem;
    }

    /* モバイル版：種列を非表示 */
    #cards-table th.type-header,
    #cards-table td:first-child {
        display: none;
    }

    /* モバイル版：画像列を非表示 */
    #cards-table th.image-header,
    #cards-table td.image-cell {
        display: none;
    }

    /* モバイル版：AP列を表示（職業列の右） */
    #cards-table th.ap-header,
    #cards-table td:nth-child(7) {
        text-align: center;
        font-weight: 600;
        white-space: nowrap;
        padding: 8px 4px;
        font-size: 0.75rem;
    }

    /* モバイル版：カオス列を非表示 */
    #cards-table th.chaos-header,
    #cards-table td.chaos-cell {
        display: none;
    }

    /* モバイルでのカード名列：幅を調整 */
    #cards-table td:nth-child(3) {
        width: 25%;
    }

    /* モバイルでの職業列（6番目のまま） */
    #cards-table td:nth-child(6) {
        min-width: 35px;
        max-width: 45px;
    }

    /* モバイル版：職業は2文字省略 */
    .job-short {
        display: inline;
        font-size: 0.75rem;
    }

    .job-full {
        display: none;
    }

    /* モバイルでの効果列を見やすく */
    #cards-table td:last-child {
        width: 75%;
    }

    /* モバイル版：効果に [種類/AP:値] を表示 */
    .effect-pc {
        display: none;
    }

    .effect-sp {
        display: inline;
    }

    /* モバイル版：カード名と画像の組み合わせ */
    .card-name-with-image {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .card-name-text {
        display: block;
        font-weight: 600;
        width: 100%;
    }

    .card-image-sp {
        display: block;
        width: 60px;
        height: 60px;
    }

    .card-image-sp img {
        width: 60px;
        height: 60px;
        object-fit: cover;
        border-radius: 4px;
    }
}


/* スクロールバーのスタイル（Webkit） */
.table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: #333333;
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #444444;
}

/* メッセージ（データなし） */
.no-data-message {
    text-align: center;
    padding: 40px 20px;
    color: #666666;
    font-size: 1rem;
}