:root {
    --bg: #0f1015;
    --panel: #161922;
    --panel-border: #2a2f3d;
    --text: #f4f6ff;
    --muted: #b7bdd1;
    --accent: #ff6a00;
    --accent-2: #ee0979;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    /* Prevent text size adjustment on orientation change */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html,
body {
    min-height: 100%;
    /* Hard-stop any horizontal overflow at the root level */
    overflow-x: hidden;
    max-width: 100vw;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--text);
    font-family: 'Roboto', Arial, sans-serif;
    background:
        radial-gradient(circle at top left, #251438 0%, transparent 40%),
        radial-gradient(circle at top right, #14344a 0%, transparent 33%),
        var(--bg);
    display: grid;
    place-items: center;
    padding: 2.2rem 1rem 1.4rem;
    /* Respect notch / home-bar safe areas */
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(1.4rem, env(safe-area-inset-bottom));
}

.container {
    /* Use 100vw so the container is always bounded by the actual viewport,
       even if the body has been pushed wider by an overflowing child. */
    width: min(1024px, calc(100vw - 2rem));
    max-width: 100%;
    box-sizing: border-box;
}

.logo-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    text-decoration: none;
    color: var(--text);
    background: rgba(25, 28, 39, 0.75);
    backdrop-filter: blur(6px);
    margin-bottom: 1rem;
}

.logo-pill-image {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.player-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent), var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 1rem;
    padding: 1.3rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.32);
    /* Prevent any child (cast grid, related grid, etc.) from breaking out */
    max-width: 100%;
    overflow: hidden;
}

.title {
    font-size: clamp(1.55rem, 5vw, 2.2rem);
    margin: 0;
    overflow-wrap: break-word;
    line-height: 1.25;
}

.subtitle {
    margin: 0.45rem 0 1rem;
    color: var(--muted);
}

.subtitle strong {
    color: #ffffff;
}

.trailer-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid #333b50;
    background: #000;
}

.trailer-container iframe {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.back-home {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.back-home button,
.back-home-btn {
    border: none;
    border-radius: 0.6rem;
    padding: 0.7rem 1rem;
    /* Ensure at least 48px tall for mobile tap targets */
    min-height: 48px;
    font-size: 0.95rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.15s ease, filter 0.2s ease;
}

.back-home-btn {
    color: #fff;
    background: linear-gradient(45deg, var(--accent), var(--accent-2));
    font-weight: 700;
}

.secondary-action {
    background: #2a2f40;
    color: var(--text);
}

#playlistBtn {
    background: linear-gradient(45deg, #1a1a2e, #16213e);
    border: 1px solid rgba(255, 106, 0, 0.45);
    color: var(--text);
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease, filter 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

#playlistBtn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, var(--accent), var(--accent-2));
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 0;
}

#playlistBtn > * {
    position: relative;
    z-index: 1;
}

#playlistBtn:not(:disabled):hover {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(255, 106, 0, 0.3);
}

#playlistBtn:not(:disabled):hover::before {
    opacity: 0.18;
}

#playlistBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.back-home button:hover,
.back-home-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

footer {
    margin-top: 1.1rem;
    font-size: 0.95rem;
    color: var(--muted);
}

footer a {
    color: #8ff88a;
    font-weight: 700;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.movie-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(6, 7, 10, 0.95);
    align-items: center;
    justify-content: center;
}

.modal-inner {
    position: relative;
    width: min(1200px, 96vw);
    height: min(85vh, 760px);
    border: 1px solid #3a3f53;
    border-radius: 0.8rem;
    overflow: hidden;
    background: #0f1118;
}

#movieFrame {
    width: 100%;
    height: 100%;
    border: 0;
    display: none;
    background: #000;
}

.modal-controls {
    position: absolute;
    top: 0.6rem;
    right: 0.9rem;
    /* Must be above the iframe-ad-blocker-top-right (z-index: 3) */
    z-index: 10;
    display: none;
}

#fullscreenModalBtn,
#closeModalBtn {
    border: none;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    width: 2.2rem;
    height: 2.2rem;
    /* Minimum 48px touch target via padding trick */
    min-width: 44px;
    min-height: 44px;
    border-radius: 0.45rem;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.2s ease;
}

#closeModalBtn {
    font-size: 1.6rem;
}

.modal-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.loader-text {
    color: #d8ddf0;
    font-size: 1.05rem;
}

