:root {
  --bg: #140a17;
  --bg2: #1d0f22;
  --card: #26132c;
  --line: rgba(255, 140, 200, .16);
  --text: #fff3f9;
  --muted: #c9a9bd;
  --pink: #ff4fa3;
  --pink2: #ff8cc8;
  --rose: #ffc2df;
  --gold: #ffd36e;
  --blue: #5b8cff;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --font: 'Prompt', system-ui, sans-serif;
  --display: 'Mitr', 'Prompt', sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(255, 79, 163, .22), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(91, 140, 255, .12), transparent 60%),
    var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}
body.lock { overflow: hidden; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#sparkles { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
main, .topbar, .footer { position: relative; z-index: 1; }

/* ---------- Intro ---------- */
.intro {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-content: center; justify-items: center; gap: 22px;
  background: radial-gradient(circle at center, #3a1233, var(--bg) 70%);
  animation: introOut .7s ease 2.1s forwards;
}
.intro-logo { position: relative; width: min(46vw, 230px); aspect-ratio: 1; animation: pop 1s cubic-bezier(.2, 1.6, .4, 1) both; }
.intro-logo img { position: absolute; inset: 8px; border-radius: 50%; width: calc(100% - 16px); }
.intro-logo .ring, .logo-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--pink), var(--gold), var(--blue), var(--pink2), var(--pink));
  animation: spin 2.6s linear infinite;
  filter: blur(.5px);
}
.intro-logo .ring::after, .logo-ring::after {
  content: ''; position: absolute; inset: -14px; border-radius: 50%;
  background: inherit; filter: blur(22px); opacity: .55; z-index: -1;
}
.intro-text {
  font-family: var(--display); font-size: clamp(26px, 6vw, 42px); font-weight: 600;
  background: linear-gradient(90deg, var(--rose), var(--pink), var(--gold), var(--pink));
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 2s linear infinite, rise .8s .35s both;
}
@keyframes pop { from { transform: scale(.2) rotate(-25deg); opacity: 0; } }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shine { to { background-position: 300% 0; } }
@keyframes introOut { to { opacity: 0; visibility: hidden; transform: scale(1.08); } }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px clamp(16px, 4vw, 48px);
  background: rgba(20, 10, 23, .72);
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid transparent;
  transition: border-color .3s, background .3s;
}
.topbar.scrolled { border-color: var(--line); background: rgba(20, 10, 23, .9); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; flex-shrink: 0; }
.logo-wrap { position: relative; width: 58px; height: 58px; display: block; transition: transform .5s cubic-bezier(.2, 1.4, .4, 1); }
.logo-wrap .logo { position: absolute; inset: 3px; width: 52px; height: 52px; border-radius: 50%; animation: float 3.5s ease-in-out infinite; }
.logo-ring { animation-duration: 4s; }
.logo-crown {
  position: absolute; top: -12px; left: -6px; font-size: 20px;
  transform: rotate(-25deg); filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
  animation: bob 2.4s ease-in-out infinite;
}
.brand:hover .logo-wrap { transform: scale(1.12) rotate(-8deg); }
.brand:hover .logo-ring { animation-duration: 1s; }
.logo-wrap.wiggle { animation: wiggle .6s ease; }
@keyframes float { 50% { transform: translateY(-2px); } }
@keyframes bob { 50% { transform: rotate(-15deg) translateY(-3px); } }
@keyframes wiggle { 25% { transform: rotate(14deg) scale(1.1); } 50% { transform: rotate(-12deg) scale(1.15); } 75% { transform: rotate(6deg); } }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--display); font-weight: 600; font-size: 22px; letter-spacing: .3px; }
.brand-text em {
  font-style: normal;
  background: linear-gradient(90deg, var(--pink), var(--gold), var(--pink2), var(--pink));
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 4s linear infinite;
}
.brand-text small { color: var(--muted); font-size: 12px; }

.search {
  flex: 1; max-width: 460px; margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 14px; height: 44px;
  transition: border-color .25s, box-shadow .25s, background .25s;
}
.search:focus-within { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(255, 79, 163, .18); background: rgba(255, 255, 255, .09); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--pink2); stroke-width: 2.2; stroke-linecap: round; flex-shrink: 0; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font: inherit; font-size: 15px; }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.clear { background: none; border: 0; color: var(--muted); padding: 4px; }

