:root {
  --bg: #05060c;
  --surface: rgba(14, 18, 36, 0.72);
  --line: rgba(255, 255, 255, 0.12);
  --ink: #eef1f8;
  --muted: #a7b0c8;
  --accent: #9fd3ff;
  --gold: #f2c86b;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  background: var(--bg);
}
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
img, video { display: block; max-width: 100%; }

/* ma trơi bay khắp trang */
#wisps { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.hero, main, .foot { position: relative; z-index: 1; }

/* ---------- Đầu trang: trailer chạy nền ---------- */
.hero {
  position: relative;
  min-height: min(78vh, 720px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  isolation: isolate;
}
.hero-video {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.08);
  animation: heroDrift 24s ease-in-out infinite alternate;
}
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(5, 6, 12, .25) 0%, rgba(5, 6, 12, .35) 45%, var(--bg) 100%),
    radial-gradient(ellipse at 30% 40%, transparent, rgba(5, 6, 12, .55));
}
@keyframes heroDrift { from { transform: scale(1.08) translate3d(-1.5%, 0, 0); } to { transform: scale(1.16) translate3d(1.5%, -1%, 0); } }

.hero-inner {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px 10px;
}
.back {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(5, 6, 12, .55);
  backdrop-filter: blur(6px);
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
}
.kicker { margin: 0 0 6px; letter-spacing: .32em; text-transform: uppercase; font-size: 12px; color: var(--gold); animation: rise .9s var(--ease) both; }
.hero h1 {
  margin: 0;
  font-family: 'Noto Serif', serif;
  font-size: clamp(42px, 9vw, 104px);
  line-height: .98;
  perspective: 800px;
}
.hero h1 span {
  display: block;
  color: #fff;
  text-shadow: 0 0 26px rgba(159, 211, 255, .65), 0 6px 30px rgba(0, 0, 0, .8);
  animation: flipIn 1.1s var(--ease) both, float 6s ease-in-out 1.2s infinite;
  transform-origin: 50% 100%;
}
.hero h1 span + span { animation-delay: .15s, 1.4s; color: var(--accent); }
.lead { max-width: 560px; margin: 12px 0 0; color: #d3d9ea; animation: rise 1s .3s var(--ease) both; }
@keyframes flipIn { from { opacity: 0; transform: rotateX(-80deg) translateZ(-60px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.tabs {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 1180px;
  margin: 18px auto 0;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs button {
  flex: none;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 14, 30, .75);
  backdrop-filter: blur(8px);
  white-space: nowrap;
  transition: background .3s, border-color .3s, transform .3s var(--ease), box-shadow .3s;
}
.tabs button:hover { transform: translateY(-2px); border-color: var(--accent); }
.tabs button[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #06122a;
  font-weight: 700;
  box-shadow: 0 0 24px rgba(159, 211, 255, .45);
}

/* ---------- Khung chung + chuyển thẻ xoay 3D ---------- */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 16px 40px;
  perspective: 1600px;
}
.panel { transform-origin: 50% 0; }
.panel.enter { animation: panelIn .7s var(--ease) both; }
@keyframes panelIn { from { opacity: 0; transform: rotateY(-24deg) translateZ(-200px) translateX(6%); } to { opacity: 1; transform: none; } }
.status { color: var(--muted); text-align: center; }
.status:empty { display: none; }

/* ---------- Phái: vòng xoay 3D ---------- */
.ring-wrap { position: relative; display: flex; align-items: center; justify-content: center; }
.ring-scene {
  position: relative;
  width: 100%;
  height: clamp(250px, 34vw, 360px);
  perspective: 1100px;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}
.ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  transition: transform 1s var(--ease);
}
.ring-card {
  position: absolute;
  left: calc(var(--w) / -2);
  top: calc(var(--h) / -2);
  width: var(--w);
  height: var(--h);
  --w: clamp(150px, 19vw, 210px);
  --h: clamp(200px, 26vw, 280px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #0b0e1c;
  transition: border-color .4s, box-shadow .4s, filter .4s, opacity .4s;
  filter: brightness(.55) saturate(.8);
}
.ring-card img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.ring-card span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 26px 10px 10px;
  background: linear-gradient(transparent, rgba(5, 6, 12, .95));
  font-family: 'Noto Serif', serif;
  font-size: 18px;
  font-weight: 700;
}
.ring-card.active {
  filter: none;
  border-color: var(--gold);
  box-shadow: 0 0 40px rgba(242, 200, 107, .45), 0 20px 50px rgba(0, 0, 0, .6);
}
.ring-card.active img { transform: scale(1.06); }
.ring-nav {
  position: absolute;
  z-index: 2;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(10, 14, 30, .8);
  font-size: 26px;
  line-height: 1;
  transition: transform .2s, border-color .2s;
}
.ring-nav:hover { transform: scale(1.1); border-color: var(--gold); }
.ring-nav.prev { left: 0; }
.ring-nav.next { right: 0; }

/* sân khấu chi tiết phái */
.class-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 24px;
  margin-top: 18px;
  perspective: 1200px;
}
.class-stage > * { animation: stageIn .8s var(--ease) both; }
.class-stage > :nth-child(2) { animation-delay: .12s; }
@keyframes stageIn { from { opacity: 0; transform: rotateX(18deg) translateY(40px) translateZ(-80px); } to { opacity: 1; transform: none; } }

.video-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .55);
  transform: rotateY(6deg);
  transform-style: preserve-3d;
  transition: transform .6s var(--ease);
}
.video-card:hover { transform: rotateY(0deg) translateZ(10px); }
.video-card video { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.video-card .label {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 4px 10px;
  border-radius: 99px;
  background: rgba(5, 6, 12, .7);
  font-size: 12px;
  letter-spacing: .08em;
}
.video-card .sound {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(5, 6, 12, .75);
  font-size: 13px;
}

.portrait-row { display: flex; gap: 14px; margin-top: 16px; perspective: 900px; }
.flip {
  flex: 0 1 180px;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: none;
  perspective: 900px;
}
.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .8s var(--ease);
}
.flip:hover .flip-inner, .flip:focus-visible .flip-inner, .flip.on .flip-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  backface-visibility: hidden;
  background: #0b0e1c;
}
.flip-face img { width: 100%; height: 100%; object-fit: cover; }
.flip-face.back {
  display: grid;
  place-items: center;
  padding: 10px;
  transform: rotateY(180deg);
  background: radial-gradient(circle, rgba(242, 200, 107, .25), rgba(10, 14, 30, .95));
  font-family: 'Noto Serif', serif;
  font-size: 18px;
  text-align: center;
}
.flip-face.back small { display: block; margin-top: 4px; font-family: 'Be Vietnam Pro', sans-serif; font-size: 12px; color: var(--muted); }
.flip-face.front span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 8px 8px;
  background: linear-gradient(transparent, rgba(5, 6, 12, .9));
  font-size: 13px;
}

