.movie-details-container {
    width: 100%;
    height: auto;
    background: rgba(0, 0, 0, .6);
    padding: 15px;
    border-radius: 8px;
    /* โปสเตอร์เคยฟิกซ์ที่ 261px — ขยายประมาณ 306px สูงสุด และยังยืดบนจอกลางได้ด้วย 42vw */
    --poster-column-max-w: min(306px, 42vw);
}
.movie-details-container2 {
    width: 80%;
    height: auto;
    background: rgba(0, 0, 0, .6);
    padding: 15px;
    border-radius: 8px;
}
.movie-details-medias {
    margin-top: 10px;
    width: 100%;
    min-height: 350px;
    height: auto;
    background: #000;
    display: flex;
    justify-content: space-evenly;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    box-sizing: border-box;
}
.movie-details-poster {
    width: var(--poster-column-max-w);
    max-width: var(--poster-column-max-w);
    height: auto;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
}
.movie-details-poster img {
    width: 100%;
    max-width: var(--poster-column-max-w);
    height: auto;
    display: block;
    object-fit: contain;
    object-position: center center;
}
.movie-details-trailer {
    width: 433px;
    height: 350px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.movie-details-heading {
    width: 100%;
    height: auto;
    min-height: 40px;
    border-radius: 8px 8px 0 0;
    background: #85180f;
    padding: clamp(6px, 1.4vw, 10px);
    overflow: visible;
    text-align: center;
}

.movie-details-container .movie-details-heading h1 {
    font-size: clamp(0.92rem, 2.85vw, 1.35rem);
    font-weight: 600;
    line-height: 1.35;
    margin: 0;
    padding: 2px 4px;
    color: #fff;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* ถาดรายการตอน — grid สม่ำเสมอ อ่านง่าย */
.movie-details-container#ep-list {
    width: min(46rem, 100%);
    max-width: 100%;
    margin-inline: auto;
    padding: clamp(12px, 2.2vw, 18px);
    box-sizing: border-box;
    align-self: center;
    background: rgba(12, 14, 18, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
}

#ep-list #eplist-blocks-container {
    width: 100%;
}

#ep-list .eplist-pagination-bar {
    padding-bottom: 10px;
    margin-bottom: 0.35rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#ep-list .epblock-page {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(5.75rem, 1fr));
    gap: 0.65rem 0.75rem;
    width: 100%;
    max-width: 40rem;
    margin-inline: auto;
    padding: 6px 2px 10px;
    align-content: start;
    justify-items: stretch;
    grid-auto-rows: auto;
}

@media (min-width: 480px) {
    #ep-list .epblock-page {
        grid-template-columns: repeat(auto-fill, minmax(6.25rem, 1fr));
        gap: 0.75rem 0.85rem;
        max-width: 44rem;
    }
}

@media (min-width: 768px) {
    #ep-list .epblock-page {
        grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
        gap: 0.85rem 1rem;
        max-width: 46rem;
    }
}

/* ฟิลเลอร์สมัย space-between เดิม — ถ้ามีจากแคช ไม่ต้องกินที่ */
#ep-list .epblock-slot-empty {
    display: none !important;
}

.movie-details-container#ep-list .eplist-pagination-bar .eplist-page-select {
    width: min(280px, 100%);
    min-height: 44px;
    font-size: clamp(14px, 2vw, 16px);
    font-weight: 600;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(22, 26, 32, 0.95);
    color: #f1f3f5;
}

.movie-details-container#ep-list .movie-details-episode-block {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    margin-top: 0;
    min-height: 0;
    overflow: hidden;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.2s ease;
}

.movie-details-container#ep-list .movie-details-episode-block.episode-block--current {
    border-color: rgba(255, 235, 110, 0.85);
    box-shadow:
        0 0 0 2px rgba(255, 235, 110, 0.45),
        0 10px 26px rgba(0, 0, 0, 0.45);
}

.movie-details-episode-block {
    width: 91px;
    height: 91px;
    background: linear-gradient(to bottom, black, #290101);
    margin-top: 10px;
    border-radius: 6px;
    position: relative;
    box-sizing: border-box;
}
.episode-block-top {
    width: 100%;
    height: 30px;
    text-align: center;
    line-height: 2.0em;
    color: #838383;
    box-sizing: border-box;
}
.episode-block-bottom {
    width: 100%;
    height: 61px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: #b5b5b5;
    box-sizing: border-box;
}
.episode-block-bottom a {
    text-decoration: none;
    color: #fff;
}
.movie-details-episode-block:hover {
    background: #290101;
    color: #fff;
    cursor: pointer;
}

/* รายการตอน: thumbnail + แถบข้อความล่างอ่านง่าย */
#ep-list .movie-details-episode-block:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(220, 53, 69, 0.35);
}

#ep-list .movie-details-episode-block.episode-block--current:hover {
    box-shadow:
        0 0 0 2px rgba(255, 235, 110, 0.55),
        0 14px 32px rgba(0, 0, 0, 0.48),
        0 0 0 1px rgba(220, 53, 69, 0.25);
}