.icon-btn {
  position: relative; width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255, 79, 163, .12); border: 1px solid var(--line); color: var(--pink2); font-size: 18px;
  transition: transform .2s, background .2s;
}
.icon-btn:hover { transform: scale(1.08); background: rgba(255, 79, 163, .25); }
.icon-btn.active { background: var(--pink); color: #fff; }
.icon-btn b {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--gold); color: #3a1233; font-size: 11px; line-height: 20px;
}

/* ---------- Hero ---------- */
main { padding: 0 clamp(16px, 4vw, 48px) 40px; }
.hero {
  position: relative; margin: 20px 0 8px; border-radius: 28px; overflow: hidden;
  min-height: 380px; border: 1px solid var(--line); box-shadow: var(--shadow);
  isolation: isolate;
}
.hero-bg {
  position: absolute; inset: -30px; z-index: -2;
  background-size: cover; background-position: center;
  filter: blur(28px) saturate(140%) brightness(.55);
  transform: scale(1.1); transition: background-image .6s;
}
.hero::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, rgba(20, 10, 23, .95) 0%, rgba(20, 10, 23, .6) 55%, rgba(20, 10, 23, .1));
}
.hero-inner { display: flex; align-items: center; gap: 32px; padding: clamp(24px, 5vw, 56px); }
.hero-info { flex: 1; min-width: 0; animation: rise .6s both; }
.hero-info.swap { animation: none; }
.hero .hero-title { font-family: var(--display); font-weight: 600; font-size: clamp(26px, 4.2vw, 48px); margin: 14px 0 6px; line-height: 1.2; text-wrap: balance; }
.meta { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.desc { color: #e9d3df; line-height: 1.7; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; max-width: 640px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.hero-poster {
  width: clamp(150px, 20vw, 230px); aspect-ratio: 3/4; border-radius: 18px; flex-shrink: 0;
  background: var(--card) center/cover; box-shadow: 0 20px 60px rgba(255, 79, 163, .35);
  transform: rotate(3deg); transition: transform .5s; animation: rise .6s .1s both;
}
.hero:hover .hero-poster { transform: rotate(0) scale(1.03); }
.hero-dots { position: absolute; bottom: 16px; left: clamp(24px, 5vw, 56px); display: flex; gap: 8px; }
.hero-dots button { width: 10px; height: 10px; border-radius: 999px; border: 0; padding: 0; background: rgba(255, 255, 255, .3); transition: width .3s, background .3s; }
.hero-dots button.on { width: 28px; background: var(--pink); }

.pill { display: inline-block; padding: 5px 12px; border-radius: 999px; font-size: 13px; background: rgba(255, 79, 163, .18); color: var(--rose); border: 1px solid rgba(255, 79, 163, .35); }
.pill.glow { animation: glow 2s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 18px rgba(255, 79, 163, .55); } }

.btn {
  border: 0; border-radius: 999px; padding: 12px 24px; font-weight: 500; font-size: 15px;
  transition: transform .2s, box-shadow .2s, background .2s; position: relative; overflow: hidden;
}
.btn.sm { padding: 9px 16px; font-size: 14px; }
.btn.primary { background: linear-gradient(135deg, var(--pink), #ff6fb5 60%, var(--gold)); color: #fff; box-shadow: 0 8px 24px rgba(255, 79, 163, .4); }
.btn.primary::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-120%);
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .45), transparent 70%);
}
.btn.primary:hover::after { transform: translateX(120%); transition: transform .7s; }
.btn.ghost { background: rgba(255, 255, 255, .08); border: 1px solid var(--line); }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; pointer-events: none; }