@media (max-width: 700px) {
    body {
        padding: 0.75rem 1rem 1rem;
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .player-card {
        padding: 1rem;
        border-radius: 0.75rem;
    }

    .subtitle {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }

    .trailer-container {
        border-radius: 0.5rem;
    }

    /* Hide keyboard-only hints on touch devices */
    .keyboard-hint {
        display: none;
    }

    /* Stack action buttons and make them full-width for easy tapping */
    .back-home {
        flex-direction: column;
        gap: 0.65rem;
    }

    .back-home button,
    .back-home-btn {
        width: 100%;
        padding: 0.9rem 1rem;
        min-height: 52px;
        font-size: 1rem;
        justify-content: center;
    }

    /* Full-width episode dropdowns */
    .episode-selector {
        flex-direction: column;
    }

    .selector-group {
        width: 100%;
    }

    .selector-group select {
        width: 100%;
        min-width: unset;
        font-size: 1rem;
        padding: 0.75rem 0.75rem;
        /* 48px minimum touch target */
        min-height: 48px;
    }

    /* Larger touch targets for modal controls */
    #fullscreenModalBtn,
    #closeModalBtn {
        width: 2.8rem;
        height: 2.8rem;
        min-width: 48px;
        min-height: 48px;
        font-size: 1.25rem;
    }

    #closeModalBtn {
        font-size: 1.8rem;
    }

    /* Full-screen modal on mobile, with safe area support */
    .modal-inner {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        border: 0;
    }

    .modal-controls {
        top: max(0.6rem, env(safe-area-inset-top));
        right: max(0.9rem, env(safe-area-inset-right));
    }
}

/* Episode selector for TV series */
.episode-selector {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

/* Movie details section */
.movie-details {
    margin-top: 1.2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--panel-border);
}

.details-grid {
    display: flex;
    gap: 1.2rem;
    align-items: flex-start;
}

.detail-poster {
    width: 160px;
    border-radius: 0.6rem;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.detail-info {
    flex: 1;
    min-width: 0;
}

.detail-tagline {
    font-style: italic;
    color: var(--accent);
    margin-bottom: 0.6rem;
    font-size: 0.95rem;
    overflow-wrap: break-word;
}

.detail-overview {
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
    overflow-wrap: break-word;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    font-size: 0.88rem;
}

.detail-meta > span {
    color: var(--muted);
}

.genre-pill {
    display: inline-block;
    background: rgba(255, 255, 255, 0.08);
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    color: var(--text);
}

.detail-rating {
    background: linear-gradient(45deg, var(--accent), var(--accent-2));
    color: #fff !important;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.82rem;
}

/* Cast section */
.cast-section {
    margin-top: 1.2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--panel-border);
}

.cast-heading {
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
}

.cast-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.8rem;
}

.cast-card {
    text-align: center;
}

.cast-card img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 0.5rem;
    display: block;
}

.cast-name {
    font-size: 0.82rem;
    margin-top: 0.35rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cast-character {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 700px) {
    .details-grid {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .detail-poster {
        width: 120px;
    }

    .detail-meta {
        justify-content: center;
    }

    .cast-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .related-card {
        width: 90px;
    }
}

.selector-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.selector-group label {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
}

.selector-group select {
    background: #1e2230;
    color: var(--text);
    border: 1px solid var(--panel-border);
    border-radius: 0.5rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.92rem;
    min-width: 140px;
    cursor: pointer;
    touch-action: manipulation;
    appearance: auto;
}

.selector-group select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* Related titles section */
.related-section {
    margin-top: 1.2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--panel-border);
}

.related-heading {
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
}

.related-grid {
    display: flex;
    gap: 0.75rem;
    /* Contain the scroll region so it never blows out the page width */
    overflow-x: auto;
    overflow-y: visible;
    /* Clip the scrollable area to the container – critical on mobile */
    max-width: 100%;
    width: 100%;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--panel-border) transparent;
    -webkit-overflow-scrolling: touch;
    scroll-padding-inline: 0.5rem;
}

.related-grid::-webkit-scrollbar {
    height: 5px;
}

.related-grid::-webkit-scrollbar-thumb {
    background: var(--panel-border);
    border-radius: 3px;
}

.related-card {
    flex-shrink: 0;
    width: 110px;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.15s ease, filter 0.15s ease;
}

.related-card:hover {
    transform: translateY(-3px);
    filter: brightness(1.1);
}

.related-card img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 0.5rem;
    display: block;
    background: var(--panel);
}

.related-card-info {
    padding: 0.3rem 0.1rem 0;
}

