:root {
  --primary: #E50914;
  --accent: #FF5A5F;
  --bg: #0B0D17;
  --surface: #151927;
  --surface2: #1E2335;
  --line: #2A3046;
  --text: #EEF0F7;
  --muted: #8E95AB;
  --ok: #22C55E;
  --warn: #F59E0B;
  --bad: #F43F5E;
  --safe-x: 32px;
  --safe-y: 18px;
}

* { box-sizing: border-box; }
/* O app é desenhado num "palco" fixo de 1280x720 (resolução real da TV) e depois
   redimensionado (via transform: scale, feito em js/config.js) pra caber na tela
   de qualquer tamanho — assim não sobra um vazio preto quando testado num monitor
   maior, e continua certinho numa TV 1280x720 de verdade. */
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg); }
body { font-family: "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); }
#app { position: absolute; top: 0; left: 0; width: 1280px; height: 720px; overflow: hidden; transform-origin: 0 0; }

img { -webkit-user-drag: none; }
button, [data-focusable] { cursor: pointer; }

.screen { position: absolute; inset: 0; padding: var(--safe-y) var(--safe-x); display: flex; flex-direction: column; }
.screen.center { align-items: center; justify-content: center; text-align: center; }

.muted { color: var(--muted); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { height: 36px; }
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: .5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 2px solid transparent;
  background: var(--primary); color: #fff; font-size: 15px; font-weight: 700;
  outline: none; white-space: nowrap;
}
.btn.ghost { background: var(--surface2); color: var(--text); }
.btn.danger { background: var(--bad); }
.btn.is-focused, [data-focusable].is-focused { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,255,255,.08); transform: scale(1.04); }
.btn:disabled { opacity: .6; }

input.field {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 2px solid var(--line);
  background: var(--surface2); color: var(--text); font-size: 15px; outline: none;
}
input.field.is-focused { border-color: var(--accent); }
.label { font-size: 13px; color: var(--muted); margin-bottom: 4px; display: block; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }

