.hidden {
  display: none !important;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #0f0f0f;
  -ms-overflow-style: none;
  scrollbar-width: none;
  overflow-x: hidden;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
}

body {
  color: #fff;
}

.app-shell {
  min-height: 100vh;
  color: #fff;
  background: #0f0f0f;
  padding-bottom: 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 40px;
  background: rgba(15, 15, 15, 0.88);
  backdrop-filter: blur(6px);
}

.brand {
  color: #e50914;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.search-wrap {
  position: relative;
  width: min(500px, 100%);
  flex: 1 1 320px;
}

.search-wrap input {
  width: 100%;
  border: 1px solid #2b2b2b;
  border-radius: 999px;
  background: #141414;
  color: #fff;
  padding: 11px 15px;
  font-size: 0.96rem;
}

.search-results {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  background: #181818;
  border: 1px solid #2d2d2d;
  border-radius: 12px;
  overflow: hidden;
  max-height: 340px;
  overflow-y: auto;
}

.search-item {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid #2a2a2a;
  cursor: pointer;
}

.search-item:last-child {
  border-bottom: none;
}

.search-item img {
  width: 100%;
  border-radius: 6px;
}

.search-item p {
  margin: 4px 0;
  color: #fff;
}

.search-item small {
  color: #b6b6b6;
}

.hero-banner {
  position: relative;
  min-height: 62vh;
  display: flex;
  align-items: end;
  padding: 60px 40px;
  background-size: cover;
  background-position: center;
  opacity: 1;
  transition: opacity 220ms ease-in-out;
}

.hero-banner.hero-fade-out {
  opacity: 0.32;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, #0f0f0f 8%, rgba(15, 15, 15, 0.45) 55%);
}

.hero-content {
  position: relative;
  max-width: 700px;
  z-index: 1;
}

.hero-content h1 {
  margin: 0 0 14px;
  font-size: clamp(2rem, 4vw, 3.6rem);
  min-height: 2.2em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-content p {
  margin: 0;
  color: #ebebeb;
  line-height: 1.5;
  min-height: 4.5em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-actions {
  margin-top: 24px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-actions button {
  border: 0;
  border-radius: 8px;
  padding: 10px 20px;
  font-weight: 700;
  cursor: pointer;
}

.hero-actions .ghost-btn {
  background: rgba(109, 109, 110, 0.7);
  color: #fff;
}

.topbar-install {
  border: 1px solid #3a3a3a;
  border-radius: 999px;
  background: #1b1b1b;
  color: #fff;
  padding: 8px 14px;
  font-size: 0.86rem;
  cursor: pointer;
  white-space: nowrap;
}

.ad-slot {
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 30;
}

.ad-slot iframe {
  border: 0;
  padding: 0;
  width: min(100%, 820px);
  min-height: 96px;
  overflow: hidden;
  display: block;
  margin: 0 auto;
}

.status {
  margin: 22px 40px 0;
  color: #d0d0d0;
}

.status.error {
  color: #ff6f6f;
}

.media-row {
  margin-top: 24px;
  padding: 0 40px;
}

.media-row h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

.row-controls {
  display: flex;
  justify-content: end;
  gap: 8px;
  margin-bottom: 10px;
}

.row-controls button {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid #373737;
  background: #191919;
  color: #fff;
  cursor: pointer;
}

.row-controls button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.row-grid {
  display: flex;
  gap: 12px;
  overflow-x: hidden;
  overflow-y: hidden;
  padding: 0 2px 10px;
  scroll-behavior: smooth;
}

.row-grid::-webkit-scrollbar {
  height: 8px;
}

.row-grid::-webkit-scrollbar-thumb {
  background: #2f2f2f;
  border-radius: 999px;
}

.row-grid .poster-card {
  flex: 0 0 clamp(130px, 22vw, 190px);
  scroll-snap-align: start;
}

.is-touch-os .row-controls {
  display: none;
}

.dpad-mode .row-controls {
  display: none;
}

.dpad-mode .row-grid .poster-card {
  flex: 1 1 0;
  min-width: 0;
}

.is-touch-os .row-grid {
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  touch-action: auto;
}

.poster-card {
  cursor: pointer;
  position: relative;
}

.more-card {
  display: grid;
  place-items: center;
  min-height: 100%;
  border: 1px dashed #565656;
  border-radius: 10px;
  background: #161616;
}

.genre-card {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 2 / 3;
  min-height: 100%;
  border: 1px solid #343434;
  border-radius: 10px;
  background: #111;
  overflow: hidden;
}

.genre-card-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.45);
}

.genre-card-inner {
  position: relative;
  z-index: 1;
  text-align: center;
  width: 100%;
  margin-top: auto;
  padding: 14px 10px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.7), transparent 90%);
}

.genre-card-inner span {
  display: block;
  font-size: 1rem;
  font-weight: 800;
}

.entity-logo-card {
  background: #101010;
}