.info h2 { display: flex; align-items: center; gap: 12px; margin: 0; font-family: 'Noto Serif', serif; font-size: clamp(30px, 4vw, 44px); }
.info h2 img { width: 56px; height: 56px; animation: spinGlow 8s linear infinite; filter: drop-shadow(0 0 10px rgba(242, 200, 107, .7)); }
@keyframes spinGlow { to { transform: rotateY(360deg); } }
.info .names { margin: 4px 0 10px; color: var(--muted); }
.role { display: inline-block; margin-bottom: 12px; padding: 4px 12px; border-radius: 99px; background: rgba(242, 200, 107, .14); color: var(--gold); font-size: 13px; }
.info p { margin: 0 0 12px; line-height: 1.7; color: #dfe4f2; }
.chips-label { margin: 14px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chips li {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .03);
  font-size: 13px;
  animation: chipIn .5s var(--ease) both;
  animation-delay: calc(var(--i) * 60ms + .3s);
}
@keyframes chipIn { from { opacity: 0; transform: translateZ(-60px) rotateX(70deg); } to { opacity: 1; transform: none; } }

/* ---------- Vật phẩm: thẻ lật 3D bay vào ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 20px; }
.filters button {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
  transition: border-color .2s, color .2s, transform .2s;
}
.filters button:hover { transform: translateY(-2px); }
.filters button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  perspective: 1400px;
}
.item {
  height: 190px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  perspective: 900px;
  animation: itemIn .7s var(--ease) both;
  animation-delay: calc(var(--i) * 28ms);
}
@keyframes itemIn { from { opacity: 0; transform: translateZ(-500px) rotateX(40deg) rotateY(calc(var(--r) * 1deg)); } to { opacity: 1; transform: none; } }
.item .flip-inner { transition: transform .7s var(--ease); }
.item:hover .flip-inner { transform: translateZ(30px) rotateX(6deg); }
.item.on .flip-inner { transform: rotateY(180deg); }
.item .flip-face { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 14px; background: linear-gradient(160deg, rgba(30, 36, 66, .9), rgba(10, 12, 24, .95)); }
.item .flip-face.front img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .6));
  animation: bob 4s ease-in-out infinite;
  animation-delay: calc(var(--i) * -170ms);
}
@keyframes bob { 0%, 100% { transform: translateY(0) rotateY(-10deg); } 50% { transform: translateY(-7px) rotateY(10deg); } }
.item .flip-face.front::before {
  content: '';
  position: absolute;
  width: 110px;
  height: 110px;
  top: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 200, 107, .22), transparent 70%);
}
.item h3 { position: relative; margin: 0; font-size: 14px; text-align: center; line-height: 1.3; }
.item .cat { font-size: 11px; color: var(--muted); }
.item .flip-face.back { justify-content: flex-start; align-items: stretch; gap: 6px; overflow-y: auto; font-size: 12px; line-height: 1.5; color: #d3d9ea; text-align: left; }
.item .flip-face.back strong { font-size: 14px; color: #fff; }
.item .price { color: var(--gold); }
.more {
  display: block;
  margin: 24px auto 0;
  padding: 10px 26px;
  border: 1px solid var(--gold);
  border-radius: 99px;
  background: rgba(242, 200, 107, .08);
  color: var(--gold);
}

/* ---------- Cốt truyện: xoay vào khi cuộn ---------- */
.lore { max-width: 900px; margin: 0 auto; padding: 0; list-style: none; perspective: 1200px; }
.lore li {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 40px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  backdrop-filter: blur(6px);
  opacity: 0;
  transform: rotateX(28deg) translateY(80px) translateZ(-120px);
  transform-origin: 50% 0;
  transition: opacity .9s var(--ease), transform .9s var(--ease);
}
.lore li.seen { opacity: 1; transform: none; }
.lore li.with-img { grid-template-columns: 1fr minmax(0, 300px); }
.lore h2 { margin: 0; font-family: 'Noto Serif', serif; font-size: 26px; }
.lore .en { margin: 2px 0 12px; font-size: 13px; color: var(--muted); }
.lore p { margin: 0; font-family: 'Noto Serif', serif; line-height: 1.8; color: #dfe4f2; }
.lore figure { margin: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); cursor: zoom-in; transform: rotateY(-8deg); transition: transform .6s var(--ease); }
.lore figure:hover { transform: rotateY(0) scale(1.03); }
.src { display: inline-block; margin-top: 10px; font-size: 12px; color: var(--muted); }
.src a { color: var(--muted); }

/* ---------- Thư viện: coverflow 3D ---------- */
.flow {
  position: relative;
  height: clamp(300px, 46vw, 480px);
  perspective: 1200px;
  overflow: hidden;
  touch-action: pan-y;
  cursor: grab;
  outline: none;
}
.flow:active { cursor: grabbing; }
.flow-track { position: absolute; left: 50%; top: 50%; transform-style: preserve-3d; }
.flow-item {
  position: absolute;
  width: clamp(220px, 34vw, 440px);
  aspect-ratio: 4 / 3;
  margin-left: calc(clamp(220px, 34vw, 440px) / -2);
  margin-top: calc(clamp(220px, 34vw, 440px) * -.375);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #0b0e1c;
  box-shadow: 0 30px 60px rgba(0, 0, 0, .6);
  transition: transform .7s var(--ease), opacity .7s, filter .7s;
  -webkit-box-reflect: below 6px linear-gradient(transparent 70%, rgba(255, 255, 255, .18));
}
.flow-item img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.flow-cap { min-height: 1.4em; margin: 10px 0 6px; text-align: center; color: var(--muted); }
.flow-range { display: block; width: min(600px, 100%); margin: 0 auto; accent-color: var(--gold); }

/* ---------- Xem ảnh lớn ---------- */
dialog {
  max-width: min(1100px, 94vw);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #000;
  color: var(--ink);
}
dialog[open] { animation: zoomIn .45s var(--ease); }
@keyframes zoomIn { from { opacity: 0; transform: scale(.85) rotateX(12deg); } to { opacity: 1; transform: none; } }
dialog::backdrop { background: rgba(0, 0, 0, .82); }
dialog img { max-height: 82vh; margin: 0 auto; }
dialog p { margin: 0; padding: 10px 14px; font-size: 14px; color: var(--muted); }
dialog .close { position: absolute; top: 8px; right: 8px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .6); font-size: 24px; line-height: 1; }

