:root {
    --bg: #0f1720;
    --card: #0b1220;
    --accent: #06b6d4;
    --muted: #9ca3af;
    --glass: rgba(255, 255, 255, 0.03)
}

html,
body {
    height: 100%;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, Segoe UI, Roboto, "Helvetica Neue", Arial
}

body {
    min-height: 100vh;
    background: linear-gradient(180deg, #071027 0%, #071a2a 100%);
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
    color: #e6eef6;
    padding: 24px;
}

.app {
    max-width: 1100px;
    margin: 0 auto
}

header {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center
}

.logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #7c3aed, #ff0080, #00f0ff);
    background-size: 300% 300%; 
    animation: gradientShift 10s ease infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: Snell Roundhand, 'cursive';
    font-weight: 700;
    font-size: 20px;
    color: #fff;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.logo:hover{
    background: linear-gradient(135deg, #7c3aed, var(--accent));
    font-weight: 800;
}
h1 {
    font-size: 20px;
    margin: 0
}

.controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap
}

input[type=search] {
    padding: 10px 14px;
    border-radius: 10px;
    border: 0;
    background: var(--glass);
    color: inherit;
    min-width: 260px;
    max-width: 100%
}

input[type=search]:hover{
    background: rgb(255 255 255 / 8%);
}
select,
button {
    padding: 10px 12px;
    border-radius: 10px;
    border: 0;
    background: #7e2eff;
    color: inherit;
    white-space: nowrap;
}
button:hover, select:hover{
    transition: 0.15s;
    background: #8537ff73;
}

select option {
    background-color: #222;
    color: white
}

select{
    appearance: none;       /* remove default arrow */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='12' viewBox='0 0 24 24' width='12' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center; /* arrow on right */
    background-size: 18px;
}
main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 28px
}

.card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.6);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%
}

.card:hover{
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.202), transparent);
}
.poster {
    width: 100%;
    aspect-ratio: 2/3;
    border-radius: 8px;
    object-fit: cover;
    background: #0b1220
}

.meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    margin-top: auto
}

.title {
    font-weight: 600;
    margin: 6px 0 0
}

.muted {
    color: var(--muted);
    font-size: 11px;
    font-weight: bold;
}

.pagination {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding: 8px;
    flex-wrap: wrap
}

.pill {
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--glass);
    border: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 12px;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 23, 0.6);
    z-index: 60
}

.modal.open {
    display: flex
}

.modal-card {
    width: min(980px, 90%);
    max-height: 90vh;
    overflow: auto;
    background: linear-gradient(180deg, #071226, #061428);
    border-radius: 12px;
    padding: 20px
}

.modal-top {
    display: flex;
    gap: 16px;
    flex-wrap: wrap
}

.backdrop {
    width: 188px;
    height: 273px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0
}

.modal-body {
    flex: 1;
    min-width: 260px
}

.videos iframe {
    width: 100%;
    max-width: 500px;
    height: 280px;
    display: block;
    margin: 1rem auto;
    border-radius: 8px
}

.similar {
    display: flex;
    gap: 10px;
    overflow: auto;
    padding-top: 8px
}

.similar .mini {
    min-width: 120px
}

footer {
    margin-top: 20px;
    color: var(--muted);
    text-align: center
}

/* Home Page */
.movies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px
}

.movie-card {
    background: #111;
    color: white;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.movie-card img {
    width: 100%;
    border-radius: 8px
}

.movie-card h3 {
    margin: 8px;
    font-size: 1rem;
}

.movie-card p {
    margin: 8px;
    margin-top: auto; /* Push to bottom */
}

/* Mobile Responsive Styles */

/* Large tablets and small desktops */
@media (max-width: 1024px) {
    body {
        padding: 20px
    }
    
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 20px
    }
    
    .movies-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr))
    }
}

