
:root {
    --bg-primary: #0a0a0c;
    --bg-card: #121215;
    --bg-card-hover: #18181c;
    --surface: #1c1c22;
    --border: #2a2a32;
    --text-primary: #eeeef0;
    --text-secondary: #8888a0;
    --text-muted: #55556a;
    --accent: #e8c547;
    --accent-dim: #c4a535;
    --accent-glow: rgba(232, 197, 71, 0.12);
    --red: #e54d4d;
    --green: #4dcc7a;
    --blue: #5b8dee;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "DM Sans", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── GRAIN OVERLAY ─── */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 9999;
}

/* ─── HEADER ─── */
.header {
    position: relative;
    padding: 2.5rem 1.25rem 2rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}

.header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('preview.jpg') center/cover no-repeat;
    opacity: 0.25;
    pointer-events: none;
}

.header-logo, .header-subtitle {
    position: relative;
    z-index: 1;
}

.header-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.header-logo svg,
.header-logo img {
    width: 28px;
    height: 28px;
    color: var(--accent);
}

.header h1 {
    font-family: "Bebas Neue", sans-serif;
    font-size: 2.6rem;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    line-height: 1;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

.header h1 span {
    color: var(--accent);
}

.header-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-top: 0.35rem;
}

/* ─── STATS BAR ─── */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 1.2rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.stat {
    text-align: center;
}

.stat-value {
    font-family: "Bebas Neue", sans-serif;
    font-size: 1.6rem;
    color: var(--accent);
    line-height: 1.1;
}

.stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

/* ─── SORT / FILTER ─── */
.controls {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.controls::-webkit-scrollbar {
    display: none;
}

.control-btn {
    flex-shrink: 0;
    padding: 0.45rem 0.9rem;
    font-family: "DM Sans", sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.control-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.control-btn.active {
    color: var(--bg-primary);
    background: var(--accent);
    border-color: var(--accent);
}

/* ─── MOVIE GRID ─── */
.movie-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1px;
    background: var(--border);
    margin: 0;
}

/* ─── MOVIE CARD ─── */
.movie-card {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-card);
    cursor: pointer;
    transition: background 0.25s;
    animation: fadeUp 0.5s ease both;
}

.movie-card:hover {
    background: var(--bg-card-hover);
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.movie-poster {
    position: relative;
    width: 100px;
    aspect-ratio: 2/3;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
}

.movie-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.movie-poster .rank-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Bebas Neue", sans-serif;
    font-size: 0.8rem;
    color: var(--accent);
    border: 1px solid rgba(232, 197, 71, 0.3);
}

.movie-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.movie-title {
    font-family: "Bebas Neue", sans-serif;
    font-size: 1.3rem;
    letter-spacing: 0.03em;
    line-height: 1.15;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.movie-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.2rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.movie-meta .dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.movie-genres {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}

.genre-tag {
    padding: 0.2rem 0.55rem;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 100px;
}

.movie-score-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.7rem;
}

.avg-score {
    font-family: "Bebas Neue", sans-serif;
    font-size: 1.7rem;
    line-height: 1;
}

