:root {
  --bg: #07060c;
  --bg-elev: #12101a;
  --bg-card: #171522;
  --bg-soft: #1e1a2c;
  --ink: #f6f2ff;
  --muted: #a79ec0;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #ff4d8d;
  --accent-2: #7c5cff;
  --accent-3: #22d3ee;
  --gold: #ffc857;
  --ok: #34d399;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --font: "Outfit", system-ui, sans-serif;
  --display: "Space Grotesk", "Outfit", system-ui, sans-serif;
  --container: 1180px;
  --header-h: 72px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.container {
  width: min(100% - 2rem, var(--container));
  margin-inline: auto;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(124, 92, 255, 0.28), transparent 55%),
    radial-gradient(700px 400px at 90% 5%, rgba(255, 77, 141, 0.22), transparent 50%),
    radial-gradient(600px 400px at 50% 100%, rgba(34, 211, 238, 0.1), transparent 55%);
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
  background: rgba(7, 6, 12, 0.72);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-shrink: 0;
}

.logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px rgba(255, 77, 141, 0.35);
}

.logo-text {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.logo-text span {
  color: var(--accent);
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.5rem;
}

.nav-link {
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  color: var(--muted);
  pointer-events: none;
}

.search input {
  width: min(280px, 42vw);
  height: 44px;
  padding: 0 1rem 0 2.4rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  outline: none;
  transition: 0.2s ease;
}

.search input:focus {
  border-color: rgba(124, 92, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
}

.burger {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
}

.burger span {
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: 0.2s ease;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #ff6a3d 45%, var(--accent-2));
  color: white;
  box-shadow: 0 12px 30px rgba(255, 77, 141, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
  color: var(--ink);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn-sm {
  min-height: 40px;
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
}

/* Hero */
.hero {
  padding: 3.5rem 0 2rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2.5rem;
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  margin: 0 0 1rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.15);
  color: #cbbdff;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.hero h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.grad {
  background: linear-gradient(100deg, var(--accent), var(--gold) 45%, var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  margin: 1.1rem 0 1.6rem;
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 38ch;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero-stats {
  display: flex;
  gap: 1.5rem;
  margin-top: 2rem;
}

.hero-stats div {
  display: flex;
  flex-direction: column;
}

.hero-stats strong {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
}

.hero-stats span {
  color: var(--muted);
  font-size: 0.9rem;
}

.hero-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  transform: perspective(1000px) rotateY(-6deg) rotateX(4deg);
}

.hero-card {
  aspect-ratio: 2/3;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: float 6s ease-in-out infinite;
}

.hero-card:nth-child(2) {
  transform: translateY(18px);
  animation-delay: -1.5s;
}

.hero-card:nth-child(3) {
  animation-delay: -3s;
}

.hero-card .poster {
  width: 100%;
  height: 100%;
}

@keyframes float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -10px; }
}

/* Sections */
.section {
  padding: 2.5rem 0;
}

.section.alt {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  border-block: 1px solid var(--line);
}

.section-head {
  margin-bottom: 1.25rem;
}

.section-head.row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.02em;
}

.section-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.filters {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.filters select {
  height: 40px;
  padding: 0 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  outline: none;
}

/* Categories */
.cat-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.85rem;
}

.cat-card {
  position: relative;
  min-height: 110px;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-card);
  overflow: hidden;
  cursor: pointer;
  transition: 0.2s ease;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.cat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--cat-grad);
  opacity: 0.85;
  transition: 0.25s ease;
}

.cat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
}

.cat-card:hover::before {
  opacity: 1;
}

.cat-card span,
.cat-card strong {
  position: relative;
  z-index: 1;
}

.cat-card strong {
  font-size: 1.05rem;
  font-weight: 700;
}

.cat-card span {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.85rem;
}

.cat-card.active {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* Genres */
.genre-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.chip {
  min-height: 40px;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  font-weight: 500;
  transition: 0.15s ease;
}

.chip:hover {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.18);
}

.chip.active {
  color: white;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(124, 92, 255, 0.3);
}

/* Movie grid */
.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.movie-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: 0.2s ease;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  color: inherit;
  width: 100%;
}

.movie-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.poster {
  aspect-ratio: 2/3;
  background:
    linear-gradient(160deg, var(--p1, #7c5cff), var(--p2, #ff4d8d));
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.poster::after {
  content: attr(data-emoji);
  font-size: 3rem;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.35));
  opacity: 0.95;
}

.poster-badge {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold);
}

.fav-btn {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: white;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1rem;
  transition: 0.15s ease;
  z-index: 2;
}

.fav-btn:hover,
.fav-btn.on {
  background: rgba(255, 77, 141, 0.9);
  transform: scale(1.05);
}

.movie-meta {
  padding: 0.85rem 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.movie-meta h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.movie-meta .sub {
  color: var(--muted);
  font-size: 0.82rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.45rem;
}

.tag {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 2rem 1rem;
}

/* Top list */
.top-list {
  display: grid;
  gap: 0.75rem;
}

.top-item {
  display: grid;
  grid-template-columns: 48px 64px 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: 0.15s ease;
}

.top-item:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: var(--bg-soft);
}

.top-rank {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--muted);
}

.top-item:nth-child(-n+3) .top-rank {
  color: var(--gold);
}

.top-thumb {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--p1), var(--p2));
  display: grid;
  place-items: center;
  font-size: 1.5rem;
}

.top-info h3 {
  margin: 0;
  font-size: 1.05rem;
}

.top-info p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.top-score {
  font-weight: 700;
  color: var(--gold);
  font-size: 1.05rem;
}

/* Footer */
.footer {
  margin-top: 2rem;
  padding: 2.5rem 0 3rem;
  border-top: 1px solid var(--line);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

.footer p {
  margin: 0;
  color: var(--muted);
}

.muted {
  opacity: 0.75;
  font-size: 0.9rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

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

.modal-card {
  position: relative;
  width: min(720px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
  z-index: 2;
}

.modal-hero {
  min-height: 180px;
  padding: 2rem 1.5rem 1.25rem;
  background: linear-gradient(135deg, var(--p1), var(--p2));
  display: flex;
  align-items: end;
}

.modal-hero h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.modal-content {
  padding: 1.25rem 1.5rem 1.75rem;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.modal-meta .score {
  color: var(--gold);
  font-weight: 700;
}

.modal-content p {
  margin: 0 0 1rem;
  color: #d7d0ea;
  line-height: 1.65;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-card { animation: none; }
  .movie-card:hover,
  .cat-card:hover,
  .btn-primary:hover { transform: none; }
}

/* Responsive */
@media (max-width: 960px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
  .hero-cards {
    max-width: 360px;
    transform: none;
  }
  .cat-row {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 760px) {
  .nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    display: none;
    flex-direction: column;
    padding: 0.75rem;
    background: rgba(10, 8, 16, 0.96);
    border-bottom: 1px solid var(--line);
    gap: 0.25rem;
  }
  .nav.open { display: flex; }
  .burger { display: flex; }
  .search input { width: min(200px, 46vw); }
  .cat-row { grid-template-columns: repeat(2, 1fr); }
  .top-item {
    grid-template-columns: 36px 52px 1fr;
    grid-template-rows: auto auto;
  }
  .top-score {
    grid-column: 3;
    justify-self: start;
  }
}

@media (max-width: 420px) {
  .movie-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .hero-stats { gap: 1rem; }
}
