/* ==========================================================================
   BÀI TỚI CỐ ĐÔ — 3D BOX & SECRET TAM YÊU THẦN BẢO GACHA STAGE
   100% GPU Compositor animations (transform & opacity only) · Zero lag
   ========================================================================== */

.ty3d-shell {
  position: relative;
  border-radius: 20px;
  padding: clamp(1.4rem, 3vw, 2.3rem) clamp(1rem, 2.6vw, 2rem) clamp(1.5rem, 3vw, 2.2rem);
  background:
    radial-gradient(ellipse 68% 58% at 50% 42%, rgba(232, 184, 75, 0.14) 0%, rgba(145, 27, 60, 0.16) 46%, transparent 74%),
    radial-gradient(ellipse 52% 48% at 86% 20%, rgba(36, 210, 255, 0.12) 0%, transparent 66%),
    linear-gradient(168deg, #0A1332 0%, #150A22 48%, #2C0B1B 100%);
  border: 2px solid rgba(232, 184, 75, 0.62);
  box-shadow:
    0 28px 72px rgba(4, 5, 18, 0.68),
    inset 0 0 0 1px rgba(255, 224, 150, 0.18);
  overflow: hidden;
  contain: layout style;
}

.ty3d-shell:not(.is-inview) *,
.ty3d-shell:not(.is-inview) *::before,
.ty3d-shell:not(.is-inview) *::after {
  animation-play-state: paused !important;
}

/* Soft Imperial Studio Light Rays */
.ty3d-bg-rays {
  position: absolute;
  inset: -25%;
  pointer-events: none;
  z-index: 0;
  background:
    conic-gradient(from 0deg at 50% 46%,
      transparent 0deg, rgba(255, 214, 114, 0.08) 18deg, transparent 36deg,
      transparent 90deg, rgba(36, 210, 255, 0.06) 110deg, transparent 132deg,
      transparent 195deg, rgba(255, 198, 86, 0.07) 216deg, transparent 240deg,
      transparent 305deg, rgba(243, 106, 158, 0.06) 324deg, transparent 360deg);
  will-change: transform;
  animation: ty3d-rays-spin 34s linear infinite;
}

.ty3d-header {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 760px;
  margin: 0 auto 1.1rem;
}

.ty3d-title {
  font-size: clamp(1.75rem, 3.3vw, 2.55rem);
  margin: 0.35rem 0 0.45rem;
  color: #FFF8EE;
  line-height: 1.15;
}

.ty3d-title-gold {
  background: linear-gradient(100deg, #FFF5CC 0%, #F7C948 45%, #FFE89E 75%, #FF9B38 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.ty3d-subtitle {
  margin: 0;
  color: rgba(255, 232, 206, 0.88);
  font-size: clamp(0.88rem, 1.3vw, 0.98rem);
  line-height: 1.58;
}

/* ---------- 3D Canvas Viewport ---------- */
.ty3d-stage-wrap {
  position: relative;
  z-index: 2;
}

.ty3d-canvas-host {
  position: relative;
  width: 100%;
  height: clamp(410px, 56vh, 550px);
  border-radius: 16px;
  background:
    radial-gradient(ellipse 52% 24% at 50% 88%, rgba(244, 196, 78, 0.22) 0%, rgba(244, 196, 78, 0.04) 55%, transparent 78%),
    radial-gradient(ellipse 66% 62% at 50% 44%, rgba(28, 16, 48, 0.65) 0%, rgba(6, 7, 18, 0.92) 78%);
  border: 1px solid rgba(255, 212, 120, 0.28);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}

.ty3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: pan-y;
}

.ty3d-canvas.is-dragging {
  cursor: grabbing;
}

/* Loading State */
.ty3d-loader {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(8, 8, 22, 0.88);
  color: #FFE49E;
  font-size: 0.86rem;
  font-weight: 700;
  transition: opacity 380ms ease;
}

.ty3d-loader.is-done {
  opacity: 0;
  pointer-events: none;
}

.ty3d-loader__ring {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255, 216, 120, 0.2);
  border-top-color: #FFD25A;
  animation: ty3d-spin 0.85s linear infinite;
}

