/* --- カラーマトリクス図のスタイル --- */
:root {
    --y-width: 4rem;   /* 左列の幅 */
    --x-width: 7rem;   /* 右列の幅 */
    --header-h: 4rem;    /* ヘッダー（横軸規格名）の高さ */
    --row-h: 6.5rem;     /* データ行（縦軸規格名とマトリクス）の高さ */
}

/* 全体コンテナ */
#chart-area {
    overflow: visible;
    background-color: #f6f6f6;
    margin: 1rem auto;
    padding: 1rem;
    border-radius: 1rem;
    font-size: 1rem;
}

#chart-area #inner {
    display: flex;
    align-items: flex-start;
}

/* --- 左側固定列 --- */
#chart-area .table-fix {
    width: var(--y-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

#chart-area .titleb.cell {
    background-color: #999;
    color: #fff;
    width: var(--y-width) !important;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: solid #fff 1px;
    box-sizing: border-box;
}

#chart-area .table-fix .titleb.cell:first-child {
    height: var(--header-h) !important;
}

#chart-area .table-fix .titleb.cell:not(:first-child) {
    height: var(--row-h) !important;
}

/* --- 右側スクロールエリア --- */
#chart-area .table-scroll-wp {
    flex-grow: 1;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

/* ヘッダー行（As, BAs...） */
#chart-area .table-scroll-row {
    display: flex;
}

#chart-area .table-scroll-row .title.cell {
    padding: 5px;
    width: var(--x-width) !important;
    height: var(--header-h) !important;
    background-color: #ddd;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: solid #fff 1px;
    box-sizing: border-box;
    flex-shrink: 0;
}

/* メインデータ行 */
#chart-area .main {
    display: flex;
    height: var(--row-h) !important;
}

#chart-area .main .cell {
    width: var(--x-width) !important;
    height: var(--row-h) !important;
    border: solid #fff 1px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* --- セル内部の要素 --- */
#chart-area .cell-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

#chart-area .color-box {
    position: relative;
    z-index: 1;
    width: 3.2rem;
    height: 3.2rem;
    display: block;
    border: 1px solid #ccc;
    cursor: pointer;
    margin: 0 !important;
}

#chart-area .cell-checkbox {
    position: absolute;
    top: 0;
    left: 0;
    width: 1.1rem;
    height: 1.1rem;
    z-index: 2;
}

#chart-area .stock-msg {
    position: absolute;
    top: calc(50% + 1.4rem);
    left: 50%;
    transform: translateX(-50%);
    display: block;
    width: 100%;
    font-size: 0.65rem;
    line-height: 1.1;
    color: #d9534f;
    text-align: center;
    margin-top: 0.4rem;
    font-weight: bold;
    white-space: normal;
    pointer-events: none;
}

#chart-area .cell.out-of-stock {
    background-color: #eee;
}

#chart-area .cell.out-of-stock .color-box {
    opacity: 0.3;
}

.clr { clear: both; }

.add-cart-all-button-wrap {
    width: 100%;
    margin: 0 auto;
}
/* --- スマホ用サイズ調整（画面幅768px以下の場合に適用） --- */
@media screen and (max-width: 768px) {
    :root {
        --y-width: 2.5rem;   /* 左の縦軸の幅（スッキリめに） */
        --x-width: 4.2rem;   /* セルの横幅（余白を削って狭く） */
        --header-h: 2.5rem;  /* 上の横軸の高さ */
        --row-h: 4rem;       /* セルの高さ（余白を削って低く） */
    }

    #chart-area .table-scroll-row .title.cell {
        font-size: 0.65rem;       /* 枠に収まりやすいよう文字を少し小さく調整 */
        line-height: 1.2;         /* 行間を少し詰めて、複数行入りやすくする */
        padding: 2px;             /* 内側の余白を限界まで減らして文字スペースを確保 */
        word-break: break-all;    /* 長い文字が来ても強制的に枠内で折り返す */
        overflow: hidden;         /* 万が一、枠（高さ）を越えても外にはみ出させない */
        text-align: center;
    }

    #chart-area {
        padding: 0.25rem;
        font-size: 0.75rem;  /* 全体の文字サイズをもう一段階小さく */
    }

    #chart-area .color-box {
        width: 2.4rem;       /* 正方形自体は小さくしすぎず、視認性をキープ */
        height: 2.4rem;
    }

    #chart-area .cell-checkbox {
        width: 1rem;
        height: 1rem;
    }

    #chart-area .stock-msg {
        /* 正方形の下部ギリギリに品切れメッセージが来るように位置調整 */
        top: calc(50% + 1.2rem); 
        font-size: 0.5rem;
        margin-top: 0.2rem;
    }
}