/* ---------- แถบเลือกแอป ---------- */
.apps { display: flex; gap: 10px; overflow-x: auto; padding: 16px 2px 4px; scrollbar-width: none; }
.apps::-webkit-scrollbar { display: none; }
.app {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px; position: relative;
  padding: 6px 14px 6px 6px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line); color: var(--text);
  transition: transform .2s, border-color .2s, background .2s, box-shadow .2s;
}
.app img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: #fff1; }
.app:hover { transform: translateY(-2px); border-color: var(--pink); }
.app.on {
  background: linear-gradient(135deg, rgba(255, 79, 163, .35), rgba(255, 211, 110, .18));
  border-color: var(--pink); box-shadow: 0 6px 20px rgba(255, 79, 163, .3);
}
.app.on img { box-shadow: 0 0 0 2px var(--pink); }
.app.off { opacity: .55; }
.app small { font-size: 11px; color: #ff9aa8; }

/* ---------- Genres ---------- */
.genres {
  display: flex; gap: 8px; overflow-x: auto; padding: 18px 2px 6px; scrollbar-width: none;
  position: sticky; top: 82px; z-index: 10;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.genres::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 8px 16px; border-radius: 999px; font-size: 14px;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line); color: var(--rose);
  transition: all .2s;
}
.chip small { opacity: .6; margin-left: 4px; }
.chip:hover { border-color: var(--pink); background: rgba(255, 79, 163, .12); }
.chip.on { background: linear-gradient(135deg, var(--pink), #ff79b9); color: #fff; border-color: transparent; box-shadow: 0 6px 18px rgba(255, 79, 163, .35); }

/* ---------- Sections & cards ---------- */
.row-section { margin-top: 22px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-title { font-family: var(--display); font-weight: 500; font-size: 22px; margin: 0 0 14px; }
.section-title span { margin-right: 6px; }
.count { color: var(--muted); font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px 16px; }
.hrow { display: grid; grid-auto-flow: column; grid-auto-columns: 150px; gap: 14px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; scrollbar-color: var(--pink) transparent; }

.card { position: relative; cursor: pointer; perspective: 800px; animation: rise .5s both; outline: none; }
.card .poster {
  position: relative; aspect-ratio: 3/4; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(135deg, #3b1838, #241029);
  transform-style: preserve-3d; transition: transform .25s ease-out, box-shadow .3s;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .35);
}
.card img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s, opacity .4s; opacity: 0; }
.card img.loaded { opacity: 1; }
.card:hover .poster, .card:focus-visible .poster { box-shadow: 0 16px 40px rgba(255, 79, 163, .35), 0 0 0 2px var(--pink); }
.card:hover img { transform: scale(1.07); }
.card .shine {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .35), transparent 45%);
}
.card:hover .shine { opacity: 1; }
.card .play {
  position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity .3s;
  background: linear-gradient(transparent 40%, rgba(20, 10, 23, .85));
}
.card .play span {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 18px;
  background: rgba(255, 79, 163, .9); box-shadow: 0 0 0 8px rgba(255, 79, 163, .25);
  transform: scale(.6); transition: transform .35s cubic-bezier(.2, 1.6, .4, 1);
}
.card:hover .play { opacity: 1; }
.card:hover .play span { transform: scale(1); }
.badge {
  position: absolute; top: 8px; left: 8px; padding: 3px 9px; border-radius: 999px; font-size: 12px;
  background: rgba(20, 10, 23, .78); backdrop-filter: blur(6px); border: 1px solid var(--line);
}
.badge.fav { left: auto; right: 8px; color: var(--pink); }
.card h4 { margin: 10px 2px 2px; font-weight: 500; font-size: 15px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card p { margin: 0 2px; color: var(--muted); font-size: 12.5px; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .2); }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--gold)); }

.skeleton .poster { background: linear-gradient(100deg, #26132c 30%, #3a1d40 50%, #26132c 70%); background-size: 300% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton h4 { height: 14px; width: 80%; border-radius: 6px; background: #2c1632; }
@keyframes shimmer { to { background-position: -300% 0; } }

.status { text-align: center; color: var(--muted); padding: 26px 10px; }
.status .big { font-size: 46px; display: block; margin-bottom: 8px; }
.status code { background: rgba(255, 255, 255, .08); padding: 2px 8px; border-radius: 6px; color: var(--gold); }
.loader { display: inline-flex; gap: 6px; }
.loader i { width: 10px; height: 10px; border-radius: 50%; background: var(--pink); animation: bounce .9s infinite ease-in-out; }
.loader i:nth-child(2) { animation-delay: .15s; background: var(--pink2); }
.loader i:nth-child(3) { animation-delay: .3s; background: var(--gold); }
@keyframes bounce { 50% { transform: translateY(-10px); } }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 3, 10, .75); backdrop-filter: blur(8px); animation: fade .25s both; }
.modal-card {
  position: relative; width: min(980px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow);
  animation: modalIn .4s cubic-bezier(.2, 1.3, .4, 1) both; scrollbar-width: thin; scrollbar-color: var(--pink) transparent;
}
@keyframes fade { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(30px) scale(.96); } }
.close {
  position: absolute; top: 14px; right: 14px; z-index: 3; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(20, 10, 23, .7); font-size: 16px; transition: transform .25s, background .25s;
}
.close.static { position: static; flex-shrink: 0; }
.close:hover { transform: rotate(90deg); background: var(--pink); }

