:root {
  --bg: #0f1115;
  --bg-2: #1a1d24;
  --bg-3: #262a34;
  --text: #eceef2;
  --muted: #9aa0ad;
  --accent: #f5b921;
  --accent-text: #1a1400;
  --shopee: #ee4d2d;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px; line-height: 1.5;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.wrap { width: 100%; max-width: 900px; margin: 0 auto; padding: 0 12px; }
main { flex: 1; padding-bottom: 32px; }
.empty { padding: 60px 0; text-align: center; color: var(--muted); }

/* Header */
.header { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--bg-3); }
.header-in { display: flex; align-items: center; gap: 12px; height: 56px; }
.logo { font-size: 20px; font-weight: 800; color: var(--accent); white-space: nowrap; }
.search { flex: 1; }
.search input {
  width: 100%; padding: 9px 14px; border-radius: 20px; font-size: 15px;
  border: 1px solid var(--bg-3); background: var(--bg-2); color: var(--text); outline: none;
}
.search input:focus { border-color: var(--accent); }

/* Thể loại (cuộn ngang) */
.tags { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.tags::-webkit-scrollbar { display: none; }
.tag { flex-shrink: 0; padding: 6px 14px; border-radius: 16px; background: var(--bg-2); color: var(--muted); font-size: 14px; }
.tag.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }

.title { margin: 18px 0 12px; font-size: 18px; border-left: 4px solid var(--accent); padding-left: 10px; }

/* Lưới phim: 3 cột trên điện thoại */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 10px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 820px) { .grid { grid-template-columns: repeat(5, 1fr); } }
.card { display: block; min-width: 0; }
.poster {
  position: relative; aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; padding: 8px;
  text-align: center; font-weight: 700; font-size: 13px; color: rgba(255,255,255,.85);
}
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.badge {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  padding: 14px 6px 4px; font-size: 12px; font-weight: 600; text-align: center;
  background: linear-gradient(transparent, rgba(0,0,0,.85)); color: #fff;
}
.card-title {
  margin-top: 6px; font-size: 13px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Trang xem */
.player { margin: 0 -12px; background: #000; aspect-ratio: 16 / 9; }
@media (min-width: 600px) { .player { margin: 12px 0 0; border-radius: 10px; overflow: hidden; } }
.player iframe, .player video { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.player .no-ep { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.info h1 { margin: 12px 0 2px; font-size: 19px; line-height: 1.3; }
.info .sub { color: var(--muted); font-size: 14px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; font-size: 12px; }
.chip { padding: 2px 8px; border-radius: 4px; background: var(--bg-3); color: var(--muted); }
.chip.hl { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.desc { color: #c3c7cf; font-size: 14px; margin: 8px 0 0; }
.desc.short { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.more { background: none; border: 0; padding: 2px 0; color: var(--accent); font-size: 14px; }

.nav-ep { display: flex; gap: 8px; margin-top: 12px; }
.nav-ep a { flex: 1; text-align: center; padding: 10px; border-radius: 8px; background: var(--bg-2); font-weight: 600; }
.nav-ep a.next { background: var(--accent); color: var(--accent-text); }
.nav-ep a.off { opacity: .35; pointer-events: none; }

.eps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
@media (min-width: 600px) { .eps { grid-template-columns: repeat(10, 1fr); } }
.eps a { padding: 9px 0; text-align: center; border-radius: 6px; background: var(--bg-2); font-size: 14px; }
.eps a.on { background: var(--accent); color: var(--accent-text); font-weight: 700; }

.btn { display: inline-block; padding: 11px 22px; border-radius: 24px; border: 0; font-weight: 700; background: var(--accent); color: var(--accent-text); }

.footer { border-top: 1px solid var(--bg-3); padding: 16px 0 calc(16px + env(safe-area-inset-bottom)); color: var(--muted); font-size: 13px; text-align: center; }

/* Popup quảng cáo */
.popup {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.popup[hidden] { display: none; }
.popup-box {
  position: relative; width: 100%; max-width: 380px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: #fff; color: #1f2328; border-radius: 22px; padding: 26px 20px 18px;
  text-align: center; animation: pop .25s ease-out;
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.qc-x {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px;
  border-radius: 50%; border: 2px solid #1f2328; background: #fff; color: #1f2328;
  font-size: 18px; font-weight: 700; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.qc-msg { margin: 4px 26px 14px; font-size: 16px; font-weight: 700; line-height: 1.45; }
.qc-pill {
  display: inline-block; max-width: 100%; margin-bottom: 14px; padding: 4px 14px;
  border: 1.5px solid #1e8a4c; border-radius: 16px; color: #1e8a4c;
  font-family: ui-monospace, Consolas, monospace; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qc-img { display: block; width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; margin-bottom: 12px; }
.qc-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 14px;
  background: #eef0ec; border-radius: 12px; text-align: left;
}
.qc-title { flex: 1; color: #e2452b; font-weight: 700; font-size: 15px; line-height: 1.35; }
.qc-qr { flex-shrink: 0; width: 76px; height: 76px; background: #fff; padding: 4px; border-radius: 4px; }
.qc-qr img, .qc-qr canvas { display: block; width: 100% !important; height: 100% !important; }
.qc-btn {
  display: block; padding: 14px 12px; border-radius: 12px; background: #1e8a4c; color: #fff;
  font-weight: 700; font-size: 16px; word-break: break-all;
  box-shadow: 0 3px 0 #146337;
}
.qc-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #146337; }
.qc-note { margin: 12px 4px 0; font-size: 13px; color: #6b7078; line-height: 1.45; }
