:root {
  --bg: #0a0a0f;
  --surface: #15151d;
  --surface-2: #1e1e28;
  --text: #f4f4f7;
  --muted: #9b9ba8;
  --accent: #e50914;
  --accent-2: #ff7a45;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

/* Garante que o atributo hidden sempre vença qualquer display do CSS */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; overflow-x: hidden; }
body.no-scroll { overflow: hidden; }

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

/* ---------- Foco visível (essencial para TV) ---------- */
[data-focusable]:focus {
  outline: 4px solid #ffffff;
  outline-offset: 4px;
  box-shadow: 0 0 0 8px rgba(229, 9, 20, .45), 0 12px 30px rgba(0, 0, 0, .6);
  z-index: 5;
  position: relative;
}

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 74px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 clamp(16px, 4vw, 56px);
  background: linear-gradient(180deg, rgba(10, 10, 15, .97), rgba(10, 10, 15, .78));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 9px; font-size: 15px; color: #fff; padding-left: 3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(229, 9, 20, .4);
}
.brand-name { font-size: 21px; font-weight: 800; letter-spacing: -.5px; }
.accent { color: var(--accent); }

.main-nav { display: flex; gap: 4px; }
.nav-link {
  border: 0; background: transparent; color: var(--muted);
  padding: 10px 16px; border-radius: 10px; font-size: 15px; font-weight: 600;
  transition: color .15s, background .15s;
}
.nav-link:hover, .nav-link.active { color: var(--text); background: rgba(255, 255, 255, .07); }

.search-box {
  margin-left: auto; position: relative; width: clamp(160px, 26vw, 340px);
}
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 22px; pointer-events: none; line-height: 1;
}
.search-box input {
  width: 100%; height: 42px; padding: 0 14px 0 42px;
  border-radius: 10px; border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .06); color: var(--text); outline: none;
  font-size: 14px;
}
.search-box input::placeholder { color: var(--muted); }
.search-box input:focus { border-color: var(--accent); background: rgba(255, 255, 255, .1); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 46px; padding: 0 24px; border-radius: 10px; border: 0;
  font-size: 15px; font-weight: 700; text-decoration: none;
  transition: transform .15s, filter .15s, background .15s;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.12); }
.btn.primary {
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 22px rgba(229, 9, 20, .35);
}
.btn.ghost { color: var(--text); background: rgba(255, 255, 255, .12); }
.btn.ghost:hover { background: rgba(255, 255, 255, .2); }

.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .65); color: #fff; font-size: 17px;
  display: grid; place-items: center;
}
.icon-btn:hover { background: rgba(0, 0, 0, .85); }