/* Golden Burst Reveal Flash */
.ty3d-flash {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, #FFFFFF 0%, #FFE48A 35%, rgba(255, 132, 24, 0.65) 70%, transparent 100%);
}

.ty3d-flash.is-burst {
  animation: ty3d-flash-burst 680ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Top HUD Overlay */
.ty3d-hud-top {
  position: absolute;
  top: 0.85rem;
  left: 0.95rem;
  right: 0.95rem;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  pointer-events: none;
}

.ty3d-hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.78rem;
  border-radius: 999px;
  background: rgba(9, 14, 38, 0.82);
  border: 1px solid rgba(255, 206, 98, 0.52);
  color: #FFE6A3;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ty3d-hud-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #FFCA4B;
  box-shadow: 0 0 10px #FFCA4B;
}

.ty3d-hud-hint {
  padding: 0.28rem 0.74rem;
  border-radius: 999px;
  background: rgba(8, 12, 32, 0.74);
  border: 1px solid rgba(156, 238, 255, 0.28);
  color: #C8F2FF;
  font-size: 0.74rem;
  font-weight: 600;
}

/* Stage 1 Secret Rarity Teaser Rail (Right side of 3D Box Stage) */
.ty3d-rarity-rail {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translate3d(0, -50%, 0);
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  pointer-events: none;
}

.ty3d-rarity-rail[hidden] {
  display: none !important;
}

.ty3d-rarity-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.8rem;
  border-radius: 12px;
  background: rgba(11, 12, 30, 0.84);
  border: 1px solid rgba(255, 212, 122, 0.3);
  min-width: 164px;
}

.ty3d-rarity-chip strong {
  display: block;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: #FFFFFF;
  line-height: 1.15;
}

.ty3d-rarity-chip span {
  display: block;
  font-size: 0.69rem;
  color: rgba(235, 240, 255, 0.78);
}

.ty3d-rarity-swatch {
  width: 22px;
  height: 30px;
  border-radius: 5px;
  flex-shrink: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
}