.detail { padding: 0 0 26px; overflow-x: hidden; }
.detail-bg { height: 160px; background: center/cover; filter: blur(20px) brightness(.6) saturate(140%); transform: scale(1.2); }
.detail-top { display: flex; gap: 26px; padding: 0 28px; margin-top: -110px; position: relative; }
.detail-poster { width: 190px; aspect-ratio: 3/4; flex-shrink: 0; border-radius: 18px; background: var(--card) center/cover; box-shadow: 0 16px 40px rgba(0, 0, 0, .55); border: 2px solid rgba(255, 255, 255, .12); }
.detail-info { padding-top: 120px; min-width: 0; }
.detail-info h2 { font-family: var(--display); font-weight: 600; font-size: clamp(22px, 3vw, 32px); margin: 0 0 6px; line-height: 1.25; }
.detail-info .desc { -webkit-line-clamp: 6; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tags span { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: rgba(91, 140, 255, .15); color: #b9cbff; border: 1px solid rgba(91, 140, 255, .3); }
#dFav.on { background: rgba(255, 79, 163, .2); color: var(--pink2); border-color: var(--pink); }

.ep-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 26px 28px 12px; }
.ep-head h3 { margin: 0; font-family: var(--display); font-weight: 500; }
.ep-ranges { display: flex; gap: 6px; flex-wrap: wrap; }
.ep-ranges button { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: none; font-size: 13px; color: var(--muted); }
.ep-ranges button.on { background: var(--pink); color: #fff; border-color: transparent; }
.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; padding: 0 28px; }
.ep-grid button {
  height: 44px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04);
  font-weight: 500; transition: all .2s; position: relative;
}
.ep-grid button:hover { border-color: var(--pink); background: rgba(255, 79, 163, .14); transform: translateY(-2px); }
.ep-grid button.watched { color: var(--muted); }
.ep-grid button.watched::after { content: ''; position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.ep-grid button.now { background: linear-gradient(135deg, var(--pink), #ff79b9); color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(255, 79, 163, .4); }
.ep-grid.compact { padding: 0 18px 18px; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); max-height: 150px; overflow: auto; }
.ep-grid.compact button { height: 38px; font-size: 14px; }

.player-modal { padding: 12px; }
/* วิดีโอเป็นแนวตั้ง (9:16) → วางวิดีโอซ้าย แผงควบคุมขวา */
.player {
  width: min(960px, 100%); display: grid; overflow: hidden;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas: "video head" "video bar" "video eps";
}
.player .video-box { grid-area: video; height: min(86vh, 820px); aspect-ratio: 9 / 16; }
.player .video-box video { width: 100%; height: 100%; max-height: none; aspect-ratio: auto; object-fit: contain; }
.player-head { grid-area: head; }
.player-bar { grid-area: bar; }
.player .ep-grid.compact { grid-area: eps; max-height: none; align-content: start; padding-top: 4px; }
.player-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 18px; }
.player-head h3 { margin: 0; font-family: var(--display); font-weight: 500; font-size: 18px; }
.player-head small { color: var(--pink2); }
.video-box { position: relative; background: #000; }
.video-box video { width: 100%; aspect-ratio: 16/9; max-height: 70vh; display: block; background: #000; }
.video-msg { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 10px; padding: 20px; color: var(--rose); background: rgba(0, 0, 0, .7); }
.player-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; flex-wrap: wrap; }
.autonext { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; cursor: pointer; }
.autonext input { accent-color: var(--pink); width: 18px; height: 18px; }

/* ---------- กระดานเครดิตร้าน ---------- */
.credit {
  position: relative; margin-top: 22px; display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); gap: 28px; align-items: center;
  padding: 18px; border-radius: 26px; isolation: isolate;
  background: linear-gradient(135deg, rgba(255, 79, 163, .16), rgba(255, 211, 110, .08) 60%, rgba(91, 140, 255, .08));
  border: 1px solid rgba(255, 140, 200, .3); box-shadow: 0 18px 50px rgba(255, 79, 163, .18);
}
/* ขอบเรืองแสงวิ่งรอบกระดาน */
.credit::before {
  content: ''; position: absolute; inset: -2px; z-index: -1; border-radius: 28px; padding: 2px;
  background: conic-gradient(from var(--ang, 0deg), var(--pink), var(--gold), var(--pink2), var(--blue), var(--pink));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spinBorder 6s linear infinite; opacity: .8;
}
@property --ang { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@keyframes spinBorder { to { --ang: 360deg; } }
.credit-img { display: block; border-radius: 18px; overflow: hidden; box-shadow: 0 14px 36px rgba(0, 0, 0, .45); transition: transform .35s cubic-bezier(.2, 1.4, .4, 1); }
.credit-img img { width: 100%; height: auto; display: block; }
.credit-img:hover { transform: scale(1.02) rotate(-.4deg); }
.credit-info h2 { font-family: var(--display); font-weight: 600; font-size: clamp(22px, 2.6vw, 32px); margin: 12px 0 8px; line-height: 1.25; }
.credit-info h2 em { font-style: normal; color: var(--gold); }
.credit-score { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.credit-score .stars { color: var(--gold); font-size: 22px; letter-spacing: 2px; text-shadow: 0 0 12px rgba(255, 211, 110, .5); }
.credit-score b { font-size: 16px; padding: 3px 12px; border-radius: 999px; background: rgba(74, 222, 128, .15); color: #b7f5cc; }
.credit-points { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 8px; color: #ecd6e2; font-size: 15px; }
.credit-points b { color: var(--rose); font-weight: 500; }
.credit-btn { display: inline-block; text-decoration: none; font-size: 16px; padding: 14px 26px; }

/* ---------- โปรโมชั่น ---------- */
.promo-section { margin-top: 24px; }
.hot {
  font-style: normal; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; margin-left: 6px; vertical-align: middle;
  background: linear-gradient(135deg, #ff3d6e, var(--gold)); color: #fff; animation: glow 1.6s ease-in-out infinite;
}
.promo-all { color: var(--pink2); text-decoration: none; font-size: 14px; white-space: nowrap; }
.promo-all:hover { text-decoration: underline; }
.promo-row {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 280px); gap: 16px;
  overflow-x: auto; padding: 4px 2px 14px; scroll-snap-type: x mandatory; scrollbar-width: thin; scrollbar-color: var(--pink) transparent;
}
.promo-card {
  position: relative; display: block; border-radius: 20px; overflow: hidden; scroll-snap-align: start;
  background: var(--card); border: 1px solid var(--line); text-decoration: none; color: inherit;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4); transition: transform .3s cubic-bezier(.2, 1.4, .4, 1), box-shadow .3s;
  animation: rise .5s both;
}
.promo-card img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; display: block; transition: transform .6s; }
.promo-card:hover { transform: translateY(-6px) rotate(-.6deg); box-shadow: 0 18px 44px rgba(255, 79, 163, .45), 0 0 0 2px var(--pink); }
.promo-card:hover img { transform: scale(1.04); }
.promo-card::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, .35) 50%, transparent 65%);
  transform: translateX(-120%); animation: sweep 4.5s ease-in-out infinite;
}
.promo-card:nth-child(2)::after { animation-delay: 1.5s; }
.promo-card:nth-child(3)::after { animation-delay: 3s; }
@keyframes sweep { 0%, 60% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
.promo-card .buy {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); white-space: nowrap;
  padding: 10px 22px; border-radius: 999px; font-weight: 600; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, var(--pink), #ff6fb5 60%, var(--gold)); box-shadow: 0 8px 24px rgba(255, 79, 163, .55);
  animation: pulse 2s ease-in-out infinite;
}
.promo-card .ttl { position: absolute; top: 10px; left: 10px; right: 10px; font-size: 13px; padding: 4px 10px; border-radius: 999px; background: rgba(20, 10, 23, .75); backdrop-filter: blur(6px); width: max-content; max-width: calc(100% - 20px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.07); } }

