/* ===== Charts Section ===== */
.charts-section {
    display: grid;
    /* Even split between the progress table and the charts stack. The table
       gets its room back via column compression in the 1101–1300px range. */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: 1fr;
    gap: 1rem;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* Left side: progress table */
.charts-section .section--full {
    min-height: 0;
}

/* 1:1 fallback: on narrower desktops the six-column progress table cannot
   fit the game-name column, so tighten cell padding and compress the fixed
   columns instead of widening the left track away from 1:1. */
@media (min-width: 1101px) and (max-width: 1300px) {
    .charts-section .table--progress th,
    .charts-section .table--progress td {
        padding-inline: 0.375rem;
    }

    .charts-section .table--progress col:nth-child(2) {
        width: 4.5rem !important;
    }

    .charts-section .table--progress col:nth-child(3) {
        width: 5.25rem !important;
    }

    .charts-section .table--progress col:nth-child(4) {
        width: 5rem !important;
    }

    .charts-section .table--progress col:nth-child(5) {
        width: 7rem !important;
    }

    /* Keep the action button clear of the card's right edge */
    .charts-section .table--progress col:nth-child(6) {
        width: 4.5rem !important;
    }
}

/* Right side: charts stack */
.charts-section .charts-right {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 1rem;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.charts-section .charts-right .chart-card {
    min-height: 0;
    overflow: hidden;
}

/* Two-column grid collapses at ≤1100px (see responsive.css) */

.chart-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chart-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--color-text);
    flex-shrink: 0;
}

.chart-container {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
}

@media (max-width: 640px) {
    .chart-container {
        height: 12.5rem;
    }
}

/* ===== H5: stacked chart cards with fixed height, page scrolls ===== */
@media (max-width: 768px) {
    .charts-section {
        gap: 0.75rem;
        flex: none;
    }

    .chart-card {
        height: clamp(16.25rem, 42dvh, 21.25rem);
        flex: none;
        padding: 0.875rem;
    }
}

.chart-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

/* ===== Trend chart fullscreen viewer ===== */
.chart-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.chart-card__head .chart-title {
    margin-bottom: 0;
}

.chart-expand-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.chart-expand-btn:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

html.trend-fullscreen-open,
html.trend-fullscreen-open body {
    overflow: hidden;
}

.trend-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: var(--color-surface);
    animation: fadeIn 150ms ease;
}

.trend-fullscreen__stage {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
}

.trend-fullscreen__title {
    flex-shrink: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text);
}

/* While rotated, the close button sits over the title's top edge;
   indent the title so the two never overlap */
.trend-fullscreen--rotate .trend-fullscreen__title {
    padding-left: 2.25rem;
}

.trend-fullscreen__stage .chart-container {
    flex: 1;
    min-height: 0;
    height: auto;
}

/* Portrait phones: rotate the stage 90° so the chart reads landscape */
.trend-fullscreen--rotate .trend-fullscreen__stage {
    inset: auto;
    top: 50%;
    left: 50%;
    width: 100dvh;
    height: 100vw;
    transform: translate(-50%, -50%) rotate(90deg);
}

.trend-fullscreen__close {
    position: fixed;
    top: calc(0.5rem + env(safe-area-inset-top, 0px));
    right: calc(0.5rem + env(safe-area-inset-right, 0px));
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 50%;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 1.125rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

@media (max-width: 768px) {
    .chart-expand-btn {
        display: inline-flex;
    }

    .chart-card__head {
        margin-bottom: 0.5rem;
    }
}
