:root {
  --bg: #141414;
  --red: #e50914;
  --text: #fff;
  --muted: #b3b3b3;
  --card: #181818;
  --pad: 4vw;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Be Vietnam Pro", Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; }
svg { width: 1.4em; height: 1.4em; fill: currentColor; }
.hidden { display: none !important; }
body.locked { overflow: hidden; }

/* ===== Hồ sơ ===== */
.profiles {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2rem;
  transition: opacity .4s;
}
.profiles h1 { font-size: clamp(1.8rem, 3.5vw, 3.5rem); font-weight: 500; }
.profile-list { display: flex; gap: 2vw; flex-wrap: wrap; justify-content: center; }
.profile { display: flex; flex-direction: column; align-items: center; gap: .7rem; color: #808080; cursor: pointer; }
.profile .pic {
  width: clamp(84px, 10vw, 160px); aspect-ratio: 1; border-radius: 6px;
  display: grid; place-items: center; font-size: 3rem; border: 3px solid transparent; transition: border-color .2s;
}
.profile:hover { color: #fff; }
.profile:hover .pic { border-color: #fff; }
.profile-name { font-size: clamp(1rem, 1.6vw, 1.4rem); }
.profile-input {
  margin-top: .5rem; padding: .6rem 1rem; width: clamp(180px, 22vw, 280px);
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.3); border-radius: 4px;
  color: #fff; font-size: 1rem; text-align: center; outline: none; transition: border-color .2s;
}
.profile-input:focus { border-color: #fff; background: rgba(255,255,255,.14); }
.profile-input::placeholder { color: rgba(255,255,255,.4); }

/* ===== Nav ===== */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--pad); height: 68px;
  background: linear-gradient(180deg, rgba(0,0,0,.75) 10%, transparent);
  transition: background-color .4s;
}
.nav.solid { background-color: var(--bg); }
.nav-left, .nav-right { display: flex; align-items: center; gap: 1.4rem; }
.logo { color: var(--red); font-weight: 900; font-size: 1.9rem; letter-spacing: -1px; }
.nav-links { display: flex; gap: 1.2rem; font-size: .88rem; }
.nav-links a { color: #e5e5e5; transition: color .3s; white-space: nowrap; }
.btn { white-space: nowrap; }
@media (max-width: 1000px) {
  .nav { height: 96px; align-items: flex-start; padding-top: 14px;
    background: linear-gradient(180deg, rgba(0,0,0,.9) 0%, rgba(0,0,0,.55) 75%, transparent); }
  .nav-links {
    display: flex !important; position: absolute; left: 0; right: 0; top: 56px;
    padding: 6px var(--pad); overflow-x: auto; scrollbar-width: none; font-size: .85rem;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .rows.flat, .grid-view { padding-top: 120px; }
}
.nav-links a:hover { color: var(--muted); }
.nav-links a.active { color: #fff; font-weight: 700; }
/* Dropdown Streaming */
.nav-dropdown { position: relative; }
.dropdown-toggle { cursor: pointer; }
.dropdown-menu {
  display: none; position: absolute; top: 100%; left: 0; flex-direction: column;
  background: rgba(10,10,10,.97); border: 1px solid rgba(255,255,255,.12);
  border-radius: 6px; padding: .4rem 0; min-width: 180px; z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.dropdown-menu a { padding: .55rem 1rem; color: #e5e5e5; font-size: .85rem; white-space: nowrap; }
.dropdown-menu a:hover { color: #fff; background: rgba(255,255,255,.1); }
.nav-dropdown:hover .dropdown-menu,
.nav-dropdown.open .dropdown-menu { display: flex; }
.icon-btn { background: none; color: #fff; display: grid; place-items: center; }
.avatar { width: 32px; height: 32px; border-radius: 4px; display: grid; place-items: center; font-size: 1.1rem; cursor: pointer; }
.search { display: flex; align-items: center; border: 1px solid transparent; padding: 4px 6px; transition: all .3s; }
.search input {
  width: 0; background: transparent; border: none; outline: none; color: #fff;
  font-family: inherit; font-size: .9rem; transition: width .3s;
}
.search.open { border-color: #fff; background: rgba(0,0,0,.75); }
.search.open input { width: 220px; margin-left: 6px; }

/* ===== Hero ===== */
.hero { position: relative; height: 56.25vw; min-height: 460px; max-height: 92vh; }
.hero-bg { position: absolute; inset: 0; background-size: cover; background-position: center top; }
.hero-bg::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(77deg, rgba(0,0,0,.65) 0%, transparent 70%);
}
.hero-content { position: absolute; left: var(--pad); bottom: 32%; width: 40%; z-index: 2; }
.hero-tag { display: flex; align-items: center; gap: .5rem; font-weight: 700; letter-spacing: 3px; font-size: .9rem; color: #ddd; margin-bottom: .6rem; }
.hero-tag b { color: var(--red); font-size: 1.4rem; letter-spacing: 0; }
.hero-title { font-size: clamp(2rem, 5vw, 5rem); font-weight: 900; line-height: 1; margin-bottom: 1.2rem; text-shadow: 2px 2px 6px rgba(0,0,0,.5); }
.hero-desc { font-size: clamp(.85rem, 1.2vw, 1.25rem); line-height: 1.4; text-shadow: 1px 1px 3px rgba(0,0,0,.6); margin-bottom: 1.5rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero-actions { display: flex; gap: .7rem; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .6rem 1.8rem; border-radius: 4px; font-size: clamp(.9rem, 1.2vw, 1.15rem); font-weight: 700;
  transition: opacity .2s;
}
.btn-play { background: #fff; color: #000; }
.btn-play:hover { background: rgba(255,255,255,.75); }
.btn-info { background: rgba(109,109,110,.7); color: #fff; }
.btn-info:hover { background: rgba(109,109,110,.4); }
.hero-age {
  position: absolute; right: 0; bottom: 35%; z-index: 2;
  background: rgba(51,51,51,.6); border-left: 3px solid #dcdcdc; padding: .4rem 3.5vw .4rem .8rem; font-size: 1.1rem;
}
.hero-fade { position: absolute; left: 0; right: 0; bottom: 0; height: 14.7vw; background: linear-gradient(180deg, transparent, rgba(20,20,20,.6) 40%, var(--bg)); }

/* ===== Hàng phim ===== */
.rows { position: relative; z-index: 3; margin-top: -10vw; padding-bottom: 3rem; }
.rows.flat { margin-top: 90px; }
.row { margin-bottom: 3vw; }
.row h2 { padding: 0 var(--pad); font-size: clamp(1rem, 1.4vw, 1.4rem); font-weight: 700; margin-bottom: .6rem; color: #e5e5e5; }
.row-wrap { position: relative; }
.row-track {
  display: flex; gap: .4vw; overflow-x: auto; scroll-behavior: smooth;
  padding: 1.5vw var(--pad); margin: -1.5vw 0; scrollbar-width: none;
}
.row-track::-webkit-scrollbar { display: none; }
.arrow {
  position: absolute; top: 0; bottom: 0; width: var(--pad); z-index: 10;
  background: rgba(20,20,20,.5); color: #fff; font-size: 2.5rem; opacity: 0; transition: opacity .2s, background .2s;
}
.row-wrap:hover .arrow { opacity: 1; }
.arrow:hover { background: rgba(20,20,20,.8); }
.arrow.left { left: 0; } .arrow.right { right: 0; }

.card {
  flex: 0 0 calc((100% - 5 * .4vw) / 6);
  position: relative; border-radius: 4px; cursor: pointer;
  transition: transform .3s ease .15s, box-shadow .3s ease .15s; background: var(--card);
}
.card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 4px; display: block; }
.card .card-label {
  position: absolute; left: 8px; bottom: 6px; font-weight: 900; font-size: .9rem; text-shadow: 0 0 6px #000;
}
.card .card-info {
  position: absolute; left: 0; right: 0; top: 100%; background: var(--card); padding: .7rem;
  border-radius: 0 0 4px 4px; opacity: 0; pointer-events: none; transition: opacity .3s ease .15s;
  box-shadow: 0 8px 16px rgba(0,0,0,.75);
}
.card:hover { transform: scale(1.35) translateY(-18%); z-index: 20; box-shadow: 0 8px 16px rgba(0,0,0,.75); }
.card:hover img { border-radius: 4px 4px 0 0; }
.card:hover .card-info { opacity: 1; pointer-events: auto; }
.row-track .card:first-child:hover { transform-origin: left center; }
.row-track .card:last-child:hover { transform-origin: right center; }
.card-btns { display: flex; gap: .35rem; margin-bottom: .5rem; }
.circle-btn {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5);
  background: rgba(42,42,42,.6); color: #fff; display: grid; place-items: center; font-size: .85rem;
}
.circle-btn:hover { border-color: #fff; }
.circle-btn.white { background: #fff; color: #000; border-color: #fff; }
.circle-btn.push { margin-left: auto; }
.circle-btn svg { width: 1em; height: 1em; }
.modal .circle-btn { width: 42px; height: 42px; font-size: 1.2rem; }
.card-meta { font-size: .62rem; display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; margin-bottom: .35rem; }
.match { color: #46d369; font-weight: 700; }
.age { border: 1px solid rgba(255,255,255,.4); padding: 0 .3rem; }
.hd { border: 1px solid rgba(255,255,255,.4); border-radius: 3px; padding: 0 .25rem; font-size: .55rem; }
.card-genres { font-size: .6rem; color: #ddd; }
.card-genres span + span::before { content: " • "; color: #646464; }

.badge-free {
  position: absolute; top: 6px; left: 6px; background: var(--red); color: #fff;
  font-size: .58rem; font-weight: 900; letter-spacing: .5px; padding: 2px 5px; border-radius: 2px;
}
.card.top .badge-free { left: auto; right: 6px; }

/* Top 10 */
.card.top { flex-basis: calc((100% - 4 * .4vw) / 5); background: none; display: flex; align-items: center; }
.card.top .num {
  font-size: clamp(5rem, 11vw, 12rem); font-weight: 900; line-height: .8; letter-spacing: -1.2vw;
  color: var(--bg); -webkit-text-stroke: 3px #595959; width: 50%; text-align: right;
}
.card.top img { width: 50%; aspect-ratio: 2/3; }
.card.top:hover { transform: scale(1.08); }
.card.top .card-info { display: none; }

/* Grid (tìm kiếm / danh sách) */
.grid-view { padding: 100px var(--pad) 3rem; min-height: 70vh; }
.grid-view h2 { font-size: 1.4rem; margin-bottom: 1.5rem; color: #e5e5e5; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4vw .5vw; }
.grid .card { flex: none; }
.empty { color: var(--muted); }

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.7);
  overflow-y: auto; padding: 2rem 1rem; display: flex; justify-content: center; align-items: flex-start;
  animation: fade .25s;
}
@keyframes fade { from { opacity: 0 } }
.modal-box {
  width: min(850px, 100%); background: var(--card); border-radius: 8px; overflow: hidden; position: relative;
  box-shadow: 0 3px 10px rgba(0,0,0,.75); animation: pop .3s;
}
@keyframes pop { from { transform: scale(.9); opacity: 0 } }
.modal-close {
  position: absolute; top: 1rem; right: 1rem; z-index: 5; width: 36px; height: 36px; border-radius: 50%;
  background: #181818; color: #fff; font-size: 1.1rem;
}
.modal-hero { position: relative; aspect-ratio: 16/9; background-size: cover; background-position: center; }
.modal-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, var(--card) 0%, transparent 50%); }
.modal-hero-content { position: absolute; left: 3rem; bottom: 2.5rem; z-index: 2; }
.modal-hero-content h2 { font-size: clamp(1.6rem, 4vw, 3rem); font-weight: 900; margin-bottom: 1.2rem; text-shadow: 2px 2px 6px #000; }
.modal-body { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; padding: 0 3rem 2rem; line-height: 1.5; }
.meta { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; color: #bcbcbc; flex-wrap: wrap; }
.modal-side { font-size: .85rem; color: #ddd; }
.modal-side p { margin-bottom: .7rem; }
.modal-side span { color: #777; }
.modal-similar { padding: 0 3rem 3rem; }
.modal-similar h3 { font-size: 1.5rem; margin-bottom: 1.2rem; }

/* ===== Episodes (Netflix-style) ===== */
.modal-episodes { padding: 0 3rem 2rem; }
.episodes-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; }
.episodes-bar h3 { font-size: 1.4rem; }
.season-select {
  background: #1a1a1a; color: #fff; border: 1px solid #444; border-radius: 4px;
  padding: .6rem 2.5rem .6rem 1rem; font-size: .9rem; font-family: inherit; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23fff' d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center;
}
.season-select:hover { border-color: #fff; }
.episode-list { max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; }
.episode-list::-webkit-scrollbar { width: 6px; }
.episode-list::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
.episode {
  display: flex; gap: 1rem; padding: .7rem; background: #1a1a1a; border-radius: 4px;
  cursor: pointer; transition: background .2s; border: 1px solid transparent;
}
.episode:hover { background: #2a2a2a; border-color: rgba(255,255,255,.1); }
.episode.watched { opacity: .75; }
.episode.watched:hover { opacity: 1; }
.ep-thumb { position: relative; flex-shrink: 0; width: 160px; aspect-ratio: 16/9; border-radius: 4px; overflow: hidden; background: #000; }
.ep-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ep-num {
  position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,.85);
  color: #fff; font-size: .72rem; font-weight: 700; padding: 1px 6px; border-radius: 2px;
}
.ep-watched-badge {
  position: absolute; top: 4px; right: 4px; background: var(--red); color: #fff;
  font-size: .72rem; font-weight: 700; width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.ep-progress-bar {
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: rgba(255,255,255,.2); z-index: 1;
}
.ep-progress-fill { height: 100%; background: var(--red); transition: width .3s; }
.episode.watched .ep-progress-fill { width: 100% !important; }
.ep-play-icon {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.4); opacity: 0; transition: opacity .2s;
}
.episode:hover .ep-play-icon { opacity: 1; }
.ep-play-icon svg { width: 36px; height: 36px; fill: #fff; }
.ep-info { flex: 1; min-width: 0; }
.ep-info-head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .3rem; }
.ep-info b { color: #fff; font-size: .95rem; }
.ep-info .ep-runtime { font-size: .75rem; color: #888; flex-shrink: 0; }
.ep-info p { font-size: .8rem; color: #aaa; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.similar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.sim { background: #2f2f2f; border-radius: 4px; overflow: hidden; cursor: pointer; }
.sim img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.sim div { padding: .8rem; font-size: .8rem; color: #d2d2d2; }
.sim b { display: block; color: #fff; font-size: .95rem; margin-bottom: .3rem; }

/* ===== Player ===== */
.player { position: fixed; inset: 0; background: #000; z-index: 80; }
.player-stage, .player-stage video, .player-stage iframe { width: 100%; height: 100%; border: 0; display: block; }
.player-back {
  position: absolute; top: 1.2rem; left: 1.2rem; z-index: 2; background: none; color: #fff;
  display: flex; align-items: center; gap: .8rem; font-size: 1.1rem; font-weight: 700; opacity: .85;
}
.player-back svg { width: 2.2rem; height: 2.2rem; }
.player-back:hover { opacity: 1; }

/* ===== Footer ===== */
.footer { max-width: 980px; margin: 0 auto; padding: 2rem var(--pad) 3rem; color: #808080; font-size: .8rem; }
.footer-links { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: 1.5rem; }
.footer a:hover { text-decoration: underline; }

/* ===== Responsive ===== */
@media (max-width: 1000px) {
  .hero { min-height: 560px; }
  .hero-content { bottom: 18%; width: 70%; }
}
@media (max-width: 1100px) { .card { flex-basis: calc((100% - 3 * .4vw) / 4); } .card.top { flex-basis: calc((100% - 2 * .4vw) / 3); } }
@media (max-width: 800px) {
  :root { --pad: 16px; }
  .card { flex-basis: calc((100% - 2 * 6px) / 3); }
  .card.top { flex-basis: 45%; }
  .card:hover { transform: none; }
  .card .card-info { display: none; }
  .card .card-label { font-size: .68rem; left: 5px; bottom: 4px; }
  .btn { padding: .55rem 1.1rem; white-space: nowrap; }
  .row-track { gap: 6px; }
  .hero-content { width: 85%; bottom: 22%; }
  .hero-age { display: none; }
  .rows { margin-top: 0; }
  .modal-body { grid-template-columns: 1fr; padding: 0 1.2rem 1.5rem; }
  .modal-hero-content { left: 1.2rem; bottom: 1rem; }
  .modal-similar { padding: 0 1.2rem 2rem; }
  .modal-episodes { padding: 0 1.2rem 1.5rem; }
  .ep-thumb { width: 120px; }
  .search.open input { width: 130px; }
  .footer-links { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 1rem 6px; }
}
