/* ranking-table-maker.css */
:root {
    --cw-max-width: 1000px;
    --cw-breakpoint-md: 800px;
    --cw-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    --cw-text-color-primary: #212529;
    --cw-bg-primary: #fff;
    --cw-border-color: #dee2e6;
}

.ranking-table-maker-root {
    position: relative;
    font-family: var(--cw-font-family);
    margin: 2em auto;
    max-width: var(--cw-max-width);
}

.cw-loading, .cw-error {
    text-align: center; padding: 4rem 1rem; font-size: 1.1rem; color: #6c757d; min-height: 200px; display: flex; align-items: center; justify-content: center; flex-direction: column; background-color: #f8f9fa; border-radius: 8px;
}

.cw-spinner { width: 48px; height: 48px; border: 5px solid #f3f3f3; border-top: 5px solid #007bff; border-radius: 50%; animation: spinner-rotate 1s linear infinite; margin-bottom: 1.5rem; }
@keyframes spinner-rotate { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

#cw-list { display: flex; flex-direction: column; border: 1px solid var(--cw-border-color); border-radius: 0.3rem; overflow: hidden; background-color: var(--cw-bg-primary); }
.cw-table-header, .cw-table-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--cw-border-color); }
.cw-table-row:last-child { border-bottom: none; }
.cw-table-row:hover { background-color: #f8f9fa; }
.cw-table-header { background-color: #f8f9fa; color: #6c757d; font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }

.cw-table-cell { padding: 0.9em 0.8em; display: flex; align-items: center; font-size: 0.9rem; color: var(--cw-text-color-primary); line-height: 1.5; }
.cw-cell-rank { flex: 0 0 65px; justify-content: center; font-weight: 700; font-size: 1.05rem; }
.cw-cell-rank span { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background-color: #e9ecef; color: #495057; }
.cw-rank-1 span { background-color: #ffd700; color: #3d2800; }
.cw-rank-2 span { background-color: #c0c0c0; color: #3d3d3d; }
.cw-rank-3 span { background-color: #cd7f32; color: #fff; }

.cw-cell-image { flex: 0 0 90px; justify-content: center; }
.cw-cell-image img { width: 70px; height: 70px; object-fit: contain; border-radius: 0.25rem; }
.cw-cell-title { flex: 1 1 32%; min-width: 200px; font-weight: 500; }
.cw-title-multiline { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.cw-cell-price { flex: 0 0 140px; justify-content: center; font-weight: 600; color: #c82333; flex-direction: column; align-items: flex-end; gap: 2px; }
.cw-cell-rating { flex: 0 0 95px; justify-content: center; font-weight: 600; color: #ffc107; }
.cw-cell-buy { flex: 0 0 125px; display: flex; flex-direction: column; gap: 0.45em; align-items: stretch; justify-content: center; }
.cw-buy-btn { padding: 0.55em 0.5em; border-radius: 0.2rem; text-decoration: none; color: white !important; font-size: 0.8rem; text-align: center; display: block; font-weight: 500; transition: opacity 0.2s; }
.cw-buy-btn:hover { opacity: 0.88; }
.cw-buy-btn.az { background: #ff9900; }
.cw-buy-btn.rk { background: #bf0000; }
.cw-buy-btn.yh { background: #004097; }

.cw-timestamp { display: inline; font-size: 0.8em; color: #6c757d; font-weight: 400; line-height: 1.3; white-space: nowrap; margin-left: 0.5em; }

.rtm-disclaimer {
    font-size: 0.85em;
    line-height: 1.6;
    color: #6c757d;
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 6px;
    white-space: pre-wrap;
}

@media (max-width: 799px) {
    #cw-list { min-width: 0; border: none; background-color: transparent; gap: 1rem; }
    .cw-table-header { display: none; }
    .cw-table-row {
        position: relative; /* ★★★ 修正箇所 ★★★ */
        display: grid;
        grid-template-columns: 90px 1fr;
        grid-template-rows: auto auto auto auto;
        gap: 0 1rem;
        border: 1px solid var(--cw-border-color);
        background-color: var(--cw-bg-primary);
        border-radius: 8px; padding: 1rem;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    }
    .cw-cell-rank { position: absolute; top: 0; left: 0; }
    .cw-cell-rank span { border-top-left-radius: 8px; border-bottom-right-radius: 8px; border-top-right-radius: 0; border-bottom-left-radius: 0; }
    .cw-cell-image { grid-column: 1 / 2; grid-row: 1 / -1; align-self: center; }
    .cw-cell-title { grid-column: 2 / 3; grid-row: 1 / 2; font-weight: bold; line-height: 1.5; align-items: flex-start;}
    .cw-cell-price { grid-column: 2 / 3; grid-row: 2 / 3; font-weight: bold; color: #c82333; font-size: 1rem; align-items: flex-start; margin-top: 0.5rem; }
    .cw-cell-rating {
        grid-column: 2 / 3;
        grid-row: 3 / 4;
        justify-content: flex-start;
        margin-top: 0.25rem;
    }
    .cw-cell-buy {
        grid-column: 2 / 3;
        grid-row: 4 / 5;
        margin-top: auto;
        padding-top: 0.5rem;
        width: 100%;
        flex-direction: row;
        gap: 0.5rem;
    }
    .cw-buy-btn { flex-grow: 1; }
}