.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 6px; }
.grow { flex: 1; }
.space-between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* ---------- layout principal ---------- */
.shell { display: flex; height: 100%; width: 100%; }
.sidebar {
  width: 190px; flex: 0 0 190px; background: var(--bg);
  display: flex; flex-direction: column; padding: 10px 10px; gap: 3px; overflow-y: auto; overflow-x: hidden;
}
.sidebar .brand { padding: 6px 6px 18px; }
.menu-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px;
  color: var(--muted); font-size: 14px; font-weight: 600; outline: none;
  box-shadow: 0 0 0 0 transparent; transition: background .15s, color .15s;
}
.menu-item .ic { font-size: 17px; width: 20px; text-align: center; }
.menu-item.active { color: #fff; background: var(--primary); }
.menu-item.is-focused { color: var(--text); box-shadow: 0 0 0 2px var(--accent) inset; }
.menu-item.active.is-focused { box-shadow: 0 0 0 2px #fff inset; }

.content { flex: 1; overflow-y: auto; padding: 18px 26px; min-width: 0; }
.content::-webkit-scrollbar { display: none; }

h1.page-title { font-size: 22px; margin: 0 0 14px; }
h2.row-title { font-size: 16px; margin: 18px 0 10px; color: var(--text); font-weight: 700; }

/* ---------- banner ---------- */
.banner { position: relative; width: 100%; height: 300px; border-radius: 16px; overflow: hidden; margin-bottom: 8px; background: var(--surface); }
.banner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.banner .shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.85) 10%, rgba(0,0,0,.15) 60%, transparent), linear-gradient(0deg, rgba(0,0,0,.75), transparent 55%); }
.banner .info { position: absolute; left: 24px; bottom: 22px; max-width: 60%; }
.banner .info .title { font-size: 26px; font-weight: 800; margin: 0 0 8px; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.banner .dots { position: absolute; right: 20px; bottom: 20px; display: flex; gap: 6px; }
.banner .dots span { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.35); }
.banner .dots span.on { background: #fff; }
.banner .info .eyebrow { color: var(--primary); font-weight: 800; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 6px; }

.avatar-circle { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; flex: 0 0 36px; }
.exp-badge { background: var(--surface2); border: 1px solid var(--line); border-radius: 20px; padding: 8px 16px; font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* ---------- grades ---------- */
.hrow { display: flex; gap: 14px; overflow: hidden; padding: 4px 2px 10px; }
.card-poster {
  flex: 0 0 150px; width: 150px; border-radius: 10px; overflow: hidden; border: 2px solid transparent;
  background: var(--surface2); outline: none;
}
.card-poster .thumb { width: 100%; height: 210px; object-fit: cover; background: var(--surface2); display: block; }
.card-poster .cap { padding: 7px 8px; font-size: 12.5px; line-height: 1.25; }
.card-poster.is-focused { border-color: var(--accent); transform: scale(1.06); z-index: 2; }
.card-poster .cap .muted { font-size: 11px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, 150px); gap: 14px; }

.chan-card {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; border: 2px solid transparent;
  background: var(--surface); width: 100%; text-align: left; outline: none;
}
.chan-card img { width: 40px; height: 40px; object-fit: contain; background: var(--surface2); border-radius: 6px; }
.chan-card .name { font-size: 13.5px; font-weight: 600; }
.chan-card .epg { font-size: 11.5px; color: var(--muted); }
.chan-card.is-focused { border-color: var(--accent); background: var(--surface2); }

.cat-pill {
  padding: 8px 14px; border-radius: 999px; background: var(--surface2); color: var(--muted); font-size: 13px;
  font-weight: 600; border: 2px solid transparent; outline: none; white-space: nowrap;
}
.cat-pill.active { color: var(--text); background: var(--primary); }
.cat-pill.is-focused { border-color: var(--accent); }

/* ---------- Filmes/Séries: categorias na lateral ---------- */
.vod-layout { display: flex; gap: 24px; align-items: flex-start; height: 100%; }
.vod-side { flex: 0 0 200px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; max-height: 100%; }
.vod-side::-webkit-scrollbar { display: none; }
.side-item {
  text-align: left; padding: 10px 14px; border-radius: 8px; color: var(--muted); font-size: 13.5px;
  font-weight: 600; border: 2px solid transparent; outline: none; background: transparent;
}
.side-item.active { color: var(--text); background: var(--surface2); border-color: var(--primary); }
.side-item.is-focused { border-color: var(--accent); }
.vod-main { flex: 1; min-width: 0; height: 100%; overflow-y: auto; }
.vod-main::-webkit-scrollbar { display: none; }
.vod-search {
  width: 100%; margin: 4px 0 18px; padding: 12px 16px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--line); color: var(--text); font-size: 14px; outline: none;
}
.vod-search:focus { border-color: var(--accent); }
.side-label { color: var(--muted); font-size: 11.5px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; padding: 4px 14px 8px; }

/* ---------- Canais: categorias | lista | player ---------- */
.live-layout { display: flex; gap: 18px; height: 100%; }
.chan-list-pane { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.chan-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; flex: 1; }
.chan-list::-webkit-scrollbar { display: none; }
.chan-card { position: relative; }
.chan-card.active { background: var(--surface2); }
.chan-card.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--primary); }
.live-stage { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.live-video-box { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 14px; overflow: hidden; flex: 0 0 auto; }
.live-video-box video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.live-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.live-info-bar { display: flex; align-items: center; gap: 14px; padding: 14px 2px; }
.live-info-bar .chan-icon { width: 46px; height: 46px; border-radius: 8px; background: var(--surface2); object-fit: contain; flex: 0 0 46px; }
.live-info-bar .meta { flex: 1; min-width: 0; }
.live-info-bar .meta .name { font-weight: 800; font-size: 16px; }
.live-info-bar .meta .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.live-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.live-action-btn {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px;
  border: 1.5px solid var(--line); background: transparent; color: var(--text); font-size: 13px; font-weight: 600; outline: none; white-space: nowrap;
}
.live-action-btn.active { border-color: var(--primary); color: var(--primary); }
.live-action-btn.is-focused { border-color: var(--accent); }
.live-tip { margin-top: 6px; background: var(--surface2); border-radius: 10px; padding: 10px 14px; font-size: 12px; color: var(--muted); }
.back-btn {
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface2); color: var(--text);
  font-size: 18px; display: flex; align-items: center; justify-content: center; outline: none; border: 2px solid transparent;
}
.back-btn.is-focused { border-color: var(--accent); }