.entity-logo-wrap {
  position: absolute;
  inset: 12px 12px 56px;
  display: grid;
  place-items: center;
  background: #0f0f0f;
  border-radius: 8px;
  border: 1px solid #2f2f2f;
  padding: 12px;
  overflow: hidden;
}

.entity-logo {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: auto !important;
  object-fit: contain !important;
  border-radius: 0 !important;
  /* Keep original brand colors while slightly improving readability */
  filter: brightness(1.08) contrast(1.08);
}

.entity-logo.entity-logo-dark {
  filter: grayscale(1) brightness(0) invert(1) contrast(1.08);
}

.more-card-inner {
  text-align: center;
  padding: 14px;
}

.more-card-inner span {
  display: block;
  font-size: 1.12rem;
  font-weight: 800;
}

.more-card-inner small {
  color: #bbbbbb;
}

.poster-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.poster-fallback {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  border: 1px solid #333;
  background: #1c1c1c;
  color: #aaa;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
}

.meta {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.meta p {
  margin: 0;
  font-size: 0.9rem;
  color: #f5f5f5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.score {
  color: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 700;
  font-size: 0.78rem;
  border: 1px solid transparent;
  position: relative;
}

.score-low {
  background: #cf2f2f;
  border-color: #e46262;
}

.score-mid {
  color: #2a2400;
  background: #f3c94f;
  border-color: #ffd86f;
}

.score-high {
  background: #2ba34a;
  border-color: #5bc676;
}

.poster-fire-stack {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 30px;
  pointer-events: none;
  z-index: 3;
}

.poster-fire-stack .glow {
  position: absolute;
  inset: 8px 0 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 183, 120, 0.7);
  filter: blur(6px);
  animation: flame-glow-pulse 0.45s linear infinite;
}

.poster-fire-stack .flame {
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 12px;
  height: 16px;
  transform: translateX(-50%);
  border-radius: 60% 60% 50% 50%;
  background: radial-gradient(circle at 50% 70%, #fff7c2 0%, #ffd25d 35%, #ff9228 70%, #ff4a0a 100%);
  animation: burnBabyBurn 0.4s linear infinite;
  box-shadow: 0 0 6px rgba(255, 124, 0, 0.8);
}

@keyframes burnBabyBurn {
  0% {
    transform: translateX(-50%) scale(0.94) rotate(-3deg);
  }
  100% {
    transform: translateX(-50%) scale(1.06) rotate(3deg);
  }
}

@keyframes flame-glow-pulse {
  0% {
    opacity: 0.45;
    transform: scale(0.9);
  }
  100% {
    opacity: 0.85;
    transform: scale(1.15);
  }
}

.details-page {
  min-height: 100vh;
  background: #0f0f0f;
  color: #fff;
  overflow-x: hidden;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  text-decoration: none;
  margin: 18px 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #3a3a3a;
  background: #181818;
  font-weight: 700;
}

.details-hero {
  min-height: 78vh;
  margin: 0 40px 20px;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  background-size: cover;
  background-position: center;
  background-color: #181818;
  display: grid;
  grid-template-columns: 1.25fr 340px;
  align-items: end;
  min-width: 0;
}

.details-content {
  position: relative;
  z-index: 1;
  max-width: 100%;
  min-width: 0;
  padding: 34px;
  backdrop-filter: blur(2px);
}

.details-content h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 3.8vw, 3.5rem);
  overflow-wrap: anywhere;
}