#ep-list .movie-details-episode-block .episode-block-media {
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    overflow: hidden;
}

#ep-list .movie-details-episode-block .episode-block-media-fallback {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: saturate(0.92) brightness(0.88);
}

#ep-list .movie-details-episode-block.is-thumb-loaded .episode-block-media-fallback {
    display: none !important;
    background-image: none !important;
}

#ep-list .movie-details-episode-block.is-thumb-fallback .episode-block-media-fallback {
    display: block !important;
}

#ep-list .movie-details-episode-block .episode-block-thumb {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.45s ease, transform 0.45s ease;
    transform: scale(1.03);
}

#ep-list .movie-details-episode-block.is-thumb-loaded .episode-block-thumb {
    opacity: 1;
    transform: scale(1);
}

#ep-list .movie-details-episode-block:hover.is-thumb-loaded .episode-block-thumb {
    transform: scale(1.05);
}

#ep-list .movie-details-episode-block .episode-block-shade {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.15) 0%,
        rgba(0, 0, 0, 0.2) 38%,
        rgba(0, 0, 0, 0.55) 72%,
        rgba(0, 0, 0, 0.82) 100%
    );
}

#ep-list .movie-details-episode-block .episode-block-footer {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0.2rem;
    width: 100%;
    padding: 0.45rem 0.35rem 0.55rem;
    box-sizing: border-box;
    text-align: center;
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.45) 28%,
        rgba(0, 0, 0, 0.88) 100%
    );
    border-radius: 0 0 9px 9px;
}

#ep-list .movie-details-episode-block .episode-block-label {
    font-size: clamp(0.7rem, 2.4vw, 0.82rem);
    font-weight: 600;
    letter-spacing: 0.08em;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.94);
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.95),
        0 0 12px rgba(0, 0, 0, 0.65);
}

#ep-list .movie-details-episode-block .episode-block-num {
    position: relative;
    display: block;
    min-width: 1.25em;
    font-size: clamp(1.28rem, 4.8vw, 1.72rem);
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    color: #ffffff;
    text-decoration: none !important;
    text-shadow:
        0 2px 6px rgba(0, 0, 0, 0.95),
        0 0 1px rgba(0, 0, 0, 1);
}

#ep-list .movie-details-episode-block.episode-block--current .episode-block-num {
    color: #fff59d;
    text-shadow:
        0 0 12px rgba(255, 230, 120, 0.55),
        0 2px 8px rgba(0, 0, 0, 0.95);
}

#ep-list .movie-details-episode-block:hover .episode-block-num {
    color: #ffffff;
}

#ep-list .movie-details-episode-block.episode-block--current:hover .episode-block-num {
    color: #fffde7;
}

/* การ์ดตอนเป็นลิงก์ห่อทั้งกล่อง — ไม่พึ่ง stretched-link */
#ep-list a.movie-details-episode-block {
    display: block;
    text-decoration: none !important;
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

#ep-list a.movie-details-episode-block:focus-visible {
    outline: 2px solid rgba(255, 213, 120, 0.95);
    outline-offset: 2px;
}

/* โหลด thumbnail ตอนไม่สำเร็จ / หมดเวลา — ตัวเลขสีแดง + ป้ายมุมเครื่องหมายตกใจ */
#ep-list .movie-details-episode-block.is-thumb-error .episode-block-label {
    color: #ffa8a8;
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.95),
        0 0 10px rgba(201, 42, 42, 0.45);
}

#ep-list .movie-details-episode-block.is-thumb-error .episode-block-num {
    color: #ff6b6b;
    text-shadow:
        0 2px 6px rgba(0, 0, 0, 0.95),
        0 0 14px rgba(224, 49, 49, 0.55);
}

#ep-list .movie-details-episode-block.is-thumb-error.episode-block--current .episode-block-num {
    color: #ff8787;
    text-shadow:
        0 2px 8px rgba(0, 0, 0, 0.95),
        0 0 12px rgba(224, 49, 49, 0.5);
}

#ep-list .movie-details-episode-block.is-thumb-error:hover .episode-block-num {
    color: #ff8787;
}

.episode-block-thumb-error-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: clamp(1.05rem, 4.2vw, 1.25rem);
    height: clamp(1.05rem, 4.2vw, 1.25rem);
    padding: 0;
    font-size: clamp(0.72rem, 2.8vw, 0.82rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0;
    color: #fff;
    text-align: center;
    background: linear-gradient(165deg, #e03131 0%, #c92a2a 100%);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(0, 0, 0, 0.25) inset;
    pointer-events: none;
}

#ep-list .movie-details-episode-block.episode-block--watched {
    border-color: rgba(120, 210, 140, 0.72);
    box-shadow:
        0 0 0 1px rgba(120, 210, 140, 0.22),
        0 4px 14px rgba(0, 0, 0, 0.32);
}

#ep-list .movie-details-episode-block.episode-block--watched .episode-block-thumb,
#ep-list .movie-details-episode-block.episode-block--watched .episode-block-media-fallback {
    filter: saturate(0.72) brightness(0.92);
}