.buy-fab {
  position: fixed; left: 18px; bottom: 20px; z-index: 30; display: flex; align-items: center; gap: 8px;
  padding: 12px 18px 12px 14px; border-radius: 999px; text-decoration: none; color: #fff; font-weight: 600;
  background: linear-gradient(135deg, #ff3d6e, var(--pink) 50%, var(--gold)); box-shadow: 0 10px 28px rgba(255, 79, 163, .55);
  /* backwards: หลังเล่นจบไม่ค้าง transform ไว้ → คลาส hide / near-promo ทำงานได้ */
  animation: fabIn .6s cubic-bezier(.2, 1.5, .4, 1) backwards;
}
.buy-fab .ico { font-size: 20px; display: inline-block; animation: wobble 6s ease-in-out 3s infinite; }
.buy-fab:hover { filter: brightness(1.08); }
@keyframes fabIn { from { transform: translateY(60px) scale(.6); opacity: 0; } }
@keyframes wobble { 0%, 90%, 100% { transform: none; } 92% { transform: rotate(-6deg) scale(1.06); } 94% { transform: rotate(6deg) scale(1.06); } 96% { transform: rotate(-3deg); } }
body.lock .buy-fab { display: none; }
.buy-fab.near-promo { transform: translateY(160%); opacity: 0; pointer-events: none; }

.promo-mini { margin-left: auto; text-decoration: none; }
.player-head > div:first-child { min-width: 0; }

.promo-pop { width: min(440px, 100%); padding: 18px; text-align: center; }
.promo-pop img { width: 100%; border-radius: 16px; display: block; max-height: 68vh; object-fit: contain; background: #000; }
.promo-pop-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.promo-pop-actions .btn { text-decoration: none; }
.footer-link { color: var(--pink2); text-decoration: none; font-size: 14px; }
.footer-link:hover { text-decoration: underline; }
.footer p + p { margin-top: 8px; }
.about { max-width: 760px; margin: 0 auto 26px; text-align: left; }
.about h2 { font-family: var(--display); font-weight: 500; font-size: 17px; color: var(--rose); margin: 0 0 8px; }
.about p { font-size: 13.5px; line-height: 1.75; margin: 0 0 8px; }
.about b { color: var(--rose); font-weight: 500; }
.about-link { color: var(--pink2); text-decoration: underline; text-underline-offset: 3px; margin: 0 2px; }
.video-msg .big { font-size: 42px; }
/* ลายน้ำชื่อเว็บบนวิดีโอ (อัดหน้าจอไปก็ติดชื่อเว็บไปด้วย) */
.wm {
  position: absolute; top: 12px; right: 12px; z-index: 2; pointer-events: none; user-select: none;
  font: 600 13px/1 'Mitr', sans-serif; color: rgba(255, 255, 255, .55); letter-spacing: .3px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .7); padding: 6px 10px; border-radius: 999px; background: rgba(20, 10, 23, .25);
  animation: wmMove 40s ease-in-out infinite;
}
@keyframes wmMove {
  0%, 22% { top: 12px; right: 12px; }
  25%, 47% { top: 12px; right: calc(100% - 12px - var(--wmw, 170px)); }
  50%, 72% { top: calc(100% - 90px); right: calc(100% - 12px - var(--wmw, 170px)); }
  75%, 97% { top: calc(100% - 90px); right: 12px; }
  100% { top: 12px; right: 12px; }
}
.tap-play {
  width: 84px; height: 84px; border-radius: 50%; border: 0; justify-self: center; font-size: 34px; color: #fff; padding-left: 6px;
  background: linear-gradient(135deg, var(--pink), #ff6fb5 60%, var(--gold)); box-shadow: 0 0 0 10px rgba(255, 79, 163, .25), 0 10px 30px rgba(255, 79, 163, .5);
  animation: glow 1.6s ease-in-out infinite;
}
.video-msg .btn { text-decoration: none; justify-self: center; }

/* ---------- Misc ---------- */
.footer { text-align: center; padding: 30px 16px 50px; color: var(--muted); border-top: 1px solid var(--line); }
.footer img { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 10px; box-shadow: 0 0 30px rgba(255, 79, 163, .4); animation: float 4s ease-in-out infinite; }
.footer p { margin: 0; }

.to-top {
  position: fixed; right: 20px; bottom: 20px; z-index: 30; width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: linear-gradient(135deg, var(--pink), var(--gold)); color: #fff; font-size: 20px; box-shadow: 0 8px 24px rgba(255, 79, 163, .45);
  opacity: 0; transform: translateY(20px) scale(.8); pointer-events: none; transition: all .3s;
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }

.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 120; transform: translate(-50%, 40px); opacity: 0;
  padding: 12px 22px; border-radius: 999px; background: rgba(38, 19, 44, .95); border: 1px solid var(--pink);
  box-shadow: 0 10px 30px rgba(255, 79, 163, .3); transition: all .35s cubic-bezier(.2, 1.4, .4, 1); pointer-events: none;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.burst { position: fixed; pointer-events: none; z-index: 130; font-size: 16px; animation: burst .9s ease-out forwards; }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) scale(.3) rotate(180deg); opacity: 0; } }