.details-info {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.details-info span {
  background: rgba(30, 30, 30, 0.85);
  border: 1px solid #3f3f3f;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.86rem;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.details-info .score {
  border-color: transparent;
}

.details-info .score-low {
  background: #cf2f2f;
  border-color: #e46262;
  color: #fff;
}

.details-info .score-mid {
  background: #f3c94f;
  border-color: #ffd86f;
  color: #2a2400;
}

.details-info .score-high {
  background: #2ba34a;
  border-color: #5bc676;
  color: #fff;
}

.genre-list {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.genre-list span {
  padding: 5px 10px;
  background: rgba(229, 9, 20, 0.2);
  border: 1px solid rgba(229, 9, 20, 0.45);
  border-radius: 999px;
  font-size: 0.85rem;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.detail-block {
  margin-top: 16px;
}

.detail-block h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.detail-block p {
  margin: 0;
  color: #d6d6d6;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.details-content > p {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.detail-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-actions button,
.chips button {
  text-decoration: none;
  color: #fff;
  border: 1px solid #3a3a3a;
  background: #1b1b1b;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.86rem;
  cursor: pointer;
}

#detailsWatchNowBtn {
  background: #e50914;
  border-color: #e50914;
  padding: 10px 18px;
  font-size: 0.94rem;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(229, 9, 20, 0.28);
}

.details-stats {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  max-width: 480px;
}

.stat-card {
  background: rgba(18, 18, 18, 0.88);
  border: 1px solid #333;
  border-radius: 10px;
  padding: 10px;
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: #aaa;
  margin-bottom: 5px;
}

.stat-card strong {
  font-size: 0.95rem;
}

.details-poster-wrap {
  position: relative;
  z-index: 1;
  align-self: center;
  padding: 18px;
}

.details-poster-wrap img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid #353535;
  box-shadow: 0 15px 38px rgba(0, 0, 0, 0.45);
}

.fullscreen-player {
  position: fixed;
  inset: 0;
  z-index: 120;
  width: 100vw;
  height: 100vh;
  background: #000;
  padding: 0;
}

.fullscreen-player-inner {
  width: 100%;
  height: 100%;
}

.fullscreen-player-inner iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.fullscreen-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: 1px solid #3c3c3c;
  background: rgba(23, 23, 23, 0.92);
  color: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  z-index: 2;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cast-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
  align-items: flex-start;
}

.cast-card {
  margin: 0;
  width: 140px;
  min-width: 140px;
  max-width: 140px;
  border: 1px solid #353535;
  border-radius: 14px;
  background: #171717;
  padding: 12px 10px 10px;
  text-align: center;
  cursor: pointer;
}

.cast-card img,
.cast-fallback {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #222;
  color: #aaa;
  font-size: 0.8rem;
  margin: 0 auto;
  border: 1px solid #3b3b3b;
}

.cast-card p,
.cast-card small {
  margin: 0;
  padding: 0;
}

.cast-card p {
  margin-top: 7px;
  font-size: 0.86rem;
}

.cast-card small {
  display: block;
  margin: 4px 0 8px;
  color: #a9a9a9;
  font-size: 0.75rem;
}

.related-section {
  padding: 0 40px 28px;
}

.related-section h2 {
  margin: 12px 0;
  font-size: 1.15rem;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.category-shell h1 {
  margin: 0 0 14px;
}

.category-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.category-toolbar label {
  color: #cfcfcf;
  font-size: 0.9rem;
}

.category-toolbar select {
  border: 1px solid #393939;
  background: #171717;
  color: #fff;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.88rem;
}

.dpad-mode .dpad-focus {
  outline: 3px solid #e50914;
  outline-offset: 3px;
  border-radius: 10px;
  box-shadow: 0 0 18px rgba(229, 9, 20, 0.5);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), outline-color 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.dpad-mode .poster-card.dpad-focus,
.dpad-mode .search-item.dpad-focus,
.dpad-mode .cast-card.dpad-focus {
  transform: scale(1.06);
  margin-left: 6px;
  margin-right: 6px;
  position: relative;
  z-index: 4;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.dpad-mode .row-grid.dpad-active-container,
.dpad-mode .related-grid.dpad-active-container,
.dpad-mode .cast-grid.dpad-active-container,
.dpad-mode #genresGrid.dpad-active-container,
.dpad-mode #entitiesGrid.dpad-active-container,
.dpad-mode #categoryGrid.dpad-active-container {
  padding: 20px;
  margin: -20px;
  overflow: visible;
  scroll-snap-type: none !important;
}

@media (max-width: 768px) {
  .topbar,
  .hero-banner,
  .media-row,
  .details-hero {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .brand {
    font-size: 1.35rem;
  }

  .topbar-install {
    width: auto;
    margin-left: auto;
    padding: 7px 11px;
    font-size: 0.8rem;
  }

  .search-wrap {
    order: 3;
    width: 100%;
    flex: 1 1 100%;
  }

  .row-grid .poster-card {
    flex-basis: clamp(140px, 36vw, 190px);
  }

  .hero-banner {
    min-height: 56vh;
    padding-top: 34px;
    padding-bottom: 28px;
  }

  .hero-content h1 {
    margin-bottom: 10px;
  }

  .hero-content p {
    font-size: 0.95rem;
  }

  .details-hero {
    grid-template-columns: 1fr;
    margin: 0 16px 20px;
  }

  .details-content {
    padding: 20px;
  }

  .details-poster-wrap {
    display: none;
  }

  .back-link {
    margin-left: 16px;
  }

  .related-section {
    padding: 0 16px 28px;
  }

  .cast-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .cast-card {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .ad-slot iframe {
    width: 100%;
  }

  .fullscreen-player {
    padding: 0;
  }
}

@media (max-width: 560px) {
  .topbar {
    gap: 6px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .search-wrap input {
    padding: 9px 12px;
    font-size: 0.9rem;
  }

  .row-grid .poster-card {
    flex-basis: clamp(145px, 44vw, 185px);
  }

  .media-row {
    margin-top: 18px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .status {
    margin-left: 14px;
    margin-right: 14px;
  }

  .hero-actions button {
    width: 100%;
    justify-content: center;
  }

  .details-content {
    padding: 16px;
  }

  .details-info span,
  .genre-list span,
  .detail-actions button,
  .chips button {
    font-size: 0.8rem;
  }
}
