:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f9f9f9;
    --text-primary: #030303;
    --text-secondary: #606060;
    --accent-primary: #ff0000;
    --accent-secondary: #c00000;
    --border-color: #cccccc;
    --shadow-light: 0 1px 4px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 8px rgba(0, 0, 0, 0.15);
    --font-family: 'Roboto', sans-serif;
    --header-height: 60px;
    --border-radius-lg: 12px;
    --border-radius-md: 6px;
    --transition-speed-fast: 0.2s;
    --transition-speed-medium: 0.3s;
    --search-input-bg: #212121;
    --search-input-text: #e8eaed;
    --search-placeholder-text: #9aa0a6;
    --search-border-color: #505050;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

header {
    background-color: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-light);
    border-bottom: 1px solid var(--border-color);
    height: var(--header-height);
    padding: 0 15px;
    display: flex;
    align-items: center;
}

.header-content {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    gap: 20px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    font-size: 1.5em;
    font-weight: 700;
    color: var(--text-primary);
    gap: 8px;
    text-decoration: none;
    transition: transform var(--transition-speed-fast) ease;
}

.logo:hover {
    transform: scale(1.05);
}

.logo-icon {
    color: var(--accent-primary);
    font-size: 1.3em;
    line-height: 1;
}

.logo-text {
    font-size: 0.9em;
    font-weight: inherit;
    margin: 0;
    padding: 0;
    line-height: normal;
    display: inline;
}

.random-movie-btn {
    background-color: var(--accent-primary);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    cursor: pointer;
    font-weight: 500;
    transition: background-color var(--transition-speed-fast) ease;
    white-space: nowrap;
}

.random-movie-btn:hover {
    background-color: var(--accent-secondary);
}

.header-main-search-wrapper {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
}

.header-search-area {
    display: flex;
    width: 100%;
    max-width: 550px;
}

#search-input {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid var(--search-border-color);
    border-radius: 40px;
    outline: none;
    background-color: var(--search-input-bg);
    font-size: 0.9em;
    color: var(--search-input-text);
}

#search-input::placeholder {
    color: var(--search-placeholder-text);
    opacity: 1;
}

#search-input::-webkit-search-decoration,
#search-input::-webkit-search-cancel-button,
#search-input::-webkit-search-results-button,
#search-input::-webkit-search-results-decoration {
    -webkit-appearance: none;
}

.filter-bar {
    background-color: var(--bg-secondary);
    padding: 8px 15px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
    position: sticky;
    top: var(--header-height);
    z-index: 999;
    display: flex;
    justify-content: center;
}

.filter-bar-content {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 850px;
    flex-wrap: wrap;
    justify-content: space-around;
}

.header-filters {
    flex-shrink: 0;
    min-width: 180px;
    position: relative;
    flex-grow: 1;
    max-width: 280px;
}

.custom-year-select-wrapper {
    min-width: 160px;
}

.simple-filter-select {
    padding: 9px 12px;
    border: 1px solid var(--search-border-color);
    border-radius: 20px;
    background-color: var(--search-input-bg);
    color: var(--search-input-text);
    font-size: 0.85em;
    outline: none;
    cursor: pointer;
    min-width: 150px;
    height: 38px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%239aa0a6'%3E%3Cpath d='M8 11L3 6h10L8 11z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
    padding-right: 30px;
    flex-grow: 1;
    max-width: 220px;
}

.simple-filter-select option {
    background-color: var(--search-input-bg);
    color: var(--search-input-text);
}

.custom-hero-select-trigger,
.custom-year-select-trigger {
    background-color: var(--search-input-bg);
    color: var(--search-input-text);
    padding: 9px 12px;
    border: 1px solid var(--search-border-color);
    border-radius: 20px;
    font-size: 0.85em;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    height: 38px;
}

.custom-hero-select-trigger .selected-hero-name,
.custom-year-select-trigger .selected-year-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px;
}

.custom-hero-select-trigger .arrow,
.custom-year-select-trigger .arrow {
    transition: transform var(--transition-speed-fast) ease;
}

.custom-hero-select-trigger.open .arrow,
.custom-year-select-trigger.open .arrow {
    transform: rotate(180deg);
}

.custom-hero-select-options,
.custom-year-select-options {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background-color: var(--search-input-bg);
    border: 1px solid var(--search-border-color);
    border-radius: var(--border-radius-md);
    z-index: 1001;
    max-height: 280px;
    display: none;
    box-shadow: var(--shadow-medium);
    flex-direction: column;
}