/* ---------- Destaque ---------- */
.hero {
  position: relative; min-height: min(68vh, 620px);
  display: flex; align-items: flex-end;
  padding: clamp(24px, 5vw, 70px);
  overflow: hidden;
  background: radial-gradient(circle at 75% 30%, #2a1020 0%, transparent 55%), #101018;
}
.hero-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center 25%;
  filter: saturate(1.05);
  transform: scale(1.02);
}
.hero-fade {
  position: absolute; inset: 0;
  background:
    linear-gradient(0deg, var(--bg) 2%, rgba(10, 10, 15, .6) 40%, transparent 75%),
    linear-gradient(90deg, rgba(10, 10, 15, .92) 0%, rgba(10, 10, 15, .35) 55%, transparent 100%);
}
.hero-content { position: relative; z-index: 2; max-width: 640px; }
.hero-badge {
  display: inline-block; margin-bottom: 16px; padding: 5px 12px;
  border-radius: 6px; font-size: 11px; font-weight: 800; letter-spacing: 2px;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.hero h1 {
  margin: 0 0 12px; font-size: clamp(36px, 6vw, 76px); line-height: 1.02;
  letter-spacing: -2px; font-weight: 850;
  text-shadow: 0 4px 30px rgba(0, 0, 0, .7);
}
.hero-meta { color: #e3e3ea; font-size: 15px; font-weight: 600; margin-bottom: 18px; }
.hero-desc {
  margin: 0 0 26px; color: #d0d0d9; font-size: clamp(14px, 1.6vw, 17px);
  line-height: 1.6; max-width: 560px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- Fileiras ---------- */
.rows { padding: 8px 0 40px; }
.row { margin: 0 0 38px; padding-left: clamp(16px, 4vw, 56px); }
.row-title {
  margin: 0 0 16px; font-size: clamp(19px, 2.2vw, 26px); font-weight: 750;
  letter-spacing: -.5px;
}
.row-title::before {
  content: ""; display: inline-block; width: 4px; height: 22px;
  background: linear-gradient(var(--accent), var(--accent-2));
  border-radius: 3px; margin-right: 12px; vertical-align: -3px;
}
.row-track {
  display: flex; gap: 16px; overflow-x: auto; padding: 10px 14px 22px 2px;
  scroll-snap-type: x mandatory; scrollbar-width: none;
  scroll-padding-left: 2px;
}
.row-track::-webkit-scrollbar { display: none; }

.card {
  position: relative;
  flex: 0 0 auto; width: clamp(132px, 15vw, 210px);
  padding: 0; border: 0; background: transparent; color: inherit;
  scroll-snap-align: start; text-align: left;
  transition: transform .18s ease;
}
.card:hover { transform: translateY(-5px); }
.card:focus { transform: scale(1.06); }

.card-placeholder {
  position: relative; width: 100%; aspect-ratio: 2 / 3;
  border-radius: var(--radius); overflow: hidden;
  background:
    linear-gradient(145deg, #2c1830 0%, #1b1b2a 55%, #101019 100%);
  display: grid; place-items: center;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .45);
  background-size: cover; background-position: center;
}
.card-placeholder > span {
  font-size: clamp(38px, 5vw, 68px); font-weight: 900;
  color: rgba(255, 255, 255, .12); letter-spacing: -4px;
}
.card-shade {
  position: absolute; inset: 0;
  background: linear-gradient(0deg, rgba(0, 0, 0, .85), transparent 55%);
}
.card-top { position: absolute; left: 10px; top: 10px; }
.type-badge {
  display: inline-block; padding: 3px 8px; border-radius: 5px;
  font-size: 10px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  color: #fff; background: rgba(0, 0, 0, .75); border: 1px solid rgba(255, 255, 255, .25);
}
.type-badge.series { background: rgba(88, 74, 200, .9); border-color: #8f7fff; }
.type-badge.anime { background: rgba(210, 55, 120, .9); border-color: #ff8ec4; }
.card-info { position: absolute; left: 12px; right: 12px; bottom: 11px; }
.card-title {
  font-size: 14px; font-weight: 750; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  text-shadow: 0 2px 8px #000;
}
.card-meta { font-size: 11px; color: #c9c9d3; margin-top: 3px; }
.progress {
  position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: rgba(255, 255, 255, .22);
}
.progress i { display: block; height: 100%; background: var(--accent); }

.search-heading {
  padding: 44px clamp(16px, 4vw, 56px) 6px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.search-heading h1 { margin: 0; font-size: 30px; }

.empty-state {
  padding: 80px 24px; text-align: center; color: var(--muted);
}
.empty-state strong { display: block; color: var(--text); font-size: 22px; margin-bottom: 10px; }

.footer {
  border-top: 1px solid rgba(255, 255, 255, .06);
  padding: 26px clamp(16px, 4vw, 56px);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  color: var(--muted); font-size: 13px;
}

/* ---------- Modal de detalhes ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.overlay[hidden] { display: none; }
.overlay-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .8); backdrop-filter: blur(6px); }
.detail-card {
  position: relative; z-index: 1; width: min(880px, 100%);
  max-height: 90vh; overflow: auto;
  background: var(--surface); border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 20px; box-shadow: var(--shadow);
}
.detail-close { position: absolute; top: 18px; right: 18px; z-index: 3; }
.detail-hero {
  position: relative; min-height: 300px; padding: 36px;
  display: flex; align-items: flex-end;
  background: linear-gradient(135deg, #2a1020, #181824);
  background-size: cover; background-position: center 25%;
}
.detail-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(0deg, var(--surface), rgba(21, 21, 29, .25));
}
.detail-hero > * { position: relative; z-index: 1; }
.detail-hero h2 { margin: 0 0 10px; font-size: clamp(28px, 4vw, 46px); line-height: 1.05; }
.detail-meta { color: #dddde6; font-weight: 600; font-size: 14px; }
.detail-body { padding: 10px 36px 36px; }
.detail-body p { color: #c5c5d0; line-height: 1.7; font-size: 15px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

/* ---------- Temporadas e episódios ---------- */
.seasons { margin-top: 30px; border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 22px; }
.seasons h3 { margin: 0 0 14px; font-size: 19px; }
.season-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.season-tab {
  padding: 9px 16px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .05); color: var(--muted); font-weight: 700; font-size: 13px;
}
.season-tab.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
.episode-list { display: grid; gap: 8px; }
.episode {
  display: flex; align-items: center; gap: 16px; width: 100%; text-align: left;
  padding: 12px 16px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .04); color: var(--text);
  transition: background .15s, transform .15s;
}
.episode:hover { background: rgba(255, 255, 255, .1); transform: translateX(3px); }
.ep-num { font-size: 20px; font-weight: 800; color: var(--accent); min-width: 34px; }
.ep-info { flex: 1; min-width: 0; }
.ep-info strong { display: block; font-size: 14px; }
.ep-info small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.ep-progress { width: 70px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.2); overflow: hidden; }
.ep-progress i { display: block; height: 100%; background: var(--accent); }
.ep-play { color: var(--muted); }
.muted { color: var(--muted); }

/* ---------- Player ---------- */
.player {
  position: fixed; inset: 0; z-index: 80; background: #000;
  display: flex; flex-direction: column;
}
.player[hidden] { display: none; }
.player-bar {
  flex: 0 0 auto; min-height: 60px; padding: 10px 20px;
  display: flex; align-items: center; gap: 18px;
  background: #08080c;
}
.player-bar .icon-btn { width: auto; border-radius: 10px; padding: 0 16px; font-size: 14px; gap: 8px; display: flex; }
.player-title { font-weight: 700; font-size: 16px; }
.player-hint { margin-left: auto; color: var(--muted); font-size: 12px; }
#video { flex: 1; width: 100%; min-height: 0; background: #000; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px);
  z-index: 100; padding: 13px 22px; border-radius: 10px;
  background: #24242f; color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsivo ---------- */
@media (max-width: 760px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 10px 16px; padding: 12px 16px; }
  .main-nav { order: 3; width: 100%; }
  .search-box { width: 100%; margin-left: 0; }
  .hero { min-height: 56vh; padding: 24px 20px; }
  .hero h1 { font-size: 38px; letter-spacing: -1px; }
  .row { padding-left: 16px; }
  .player-hint { display: none; }
  .detail-hero { padding: 26px 22px; min-height: 240px; }
  .detail-body { padding: 10px 22px 26px; }
  .footer { flex-direction: column; }
}

/* TV: mais espaço e foco ainda mais forte */
@media (min-width: 1600px) {
  .card { width: 230px; }
  [data-focusable]:focus { outline-width: 6px; }
}