.foot { max-width: 1180px; margin: 0 auto; padding: 20px 16px max(30px, env(safe-area-inset-bottom)); font-size: 12px; color: rgba(255, 255, 255, .45); text-align: center; }
.foot a { color: rgba(255, 255, 255, .7); }

/* ---------- Điện thoại ---------- */
@media (max-width: 820px) {
  .class-stage { grid-template-columns: 1fr; }
  .video-card { transform: none; }
  .lore li.with-img { grid-template-columns: 1fr; }
  .lore figure { transform: none; }
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .ring-nav { width: 40px; height: 40px; }
}

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

.video-card .official-class-art{display:block;width:100%;height:auto;max-height:380px;aspect-ratio:16/9;object-fit:contain;background:#080b17}
.class-stage .asset-note{font-size:11px;line-height:1.6;opacity:.72}

/* 2026-11: thư viện 11 nghề - ảnh Mgame không bị crop */
html {-webkit-text-size-adjust:100%;overflow-x:clip}
body {min-width:0;max-width:100vw}
.panel[hidden] {display:none!important}
.class-count {margin:0 0 8px;color:#bfc6d9;letter-spacing:.035em;font-size:13px}
.ring-card img {object-fit:contain;object-position:center center;background:radial-gradient(circle at 50% 40%,#34314c,#0b0e1c 75%)}
.ring-card.active img {transform:none}
.class-media-stack {display:grid;gap:12px;min-width:0}
.class-media-stack .video-card {min-width:0}
.class-media-stack .official-class-art {display:block;width:100%;aspect-ratio:4/3;min-height:140px;max-height:320px;object-fit:contain;object-position:center;background:radial-gradient(ellipse at center,#28304b,#090d1a 75%);padding:8px}
.class-media-stack .skill-preview {width:100%;max-height:240px;min-height:135px;object-fit:contain;background:#090b16}
.class-media-stack .video-card .label {z-index:1}
.class-stage .asset-note {font-size:11px;line-height:1.6;opacity:.72}
@media(max-width:820px) {
  .hero {
    height:auto;min-height:clamp(350px,51dvh,510px);max-height:none;
    justify-content:flex-end;background:#090b17;
  }
  .hero-video {
    inset:0;width:100%;height:100%;max-width:none;
    object-fit:contain;object-position:center 28%;transform:none!important;animation:none!important;
    background:linear-gradient(180deg,#1b1a33,#060812);
  }
  .hero::after {
    background:linear-gradient(180deg,rgba(5,6,12,.1) 0%,rgba(5,6,12,.16) 29%,rgba(5,6,12,.85) 75%,#05060c 100%);
  }
  .hero-inner {padding:74px 18px 4px;max-width:100%}
  .hero h1 {font-size:clamp(34px,10vw,52px);line-height:1.08}
  .kicker {font-size:10px;letter-spacing:.19em}
  .lead {font-size:13px;line-height:1.55;max-width:330px}
  .back {top:max(12px,env(safe-area-inset-top));left:16px;font-size:12px;padding:10px 13px;min-height:42px}
  .tabs {max-width:100%;gap:7px;margin:12px 0 0;padding:10px 14px 12px;scroll-snap-type:x proximity}
  .tabs button {font-size:13px;min-height:44px;padding:10px 15px;scroll-snap-align:start}
  main {padding:12px 12px 32px;max-width:100%;perspective:none}
  .class-count {margin:0 3px 8px;font-size:11px}
  .panel.enter {animation:none}
  .ring-wrap {display:block;min-width:0}
  .ring-scene {
    width:100%;height:auto;min-height:210px;overflow-x:auto;overflow-y:hidden;
    perspective:none;mask-image:none;-webkit-mask-image:none;
    scroll-snap-type:x mandatory;scrollbar-width:none;-webkit-overflow-scrolling:touch;
    touch-action:pan-x;
  }
  .ring-scene::-webkit-scrollbar {display:none}
  .ring {
    position:relative;left:auto;top:auto;display:flex;align-items:stretch;
    width:max-content;min-width:100%;height:auto;padding:5px 18px 8px;gap:10px;
    transform:none!important;transform-style:flat;transition:none;
  }
  .ring-card {
    position:relative;left:auto;top:auto;flex:0 0 150px;
    width:150px;height:195px;--w:150px;--h:195px;
    transform:none!important;scroll-snap-align:center;
    border-radius:13px;filter:none;box-shadow:none;
  }
  .ring-card img {height:100%;width:100%;padding:6px 6px 34px;object-fit:contain}
  .ring-card span {font-size:14px;padding:16px 6px 10px;text-align:center}
  .ring-nav {display:none}
  .class-stage {margin-top:12px;display:grid;grid-template-columns:minmax(0,1fr);gap:14px;perspective:none}
  .class-stage > * {animation:none}
  .video-card,.video-card:hover {transform:none}
  .class-media-stack .official-class-art {max-height:280px;aspect-ratio:5/4}
  .info h2 {font-size:clamp(25px,7vw,36px)}
  .info h2 img {width:42px;height:42px}
  .info p {font-size:13px}
  .portrait-row {gap:8px}
  .flip {flex-basis:140px}
  .foot {padding:16px 12px max(28px,env(safe-area-inset-bottom))}
}
@media(max-width:380px) {
  .ring-card {flex-basis:136px;width:136px;height:184px}
  .ring {gap:8px}
  .hero {min-height:350px}
}
@media(prefers-reduced-motion:reduce) {.hero-video {animation:none!important}}

/* Keep motion previews unzoomed and playable on iPhone. */
.class-media-stack .video-card video {width:100%;max-height:320px;aspect-ratio:16/9;object-fit:contain;background:#090d1c}

/* Keep mobile hero artwork at its actual display size. */
@media (max-width: 760px) {
  .hero-video { transform: none; animation: none; object-position: center; }
  .hero h1 span { animation: none; transform: none; }
}