.custom-hero-select-options.open,
.custom-year-select-options.open {
    display: flex;
}

.hero-options-search-input-container,
.year-options-search-input-container {
    padding: 10px 10px 5px 10px;
    border-bottom: 1px solid var(--search-border-color);
    flex-shrink: 0;
}

.hero-options-search-input,
.year-options-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--search-border-color);
    border-radius: 15px;
    background-color: #333;
    color: var(--search-input-text);
    font-size: 0.9em;
    outline: none;
}

.hero-options-search-input::placeholder,
.year-options-search-input::placeholder {
    color: var(--search-placeholder-text);
    opacity: 0.8;
}

.hero-options-list-container,
.year-options-list-container {
    overflow-y: auto;
    flex-grow: 1;
}

.hero-options-list,
.year-options-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.hero-options-list li,
.year-options-list li {
    padding: 10px 15px;
    color: var(--search-input-text);
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color var(--transition-speed-fast) ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hero-options-list li:hover,
.hero-options-list li.focused,
.year-options-list li:hover,
.year-options-list li.focused {
    background-color: #444;
}

.hero-options-list li.selected-option,
.year-options-list li.selected-option {
    background-color: var(--accent-secondary);
    font-weight: 500;
}

.hero-options-list .no-hero-results,
.year-options-list .no-year-results {
    padding: 10px 15px;
    color: var(--search-placeholder-text);
    font-style: italic;
    cursor: default;
}

.hero-section {
    background-color: var(--accent-primary);
    color: var(--bg-primary);
    padding: 40px 20px;
    text-align: center;
}

.hero-content-wrapper {
    max-width: 900px;
    margin: 0 auto;
}

.hero-section h2 {
    font-size: 2.2em;
    margin-bottom: 15px;
    font-weight: 700;
    line-height: 1.2;
}

.hero-section p {
    font-size: 1.1em;
    line-height: 1.6;
    color: #f0f0f0;
    margin-bottom: 20px;
}

.ad-placeholder {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    background-color: #e9e9e9;
    border: 1px dashed #cccccc;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 25px auto;
    text-align: center;
    color: #777777;
    font-size: 0.9em;
    font-style: italic;
    overflow: hidden;
}

main {
    flex-grow: 1;
    padding: 25px 20px;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px 15px;
}

.movie-item {
    background-color: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInItem var(--transition-speed-medium) ease-out forwards;
    position: relative;
}

.movie-item.highlighted::after {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border: 3px solid var(--accent-primary);
    border-radius: var(--border-radius-lg);
    animation: pulseHighlight 1.5s ease-out;
    pointer-events: none;
    z-index: 6;
}

@keyframes pulseHighlight {
    0% {
        opacity: 0.7;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.02);
    }

    100% {
        opacity: 0;
        transform: scale(1.05);
    }
}

.movie-item:nth-child(1) {
    animation-delay: 0.05s;
}

.movie-item:nth-child(2) {
    animation-delay: 0.1s;
}

.movie-item:nth-child(3) {
    animation-delay: 0.15s;
}

.movie-item:nth-child(4) {
    animation-delay: 0.2s;
}

@keyframes fadeInItem {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.thumbnail-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    margin-bottom: 12px;
    background-color: #e0e0e0;
    transition: box-shadow var(--transition-speed-fast) ease, transform var(--transition-speed-fast) ease, border-radius var(--transition-speed-fast) ease;
}

.movie-item:hover .thumbnail-container {
    border-radius: 0;
    transform: scale(1.03);
    box-shadow: var(--shadow-medium);
    z-index: 5;
}

.movie-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: inherit;
    transition: border-radius var(--transition-speed-fast) ease;
}

.movie-details {
    padding: 0 5px;
}

.movie-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    max-height: calc(1.4em * 2);
    transition: color var(--transition-speed-fast) ease;
}

.movie-item:hover .movie-title {
    color: var(--accent-primary);
}

#loading-indicator {
    text-align: center;
    padding: 30px 0;
    font-size: 1.1em;
    color: var(--text-secondary);
    display: none;
    width: 100%;
    margin-top: 20px;
    opacity: 0;
    transition: opacity var(--transition-speed-medium) ease;
}

#loading-indicator.visible {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 1;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--accent-primary);
    margin: 0 auto 10px auto;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.no-results {
    text-align: center;
    padding: 40px 20px;
    font-size: 1.2em;
    color: var(--text-secondary);
    width: 100%;
    grid-column: 1 / -1;
    opacity: 0;
    animation: fadeInItem 0.5s ease-out forwards;
}