.related-card-title {
    font-size: 0.8rem;
    font-weight: 600;
    margin: 0 0 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.related-card-meta {
    font-size: 0.72rem;
    color: var(--muted);
    margin: 0;
}

.iframe-nav-blocker,
.iframe-ad-blocker-top-right,
.iframe-ad-blocker-bottom-left,
.iframe-ad-blocker-bottom-right {
    position: absolute;
    width: 150px;
    height: 150px;
    z-index: 3;
    cursor: default;
}

.iframe-nav-blocker {
    top: 0;
    left: 0;
}

.iframe-ad-blocker-top-right {
    top: 0;
    right: 0;
}

.iframe-ad-blocker-bottom-left {
    bottom: 0;
    left: 0;
}

.iframe-ad-blocker-bottom-right {
    bottom: 0;
    right: 0;
}

/* Larger corner overlays on mobile where ad tap targets are harder to miss */
@media (max-width: 640px) {
    .iframe-nav-blocker,
    .iframe-ad-blocker-top-right,
    .iframe-ad-blocker-bottom-left,
    .iframe-ad-blocker-bottom-right {
        width: 200px;
        height: 200px;
    }
}

/* ── Playlist Picker Modal ── */
.playlist-picker {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.playlist-picker[hidden] {
    display: none;
}

.playlist-picker-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
}

.playlist-picker-panel {
    position: relative;
    background: #17171c;
    border: 1px solid #2b2b35;
    border-radius: 0.85rem;
    width: min(360px, 92vw);
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    animation: pickerSlideIn 0.2s ease;
}

@keyframes pickerSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.playlist-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #2b2b35;
    background: linear-gradient(90deg, rgba(255, 106, 0, 0.06), rgba(238, 9, 121, 0.06));
}

.playlist-picker-title {
    font-size: 0.97rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.playlist-picker-close {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.25rem 0.45rem;
    line-height: 1;
    border-radius: 0.35rem;
    touch-action: manipulation;
    transition: background 0.15s ease, color 0.15s ease;
}

.playlist-picker-close:hover {
    background: rgba(255, 255, 255, 0.14);
    color: var(--text);
}

.playlist-picker-list {
    list-style: none;
    overflow-y: auto;
    max-height: 260px;
    padding: 0.4rem 0;
    margin: 0;
    scrollbar-width: thin;
    scrollbar-color: #2b2b35 transparent;
}

.playlist-picker-list::-webkit-scrollbar {
    width: 4px;
}

.playlist-picker-list::-webkit-scrollbar-thumb {
    background: #2b2b35;
    border-radius: 3px;
}

.playlist-picker-item {
    width: 100%;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0.7rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-align: left;
    transition: background 0.15s ease;
    font-size: 0.93rem;
    touch-action: manipulation;
}

.playlist-picker-item:hover {
    background: rgba(255, 106, 0, 0.07);
}

.playlist-picker-item.in-list {
    color: var(--accent);
}

.playlist-picker-item-check {
    width: 1.3rem;
    height: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 106, 0, 0.12);
    font-size: 0.75rem;
    flex-shrink: 0;
    color: var(--accent);
    border: 1px solid rgba(255, 106, 0, 0.25);
}

.playlist-picker-item-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.playlist-picker-item-count {
    color: var(--muted);
    font-size: 0.78rem;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.06);
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
}

.playlist-picker-create {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid #2b2b35;
    background: rgba(0, 0, 0, 0.2);
}

.playlist-picker-input {
    flex: 1;
    background: #0f1012;
    border: 1px solid #2b2b35;
    border-radius: 0.5rem;
    color: var(--text);
    padding: 0.55rem 0.7rem;
    font-size: 0.88rem;
    min-width: 0;
    transition: border-color 0.2s ease, outline 0.2s ease;
}

.playlist-picker-input::placeholder {
    color: #555870;
}

.playlist-picker-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: transparent;
}

.playlist-picker-create-btn {
    border: none;
    border-radius: 0.5rem;
    background: linear-gradient(45deg, var(--accent), var(--accent-2));
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    padding: 0.55rem 0.85rem;
    font-size: 0.85rem;
    white-space: nowrap;
    touch-action: manipulation;
    transition: filter 0.2s ease, transform 0.15s ease;
}

.playlist-picker-create-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* ── Toast Notification ── */
.playlist-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(1.5rem);
    background: rgba(23, 23, 28, 0.96);
    border: 1px solid #2b2b35;
    color: var(--text);
    padding: 0.6rem 1.3rem;
    border-radius: 2rem;
    font-size: 0.88rem;
    opacity: 0;
    transition: opacity 0.22s ease, transform 0.22s ease;
    pointer-events: none;
    z-index: 9999;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.playlist-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Party Mode ── */