.score-bar-track {
    flex: 1;
    height: 4px;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.score-voters {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ─── EXPANDED DETAIL ─── */
.movie-detail {
    display: none;
    grid-column: 1 / -1;
    overflow: hidden;
    background: var(--bg-card);
}

.movie-detail.open {
    display: block;
    max-height: 0;
    padding: 0 1.25rem;
    animation: detailDeploy 0.5s ease forwards;
}

.movie-detail.closing {
    display: block;
    max-height: 600px;
    padding: 0 1.25rem 1.25rem;
    animation: detailCollapse 0.3s ease forwards;
}

@keyframes detailDeploy {
    from {
        max-height: 0;
        padding: 0 1.25rem;
    }
    to {
        max-height: 600px;
        padding: 0 1.25rem 1.25rem;
    }
}

@keyframes detailCollapse {
    from {
        max-height: 600px;
        padding: 0 1.25rem 1.25rem;
    }
    to {
        max-height: 0;
        padding: 0 1.25rem;
    }
}

.detail-inner {
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.detail-section-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

.score-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.member-score {
    display: grid;
    grid-template-columns: 70px 1fr 30px;
    align-items: center;
    gap: 0.6rem;
}

.member-name {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.member-bar-track {
    height: 3px;
    background: var(--surface);
    border-radius: 3px;
    overflow: hidden;
}

.member-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.member-val {
    font-family: "Bebas Neue", sans-serif;
    font-size: 1rem;
    text-align: right;
}

.detail-date {
    margin-top: 0.9rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.detail-date svg {
    width: 14px;
    height: 14px;
    opacity: 0.5;
}

/* ─── RANKING TABLE ─── */
.ranking-section {
    padding: 1.5rem 1.25rem 2.5rem;
}

.section-title {
    font-family: "Bebas Neue", sans-serif;
    font-size: 1.4rem;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.member-ranking {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.member-rank-row {
    display: grid;
    grid-template-columns: 24px 1fr auto 50px 20px;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.8rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.member-rank-row:hover {
    background: var(--bg-card-hover);
}

.member-rank-chevron {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
    text-align: center;
}

.member-rank-row.open .member-rank-chevron {
    transform: rotate(180deg);
}

.member-rank-item {
    display: flex;
    flex-direction: column;
}

.member-detail-panel {
    max-height: 0;
    overflow: hidden;
    transition:
        max-height 0.3s ease,
        border-color 0.2s ease,
        margin-top 0.2s ease;
    background: var(--bg-card);
    border: 1px solid transparent;
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    margin-top: 0;
}

.member-detail-panel.open {
    max-height: 600px;
    border-color: var(--border);
    margin-top: -0.35rem;
    transition:
        max-height 1s ease,
        border-color 0.5s ease,
        margin-top 0.5s ease;
}

.member-detail-inner {
    padding: 0.6rem 0.8rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.member-movie-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.4rem;
    border-radius: 4px;
    font-size: 0.78rem;
}

.member-movie-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.02);
}

.member-movie-title {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-movie-score {
    font-family: "Bebas Neue", sans-serif;
    font-size: 0.95rem;
    min-width: 28px;
    text-align: right;
}

.member-rank-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    text-align: right;
}

.member-rank-pos {
    font-family: "Bebas Neue", sans-serif;
    font-size: 1rem;
    color: var(--accent);
    text-align: center;
}

.member-rank-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.member-rank-avg {
    font-family: "Bebas Neue", sans-serif;
    font-size: 1.15rem;
    text-align: right;
}

/* ─── FOOTER ─── */
.footer {
    text-align: center;
    padding: 2rem 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

.last-updated {
    display: block;
    margin-bottom: 0.6rem;
    font-size: 0.62rem;
    color: var(--text-muted);
    opacity: 0.7;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* ─── SCORE COLORS ─── */
.score-high {
    color: var(--green);
}
.score-mid {
    color: var(--accent);
}
.score-low {
    color: var(--red);
}

.bar-high {
    background: var(--green);
}
.bar-mid {
    background: var(--accent);
}
.bar-low {
    background: var(--red);
}

/* ─── RESPONSIVE ─── */
@media (min-width: 600px) {
    .movie-grid {
        grid-template-columns: 1fr 1fr;
    }
    .movie-card {
        grid-template-columns: 110px 1fr;
    }
    .header h1 {
        font-size: 3.2rem;
    }
    .stats-bar {
        gap: 3rem;
    }
}

@media (min-width: 960px) {
    .movie-grid {
        max-width: 960px;
        margin: 0 auto;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
    .header {
        padding: 3.5rem 2rem 2.5rem;
    }
    .header h1 {
        font-size: 3.8rem;
    }
    .controls {
        justify-content: center;
        padding: 1.25rem 2rem;
    }
    .stats-bar {
        max-width: 960px;
        margin: 0 auto;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
    .controls {
        max-width: 960px;
        margin: 0 auto;
    }
    .ranking-section {
        max-width: 960px;
        margin: 0 auto;
        padding: 2rem 1.5rem 3rem;
    }
    .member-ranking {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
    }
    .member-detail-inner {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.2rem 1rem;
    }
    .footer {
        max-width: 960px;
        margin: 0 auto;
    }
}

@media (min-width: 1200px) {
    .movie-grid {
        max-width: 1100px;
    }
    .stats-bar,
    .controls,
    .ranking-section,
    .footer {
        max-width: 1100px;
    }
    .member-ranking {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* ─── LOADING SKELETON ─── */
.poster-skeleton {
    background: linear-gradient(
        110deg,
        var(--surface) 30%,
        #25252d 50%,
        var(--surface) 70%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
    to {
        background-position: -200% 0;
    }
}