footer {
    background-color: var(--bg-secondary);
    text-align: center;
    padding: 15px;
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

#back-to-top-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001;
    background-color: var(--accent-primary);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: var(--shadow-medium);
    opacity: 0;
    visibility: hidden;
    transform: translateY(100px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

#back-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#back-to-top-btn:hover {
    background-color: var(--accent-secondary);
    transform: scale(1.1);
}

@media (min-width: 769px) and (max-width: 992px) {
    .header-content {
        gap: 20px;
    }

    .header-main-search-wrapper {
        max-width: 400px;
    }

    .filter-bar {
        top: var(--header-height);
        position: sticky;
    }

    .filter-bar-content {
        justify-content: center;
        gap: 12px;
    }

    .header-filters,
    .simple-filter-select {
        flex-grow: 0;
        min-width: 150px;
        max-width: 200px;
    }
}

@media (max-width: 768px) {
    header {
        height: auto;
        padding: 10px 15px;
    }

    .header-content {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .logo-area {
        width: auto;
        margin-bottom: 5px;
        order: 1;
    }

    .header-main-search-wrapper {
        order: 2;
        width: 100%;
        max-width: 450px;
        margin-left: auto;
        margin-right: auto;
    }

    #search-input {
        padding: 10px 15px;
        font-size: 0.9em;
    }

    .filter-bar {
        padding: 10px;
        position: static;
        box-shadow: var(--shadow-light);
        border-top: 1px solid var(--border-color);
        margin-top: 10px;
    }

    .filter-bar-content {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-around;
        gap: 8px;
    }

    .header-filters,
    .simple-filter-select,
    .custom-hero-select-wrapper,
    .custom-year-select-wrapper {
        width: auto;
        min-width: 140px;
        flex-grow: 1;
        max-width: calc(50% - 4px);
    }

    .hero-section {
        padding: 20px 15px;
    }

    .hero-section h2 {
        font-size: 1.7em;
    }

    .hero-section p {
        font-size: 0.95em;
    }

    .hero-bmc-button {
        font-size: 0.9em;
        padding: 10px 20px;
    }

    .movie-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media (max-width: 768px) and (max-height: 450px) and (orientation: landscape) {
    .header-content {
        flex-direction: row;
        justify-content: space-between;
        gap: 10px;
    }

    .logo-area {
        width: auto;
        margin-bottom: 0;
    }

    .header-main-search-wrapper {
        order: 0;
        flex-grow: 1;
        max-width: 300px;
    }

    .filter-bar {
        margin-top: 5px;
        padding: 5px 10px;
    }

    .filter-bar-content {
        gap: 5px;
    }

    .header-filters,
    .simple-filter-select {
        min-width: 120px;
        max-width: 160px;
        font-size: 0.8em;
        height: 34px;
        padding: 7px 10px;
    }

    .custom-hero-select-trigger,
    .custom-year-select-trigger {
        font-size: 0.8em;
        height: 34px;
        padding: 7px 10px;
    }

    .simple-filter-select {
        padding-right: 25px;
    }

    .movie-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 480px) {
    .header-content {
        flex-direction: column;
        gap: 10px;
    }

    .logo-area {
        order: 1;
    }

    .header-main-search-wrapper {
        order: 2;
        width: 100%;
        max-width: 100%;
        margin-top: 0;
    }

    .filter-bar {
        margin-top: 8px;
        position: static;
    }

    .filter-bar-content {
        flex-direction: column;
        gap: 10px;
    }

    .header-filters,
    .simple-filter-select,
    .custom-hero-select-wrapper,
    .custom-year-select-wrapper {
        width: 100%;
        max-width: none;
    }

    #search-input,
    .custom-hero-select-trigger,
    .custom-year-select-trigger,
    .hero-options-search-input,
    .year-options-search-input,
    .simple-filter-select {
        padding: 9px 14px;
        font-size: 0.85em;
    }

    .hero-section h2 {
        font-size: 1.5em;
    }

    .custom-hero-select-options,
    .custom-year-select-options {
        max-height: 180px;
    }

    .movie-grid {
        grid-template-columns: 1fr;
    }
}

.hero-bmc-button {
    display: inline-block;
    background-color: #FFDD00;
    color: #000000;
    padding: 12px 25px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: bold;
    font-size: 1em;
    margin-top: 20px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.hero-bmc-button:hover,
.hero-bmc-button:focus {
    background-color: #fcc700;
    color: #000000;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
