:root {
  --bg-start: #050505;
  --bg-end: #dadada;
  --surface: rgba(12, 12, 12, 0.88);
  --surface-2: rgba(28, 28, 28, 0.92);
  --text: #f5f5f5;
  --muted: #b8b8b8;
  --border: #5a5a5a;
  --accent: #f8f8f8;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  --glow: rgba(84, 233, 255, 0.22);
  --glow-2: rgba(165, 102, 255, 0.18);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  min-height: 100vh;
  color: var(--text);
  background: linear-gradient(170deg, var(--bg-start) 0%, #1a1a1a 35%, #7d7d7d 70%, var(--bg-end) 100%);
  background-attachment: fixed;
  overflow-y: auto;
}

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(8, 8, 8, 0.82);
  backdrop-filter: blur(8px);
}

.topbar-row {
  max-width: 1220px;
  margin: 0 auto;
  padding-left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.nav a {
  text-decoration: none;
  color: #efefef;
  background: #161616;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.18s ease;
}

.nav a:hover,
.nav a.active {
  color: #111;
  background: var(--accent);
  border-color: #fff;
  box-shadow: 0 8px 18px rgba(255, 255, 255, 0.2);
}

.settings-link {
  text-decoration: none;
  color: #f6f6f6;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  background: #151515;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.nav-search input {
  width: min(260px, 55vw);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #101010;
  color: #f5f5f5;
  padding: 9px 11px;
  font-size: 0.9rem;
}

.nav-search input:focus {
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: 1px;
}

main,
.home-main {
  flex: 1;
  max-width: 1120px;
  margin: 24px auto;
  padding: 0 16px 40px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 16px;
  text-align: center;
}

.content-with-ads {
  width: min(1480px, 100%);
  margin: 24px auto;
  padding: 0 16px 40px;
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 160px;
  gap: 20px;
  align-items: start;
}

.content-with-ads > main,
.content-with-ads > .home-main {
  margin: 0;
  padding: 0;
  max-width: 1120px;
  width: 100%;
}

.side-ad {
  position: sticky;
  top: 84px;
  width: 160px;
  min-height: 300px;
  display: grid;
  justify-items: center;
  align-items: start;
  border-radius: 18px;
  padding: 2px;
  background: linear-gradient(130deg, #000 0%, #fff 30%, #111 55%, #fff 78%, #000 100%);
  background-size: 220% 220%;
  animation: adFrameFlow 6s linear infinite;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.45), 0 0 24px rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.side-ad > iframe,
.side-ad > ins,
.side-ad > div {
  width: 160px;
  min-height: 300px;
  border: 0;
  border-radius: 16px;
  background: rgba(6, 6, 6, 0.92);
  overflow: hidden;
}

@keyframes adFrameFlow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@media (max-width: 1300px) {
  .content-with-ads {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-ad {
    display: none;
  }
}

.centered-page {
  display: grid;
  justify-items: center;
  gap: 16px;
}

.hero {
  background: linear-gradient(145deg, rgba(8, 8, 8, 0.94), rgba(35, 35, 35, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 24px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 36px var(--glow-2);
  padding: 26px;
  margin-bottom: 18px;
}

.hero-centered {
  width: min(980px, 100%);
  text-align: center;
  margin-bottom: 0;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  margin-bottom: 8px;
  letter-spacing: 0.4px;
}

.hero p,
.small {
  color: var(--muted);
  font-size: 0.96rem;
}

.hero-compact {
  padding: 14px 20px;
  margin-bottom: 10px;
}

.hero-compact h1 {
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  margin-bottom: 0;
}

.home-hero-title {
  margin-top: 6px;
  margin-bottom: 20px;
}

.home-hero-title h1 {
  font-size: clamp(3rem, 7vw, 5.6rem);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.mc {
  font-family: Arial, sans-serif;
  font-size: clamp(3rem, 7vw, 5.6rem);
  font-weight: 900;
  text-align: center;
  text-transform: none;
  letter-spacing: 0;
  background: linear-gradient(270deg, #000000, #ffffff, #000000);
  background-size: 400% 400%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  animation: gradientRotate 4s ease infinite;
}

.home-hero-title h1.mc {
  text-transform: none;
  letter-spacing: 0;
}

@keyframes gradientRotate {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.home-launch-grid {
  padding-bottom: 28px;
}

.home-launch-grid > .media-tile:nth-child(6) {
  grid-column: 2;
}

.home-launch-grid > .media-tile:nth-child(7) {
  grid-column: 3;
}

.home-launch-grid > .media-tile:nth-child(8) {
  grid-column: 4;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  width: min(980px, 100%);
}

.card {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: var(--surface);
  border-radius: 16px;
  padding: 15px;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  text-align: center;
}

.card:hover,
.media-tile:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: var(--shadow), 0 0 28px var(--glow);
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 9px;
  color: #fff;
}

.media-grid {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.media-grid[data-media-static] {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.media-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.movie-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.movie-section-title {
  margin: 0;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 1rem;
  letter-spacing: 0.08em;
}

.movie-section-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.popular-grid {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.popular-tile {
  min-height: 275px;
}

.popular-tile img {
  aspect-ratio: 16 / 11;
}

.media-tile {
  text-decoration: none;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: var(--surface-2);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  box-shadow: var(--shadow);
}

.media-tile img {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: cover;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  filter: saturate(1.2) contrast(1.08) brightness(1.02);
}

.media-grid[data-media-static="movie"] .media-tile img,
.media-grid[data-media-kind="movie"] .media-tile img {
  aspect-ratio: 2 / 3;
}

.media-tile span {
  padding: 12px;
  text-align: center;
  font-size: 1rem;
  color: #f0f0f0;
  font-weight: 600;
}

@media (max-width: 1000px) {
  .home-launch-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .popular-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-launch-grid > .media-tile:nth-child(6),
  .home-launch-grid > .media-tile:nth-child(7),
  .home-launch-grid > .media-tile:nth-child(8) {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .home-launch-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar-row {
    justify-content: center;
  }

  .topbar-tools {
    width: 100%;
    justify-content: center;
  }

  .nav-search input {
    width: min(420px, 75vw);
  }

  .popular-grid {
    grid-template-columns: 1fr;
  }

  .movie-section-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.input,
.btn,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  padding: 10px 11px;
  background: #0e0e0e;
  color: var(--text);
}

.btn {
  cursor: pointer;
  margin-top: 8px;
  font-weight: 700;
  background: #f2f2f2;
  color: #111;
}

.row,
.list {
  display: grid;
  gap: 8px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 8px;
  background: #141414;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.quick-links a {
  color: #efefef;
  font-weight: 600;
}

@media (max-width: 780px) {
  .topbar-row {
    justify-content: center;
  }

  .settings-link {
    margin-top: 2px;
  }
}

.media-tile {
  width: 100%;
  cursor: pointer;
}

.media-launcher {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, 0.78);
  padding: 32px 16px;
}

.media-launcher.is-open {
  display: grid;
}

.media-launcher-shell {
  width: min(95vw, 1200px);
  position: relative;
}

.media-launcher-close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 4;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
}

.media-launcher-frame-wrap {
  position: relative;
  width: min(95vw, 1200px);
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.media-launcher-loader {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  z-index: 3;
  background: linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)),
              url('https://i.imgur.com/70OvshH.png') center/cover no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
  transition: opacity 0.5s ease;
}

.media-launcher-loader.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.media-launcher-loader p {
  margin-top: 15px;
  opacity: 0.85;
}

.media-launcher-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #555;
  border-top: 5px solid #fff;
  border-radius: 50%;
  animation: mc-spin 1s linear infinite;
}

.media-launcher iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.media-launcher-shell:fullscreen,
.media-launcher-shell:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: none;
}

.media-launcher-shell:fullscreen .media-launcher-frame-wrap,
.media-launcher-shell:-webkit-full-screen .media-launcher-frame-wrap {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none;
  aspect-ratio: auto;
  margin: 0;
  border-radius: 0;
  border: 0;
}

.media-launcher-fullscreen {
  margin: 18px auto 0;
  display: block;
  padding: 14px 28px;
  font-size: 20px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: linear-gradient(45deg, #000000, #ffffff);
  color: #000;
  font-weight: 700;
  box-shadow: 0 5px 10px rgba(0,0,0,0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.media-launcher-fullscreen:hover {
  transform: scale(1.05);
  box-shadow: 0 7px 14px rgba(0,0,0,0.4);
}

body.launcher-open {
  overflow: hidden;
}

@keyframes mc-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.embed-launcher-wrap {
  position: relative;
  width: min(100%, 1400px);
  max-width: 1400px;
  aspect-ratio: 16 / 9;
  margin: 20px auto;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
}

.embed-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.embed-launcher-wrap:fullscreen,
.embed-launcher-wrap:-webkit-full-screen {
  width: 100vw;
  max-width: none;
  height: 100vh;
  aspect-ratio: auto;
  margin: 0;
  border-radius: 0;
  border: 0;
}

.embed-launcher-wrap:fullscreen .embed-frame,
.embed-launcher-wrap:-webkit-full-screen .embed-frame {
  width: 100%;
  height: 100%;
}

.embed-loader {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  z-index: 5;
  background: linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)),
              url('https://i.imgur.com/70OvshH.png') center/cover no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
}

.embed-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #555;
  border-top: 5px solid #fff;
  border-radius: 50%;
  animation: mc-spin 1s linear infinite;
}

.embed-loader p {
  margin-top: 15px;
  opacity: 0.85;
}

main.embed-main {
  max-width: 1440px;
  width: 100%;
}

.media-tile-target {
  outline: 3px solid rgba(136, 255, 159, 0.95);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(136, 255, 159, 0.35), var(--shadow);
}