#ep-list .movie-details-episode-block.episode-block--watched .episode-block-label,
#ep-list .movie-details-episode-block.episode-block--watched .episode-block-num {
    color: #9fd9ab;
}

#ep-list .movie-details-episode-block.episode-block--watched.episode-block--current {
    border-color: rgba(255, 235, 110, 0.85);
    box-shadow:
        0 0 0 2px rgba(255, 235, 110, 0.45),
        0 0 0 1px rgba(120, 210, 140, 0.35),
        0 10px 26px rgba(0, 0, 0, 0.45);
}

#ep-list .movie-details-episode-block.episode-block--watched.episode-block--current .episode-block-num {
    color: #ffe066;
}

#ep-list .movie-details-episode-block.episode-block--watched:hover {
    box-shadow:
        0 12px 28px rgba(0, 0, 0, 0.42),
        0 0 0 1px rgba(120, 210, 140, 0.45);
}

.episode-block-watched-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 4;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(20, 120, 70, 0.92);
    border: 1px solid rgba(170, 245, 195, 0.55);
    color: #ecfdf3;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.2;
    pointer-events: none;
}

.poster-meta-container {
    display: flex;
    width: auto;
    max-width: min(540px, 100%);
    min-width: 0;
    flex: 1 1 auto;
    height: auto;
    border: 2px dashed #202020;
    border-width: 0 2px 0 0;
    align-items: flex-start;
}
.movie-details-meta {
    margin-left: 10px;
}

@media (max-width: 900px) {
    .movie-details-container2 {
        width: 100%;
    }
    .movie-details-medias {
        flex-direction: column;
        height: auto;
        align-items: center;
        gap: 12px;
        padding-bottom: 12px;
    }
    .movie-details-container {
        --poster-column-max-w: min(306px, 88vw);
    }
    .movie-details-poster {
        width: var(--poster-column-max-w);
        max-width: min(306px, 100%);
        height: auto;
    }
    .movie-details-poster img {
        width: 100%;
        max-width: min(306px, 100%);
        height: auto;
        display: block;
        object-fit: contain;
    }
    .movie-details-trailer {
        position: relative;
        width: min(433px, 100%);
        height: auto;
        aspect-ratio: 16 / 9;
    }
    .movie-details-trailer iframe {
        position: absolute;
        inset: 0;
        width: 100% !important;
        height: 100% !important;
        border: 0;
    }
    .poster-meta-container {
        flex-direction: column;
        width: 100%;
        max-width: 100%;
        border-width: 2px 0 0 0;
        padding-top: 12px;
    }
}

/* ปุ่มดูหลัก — โดดชัด กดง่าย */
.movie-details-watch-wrap {
    padding: 4px 8px 12px;
}

.movie-details-watch-wrap--top {
    margin: 12px 0 14px;
    padding: 6px 10px 4px;
}

.movie-details-container .movie-details-watch-wrap--top + .movie-details-medias {
    margin-top: 0;
}

.content-container .movie-details-watch-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: clamp(52px, 12vw, 64px);
    padding: clamp(12px, 2.5vw, 16px) clamp(24px, 6vw, 44px);
    font-size: clamp(1.12rem, 3.2vw, 1.45rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1.15;
    border-radius: 999px;
    border: 2px solid rgba(255, 230, 180, 0.95);
    background: linear-gradient(165deg, #ff4a5a 0%, #d91c2e 42%, #a30a18 100%);
    color: #fff !important;
    box-shadow:
        0 3px 0 #5c0a12,
        0 10px 28px rgba(230, 40, 55, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
    animation: movie-details-watch-cta-glow 2.8s ease-in-out infinite;
}

.content-container .movie-details-watch-cta:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    color: #fff !important;
    box-shadow:
        0 5px 0 #4a0810,
        0 14px 36px rgba(255, 60, 80, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.content-container .movie-details-watch-cta:active {
    transform: translateY(1px);
    box-shadow:
        0 1px 0 #5c0a12,
        0 6px 18px rgba(200, 30, 45, 0.45),
        inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.content-container .movie-details-watch-cta:focus-visible {
    outline: 3px solid #ffd56a;
    outline-offset: 4px;
}

.movie-details-watch-cta-icon {
    width: 1.35em !important;
    height: 1.35em !important;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.movie-details-watch-cta-label {
    white-space: nowrap;
}

@keyframes movie-details-watch-cta-glow {
    0%, 100% {
        box-shadow:
            0 3px 0 #5c0a12,
            0 10px 28px rgba(230, 40, 55, 0.5),
            inset 0 1px 0 rgba(255, 255, 255, 0.22);
    }
    50% {
        box-shadow:
            0 3px 0 #5c0a12,
            0 12px 38px rgba(255, 95, 105, 0.65),
            0 0 24px rgba(255, 210, 140, 0.35),
            inset 0 1px 0 rgba(255, 255, 255, 0.22);
    }
}

@media (prefers-reduced-motion: reduce) {
    .content-container .movie-details-watch-cta {
        animation: none;
    }
}