
:root {
  --gold: #ffd86b;
  --red: #ff4d6d;
  --cyan: #6be8ff;
  --violet: #9b7bff;
  --bg1: #04020f;
  --bg2: #14063d;
  --glass: rgba(255, 255, 255, .07);
  --line: rgba(255, 255, 255, .16);
  --mx: 0;
  --my: 0;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  color: #fff;
  background: radial-gradient(ellipse at 50% -10%, #35127a 0%, var(--bg2) 38%, var(--bg1) 85%) fixed;
  overflow-x: hidden;
  perspective: 1400px;
}

/* ---------- Background layers ---------- */
canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#bg { z-index: 1; }
#fx { z-index: 3; }
.aurora { position: fixed; inset: -20%; z-index: 0; pointer-events: none; filter: blur(70px); opacity: .55; }
.aurora i {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  animation: drift 18s ease-in-out infinite alternate;
}
.aurora i:nth-child(1) { background: #7b2cff; left: 5%; top: 10%; transform: translate(calc(var(--mx) * 40px), calc(var(--my) * 30px)); }
.aurora i:nth-child(2) { background: #ff2d75; right: 0; top: 30%; animation-duration: 23s; transform: translate(calc(var(--mx) * -50px), calc(var(--my) * 40px)); }
.aurora i:nth-child(3) { background: #0fb7ff; left: 30%; bottom: 0; animation-duration: 27s; transform: translate(calc(var(--mx) * 30px), calc(var(--my) * -40px)); }
@keyframes drift {
  from { margin: 0; scale: 1; }
  to { margin: 6vmax; scale: 1.25; }
}
.baubles { position: fixed; inset: 0; z-index: 2; pointer-events: none; transform-style: preserve-3d; overflow: hidden; }
.bauble {
  position: absolute;
  top: -120px;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 28%, rgba(255, 255, 255, .9), var(--c1) 32%, var(--c2) 78%);
  box-shadow: 0 0 26px var(--c1), inset -6px -8px 16px rgba(0, 0, 0, .45);
  opacity: .8;
  animation: fall linear infinite;
}
.bauble::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -9%;
  width: 22%;
  height: 12%;
  translate: -50% 0;
  border-radius: 3px;
  background: linear-gradient(#fff3b0, #c99a2e);
}
@keyframes fall {
  0% { transform: translate3d(0, -10vh, var(--z)) rotateY(0) rotateZ(-12deg); }
  50% { transform: translate3d(40px, 55vh, var(--z)) rotateY(180deg) rotateZ(14deg); }
  100% { transform: translate3d(-20px, 118vh, var(--z)) rotateY(360deg) rotateZ(-12deg); }
}

/* ---------- Layout ---------- */
.wrap {
  position: relative;
  z-index: 4;
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(28px, 6vw, 64px) 18px 40px;
  text-align: center;
}
.eyebrow {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  padding: 7px 16px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(10px);
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  animation: rise .9s both;
}
.eyebrow b { color: var(--gold); }
h1 {
  margin: 20px 0 8px;
  font-family: 'Dancing Script', cursive;
  font-size: clamp(44px, 9vw, 96px);
  line-height: 1.05;
  background: linear-gradient(100deg, #fff 0%, var(--gold) 30%, var(--red) 55%, var(--cyan) 80%, #fff 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 24px rgba(255, 120, 160, .35));
  animation: rise 1s .1s both, shine 6s linear infinite;
  transform: translate3d(calc(var(--mx) * 8px), calc(var(--my) * 6px), 0);
}
@keyframes shine { to { background-position: -250% 0; } }
@keyframes rise {
  from { opacity: 0; transform: translateY(26px) rotateX(35deg); }
  to { opacity: 1; transform: none; }
}
.lead { font-size: clamp(15px, 2.4vw, 19px); color: #d9d2ff; animation: rise 1s .2s both; }
.lead strong { color: var(--gold); }
.now { margin-top: 10px; font-size: 13px; color: #a79fd6; font-variant-numeric: tabular-nums; animation: rise 1s .3s both; }
.greet {
  margin: 18px auto 0;
  max-width: 560px;
  font-size: 15px;
  color: #ffd1dc;
  animation: rise 1s .35s both;
}

/* ---------- Cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(16px, 3vw, 30px);
  margin-top: clamp(30px, 5vw, 54px);
}
.card[hidden] { display: none; }
.card {
  perspective: 1000px;
  animation: rise .9s both, float 7s ease-in-out infinite;
}
.card:nth-child(1) { animation-delay: .4s, 0s; }
.card:nth-child(2) { animation-delay: .55s, -1.5s; }
.card:nth-child(3) { animation-delay: .7s, -3s; }
.card:nth-child(4) { animation-delay: .85s, -4.5s; }
@keyframes float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -10px; }
}
.inner {
  position: relative;
  padding: clamp(20px, 3vw, 32px) clamp(14px, 2.4vw, 26px) clamp(22px, 3vw, 30px);
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, .03));
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .25);
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .18s ease-out;
}
.inner::before {
  content: '';
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: 28px;
  background: conic-gradient(from var(--ang, 0deg), transparent 0 60%, var(--accent) 80%, transparent);
  opacity: .0;
  filter: blur(10px);
  transition: opacity .4s;
}
.card.next .inner::before { opacity: .9; animation: spin 5s linear infinite; }
.inner::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 26px;
  pointer-events: none;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 0%), rgba(255, 255, 255, .22), transparent 55%);
}
@property --ang { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes spin { to { --ang: 360deg; } }
.card.solar { --accent: #6be8ff; }
.card.lunar { --accent: #ff4d6d; }
.badge {
  position: absolute;
  top: -13px;
  left: 50%;
  translate: -50% 0;
  padding: 4px 14px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #2a0a00;
  background: linear-gradient(90deg, var(--gold), #ffb347);
  box-shadow: 0 6px 18px rgba(255, 190, 70, .5);
  display: none;
  transform: translateZ(50px);
}
.card.next .badge { display: block; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { scale: 1.08; } }
.icon {
  font-size: 44px;
  display: inline-block;
  transform: translateZ(60px);
  animation: bob 3.4s ease-in-out infinite;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .5));
}
@keyframes bob { 50% { transform: translateZ(60px) translateY(-6px) rotate(8deg); } }
.card h2 { margin-top: 6px; font-size: clamp(18px, 2.6vw, 24px); transform: translateZ(40px); }
.card .sub { margin: 4px 0 18px; font-size: 13px; color: #bdb4ee; transform: translateZ(30px); }
.cd {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(6px, 1.4vw, 14px);
  transform: translateZ(45px);
}
.unit span { display: block; margin-top: 8px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #a79fd6; }
.num {
  padding: clamp(10px, 2vw, 18px) 0;
  border-radius: 14px;
  font-size: clamp(24px, 4.4vw, 44px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, rgba(255, 255, 255, .16) 0 49%, rgba(0, 0, 0, .25) 50% 100%);
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 10px 20px -8px rgba(0, 0, 0, .6);
  text-shadow: 0 0 18px var(--accent);
}
.num.pop { animation: flip .55s cubic-bezier(.2, .8, .2, 1); }
@keyframes flip {
  0% { transform: rotateX(-90deg); opacity: .3; }
  100% { transform: rotateX(0); opacity: 1; }
}
.party { display: none; padding: 26px 0; font-size: 22px; font-weight: 800; color: var(--gold); }
.card.done .party { display: block; animation: pulse 1.2s infinite; }
.card.done .cd { display: none; }

/* ---------- Footer ---------- */
.foot { position: relative; z-index: 4; padding: 10px 18px calc(34px + env(safe-area-inset-bottom, 0px)); }
.foot-card {
  max-width: 760px;
  margin: 0 auto;
  padding: 26px 22px;
  text-align: center;
  border-radius: 26px;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .03));
  backdrop-filter: blur(14px);
  box-shadow: 0 30px 60px -25px rgba(0, 0, 0, .8);
}
.foot-line { height: 2px; margin: 0 auto 18px; width: 120px; border-radius: 2px; background: linear-gradient(90deg, var(--red), var(--gold), var(--cyan)); }
.foot-card p { font-size: 14px; color: #cfc8f5; }
.brand {
  display: inline-block;
  margin: 0 4px;
  font-weight: 800;
  letter-spacing: .08em;
  text-decoration: none;
  background: linear-gradient(90deg, var(--gold), var(--red), var(--violet), var(--cyan), var(--gold));
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shine 5s linear infinite;
  transition: transform .25s;
}
.brand:hover { transform: translateY(-2px) scale(1.08); }
.rainbow-text {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: .2em;
  text-transform: uppercase;
  background: linear-gradient(90deg, #ff5f6d, #ffc371, #7cf2a0, #6be8ff, #b18cff, #ff5f6d);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shine 6s linear infinite;
}
.wish { margin-top: 12px; font-size: 13px; color: #a79fd6; }


/* ---------- FPS counter ---------- */
#fpsCounter {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 12px;
  z-index: 10;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(10, 4, 32, .55);
  backdrop-filter: blur(8px);
  font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .06em;
  color: #6dffb0;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
#fpsCounter.mid { color: var(--gold); }
#fpsCounter.low { color: var(--red); }

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .baubles, canvas { display: none; }
}

/* =====================================================
   RESPONSIVE UPGRADE: ĐT, iPad, laptop, PC, TV, 4K...
   (đặt cuối file để ghi đè, không xóa code cũ)
   ===================================================== */

/* ---------- Nền tảng chung ---------- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  min-height: 100vh;
  min-height: 100dvh; /* tránh bị thanh địa chỉ che trên ĐT */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, canvas { max-width: 100%; }
.card h2, .lead { text-wrap: balance; overflow-wrap: anywhere; }

/* Tai thỏ / viền cong: chừa an toàn hai bên */
.wrap {
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
}
.foot {
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
}
#fpsCounter { left: max(12px, env(safe-area-inset-left, 0px)); }

/* ---------- Trình duyệt cũ (TV đời cũ, Safari cũ) ---------- */
canvas { top: 0; left: 0; right: 0; bottom: 0; }
.baubles { top: 0; left: 0; right: 0; bottom: 0; }
.aurora { top: -20%; left: -20%; right: -20%; bottom: -20%; }
.inner::before { top: -2px; left: -2px; right: -2px; bottom: -2px; }
.inner::after { top: 0; left: 0; right: 0; bottom: 0; }

@supports not (translate: 0) {
  .badge { transform: translate(-50%, 0) translateZ(50px); }
  .bauble::before { transform: translateX(-50%); }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .eyebrow, .inner, .foot-card, #fpsCounter { background-color: rgba(24, 10, 66, .82); }
}

/* ---------- Điều khiển bằng remote TV / bàn phím ---------- */
a:focus-visible,
.brand:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 5px;
  border-radius: 8px;
}

/* ---------- Thiết bị cảm ứng (không có hover) ---------- */
@media (hover: none) {
  .brand:hover { transform: none; }
  .inner { transition: transform .35s ease-out; }
}

/* ---------- Máy yếu / màn nhỏ: giảm tải hiệu ứng nặng ---------- */
@media (max-width: 720px), (pointer: coarse) {
  .aurora { filter: blur(44px); opacity: .5; }
  .inner, .eyebrow, .foot-card { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
  .bauble:nth-child(n+6) { display: none; }
}

/* ---------- Điện thoại cỡ lớn / tablet nhỏ (≤ 720px) ---------- */
@media (max-width: 720px) {
  .eyebrow { font-size: 11px; letter-spacing: .08em; padding: 6px 12px; gap: 6px; flex-wrap: wrap; justify-content: center; }
  .greet { font-size: 14px; }
  .icon { font-size: 38px; }
  .inner { border-radius: 22px; }
  .foot-card { padding: 22px 16px; }
  #fpsCounter { font-size: 11px; padding: 5px 9px; }
}

/* ---------- Điện thoại nhỏ (≤ 480px) ---------- */
@media (max-width: 480px) {
  .wrap { padding-top: 34px; }
  .grid { gap: 20px; }
  .cd { gap: 6px; }
  .num { border-radius: 10px; font-size: clamp(22px, 8vw, 32px); }
  .unit span { font-size: 10px; letter-spacing: .08em; }
  .card .sub { font-size: 12px; }
  .wish { font-size: 12px; }
}

/* ---------- Màn rất nhỏ / gập (≤ 340px): chia 2x2 ---------- */
@media (max-width: 340px) {
  .cd { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .num { font-size: 30px; }
}

/* ---------- Tablet dọc, iPad (721px - 1024px) ---------- */
@media (min-width: 721px) and (max-width: 1024px) {
  .wrap { max-width: 880px; }
  .grid { gap: 20px; }
  .inner { padding-left: 14px; padding-right: 14px; }
  .num { font-size: clamp(24px, 4.6vw, 38px); }
}

/* ---------- Điện thoại / tablet nằm ngang (chiều cao thấp) ---------- */
@media (max-height: 520px) and (orientation: landscape) {
  .wrap { padding-top: 16px; padding-bottom: 16px; }
  h1 { margin: 10px 0 4px; font-size: clamp(34px, 7vw, 56px); }
  .greet, .now { display: none; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 18px; }
  .icon { font-size: 30px; }
  .card .sub { margin-bottom: 10px; }
  .num { padding: 6px 0; font-size: clamp(20px, 4vw, 30px); }
  .foot { padding-top: 0; }
  .foot-card { padding: 14px 16px; }
}

/* ---------- Laptop / PC lớn (≥ 1280px) ---------- */
@media (min-width: 1280px) {
  .wrap { max-width: 1240px; }
  .grid { gap: 34px; }
  .inner { padding: 36px 30px 34px; }
}

/* ---------- Full HD, màn rộng (≥ 1600px) ---------- */
@media (min-width: 1600px) {
  .wrap { max-width: 1480px; padding-top: 72px; }
  .eyebrow { font-size: 15px; padding: 9px 22px; }
  .lead { font-size: 22px; }
  .now { font-size: 15px; }
  .greet { font-size: 18px; max-width: 700px; }
  .card h2 { font-size: 28px; }
  .card .sub { font-size: 15px; }
  .icon { font-size: 54px; }
  .num { font-size: clamp(40px, 3vw, 58px); border-radius: 18px; }
  .unit span { font-size: 13px; }
  .foot-card { max-width: 920px; padding: 32px 28px; }
  .foot-card p { font-size: 16px; }
  .wish { font-size: 15px; }
  #fpsCounter { font-size: 14px; padding: 8px 14px; }
}

/* ---------- TV / màn hình 2K - 4K (≥ 1920px) ---------- */
@media (min-width: 1920px) {
  .wrap {
    max-width: 1760px;
    padding-left: 3vw;  /* chừa overscan của TV */
    padding-right: 3vw;
    padding-top: 5vh;
  }
  h1 { font-size: clamp(110px, 7vw, 170px); }
  .eyebrow { font-size: 18px; }
  .lead { font-size: 28px; }
  .now { font-size: 18px; }
  .greet { font-size: 22px; max-width: 860px; }
  .grid { gap: 46px; }
  .inner { padding: 46px 40px 44px; border-radius: 34px; }
  .icon { font-size: 70px; }
  .card h2 { font-size: 36px; }
  .card .sub { font-size: 19px; margin-bottom: 26px; }
  .cd { gap: 20px; }
  .num { font-size: clamp(58px, 3.4vw, 96px); padding: 24px 0; }
  .unit span { font-size: 16px; margin-top: 12px; }
  .badge { font-size: 15px; padding: 6px 20px; top: -18px; }
  .party { font-size: 34px; padding: 40px 0; }
  .foot-card { max-width: 1100px; padding: 40px 36px; border-radius: 34px; }
  .foot-card p { font-size: 20px; }
  .rainbow-text { font-size: 16px; }
  .wish { font-size: 18px; }
  #fpsCounter { font-size: 18px; padding: 10px 18px; border-radius: 14px; top: 2vh; left: 2vw; }
}

/* ---------- TV 4K / 8K, màn siêu lớn (≥ 2560px) ---------- */
@media (min-width: 2560px) {
  .wrap { max-width: 2300px; }
  h1 { font-size: clamp(150px, 6vw, 240px); }
  .eyebrow { font-size: 24px; padding: 12px 30px; }
  .lead { font-size: 38px; }
  .now { font-size: 24px; }
  .greet { font-size: 28px; max-width: 1100px; }
  .inner { padding: 64px 56px 60px; border-radius: 44px; }
  .icon { font-size: 96px; }
  .card h2 { font-size: 50px; }
  .card .sub { font-size: 26px; }
  .num { font-size: clamp(84px, 3.6vw, 140px); padding: 34px 0; border-radius: 26px; }
  .unit span { font-size: 22px; }
  .foot-card { max-width: 1500px; padding: 56px 48px; }
  .foot-card p { font-size: 28px; }
  .rainbow-text { font-size: 22px; }
  .wish { font-size: 24px; }
  #fpsCounter { font-size: 24px; padding: 14px 24px; }
}

/* ---------- Màn rất rộng nhưng thấp (ultrawide) ---------- */
@media (min-aspect-ratio: 21/9) and (min-width: 1600px) {
  .wrap { max-width: 1900px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 720px)); justify-content: center; }
}

/* ---------- Tăng tương phản khi người dùng yêu cầu ---------- */
@media (prefers-contrast: more) {
  :root { --line: rgba(255, 255, 255, .5); --glass: rgba(255, 255, 255, .16); }
  .card .sub, .unit span, .now, .wish { color: #fff; }
}

/* ---------- In ra giấy ---------- */
@media print {
  body { background: #fff; color: #000; }
  .aurora, .baubles, canvas, #fpsCounter { display: none !important; }
  .inner, .foot-card { box-shadow: none; background: none; border-color: #999; }
  h1, .brand, .rainbow-text { -webkit-text-fill-color: #000; color: #000; background: none; }
}