.party-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.party-overlay[hidden] {
    display: none;
}

.party-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.party-panel {
    position: relative;
    width: 90%;
    max-width: 400px;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--panel, #161922);
    border: 1px solid var(--panel-border, #2a2f3d);
    border-radius: 1rem;
    padding: 2rem 1.5rem 1.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: partySlideIn 0.3s ease;
}

@keyframes partySlideIn {
    from { opacity: 0; transform: scale(0.92) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.party-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--muted, #b7bdd1);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    transition: color 0.2s, background 0.2s;
}

.party-close:hover {
    color: var(--text, #f4f6ff);
    background: rgba(255,255,255,0.08);
}

.party-view[hidden] { display: none; }

.party-heading {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    background: linear-gradient(135deg, var(--accent, #ff6a00), var(--accent-2, #ee0979));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.party-desc {
    font-size: 0.9rem;
    color: var(--muted, #b7bdd1);
    margin: 0 0 1.25rem;
    line-height: 1.5;
}

.party-field {
    margin-bottom: 1rem;
}

.party-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted, #b7bdd1);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.party-select,
.party-input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    font-size: 1rem;
    color: var(--text, #f4f6ff);
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--panel-border, #2a2f3d);
    border-radius: 0.6rem;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.party-select:focus,
.party-input:focus {
    border-color: var(--accent, #ff6a00);
}

/* ── Custom party dropdown ── */
.party-dropdown {
    position: relative;
    width: 100%;
    outline: none;
}

.party-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    color: var(--text, #f4f6ff);
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--panel-border, #2a2f3d);
    border-radius: 0.6rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    box-sizing: border-box;
}

.party-dropdown-trigger:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.25);
}

.party-dropdown:focus .party-dropdown-trigger,
.party-dropdown.open .party-dropdown-trigger {
    border-color: var(--accent, #ff6a00);
    background: rgba(255,255,255,0.1);
}

.party-dropdown-arrow {
    font-size: 0.85rem;
    opacity: 0.6;
    transition: transform 0.25s ease;
}

.party-dropdown.open .party-dropdown-arrow {
    transform: rotate(180deg);
}

.party-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    margin: 0;
    padding: 0.35rem 0;
    list-style: none;
    background: var(--panel-bg, #191d2b);
    border: 1px solid var(--panel-border, #2a2f3d);
    border-radius: 0.6rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.55);
    z-index: 20;
    max-height: 250px;
    overflow-y: auto;
    animation: partyMenuFadeIn 0.18s ease-out;
}

@keyframes partyMenuFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.party-dropdown.open .party-dropdown-menu {
    display: block;
}

.party-dropdown-item {
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    color: var(--text, #f4f6ff);
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 0.3rem;
    margin: 0 0.3rem;
}

.party-dropdown-item:hover {
    background: rgba(255,255,255,0.1);
}

.party-dropdown-item.selected {
    color: var(--accent, #ff6a00);
    font-weight: 600;
    background: rgba(255,106,0,0.1);
}

.party-input {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.15rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    text-align: center;
}

.party-error {
    color: #ff4d6d;
    font-size: 0.85rem;
    margin: -0.25rem 0 0.75rem;
}

/* Party buttons */
.party-btn {
    border: none;
    cursor: pointer;
    font-weight: 600;
    border-radius: 0.6rem;
    transition: opacity 0.2s, transform 0.15s;
}

.party-btn:active { transform: scale(0.97); }

.party-btn-primary {
    display: block;
    width: 100%;
    padding: 0.8rem;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(135deg, var(--accent, #ff6a00), var(--accent-2, #ee0979));
    margin-top: 0.5rem;
}

.party-btn-primary:hover { opacity: 0.9; }

.party-btn-small {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    color: var(--text, #f4f6ff);
    background: rgba(255,255,255,0.1);
}

.party-btn-small:hover { background: rgba(255,255,255,0.18); }

/* Mode toggle */
.party-mode-toggle {
    display: flex;
    gap: 0;
    margin-top: 1.25rem;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--panel-border, #2a2f3d);
}

.party-mode-toggle[hidden] {
    display: none;
}

.party-toggle-btn {
    flex: 1;
    padding: 0.55rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted, #b7bdd1);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.party-toggle-btn:hover {
    background: rgba(255,255,255,0.05);
}

.party-toggle-btn.active {
    color: #fff;
    background: linear-gradient(135deg, var(--accent, #ff6a00), var(--accent-2, #ee0979));
}

/* Code display */
.party-code-display {
    text-align: center;
    padding: 1rem;
    margin-bottom: 1.25rem;
    background: rgba(255,255,255,0.04);
    border: 1px dashed var(--panel-border, #2a2f3d);
    border-radius: 0.75rem;
}

.party-code-label {
    display: block;
    font-size: 0.75rem;
    color: var(--muted, #b7bdd1);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.party-code-text {
    display: block;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--accent, #ff6a00);
    margin-bottom: 0.6rem;
    user-select: all;
    word-break: break-all;
}

/* Countdown */
.party-countdown-wrap {
    text-align: center;
    margin-bottom: 1rem;
}

.party-countdown-label {
    display: block;
    font-size: 0.8rem;
    color: var(--muted, #b7bdd1);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
}

.party-countdown {
    display: block;
    font-size: 2.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: linear-gradient(135deg, var(--accent, #ff6a00), var(--accent-2, #ee0979));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.party-lobby-hint {
    font-size: 0.8rem;
    color: var(--muted, #b7bdd1);
    text-align: center;
    margin: 0;
    opacity: 0.7;
}

/* User badge */
.party-user-badge {
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted, #b7bdd1);
    margin-bottom: 1rem;
}

.party-user-id {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--text, #f4f6ff);
    background: rgba(255,255,255,0.08);
    padding: 0.15rem 0.5rem;
    border-radius: 0.35rem;
}

/* Members section */
.party-members-section {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--panel-border, #2a2f3d);
    border-radius: 0.6rem;
}

.party-members-label {
    display: block;
    font-size: 0.8rem;
    color: var(--muted, #b7bdd1);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.party-member-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.party-member {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(255,255,255,0.06);
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
}

.party-member-id {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--accent, #ff6a00);
}

.party-member-you {
    font-size: 0.7rem;
    color: var(--muted, #b7bdd1);
    font-style: italic;
}

/* Party toast */
.party-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--panel, #161922);
    color: var(--accent, #ff6a00);
    border: 1px solid var(--accent, #ff6a00);
    padding: 0.6rem 1.4rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    z-index: 10001;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.party-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* When the party modal is open, float the toast above the panel */
.party-toast--over-modal {
    bottom: auto;
    top: 1.5rem;
    z-index: 10002;
    transform: translateX(-50%) translateY(-10px);
}

.party-toast--over-modal.show {
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 700px) {
    .party-panel {
        width: 95%;
        padding: 1.5rem 1.1rem 1.1rem;
    }

    .party-code-text {
        font-size: 1.3rem;
    }

    .party-countdown {
        font-size: 2.2rem;
    }
}

/* ── Party Sync Bar (overlays the movie modal during active watch) ── */

.party-sync-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.9rem;
    background: linear-gradient(0deg, rgba(0,0,0,0.88) 0%, rgba(0,0,0,0.55) 70%, transparent 100%);
    color: #fff;
    font-size: 0.85rem;
    z-index: 12;
    opacity: 1;
    transition: opacity 0.35s ease;
    pointer-events: auto;
}

.party-sync-bar:not(:hover) {
    opacity: 0.45;
}

.party-sync-left,
.party-sync-right {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.party-sync-indicator {
    background: linear-gradient(135deg, var(--accent, #ff6a00), var(--accent-2, #ee0979));
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.party-sync-timer {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--accent, #ff6a00);
    white-space: nowrap;
}

.party-sync-members {
    font-size: 0.78rem;
    opacity: 0.85;
    white-space: nowrap;
}

.party-sync-code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    color: #ccc;
    white-space: nowrap;
}

.party-sync-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    cursor: pointer;
    font-size: 0.78rem;
    padding: 0.2rem 0.5rem;
    border-radius: 0.4rem;
    transition: background 0.2s, opacity 0.2s;
    white-space: nowrap;
}

.party-sync-btn:hover {
    background: rgba(255,255,255,0.2);
}

.party-sync-leave {
    color: #ff6b6b;
    border-color: rgba(255,107,107,0.3);
}

.party-sync-leave:hover {
    background: rgba(255,107,107,0.15);
}

@media (max-width: 600px) {
    .party-sync-bar {
        flex-wrap: wrap;
        gap: 0.3rem;
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }

    .party-sync-timer {
        font-size: 0.85rem;
    }

    .party-sync-code {
        display: none;
    }
}