/* ---------- player ---------- */
.player-wrap { position: fixed; inset: 0; background: #000; z-index: 50; }
.player-wrap video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.player-wrap video.cover { object-fit: cover; }
.player-wrap video.fill { object-fit: fill; }
.player-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end;
  background: linear-gradient(0deg, rgba(0,0,0,.8), transparent 40%, transparent 70%, rgba(0,0,0,.55));
  padding: 24px 32px;
}
.player-overlay .top { position: absolute; top: 20px; left: 32px; right: 32px; display: flex; justify-content: space-between; align-items: center; }
.player-title { font-size: 20px; font-weight: 800; margin: 0 0 4px; }
.player-sub { color: var(--muted); font-size: 13px; }
.player-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--muted); }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255,255,255,.2); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* controles custom do player (necessário pro controle remoto da TV — os controles
 * nativos do <video> não são navegáveis por seta/OK, só por toque/mouse) */
.player-controls { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 14px; }
.player-btn {
  width: 58px; height: 58px; border-radius: 50%; border: 2px solid transparent; background: var(--surface2);
  color: var(--text); font-size: 22px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.player-btn.is-focused { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,255,255,.08); transform: scale(1.08); }
.player-btn.main { width: 70px; height: 70px; font-size: 28px; background: var(--accent); color: #0B0D17; }
.player-progress { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--muted); padding: 8px 10px; border-radius: 8px; border: 2px solid transparent; }
.player-progress .bar { flex: 1; height: 5px; border-radius: 3px; background: rgba(255,255,255,.2); position: relative; overflow: hidden; }
.player-progress .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); width: 0%; }
/* a barra é larga, então foco nela não usa o "scale" genérico dos outros data-focusable (ficaria estranho) */
.player-progress.is-focused { border-color: var(--accent); background: rgba(255,255,255,.06); box-shadow: none; transform: none; }
html.is-mobile [data-focus-group="player-controls"] { display: none; } /* no toque, usa os controles nativos do <video> */

/* ---------- modal / pin ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal-box { width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }

.badge { display: inline-flex; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--surface2); color: var(--muted); }
.badge.locked { background: var(--bad); color: #fff; }

.toast { position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 70; }

.scroll-x { overflow-x: auto; }
.scroll-x::-webkit-scrollbar { display: none; }

.providers-row { display: flex; gap: 14px; }
.provider-pill { background: #fff; border-radius: 12px; padding: 10px 18px; display: flex; align-items: center; justify-content: center; height: 48px; border: 2px solid transparent; outline: none; }
.provider-pill img { height: 24px; max-width: 110px; object-fit: contain; }
.provider-pill.is-focused { border-color: var(--accent); }

.empty { color: var(--muted); padding: 30px 0; text-align: center; }

/* =====================================================================
   Modo celular/tablet (web iOS/Android) — html.is-mobile, ligado em
   js/config.js quando o toque é a entrada principal do aparelho.
   O layout de TV (palco fixo 1280x720 esticado por transform, menu lateral
   fixo, 3 colunas em Canais/Filmes) continua intacto pra Whale OS/PC; aqui
   só trocamos pra um layout fluido de app de celular, sem tocar em nada
   do que já funciona na TV. ========================================= */
html.is-mobile, html.is-mobile body { overflow: auto; }
html.is-mobile #app {
  position: relative; top: auto; left: auto;
  width: 100%; height: 100%;
  transform: none !important;
}
html.is-mobile .content, html.is-mobile .chan-list, html.is-mobile .vod-main,
html.is-mobile .vod-side, html.is-mobile .hrow { -webkit-overflow-scrolling: touch; }

