/* Living Puzzle Gallery — interactive, data-driven, mobile-first */
.archive-view-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    margin-left: auto;
    border: 1px solid rgba(148, 163, 184, .17);
    border-radius: 12px;
    background: rgba(12, 17, 29, .82);
}
.archive-view-button {
    appearance: none;
    border: 0;
    border-radius: 8px;
    min-height: 36px;
    padding: 0 13px;
    color: #8793a8;
    background: transparent;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: color .2s ease, background .2s ease, box-shadow .2s ease;
}
.archive-view-button:hover { color: #f8fafc; }
.archive-view-button.is-active {
    color: #ecfeff;
    background: linear-gradient(135deg, rgba(34, 211, 238, .19), rgba(139, 92, 246, .2));
    box-shadow: inset 0 0 0 1px rgba(103, 232, 249, .22);
}
.gallery-mode-active #summary-table .archive-header { display: none !important; }
.living-gallery { display: grid; gap: 24px; padding-top: 8px; }
.gallery-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.gallery-metric {
    --metric-accent: #67e8f9;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    padding: 18px 18px 16px;
    border: 1px solid rgba(148, 163, 184, .15);
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(23, 32, 49, .92), rgba(12, 17, 28, .95));
    animation: gallery-rise .55s both;
    animation-delay: calc(var(--card-index, 0) * 40ms);
}
.gallery-metric::before {
    content: "";
    position: absolute;
    z-index: -1;
    width: 150px;
    height: 150px;
    right: -78px;
    top: -94px;
    border-radius: 50%;
    background: var(--metric-accent);
    opacity: .07;
}
.gallery-metric-cyan { --metric-accent: #67e8f9; }
.gallery-metric-violet { --metric-accent: #c4b5fd; }
.gallery-metric-blue { --metric-accent: #93c5fd; }
.gallery-metric-amber { --metric-accent: #fcd34d; }
.gallery-metric-label { color: #98a5ba; font-size: 11px; font-weight: 650; }
.gallery-metric-value { color: #f8fafc; font-size: clamp(22px, 2.3vw, 30px); line-height: 1.1; letter-spacing: -.8px; font-variant-numeric: tabular-nums; }
.gallery-metric-note { color: #6f7d92; font-size: 11px; }
.gallery-analysis { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr); gap: 14px; }
.gallery-chart-panel, .gallery-insight-panel {
    min-width: 0;
    padding: 20px;
    border: 1px solid rgba(148, 163, 184, .14);
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(19, 27, 42, .92), rgba(12, 16, 26, .96));
}
.gallery-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.gallery-panel-heading h2, .gallery-insight-panel h2, .gallery-results-heading h2 { margin: 0; color: #eef4ff; font-size: 17px; letter-spacing: -.3px; }
.gallery-panel-heading p, .gallery-results-heading p { margin: 6px 0 0; color: #7f8ba0; font-size: 12px; line-height: 1.5; }
.gallery-chart-key { flex: 0 0 auto; color: #6f819b; font-size: 9px; font-weight: 800; letter-spacing: .8px; text-align: right; }
.gallery-bar-chart { display: grid; gap: 10px; }
.gallery-bar-row {
    display: grid;
    grid-template-columns: minmax(70px, 1fr) minmax(70px, 1.3fr) 44px;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 3px 0;
    border: 0;
    color: inherit;
    text-align: left;
    background: transparent;
    cursor: pointer;
}
.gallery-bar-name { overflow: hidden; color: #b8c3d5; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.gallery-bar-track { display: block; overflow: hidden; height: 7px; border-radius: 99px; background: #202b3e; }
.gallery-bar-fill {
    display: block; height: 100%; border-radius: inherit;
    background: linear-gradient(90deg, #22d3ee, #818cf8 72%, #c4b5fd);
    box-shadow: 0 0 16px rgba(34, 211, 238, .19);
    transform-origin: left; animation: gallery-bar-grow .8s cubic-bezier(.2,.7,.2,1) both;
}
.gallery-bar-row:hover .gallery-bar-fill, .gallery-bar-row:focus-visible .gallery-bar-fill { filter: brightness(1.3); }
.gallery-bar-value { color: #e2e8f0; font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.gallery-empty-chart { color: #8491a5; font-size: 12px; }
.gallery-insight-intro { margin: 7px 0 18px; color: #7f8ba0; font-size: 12px; line-height: 1.5; }
.gallery-insight-list { display: grid; gap: 0; }
.gallery-insight-row { display: grid; grid-template-columns: 8px minmax(0,1fr); gap: 11px; padding: 12px 0; border-top: 1px solid rgba(148, 163, 184, .1); }
.gallery-insight-mark { width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; background: #67e8f9; box-shadow: 0 0 12px currentColor; }
.mark-rating { color: #c4b5fd; background: #c4b5fd; }
.mark-plays { color: #67e8f9; background: #67e8f9; }
.mark-coverage { color: #fcd34d; background: #fcd34d; }
.gallery-insight-row > div { display: grid; gap: 5px; min-width: 0; }
.gallery-insight-label { color: #8d9ab0; font-size: 11px; }
.gallery-insight-value { color: #e8edf7; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.gallery-results-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-top: 4px; }
.gallery-sort-wrap { display: flex; align-items: center; gap: 9px; color: #8491a5; font-size: 11px; }
.gallery-sort-wrap select {
    min-height: 38px; max-width: 190px; padding: 0 30px 0 11px;
    border: 1px solid rgba(148, 163, 184, .18); border-radius: 10px;
    color: #dce6f4; background: #151d2b; font: inherit; cursor: pointer;
}
.gallery-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.gallery-puzzle-card {
    content-visibility: auto;
    contain-intrinsic-size: auto 430px;
    --pointer-x: 50%; --pointer-y: 0%; --tilt-x: 0deg; --tilt-y: 0deg;
    position: relative; min-width: 0; overflow: hidden; border-radius: 17px;
    border: 1px solid rgba(148, 163, 184, .15);
    background: linear-gradient(155deg, #182235, #101622 72%);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .16);
    transform: none;
    transition: transform .18s ease, border-color .18s ease;
    animation: gallery-rise .5s both;
    animation-delay: calc(min(var(--card-index, 0), 10) * 35ms);
}
.gallery-puzzle-card::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
    background: radial-gradient(280px circle at var(--pointer-x) var(--pointer-y), rgba(103, 232, 249, .12), transparent 65%);
    transition: opacity .25s ease;
}
.gallery-puzzle-card:hover, .gallery-puzzle-card:focus-within {
    transform: translateY(-2px);
    border-color: rgba(103, 232, 249, .36);
}
.gallery-puzzle-card:hover::after, .gallery-puzzle-card:focus-within::after { opacity: 1; }
.gallery-puzzle-card.is-selected { border-color: rgba(103, 232, 249, .72); box-shadow: 0 0 0 2px rgba(103, 232, 249, .12), 0 18px 40px rgba(0,0,0,.28); }
.gallery-card-image {
    position: relative; display: flex; align-items: center; justify-content: center;
    aspect-ratio: 1.28 / 1; overflow: hidden; padding: 14px;
    background: radial-gradient(circle at 50% 20%, rgba(77, 101, 150, .19), transparent 62%), #0c121e;
    text-decoration: none;
}
.gallery-card-image img { display: block; width: 100%; height: 100%; object-fit: contain; transition: transform .22s ease; }
.gallery-puzzle-card:hover .gallery-card-image img { transform: scale(1.02); }
.gallery-image-placeholder { display: grid; place-items: center; width: 100%; height: 100%; color: #6d7b91; font-size: 12px; text-align: center; }
.gallery-image-overlay {
    display: inline-flex; align-items: center; gap: 7px;
    position: absolute; right: 12px; bottom: 12px; padding: 8px 10px;
    border: 1px solid rgba(255,255,255,.15); border-radius: 9px;
    color: #ecfeff; background: rgba(8, 14, 24, .94);
    font-size: 9px; font-weight: 800; letter-spacing: .5px; opacity: 0;
    transform: translateY(5px); transition: opacity .2s ease, transform .2s ease;
}
.gallery-puzzle-card:hover .gallery-image-overlay, .gallery-card-image:focus-visible .gallery-image-overlay { opacity: 1; transform: translateY(0); }
.gallery-card-body { position: relative; z-index: 1; padding: 15px 16px 16px; }
.gallery-card-topline { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.gallery-puzzle-number { color: #67e8f9; font-size: 10px; font-weight: 800; }
.gallery-puzzle-date { overflow: hidden; color: #77869d; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.gallery-card-body h3 { margin: 0 0 12px; color: #f1f5fb; font-size: 18px; font-weight: 700; letter-spacing: -.45px; line-height: 1.25; overflow-wrap: anywhere; }
.gallery-stars-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 18px; }
.gallery-stars-row .puzzle-stars { min-width: 0; }
.gallery-stars-row .star-bar { max-width: 100%; }
.gallery-rating-value { color: #dbeafe; font-size: 12px; font-weight: 750; font-variant-numeric: tabular-nums; }
.gallery-rating-track { overflow: hidden; height: 4px; margin-top: 9px; border-radius: 99px; background: #283448; }
.gallery-rating-fill { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #22d3ee, #818cf8); transition: width .55s ease; }
.gallery-card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 15px; }
.gallery-card-stat { display: grid; gap: 5px; min-width: 0; padding: 10px; border: 1px solid rgba(148,163,184,.1); border-radius: 10px; background: rgba(6, 11, 19, .25); }
.gallery-card-stat span { color: #7f8ba0; font-size: 10px; }
.gallery-card-stat strong { color: #e7edf7; font-size: 14px; font-variant-numeric: tabular-nums; }
.gallery-card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 15px; }
.gallery-play-button, .gallery-lmd-link { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; border-radius: 9px; text-decoration: none; font-size: 11px; font-weight: 750; transition: background .2s ease, color .2s ease, border-color .2s ease; }
.gallery-play-button { padding: 0 12px; color: #07131d; background: linear-gradient(100deg, #67e8f9, #a5b4fc); }
.gallery-play-button:hover { background: #cffafe; }
.gallery-lmd-link { padding: 0 2px; color: #9aa8bf; }
.gallery-lmd-link:hover { color: #e0f2fe; }
.gallery-empty-state { grid-column: 1 / -1; padding: 36px 18px; border: 1px dashed rgba(148,163,184,.25); border-radius: 15px; color: #e2e8f0; text-align: center; }
.gallery-empty-state p { margin-bottom: 0; color: #8997ac; font-size: 13px; }
@keyframes gallery-rise { from { opacity: 0; translate: 0 9px; } to { opacity: 1; translate: 0 0; } }
@keyframes gallery-bar-grow { from { transform: scaleX(.05); opacity: .4; } to { transform: scaleX(1); opacity: 1; } }

@media (max-width: 1050px) {
    .gallery-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .gallery-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .section-heading { flex-wrap: wrap; gap: 12px; }
    .archive-view-switch { order: 3; margin-left: 0; width: 100%; }
    .archive-view-button { flex: 1; }
    .gallery-analysis { grid-template-columns: minmax(0, 1fr); }
    .gallery-chart-panel, .gallery-insight-panel { padding: 16px; border-radius: 15px; }
    .gallery-panel-heading { flex-direction: column; gap: 8px; margin-bottom: 16px; }
    .gallery-chart-key { text-align: left; }
    .gallery-results-heading { align-items: stretch; flex-direction: column; gap: 12px; }
    .gallery-sort-wrap { justify-content: space-between; }
    .gallery-sort-wrap select { max-width: none; flex: 1; }
    .gallery-card-grid { grid-template-columns: minmax(0, 1fr); gap: 13px; }
    .gallery-card-image { aspect-ratio: 1.55 / 1; }
    .gallery-card-body { padding: 14px; }
    .gallery-card-body h3 { font-size: 17px; }
    .gallery-metric { padding: 14px; border-radius: 13px; }
    .gallery-metric-value { font-size: 24px; }
    .gallery-bar-row { grid-template-columns: minmax(72px, .9fr) minmax(45px, 1fr) 38px; gap: 8px; }
    .gallery-bar-name { font-size: 10px; }
    .gallery-bar-value { font-size: 10px; }
}
@media (max-width: 380px) {
    .gallery-metrics { gap: 8px; }
    .gallery-metric { padding: 12px; }
    .gallery-metric-value { font-size: 21px; }
    .gallery-card-stats { gap: 6px; }
    .gallery-card-stat { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
    .gallery-metric, .gallery-puzzle-card, .gallery-bar-fill { animation: none !important; }
    .gallery-puzzle-card, .gallery-card-image img, .gallery-image-overlay, .gallery-rating-fill { transition: none !important; }
    .gallery-puzzle-card { transform: none !important; }
}

/* Keep the archive view switch visible in the page header. */
.site-header .archive-view-switch {
    flex: 0 0 auto;
    margin-left: auto;
}
.site-header .live-status {
    flex: 0 0 auto;
    margin-left: 18px;
}
@media (max-width: 760px) {
    .site-header .archive-view-switch {
        order: 3;
        width: 100%;
        margin-left: 0;
    }
    .site-header .live-status {
        margin-left: auto;
    }
}


/* Keep SVG link/play glyphs consistent with the archive actions. */
.gallery-image-overlay, .gallery-play-button, .gallery-lmd-link { gap: 7px; }
.gallery-image-overlay .action-icon-svg { width: 13px; height: 13px; }
.gallery-play-button .action-icon-svg, .gallery-lmd-link .action-icon-svg { width: 14px; height: 14px; }


/* Interactive solve-distribution curve */
.gallery-distribution {
    position: relative;
    margin: 2px 0 26px;
    padding: 17px 0 19px;
    border-bottom: 1px solid rgba(148, 163, 184, .13);
    opacity: .82;
    transition: opacity .45s ease;
}
.gallery-distribution.is-visible { opacity: 1; }
.gallery-distribution-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 12px; }
.gallery-distribution-eyebrow { display: block; margin-bottom: 7px; color: #67e8f9; font-size: 9px; font-weight: 850; letter-spacing: 1.4px; }
.gallery-distribution-heading h3 { margin: 0; color: #eef4ff; font-size: 15px; letter-spacing: -.25px; }
.gallery-distribution-heading p { margin: 6px 0 0; color: #7f8ba0; font-size: 11px; line-height: 1.5; }
.gallery-distribution-switch { position: relative; display: flex; align-items: stretch; flex: 0 0 auto; overflow: hidden; border: 1px solid rgba(148,163,184,.18); border-radius: 11px; background: rgba(7,12,21,.62); }
.gallery-distribution-option { position: relative; min-height: 36px; padding: 0 13px; border: 0; color: #7f8ba0; background: transparent; font: inherit; font-size: 11px; font-weight: 750; cursor: pointer; transition: color .25s ease, background .3s ease, transform .6s cubic-bezier(.2,.8,.2,1); }
.gallery-distribution-option:first-child { transform: translateX(28px); }
.gallery-distribution-option:last-child { transform: translateX(28px); }
.gallery-distribution.is-visible .gallery-distribution-option { transform: translateX(0); }
.gallery-distribution-option.is-active { color: #07131d; background: linear-gradient(105deg,#67e8f9,#a5b4fc); }
.gallery-distribution-divider { align-self: center; width: 1px; height: 19px; background: rgba(148,163,184,.3); transition: opacity .3s ease; }
.gallery-distribution.is-visible .gallery-distribution-divider { animation: distribution-divider-in .55s .22s both; }
.gallery-distribution-chart { position: relative; width: 100%; overflow: hidden; border-radius: 12px; background: radial-gradient(ellipse at 50% 100%,rgba(34,211,238,.045),transparent 66%); }
.gallery-distribution-chart svg { display: block; width: 100%; height: auto; min-height: 150px; overflow: visible; }
.distribution-grid line { stroke: rgba(148,163,184,.13); stroke-dasharray: 2 6; }
.distribution-grid text, .distribution-axis text { fill: #718097; font-size: 10px; }
.distribution-area { fill: url(#puzzle-distribution-gradient); opacity: 0; transition: opacity .6s ease; }
.distribution-curve { fill: none; stroke: #67e8f9; stroke-width: 2.7; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 5px rgba(103,232,249,.24)); }
.distribution-points circle { cursor: crosshair; transition: r .18s ease, filter .18s ease; }
.distribution-points circle:hover, .distribution-points circle:focus { outline: none; filter: drop-shadow(0 0 5px currentColor); }
.gallery-distribution-note { min-height: 18px; margin-top: 2px; color: #91a0b6; font-size: 10px; font-variant-numeric: tabular-nums; }
@keyframes distribution-divider-in { from { opacity: 0; transform: scaleY(.1); } to { opacity: 1; transform: scaleY(1); } }
@media (max-width: 760px) {
    .gallery-distribution-heading { align-items: stretch; flex-direction: column; gap: 13px; }
    .gallery-distribution-switch { width: 100%; }
    .gallery-distribution-option { flex: 1; }
    .gallery-distribution-chart svg { min-height: 120px; }
}
@media (prefers-reduced-motion: reduce) {
    .gallery-distribution, .gallery-distribution-option, .gallery-distribution-divider, .distribution-area { transition: none !important; animation: none !important; }
    .gallery-distribution-option, .gallery-distribution-option:first-child, .gallery-distribution-option:last-child { transform: none !important; }
}


/* Radar-like horizontal scan clipped strictly to the filled distribution area. */
.distribution-scan { mix-blend-mode: screen; }
.gallery-bar-fill { transform-origin: left center; }
.gallery-bar-track { overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
    .distribution-scan { display: none !important; }
}

/* Header analytics action */
.site-header .analytics-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    margin-inline: 8px;
    padding: 0 15px;
    border: 1px solid rgba(103, 232, 249, .22);
    border-radius: 8px;
    color: #ecfeff;
    background: linear-gradient(135deg, rgba(34, 211, 238, .19), rgba(139, 92, 246, .2));
    box-shadow: inset 0 0 0 1px rgba(103, 232, 249, .06);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: color .2s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.site-header .analytics-link:hover {
    color: #fff;
    border-color: rgba(103, 232, 249, .48);
    background: linear-gradient(135deg, rgba(34, 211, 238, .28), rgba(139, 92, 246, .29));
    box-shadow: 0 0 18px rgba(34, 211, 238, .1), inset 0 0 0 1px rgba(103, 232, 249, .16);
}
@media (max-width: 760px) {
    .site-header .analytics-link {
        order: 4;
        margin-inline: 0;
    }
}



/* Touch-device performance: keep the gallery visually intact without
   continuously compositing 3D cards, blur layers, and entrance animations. */
@media (hover: none), (pointer: coarse) {
    .gallery-puzzle-card {
        contain-intrinsic-size: auto 520px;
        transform: none !important;
        transition: none !important;
        animation: none !important;
        box-shadow: 0 5px 14px rgba(0, 0, 0, .13);
    }

    .gallery-puzzle-card::after {
        display: none;
    }

    .gallery-puzzle-card:hover,
    .gallery-puzzle-card:focus-within,
    .gallery-puzzle-card.is-selected {
        transform: none !important;
        box-shadow: 0 5px 14px rgba(0, 0, 0, .13);
    }

    .gallery-card-image img,
    .gallery-puzzle-card:hover .gallery-card-image img {
        transform: none !important;
        filter: none !important;
        transition: none !important;
    }

    .gallery-image-overlay {
        display: none;
        backdrop-filter: none;
    }

    .gallery-metric,
    .gallery-bar-fill {
        animation: none !important;
    }

    .gallery-rating-fill {
        transition: none !important;
    }

    .gallery-distribution {
        transition: none !important;
    }
}


/* Keep both archive layouts mounted so switching views is immediate. */
.archive-content {
    display: block;
    min-width: 0;
}
.archive-view-panel[hidden] {
    display: none !important;
}