/* Tablets */
@media (max-width: 768px) {
    body {
        padding: 16px
    }
    
    h1 {
        font-size: 18px
    }
    
    .logo {
        width: 40px;
        height: 40px
    }
    
    .controls {
        gap: 8px
    }
    
    input[type=search] {
        min-width: 200px;
        padding: 8px 12px
    }
    
    select,
    button {
        padding: 8px 10px;
        font-size: 14px
    }
    
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 16px
    }
    
    .movies-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 16px
    }
    
    .modal-card {
        width: min(980px, 94%);
        padding: 16px
    }
    
    .backdrop {
        width: 160px;
        height: 232px
    }
}

/* Mobile phones */
@media (max-width: 640px) {
    body {
        padding: 12px
    }
    
    header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px
    }
    
    .brand {
        justify-content: center
    }
    
    .controls {
        justify-content: center;
        flex-wrap: wrap
    }
    
    input[type=search] {
        min-width: 0;
        width: 100%;
        max-width: 300px
    }
    
    select,
    button {
        flex: 1;
        min-width: 100px
    }
    
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 12px
    }
    
    .movies-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px
    }
    
    .card {
        padding: 8px
    }
    
    .title {
        font-size: 14px
    }
    
    .muted {
        font-size: 12px
    }
    
    .meta {
        font-size: 11px
    }
    
    .modal-top {
        flex-direction: column;
        align-items: center
    }
    
    .backdrop {
        width: 140px;
        height: 203px
    }
    
    .modal-body {
        min-width: 0
    }
    
    .videos iframe {
        height: 220px
    }
    
    .pagination {
        gap: 4px
    }
    
    .pill {
        padding: 4px 8px;
        font-size: 12px
    }
    
    .similar .mini {
        min-width: 100px
    }
}

/* Extra small phones */
@media (max-width: 480px) {
    body {
        padding: 8px
    }
    
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px
    }
    
    .movies-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px
    }
    
    .modal-card {
        width: min(980px, 98%);
        padding: 12px;
        max-height: 95vh
    }
    
    .backdrop {
        width: 120px;
        height: 174px
    }
    
    .videos iframe {
        height: 180px
    }
    
    input[type=search] {
        font-size: 14px
    }
    
    .title {
        font-size: 13px
    }
    
    h1 {
        font-size: 16px
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .card,
    button,
    select,
    .pill {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center
    }
    
    .card {
        flex-direction: column;
        justify-content: flex-start
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    body {
        padding: 8px 16px
    }
    
    header {
        flex-direction: row;
        margin-bottom: 12px
    }
    
    .controls {
        flex-wrap: nowrap
    }
    
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr))
    }
    
    .movies-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr))
    }
}

/* Modal Adjusted for Smartphone */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 23, 0.6);
    z-index: 60;
    padding: 10px; /* prevent edges touching on mobile */
}

.modal.open {
    display: flex;
}

.modal-card {
    width: min(980px, 90%);
    max-height: 90vh;
    overflow: auto;
    background: linear-gradient(180deg, #071226, #061428);
    border-radius: 12px;
    padding: 20px;
}

/* Layout container */
.modal-top {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.backdrop {
    width: 188px;
    height: 273px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.modal-body {
    flex: 1;
    min-width: 260px;
}

.videos iframe {
    width: 100%;
    max-width: 500px;
    height: 280px;
    display: block;
    margin: 1rem auto;
    border-radius: 8px;
}

.similar {
    display: flex;
    gap: 10px;
    overflow: auto;
    padding-top: 8px;
}

.similar .mini {
    min-width: 120px;
}

footer {
    margin-top: 20px;
    color: var(--muted);
    text-align: center;
}

/* -------------------------
   📱 Responsive adjustments
-------------------------- */
@media (max-width: 640px) {
    .modal-card {
        width: 95%;
        padding: 12px;
    }

    .modal-top {
        flex-direction: column;
        align-items: center;
    }

    .backdrop {
        align-self: flex-start;
        width: 80%;
        height: auto;
        max-width: 280px;
    }

    .modal-body {
        width: 100%;
        min-width: unset;
    }

    .videos iframe {
        max-width: 100%;
        height: 200px;
    }

    .similar .mini {
        min-width: 100px;
    }
}