/* Menu: de barra lateral pra barra inferior (padrão de app de celular),
   com espaço pra "home indicator"/notch do iPhone. */
html.is-mobile .shell { flex-direction: column; }
html.is-mobile .sidebar {
  order: 2; width: 100%; height: auto; flex: 0 0 auto;
  flex-direction: row; align-items: center; gap: 2px;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  overflow-x: auto; overflow-y: hidden; border-top: 1px solid var(--line);
}
html.is-mobile .sidebar .brand { display: none; }
html.is-mobile .menu-item {
  flex: 1 1 auto; flex-direction: column; justify-content: center; gap: 2px;
  padding: 6px 8px; font-size: 10px; white-space: nowrap;
}
html.is-mobile .menu-item .ic { font-size: 19px; width: auto; }
html.is-mobile .content {
  order: 1; flex: 1 1 auto;
  padding: calc(16px + env(safe-area-inset-top)) 14px 16px;
}

/* Focado-por-controle (seta do remote) não faz sentido no toque — desliga o
   efeito visual (senão o primeiro item aparece "selecionado" sem o usuário
   ter tocado nele) e devolve um foco simples pros campos de texto. */
html.is-mobile .is-focused, html.is-mobile [data-focusable].is-focused {
  transform: none !important; box-shadow: none !important; border-color: transparent !important;
}
html.is-mobile input.field:focus { border-color: var(--accent); }
html.is-mobile input.field, html.is-mobile .vod-search, html.is-mobile .btn,
html.is-mobile .cat-pill, html.is-mobile .side-item {
  font-size: 16px; /* evita o Safari dar zoom automático ao focar um campo com fonte < 16px */
}

/* Banner e grades de poster um pouco menores pra caber na largura do celular. */
html.is-mobile .banner { height: 190px; }
html.is-mobile .banner .info { max-width: 80%; left: 16px; bottom: 16px; }
html.is-mobile .banner .info .title { font-size: 20px; }
html.is-mobile .card-poster { flex: 0 0 118px; width: 118px; }
html.is-mobile .card-poster .thumb { height: 165px; }
html.is-mobile .grid { grid-template-columns: repeat(auto-fill, 118px); }

/* Tela de login/ativação: cartões pensados pra 420px de largura de TV
   precisam encolher pra caber numa tela de iPhone. */
html.is-mobile .screen.center .card { width: min(420px, calc(100vw - 32px)) !important; }

/* Filmes/Séries: categoria lateral vira uma fileira horizontal no topo,
   em vez de uma coluna ao lado (que não cabe num celular em pé). */
html.is-mobile .vod-layout { flex-direction: column; height: auto; gap: 14px; }
html.is-mobile .vod-side {
  flex: 0 0 auto !important; width: 100%; flex-direction: row;
  overflow-x: auto; overflow-y: hidden; max-height: none; gap: 6px;
}
html.is-mobile .vod-main { height: auto; overflow-y: visible; }

/* Canais: player em cima (é o que importa assistir), lista de canais depois,
   categorias por último — em vez das 3 colunas lado a lado da TV. */
html.is-mobile .live-layout { flex-direction: column; height: auto; gap: 14px; }
html.is-mobile .live-stage { order: -2; }
html.is-mobile .chan-list-pane { order: -1; flex: 0 0 auto !important; width: 100%; }
html.is-mobile .chan-list { max-height: 46vh; }
html.is-mobile .live-layout .vod-side { order: 0; }
html.is-mobile .live-tip { display: none; }

/* Player de filme/série/canal em tela cheia: afasta os controles do notch
   e do home indicator do iPhone. */
html.is-mobile .player-overlay {
  padding: 16px calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
html.is-mobile .player-overlay .top {
  top: calc(16px + env(safe-area-inset-top));
  left: calc(16px + env(safe-area-inset-left));
  right: calc(16px + env(safe-area-inset-right));
}
html.is-mobile .modal-box { width: calc(100vw - 32px); max-width: 420px; }
