:root {
    --bg-color: #0f0f13;
    --card-bg: rgba(255, 255, 255, 0.05);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --text-main: #ffffff;
    --text-dim: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --sidebar-width: 280px;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    -webkit-overflow-scrolling: touch; 
}

.app-header { display: flex; justify-content: center; padding: 40px 0; position: relative; z-index: 100; }
.logo1 { width: 15vw; min-width: 120px; max-width: 180px; height: auto; }
.main-container { display: flex; flex-direction: column; align-items: center; width: 100%; }
.showcase-section { width: 100%; position: relative; z-index: 10; }

.stage-container {
    perspective: 2000px;
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 170px 0 140px 0;
}

.stage {
    position: relative;
    width: 260px;
    height: 390px;
    transform-style: preserve-3d;
}

.wheel-track {
    position: relative;
    width: 100%; height: 100%;
    transform-style: preserve-3d;
    will-change: transform;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.poster-item {
    position: absolute;
    width: 100%; height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform-style: preserve-3d;
    border-radius: 18px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    background: #000;
}

.poster-item img { 
    width: 100%; height: 100%; 
    object-fit: cover; border-radius: 18px; 
    -webkit-user-drag: none;
}

.result-area {
    position: relative;
    z-index: 100;
    text-align: center;
    margin-top: 60px;
}

.result-inner {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

#movie-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 2.2rem;
    margin-bottom: 25px;
    padding: 0 15px;
    transition: opacity 0.3s ease;
}

#spin-button {
    padding: 18px 60px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.2rem;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 24px rgba(99, 102, 241, 0.35);
    letter-spacing: 0.05em;
}

#spin-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(168, 85, 247, 0.5);
}

#spin-button:active:not(:disabled) {
    transform: translateY(0px);
}

#spin-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.filter-bottom-area {
    width: 90%;
    max-width: 1000px;
    margin-top: 80px;
    padding-bottom: 60px;
    z-index: 100;
    position: relative;
}

.filter-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(5px);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    padding: 30px;
}

.filter-row { display: flex; gap: 25px; margin-bottom: 25px; }
.filter-row:last-of-type { margin-bottom: 25px; }
.filter-item { flex: 1; }
.filter-item label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.08em; text-align: center; }

select { width: 100%; padding: 12px; background: #1a1a20; border: 1px solid var(--glass-border); color: white; border-radius: 10px; text-align: center; }
.year-inputs { display: flex; gap: 10px; }

.genre-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.genre-item input { display: none; }
.genre-item label {
    display: inline-block; padding: 8px 18px; background: rgba(42, 42, 53, 0.75); 
    border-radius: 20px; font-size: 13px; cursor: pointer; border: 1px solid var(--glass-border);
    transition: background 0.15s ease, border-color 0.15s ease;
}
.genre-item label:hover { border-color: rgba(255,255,255,0.25); }
.genre-item input:checked + label { background: var(--accent-gradient); color: white; border-color: transparent; }

/* ── AUTOCOMPLETE ── */
.autocomplete-wrap {
    position: relative;
}

.autocomplete-input {
    width: 100%;
    padding: 12px;
    background: #1a1a20;
    border: 1px solid var(--glass-border);
    color: white;
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s ease;
}

.autocomplete-input:focus {
    border-color: rgba(255, 255, 255, 0.3);
}

.autocomplete-input::placeholder {
    color: var(--text-dim);
}

.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: #1e1e28;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    overflow: hidden;
    z-index: 200;
    display: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.autocomplete-dropdown.open { display: block; }

.autocomplete-option {
    padding: 10px 14px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-main);
    transition: background 0.1s ease;
}

.autocomplete-option:hover {
    background: rgba(255,255,255,0.07);
}

/* ── MINI CHIPS ── */
.mini-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    justify-content: center;
}

.mini-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px 4px 12px;
    background: rgba(99, 102, 241, 0.25);
    border: 1px solid rgba(99, 102, 241, 0.5);
    border-radius: 20px;
    font-size: 11px;
    color: var(--text-main);
}

.mini-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    line-height: 1;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.mini-chip-remove:hover {
    background: rgba(255,255,255,0.3);
}

/* ── FOOTER ── */
.app-footer {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 50px 0 40px 0;
    border-top: 1px solid var(--glass-border);
    margin-top: 20px;
}

.tmdb-logo {
    width: 140px;
    height: auto;
    opacity: 0.85;
}

.tmdb-credit {
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
    max-width: 420px;
    line-height: 1.6;
    padding: 0 20px;
}

.tmdb-credit a {
    color: #3cbec9;
    text-decoration: none;
}

.tmdb-credit a:hover {
    text-decoration: underline;
}

.modal-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.08);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    z-index: 10;
    flex-shrink: 0;
}

.modal-close-btn:hover {
    background: rgba(255,255,255,0.18);
}

/* ── MORE INFO BUTTON ── */
#more-info-button {
    padding: 12px 40px;
    background: transparent;
    color: white;
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: background 0.2s ease, border-color 0.2s ease;
    margin-bottom: 12px;
}

#more-info-button:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.3);
}

/* ── FULLSCREEN POSTER ── */
.poster-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,0);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    transition: background 0.3s ease;
    pointer-events: none;
}

.poster-fullscreen.open {
    background: rgba(0,0,0,0.92);
    pointer-events: all;
}