.ty3d-rarity-chip--gold .ty3d-rarity-swatch {
  background: linear-gradient(145deg, #FFF1A8 0%, #F4B936 52%, #A66509 100%);
  box-shadow: 0 0 12px rgba(244, 185, 54, 0.55);
}

.ty3d-rarity-chip--silver .ty3d-rarity-swatch {
  background: linear-gradient(145deg, #FFFFFF 0%, #B8CBE0 55%, #5D718C 100%);
  box-shadow: 0 0 12px rgba(196, 220, 248, 0.45);
}

.ty3d-rarity-chip--diamond .ty3d-rarity-swatch {
  background: linear-gradient(135deg, #FFFFFF 0%, #86EEFF 38%, #F4A8FF 70%, #9CF2FF 100%);
  box-shadow: 0 0 14px rgba(134, 238, 255, 0.6);
}

/* Stage 3 Per-Card Dock Row (cleanly below 3D viewport — zero overlap on card artwork) */
.ty3d-trio-labels {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  max-width: 860px;
  margin: 0.85rem auto 0;
}

.ty3d-trio-labels[hidden] {
  display: none !important;
}

.ty3d-card-dock {
  background: rgba(10, 12, 30, 0.86);
  border: 1px solid rgba(255, 212, 120, 0.34);
  border-radius: 12px;
  padding: 0.48rem 0.62rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.ty3d-card-dock__badge {
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ty3d-card-dock__name {
  font-size: 0.84rem;
  color: #FFFFFF;
}

.ty3d-card-dock__btns {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.16rem;
  flex-wrap: wrap;
}

.ty3d-mini-btn {
  padding: 0.26rem 0.56rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: #FFF7EB;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.ty3d-mini-btn:hover {
  transform: translate3d(0, -1px, 0);
  background: rgba(255, 255, 255, 0.18);
  border-color: #FFE49E;
}

.ty3d-mini-btn--gold {
  background: linear-gradient(90deg, #F5C544 0%, #F28B20 100%);
  color: #2E0900;
  border-color: transparent;
}

.ty3d-mini-btn--gold:hover {
  background: linear-gradient(90deg, #FFE07A 0%, #FFA334 100%);
  color: #2E0900;
}

/* ---------- Stage 2: Gacha Unboxing Cinema Overlay ---------- */
.ty3d-cinema {
  position: absolute;
  inset: 0;
  z-index: 12;
  background: #04030A;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ty3d-cinema[hidden] {
  display: none !important;
}

.ty3d-cinema__frame {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
}

.ty3d-cinema__video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000000;
}

.ty3d-cinema__hud {
  position: absolute;
  top: 0.75rem;
  left: 0.85rem;
  right: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
  z-index: 4;
}

.ty3d-cinema__tag {
  padding: 0.34rem 0.82rem;
  border-radius: 999px;
  background: rgba(12, 8, 22, 0.82);
  border: 1px solid rgba(255, 206, 92, 0.62);
  color: #FFE394;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.ty3d-cinema__actions {
  display: inline-flex;
  gap: 0.45rem;
}

.ty3d-cinema__btn {
  padding: 0.38rem 0.82rem;
  border-radius: 999px;
  background: rgba(12, 16, 36, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #FFFFFF;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease;
}

.ty3d-cinema__btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: #FFE49E;
}

.ty3d-cinema__btn--skip {
  background: linear-gradient(90deg, rgba(244, 184, 62, 0.92), rgba(232, 74, 12, 0.92));
  color: #2B0800;
  border-color: #FFE6A0;
  font-weight: 800;
}

.ty3d-cinema__btn--skip:hover {
  background: linear-gradient(90deg, #FFE07A, #FF701E);
}

/* ---------- STAGE 1 CONTROLS: Irresistible Pulsing Gacha Button ---------- */
.ty3d-controls {
  margin-top: 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.ty3d-controls[hidden] {
  display: none !important;
}

.ty3d-gacha-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.95rem;
  padding: 0.82rem 1.75rem 0.82rem 1.05rem;
  border-radius: 999px;
  border: 2px solid #FFE69C;
  background: linear-gradient(135deg, #FFE17D 0%, #FF9F26 42%, #D92B04 82%, #8F1028 100%);
  color: #2D0701;
  cursor: pointer;
  box-shadow:
    0 16px 42px rgba(232, 74, 12, 0.52),
    0 0 32px rgba(255, 206, 84, 0.42),
    inset 0 2px 0 rgba(255, 255, 255, 0.65);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  animation: ty3d-cta-breathe 2.6s ease-in-out infinite;
}

.ty3d-gacha-btn__glint {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

.ty3d-gacha-btn__glint i {
  position: absolute;
  top: 0;
  left: 0;
  width: 55%;
  height: 100%;
  background: linear-gradient(112deg, transparent 10%, rgba(255, 255, 255, 0.52) 50%, transparent 90%);
  animation: ty3d-cta-shimmer 3.2s ease-in-out infinite;
}

.ty3d-gacha-btn:hover {
  transform: translate3d(0, -4px, 0) scale(1.035);
}

.ty3d-gacha-btn:active {
  transform: translate3d(0, 0, 0) scale(0.985);
}

.ty3d-gacha-btn__aura {
  position: absolute;
  inset: -6px;
  border-radius: 999px;
  border: 2px solid rgba(255, 224, 130, 0.85);
  pointer-events: none;
  animation: ty3d-sonar 2.2s cubic-bezier(0.2, 0.6, 0.35, 1) infinite;
}

.ty3d-gacha-btn__aura--2 {
  border-color: rgba(255, 118, 34, 0.78);
  animation-delay: 1.1s;
}

.ty3d-gacha-btn__seal {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(145deg, #4A0716 0%, #8E1228 100%);
  border: 1.5px solid #FFE6A0;
  color: #FFE07D;
  font-size: 1.25rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(56, 4, 14, 0.55);
  animation: ty3d-star-spin 8s linear infinite;
}

.ty3d-gacha-btn__copy {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.2;
}

.ty3d-gacha-btn__label {
  font-size: clamp(0.96rem, 1.5vw, 1.12rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #FFFDF8;
  text-shadow: 0 2px 10px rgba(72, 10, 0, 0.55);
}

.ty3d-gacha-btn__sub {
  font-size: 0.76rem;
  font-weight: 700;
  color: #FFF3CC;
  text-shadow: 0 1px 6px rgba(60, 8, 0, 0.5);
}

.ty3d-gacha-btn__arrow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.24);
  color: #FFFFFF;
  font-size: 0.84rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.ty3d-sub-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.15rem;
  flex-wrap: wrap;
}

.ty3d-link-btn {
  background: none;
  border: none;
  padding: 0.25rem 0.45rem;
  color: #FFE09E;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.88;
  transition: opacity 180ms ease, color 180ms ease;
}

.ty3d-link-btn:hover {
  opacity: 1;
  color: #FFFFFF;
  text-decoration: underline;
}

/* ---------- STAGE 3 CONTROLS: 3D Cards Toolbar ---------- */
.ty3d-focus-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
}

.ty3d-tab {
  padding: 0.48rem 0.95rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 214, 128, 0.34);
  background: rgba(14, 20, 48, 0.78);
  color: #F4E8D6;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.ty3d-tab:hover {
  transform: translate3d(0, -1px, 0);
  border-color: #FFE082;
}

.ty3d-tab.is-active {
  background: linear-gradient(90deg, #F6C544 0%, #F27C1E 100%);
  color: #2F0900;
  border-color: #FFF0B8;
  font-weight: 800;
}

.ty3d-tool-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.ty3d-tool-btn {
  padding: 0.44rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(156, 238, 255, 0.34);
  background: rgba(10, 22, 62, 0.72);
  color: #E8F6FF;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.ty3d-tool-btn:hover {
  transform: translate3d(0, -1px, 0);
  background: rgba(24, 52, 128, 0.82);
  border-color: #7EEAFF;
}

.ty3d-tool-btn.is-active {
  background: rgba(36, 210, 255, 0.24);
  border-color: #24D2FF;
  color: #FFFFFF;
}

.ty3d-tool-btn--gacha {
  border-color: rgba(255, 198, 86, 0.65);
  background: rgba(168, 36, 12, 0.48);
  color: #FFE6A0;
}

.ty3d-tool-btn--gacha:hover {
  background: rgba(212, 54, 14, 0.75);
  border-color: #FFE07D;
}

.ty3d-tool-btn--link {
  border-color: rgba(255, 212, 118, 0.45);
  color: #FFE49E;
}

/* ---------- Pure GPU Keyframes ---------- */
@keyframes ty3d-rays-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes ty3d-spin {
  to { transform: rotate(360deg); }
}

@keyframes ty3d-star-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes ty3d-sonar {
  0% { transform: scale3d(1, 1, 1); opacity: 0.88; }
  100% { transform: scale3d(1.12, 1.48, 1); opacity: 0; }
}

@keyframes ty3d-cta-breathe {
  0%, 100% { transform: scale3d(1, 1, 1); }
  50% { transform: scale3d(1.024, 1.024, 1); }
}

@keyframes ty3d-cta-shimmer {
  0%, 52% { transform: translate3d(-160%, 0, 0) skewX(-20deg); }
  100% { transform: translate3d(340%, 0, 0) skewX(-20deg); }
}

@keyframes ty3d-flash-burst {
  0% { opacity: 0; transform: scale3d(0.75, 0.75, 1); }
  22% { opacity: 0.96; transform: scale3d(1.06, 1.06, 1); }
  100% { opacity: 0; transform: scale3d(1.22, 1.22, 1); }
}

@media (max-width: 900px) {
  .ty3d-rarity-rail {
    display: none;
  }
}

@media (max-width: 640px) {
  .ty3d-shell {
    padding: 1.05rem 0.72rem 1.2rem;
    border-radius: 16px;
  }
  .ty3d-header {
    margin-bottom: 0.85rem;
  }
  .ty3d-title {
    font-size: clamp(1.42rem, 6.2vw, 1.72rem);
  }
  .ty3d-subtitle {
    font-size: 0.82rem;
    line-height: 1.5;
  }
  .ty3d-canvas-host {
    height: 415px;
    border-radius: 14px;
  }
  /* Pin badge to very top & drag hint to very bottom so 3D Box/Cards are 100% unobstructed! */
  .ty3d-hud-top {
    top: 0.55rem;
    bottom: 0.55rem;
    left: 0.55rem;
    right: 0.55rem;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.4rem;
  }
  .ty3d-hud-pill {
    font-size: 0.64rem;
    padding: 0.24rem 0.64rem;
    letter-spacing: 0.06em;
  }
  .ty3d-hud-hint {
    font-size: 0.66rem;
    padding: 0.24rem 0.64rem;
    text-align: center;
    max-width: 100%;
  }
  .ty3d-cinema__hud {
    top: 0.5rem;
    left: 0.55rem;
    right: 0.55rem;
    gap: 0.4rem;
  }
  .ty3d-cinema__tag {
    font-size: 0.64rem;
    padding: 0.26rem 0.6rem;
  }
  .ty3d-cinema__btn {
    font-size: 0.68rem;
    padding: 0.28rem 0.62rem;
  }
  /* 3 compact dock columns directly below Ầm · Tử · Tuyết */
  .ty3d-trio-labels {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
    margin-top: 0.65rem;
  }
  .ty3d-card-dock {
    padding: 0.42rem 0.3rem;
    border-radius: 10px;
  }
  .ty3d-card-dock__badge {
    font-size: 0.54rem;
    letter-spacing: 0.04em;
  }
  .ty3d-card-dock__name {
    font-size: 0.74rem;
  }
  .ty3d-card-dock__btns {
    flex-direction: column;
    gap: 0.28rem;
  }
  .ty3d-mini-btn {
    width: 100%;
    padding: 0.26rem 0.3rem;
    font-size: 0.64rem;
  }
  .ty3d-controls {
    margin-top: 0.9rem;
    gap: 0.65rem;
  }
  .ty3d-gacha-btn {
    width: 100%;
    justify-content: space-between;
    gap: 0.62rem;
    padding: 0.64rem 0.85rem;
  }
  .ty3d-gacha-btn__seal {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  .ty3d-gacha-btn__label {
    font-size: 0.86rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
  }
  .ty3d-gacha-btn__sub {
    font-size: 0.68rem;
  }
  .ty3d-gacha-btn__arrow {
    width: 28px;
    height: 28px;
    font-size: 0.74rem;
  }
  .ty3d-sub-actions {
    gap: 0.5rem 1rem;
  }
  .ty3d-link-btn {
    font-size: 0.78rem;
  }
  .ty3d-focus-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 0.4rem;
  }
  .ty3d-tab {
    padding: 0.44rem 0.48rem;
    font-size: 0.73rem;
    text-align: center;
  }
  .ty3d-tool-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 0.4rem;
  }
  .ty3d-tool-btn {
    padding: 0.45rem 0.48rem;
    font-size: 0.72rem;
    text-align: center;
  }
}