/* ---------- Responsive ---------- */
/* ข้อความยาว/สั้น สลับตามขนาดจอ */
.sm-only { display: none; }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
.topbar { transition: transform .3s ease, border-color .3s, background .3s; }
.buy-fab, .to-top { transition: transform .3s ease, opacity .3s; }

/* ================= มือถือ ================= */
@media (max-width: 760px) {
  .lg { display: none; }
  .sm-only { display: inline; }

  /* หัวเว็บ: กะทัดรัด + ซ่อนตอนเลื่อนลง โผล่ตอนเลื่อนขึ้น (ได้พื้นที่ดูมากขึ้น) */
  .topbar { flex-wrap: wrap; gap: 8px 10px; padding: calc(8px + env(safe-area-inset-top)) 14px 10px; }
  .topbar.hide { transform: translateY(-100%); }
  .brand { gap: 10px; }
  .brand-text small { display: none; }
  .brand-text strong { font-size: 18px; }
  .logo-wrap { width: 42px; height: 42px; }
  .logo-wrap .logo { width: 36px; height: 36px; }
  .logo-crown { font-size: 16px; top: -9px; left: -5px; }
  .search { order: 3; flex-basis: 100%; max-width: none; height: 42px; }
  .search input { font-size: 16px; } /* < 16px แล้ว iPhone จะซูมหน้าจอเองตอนพิมพ์ */
  .icon-btn { margin-left: auto; width: 40px; height: 40px; }
  .genres { position: static; padding-top: 14px; background: none; }

  main { padding: 0 14px 30px; }
  .apps { padding-top: 12px; gap: 8px; }
  .app { padding: 5px 12px 5px 5px; font-size: 13px; }
  .app img { width: 26px; height: 26px; }

  /* แบนเนอร์แนะนำ: ย่อให้เตี้ยลง เห็นเรื่องอื่นเร็วขึ้น */
  .hero { min-height: 0; border-radius: 20px; margin-top: 14px; }
  .hero-inner { padding: 18px 18px 38px; gap: 14px; }
  .hero-poster { display: block; width: 92px; transform: none; border-radius: 12px; box-shadow: 0 10px 30px rgba(255, 79, 163, .3); align-self: flex-start; order: -1; }
  .hero .hero-title { font-size: 20px; margin: 8px 0 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .hero .pill { font-size: 12px; padding: 3px 10px; }
  .hero .meta { font-size: 12.5px; margin-bottom: 0; }
  .hero .desc { display: none; }
  .hero-actions { margin-top: 12px; gap: 8px; }
  .hero-actions .btn { padding: 10px 16px; font-size: 14px; }
  .hero-dots { left: 18px; bottom: 14px; }

  .section-title { font-size: 19px; margin-bottom: 10px; }
  .section-head { flex-wrap: nowrap; }
  .section-head .section-title { min-width: 0; white-space: nowrap; }
  .promo-all { font-size: 13px; }
  .hot { font-size: 11px; padding: 2px 7px; margin-left: 4px; }
  .promo-row { grid-auto-columns: 62vw; gap: 12px; }
  .credit { grid-template-columns: 1fr; gap: 14px; padding: 10px 10px 16px; margin-top: 16px; border-radius: 22px; }
  .credit::before { border-radius: 24px; }
  .credit-img { border-radius: 14px; }
  .credit-info { padding: 0 6px; text-align: center; }
  .credit-info h2 { font-size: 20px; margin-top: 8px; }
  .credit-score { justify-content: center; }
  .credit-points { text-align: left; font-size: 14px; }
  .credit-btn { display: block; width: 100%; }
  .promo-card .buy { padding: 8px 18px; font-size: 14px; bottom: 10px; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px 12px; }
  .hrow { grid-auto-columns: 118px; gap: 10px; }
  .card h4 { font-size: 14px; }
  .card p { font-size: 12px; }
  .badge { font-size: 11px; padding: 2px 8px; }

  /* ปุ่มลอย: เล็กลง + หลบตอนเลื่อนลง */
  .buy-fab { left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); padding: 9px 14px 9px 11px; font-size: 14px; }
  .buy-fab .ico { font-size: 18px; }
  .to-top { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); width: 44px; height: 44px; }
  .buy-fab.hide, .to-top.hide { transform: translateY(160%); opacity: 0; pointer-events: none; }

  /* หน้ารายละเอียด: แผ่นเลื่อนขึ้นจากล่าง */
  .modal { padding: 0; place-items: end center; }
  .modal-card { border-radius: 24px 24px 0 0; max-height: 92vh; max-height: 92dvh; }
  .detail-top { flex-direction: column; align-items: center; text-align: center; padding: 0 18px; margin-top: -120px; }
  .detail-poster { width: 130px; }
  .detail-info { padding-top: 0; }
  .detail-info h2 { font-size: 21px; }
  .detail-info .desc { -webkit-line-clamp: 4; font-size: 14px; }
  .detail-info .hero-actions, .tags { justify-content: center; }
  .ep-head { padding: 20px 16px 10px; }
  .ep-grid { padding-left: 16px; padding-right: 16px; grid-template-columns: repeat(5, 1fr); gap: 7px; }
  .ep-grid button { height: 42px; }

  /* ตัวเล่นวิดีโอ: เต็มจอ ใช้ dvh เพราะ 100vh บนมือถือรวมแถบเบราว์เซอร์ด้วย */
  .player-modal { place-items: stretch; padding: 0; }
  .player {
    border-radius: 0; border: 0; width: 100%; max-height: none; height: 100vh; height: 100dvh;
    grid-template-columns: 1fr; grid-template-rows: auto auto auto minmax(0, 1fr); grid-template-areas: "head" "video" "bar" "eps";
  }
  .player .video-box { height: auto; width: 100%; aspect-ratio: auto; }
  .player .video-box video { height: 60vh; height: 60dvh; }
  .player-head { padding: calc(8px + env(safe-area-inset-top)) 12px 8px; gap: 10px; }
  .player-head h3 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .player-head small { font-size: 12px; }
  .promo-mini { padding: 7px 12px; font-size: 13px; white-space: nowrap; flex-shrink: 0; }
  .player-bar { padding: 8px 12px; flex-wrap: nowrap; gap: 8px; }
  .player-bar .btn { padding: 8px 12px; font-size: 13px; white-space: nowrap; flex-shrink: 0; }
  .autonext { font-size: 12px; gap: 6px; min-width: 0; justify-content: center; flex: 1; }
  .autonext input { width: 16px; height: 16px; flex-shrink: 0; }
  .player .ep-grid.compact { padding: 4px 12px calc(12px + env(safe-area-inset-bottom)); grid-template-columns: repeat(6, 1fr); }

  .promo-pop { padding: 14px; border-radius: 22px 22px 0 0; }
  .promo-pop img { max-height: 62vh; max-height: 62dvh; }
  .toast { bottom: calc(70px + env(safe-area-inset-bottom)); font-size: 14px; }
}

/* จอเล็กมาก (เช่น iPhone SE รุ่นแรก / Android 320px) */
@media (max-width: 360px) {
  .brand-text strong { font-size: 16px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 14px 10px; }
  .hero-poster { width: 78px; }
  .hero .hero-title { font-size: 18px; }
  .ep-grid { grid-template-columns: repeat(4, 1fr); }
  .player .ep-grid.compact { grid-template-columns: repeat(5, 1fr); }
  .section-title { font-size: 17px; }
  .promo-all { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.brand-h1 { margin: 0; font: inherit; line-height: inherit; }

/* เต็มจอทั้งกล่องวิดีโอ (ลายน้ำแสดงด้วย) */
.video-box:fullscreen { display: grid; place-items: center; background: #000; }
.video-box:fullscreen video { width: 100%; height: 100vh !important; max-height: none; }