.poster-fullscreen img {
    max-width: 92vw;
    max-height: 92vh;
    border-radius: 16px;
    object-fit: contain;
    transform: scale(0.85);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.poster-fullscreen.open img {
    transform: scale(1);
    opacity: 1;
}

/* Make modal poster clickable */
.modal-poster-wrap img {
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.modal-poster-wrap img:hover {
    transform: scale(1.03);
}
.modal-close-bottom-btn {
    display: none;
    margin-top: 16px;
    padding: 14px 40px;
    background: transparent;
    color: white;
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    letter-spacing: 0.08em;
    width: 100%;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.modal-close-bottom-btn:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.3);
}

/* ── MODAL ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal-box {
    display: flex;
    gap: 30px;
    background: #16161e;
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 30px;
    max-width: 820px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    position: relative;
}

.modal-overlay.open .modal-box {
    transform: translateY(0);
}

.modal-poster-wrap {
    flex-shrink: 0;
    width: 180px;
}

.modal-poster-wrap img {
    width: 100%;
    border-radius: 14px;
    display: block;
}

.modal-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-content h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.6rem;
    margin: 0;
    line-height: 1.2;
}

.modal-meta {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-dim);
}

.modal-meta span::before {
    content: '';
}

.modal-meta .meta-rating {
    color: #f5c518;
}

#modal-overview {
    font-size: 14px;
    line-height: 1.7;
    color: #ccc;
    margin: 0;
}

.modal-trailer-wrap {
    margin-top: 8px;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16/9;
    background: #000;
}

.modal-trailer-wrap iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.modal-loading {
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    padding: 20px 0;
}

/* ── HISTORY TOGGLE BUTTON ── */
.history-toggle {
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 300;
}

.history-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* ── HISTORY BACKDROP (mobile only, hidden on desktop) ── */
.history-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 400;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: none;
}

/* ── HISTORY SIDEBAR ── */
.history-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: #13131a;
    border-right: 1px solid var(--glass-border);
    z-index: 500;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
}

.history-sidebar.open {
    transform: translateX(0);
}

/* Desktop: push main content instead of overlaying */
@media (min-width: 769px) {
    .history-backdrop { display: none !important; }

    .page-content {
        margin-left: 0;
        transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .history-sidebar.open ~ .page-content,
    body.sidebar-open .page-content {
        margin-left: var(--sidebar-width);
    }

    .history-close { display: none; }
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px 20px;
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.history-header h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    margin: 0;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.history-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.15s ease;
}

.history-close:hover { color: white; }

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-empty {
    font-size: 13px;
    color: var(--text-dim);
    text-align: center;
    margin-top: 40px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.history-item:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--glass-border);
}

.history-item img {
    width: 44px;
    height: 66px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: #000;
}

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

.history-item-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-year {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
}

/* MOBILE RESPONSIVE FIXES */
@media (max-width: 768px) {
    .stage {
        width: 150px;
        height: 225px;
    }

    .stage-container {
        padding: 30px 0 40px 0;
        perspective: 1200px;
    }

    /* Push page content up so it doesn't hide behind the fixed bar */
    .main-container {
        padding-bottom: 160px;
    }

    /* The result area becomes a fixed bottom bar on mobile */
    .result-area {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin-top: 0;
        z-index: 999;
        text-align: center;
        padding: 14px 20px 20px 20px;
        background: rgba(15, 15, 19, 0.82);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        border-top: 1px solid var(--glass-border);
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    .result-inner {
        width: 100%;
        max-width: 480px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    #movie-title {
        font-size: 1.15rem;
        margin-bottom: 12px;
    }

    #spin-button {
        width: calc(100vw - 40px);
        padding: 14px 20px;
        font-size: 1rem;
    }

    #more-info-button {
        width: calc(100vw - 40px);
        margin-bottom: 10px;
        padding: 11px 20px;
        font-size: 0.9rem;
    }

    /* Slide fixed bar down when modal opens */
    .result-area {
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .result-area.hidden-down {
        transform: translateY(200%);
    }

    /* Modal slides up as floating card with gaps on all sides */
    .modal-overlay {
        align-items: flex-end;
        justify-content: center;
        z-index: 1000;
        padding: 12px;
        box-sizing: border-box;
        align-items: stretch;
    }

    .modal-box {
        flex-direction: column;
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - 12px);
        border-radius: 20px;
        padding: 24px 20px 20px 20px;
        transform: translateY(calc(100% + 24px));
        gap: 16px;
        overflow-y: auto;
    }

    .modal-overlay.open .modal-box {
        transform: translateY(0);
    }

    .modal-poster-wrap {
        width: 100px;
        margin: 0 auto;
    }

    .modal-content h2 {
        font-size: 1.3rem;
        text-align: center;
    }

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

    /* Hide desktop modal close button on mobile */
    .modal-close-btn {
        display: none;
    }

    .modal-close-bottom-btn {
        display: block;
        width: 100%;
    }

    .history-sidebar {
        width: 100%;
    }

    .filter-row {
        flex-direction: column;
    }

    .logo1 { width: 40vw; }

    .tmdb-logo { width: 110px; }

    /* Remove the big gap between filter card and footer */
    .filter-bottom-area {
        margin-top: 30px;
        padding-bottom: 20px;
    }

    /* Shrink footer top spacing and add bottom padding so it clears the fixed bar */
    .app-footer {
        margin-top: 0;
        padding: 24px 0 180px 0;
    }
}
