/* ==========================================================================
   《互动大师 · JOYPLUS Interactive Studio》— 9:16 IMMERSIVE CINEMA PLAYER
   File: hudong/static/player.css
   Benchmark: 《盛世天下》(Road to Empress) × ReelShort VIP × Apple TV+ OSD
   Scope: Standalone /play Fullscreen Theater + Studio Embedded 9:16 Simulator
   Rules: Strict .cinema-stage-lock · Zero <12px text · 100% tabular-nums
   ========================================================================== */

[hidden],
.cinema-stage-lock [hidden],
.player-theater [hidden],
.ivd-player [hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   1. CINEMA DARK-ROOM ISOLATION LOCK (.cinema-stage-lock)
   Ensures the 9:16 theater stays pure dark obsidian even inside Daylight UI
   -------------------------------------------------------------------------- */
.cinema-stage-lock,
.player-theater,
.ivd-player {
  color-scheme: dark;

  --p-bg-stage: #050609;
  --p-bg-glass: rgba(14, 16, 24, 0.76);
  --p-bg-glass-heavy: rgba(12, 14, 21, 0.94);
  --p-border-glass: rgba(255, 255, 255, 0.16);
  --p-border-subtle: rgba(255, 255, 255, 0.09);

  --p-fg: #F5F7FB;
  --p-fg-2: #D0D6E4;
  --p-fg-muted: #8E97AB;

  --p-flame: #FF6B2C;
  --p-vermilion: #E8492F;
  --p-gold: #FFB545;
  --p-gold-light: #FFE3A3;
  --p-emerald: #22C58B;
  --p-cerulean: #4DA6FF;
  --p-crimson: #F04438;
  --p-rose-ssr: #EA7396;

  --p-font: var(--ui-font-sans, "Poppins", -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", sans-serif);
  --p-num: var(--ui-font-display, "Poppins", Bahnschrift, "DIN Alternate", "Segoe UI", sans-serif);
  --p-mono: var(--ui-font-mono, "Cascadia Mono", Consolas, ui-monospace, monospace);

  --p-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --p-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --p-snappy: cubic-bezier(0.25, 1, 0.5, 1);

  font-family: var(--p-font);
  color: var(--p-fg);
}

/* --------------------------------------------------------------------------
   2. STANDALONE /play FULLSCREEN THEATER SHELL & DESKTOP STAGE
   -------------------------------------------------------------------------- */
.player-theater {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: #040507;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px;
  overflow: hidden;
  z-index: 100;
}

/* Subtle Warm Cinema Ambilight (never purple/cyan neon!) */
.theater-ambilight {
  position: absolute;
  width: min(560px, 85vw);
  height: min(860px, 88vh);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 107, 44, 0.18) 0%,
    rgba(255, 181, 69, 0.08) 42%,
    transparent 72%
  );
  filter: blur(72px);
  pointer-events: none;
  z-index: 0;
}

/* Top-Left Back Pill Outside Frame on Desktop Theater */
.theater-exit-bar {
  position: fixed;
  top: 18px;
  left: 22px;
  right: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 120;
}
.theater-pill-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(18, 20, 28, 0.78);
  backdrop-filter: blur(16px);
  border: 1px solid var(--p-border-glass);
  color: var(--p-fg);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.theater-pill-btn:hover {
  background: rgba(28, 32, 44, 0.9);
  border-color: rgba(255, 107, 44, 0.6);
}

/* Optional Desktop Side Telemetry HUD */
.theater-side-hud {
  position: relative;
  z-index: 2;
  width: 288px;
  max-height: min(90vh, 880px);
  padding: 16px;
  border-radius: 18px;
  background: rgba(15, 17, 24, 0.84);
  backdrop-filter: blur(20px);
  border: 1px solid var(--p-border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
  overscroll-behavior: contain;
}

/* Director Mode Side HUD: Guarantee scrollable container so Fate Track / Cast Heat never starve */
#theaterRoot:not(.is-player-mode) .theater-side-hud {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
  overscroll-behavior: contain;
}
#theaterRoot:not(.is-player-mode) .theater-side-hud::-webkit-scrollbar {
  width: 5px;
}
#theaterRoot:not(.is-player-mode) .theater-side-hud::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}
#theaterRoot:not(.is-player-mode) .theater-side-hud .hud-sec.fate-sec {
  min-height: 220px;
  flex: 1 0 220px;
}

/* --------------------------------------------------------------------------
   3. CORE 9:16 INTERACTIVE PLAYER CONTAINER (Container-Query Adaptive)
   -------------------------------------------------------------------------- */
.ivd-player,
.cinema-viewport {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  aspect-ratio: 9 / 16;
  background: var(--p-bg-stage);
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  container-type: inline-size;
  container-name: player;
}

.player-theater > .ivd-player {
  width: auto;
  height: min(92dvh, 940px);
  aspect-ratio: 9 / 16;
  border-radius: 24px;
  box-shadow:
    0 32px 90px rgba(0, 0, 0, 0.88),
    0 0 0 1px rgba(255, 255, 255, 0.12);
}

.ivd-player.is-shaking {
  animation: qte-stage-shake 240ms var(--p-snappy);
}

@keyframes qte-stage-shake {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  20%  { transform: translate3d(-8px, 4px, 0) rotate(-0.8deg); }
  45%  { transform: translate3d(7px, -4px, 0) rotate(0.6deg); }
  72%  { transform: translate3d(-4px, 2px, 0) rotate(-0.3deg); }
  100% { transform: translate3d(0, 0, 0) rotate(0deg); }
}

/* --------------------------------------------------------------------------
   4. 3-SLOT ZERO-BLACK-FRAME VIDEO STACK & CINEMA FILTERS
   -------------------------------------------------------------------------- */
.video-stack {
  position: absolute;
  inset: 0;
  background: #050609;
  z-index: 1;
  overflow: hidden;
}

.video-slot,
.video-poster-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  transform: translateZ(0) scale(1);
  transition: opacity 90ms linear, transform 650ms var(--p-spring), filter 320ms ease;
  will-change: opacity, transform;
}

.video-slot.is-active {
  opacity: 1;
  z-index: 3;
}
.video-slot.is-outgoing {
  opacity: 1;
  z-index: 2;
}
.video-slot.is-preload {
  opacity: 0.001;
  z-index: 1;
}

/* Cliffhanger Slow-Mo Breathing Zoom */
.ivd-player.is-cliffhanger .video-slot.is-active {
  transform: scale(1.035);
}

/* Bad-End Crimson Desaturation Freeze */
.ivd-player.is-bad-end .video-slot.is-active {
  filter: contrast(1.15) saturate(0.38) brightness(0.72);
  transform: scale(1.02);
}

/* Time Rewind Chromatic Sweep State */
.ivd-player.is-rewinding .video-stack {
  animation: film-rewind-flash 380ms var(--p-spring);
}
@keyframes film-rewind-flash {
  0%   { filter: brightness(1) contrast(1); transform: scale(1); }
  40%  { filter: brightness(1.45) contrast(1.25) sepia(0.35); transform: scale(0.975); }
  100% { filter: brightness(1) contrast(1); transform: scale(1); }
}

/* Ambient Top/Bottom Vignette Scrims */
.cinema-vignette {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.64) 0%, transparent 20%, transparent 56%, rgba(0, 0, 0, 0.84) 100%);
  transition: box-shadow 350ms ease;
}
.ivd-player.is-cliffhanger .cinema-vignette {
  box-shadow: inset 0 0 76px rgba(0, 0, 0, 0.65);
}
.ivd-player.is-bad-end .cinema-vignette {
  background:
    radial-gradient(circle at 50% 42%, rgba(240, 68, 56, 0.16), rgba(90, 10, 12, 0.78) 88%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.92));
}

/* Dialogue Subtitle Caption Band (TikTok Golden Lower-Third MarginV = 450/1920 = 23.4%) */
.cinema-subtitle,
.ivd-subtitle-wrap {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 23.4%;
  z-index: 8;
  display: flex;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  transition: opacity 150ms ease, bottom 220ms var(--p-spring);
}
.ivd-player.has-choices:not(.is-continue-qte):not(:has(> .ivd-qte-root.is-continue-qte)) .cinema-subtitle,
.ivd-player.has-choices:not(.is-continue-qte):not(:has(> .ivd-qte-root.is-continue-qte)) .ivd-subtitle-wrap,
.ivd-player.is-bad-end .cinema-subtitle,
.ivd-player.is-bad-end .ivd-subtitle-wrap {
  opacity: 0 !important;
  visibility: hidden;
}
.cinema-subtitle > span {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 100%;
  padding: 5px 12px;
  border-radius: 8px;
  background: rgba(8, 10, 16, 0.62);
  backdrop-filter: blur(6px);
  color: #FFFFFF;
  font-family: var(--ui-font-sans, "Poppins", -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", sans-serif);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.32;
  overflow-wrap: break-word;
  text-wrap: pretty;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.92), 0 2px 8px rgba(0, 0, 0, 0.78);
}
.ivd-stage-root .ivd-sub-en,
.ivd-sub-en {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-family: var(--ui-font-sans, "Poppins", -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", sans-serif);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.32;
  overflow-wrap: break-word;
  text-wrap: pretty;
  color: #FFFFFF;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.94), 0 2px 8px rgba(0, 0, 0, 0.80);
}

/* --------------------------------------------------------------------------
   5. TOP CINEMA CHROME & WALLET / GIFT / FATE TRIGGERS
   -------------------------------------------------------------------------- */
.player-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 25;
  padding: max(12px, env(safe-area-inset-top)) 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.player-ep-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(12, 14, 20, 0.62);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 600;
  color: var(--p-fg);
  max-width: 48%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-hud-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-capsule {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(14, 16, 24, 0.72);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--p-fg);
  font: 600 12px/1 var(--p-num);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 140ms ease, transform 100ms ease;
}
.hud-capsule:hover {
  border-color: rgba(255, 181, 69, 0.6);
}
.hud-capsule:active {
  transform: scale(0.96);
}
.hud-capsule.wallet {
  border-color: rgba(255, 181, 69, 0.42);
  color: var(--p-gold-light);
}

/* Live Mini Variable Bar below Topbar */
.player-stat-strip {
  position: absolute;
  top: calc(50px + env(safe-area-inset-top, 0px));
  left: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  pointer-events: none;
}
.stat-mini-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(10, 12, 18, 0.56);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font: 600 12px/1.35 var(--p-num);
  font-variant-numeric: tabular-nums;
  color: var(--p-fg-2);
}

/* --------------------------------------------------------------------------
   6. AFFINITY / REVENGE / DIGNITY SPRING MICRO-TOASTS
   -------------------------------------------------------------------------- */
.stat-toast-stack,
.ivd-stage-root .stat-toast-stack {
  position: absolute;
  top: calc(82px + env(safe-area-inset-top, 0px));
  left: 14px;
  z-index: 36;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.stat-toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px 6px 8px;
  border-radius: 999px;
  background: rgba(14, 16, 24, 0.86);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 181, 69, 0.44);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  animation: toast-spring-in 420ms var(--p-pop) forwards;
}
.stat-toast.is-leaving {
  animation: toast-fade-up 240ms ease forwards;
}
.stat-toast-orb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: grid;
  place-items: center;
  font-size: 13px;
}
.stat-toast-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--p-fg);
}
.stat-toast-delta {
  font: 700 13px/1 var(--p-num);
  font-variant-numeric: tabular-nums;
  color: var(--p-gold);
}
.stat-toast[data-var="revenge"] .stat-toast-delta { color: var(--p-flame); }
.stat-toast[data-var="affinity"] .stat-toast-delta { color: var(--p-emerald); }
.stat-toast[data-var="dignity"] .stat-toast-delta { color: var(--p-cerulean); }

@keyframes toast-spring-in {
  0%   { opacity: 0; transform: translate3d(-14px, 8px, 0) scale(0.86); }
  100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes toast-fade-up {
  to   { opacity: 0; transform: translate3d(0, -10px, 0) scale(0.95); }
}


/* Live Interactive Stage: Floating Reaction Bursts, Cheer Rail & 3s Radar HUD */
.ivd-reaction-layer {
  position: absolute;
  inset: 0;
  z-index: 21;
  pointer-events: none;
  overflow: hidden;
}

.ivd-tap-burst {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: grid;
  place-items: center;
}

.ivd-burst-ring {
  position: absolute;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 2.5px solid var(--burst-color, #FFB545);
  box-shadow: 0 0 22px var(--burst-glow, rgba(255, 181, 69, 0.65));
  animation: stage-burst-ring 560ms var(--p-snappy) forwards;
}

.ivd-burst-pill {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(10, 12, 20, 0.86);
  backdrop-filter: blur(10px);
  border: 1.5px solid var(--burst-color, #FFB545);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.62), 0 0 18px var(--burst-glow, rgba(255, 181, 69, 0.55));
  color: #FFFFFF;
  font: 800 13.5px/1.2 var(--p-font);
  white-space: nowrap;
  animation: stage-burst-float 880ms var(--p-spring) forwards;
}

.ivd-burst-combo {
  font-style: normal;
  font: 900 13px/1 var(--p-num);
  color: #FFE3A3;
}

.ivd-burst-spark {
  position: absolute;
  font-style: normal;
  font-size: 16px;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.65));
  animation: stage-spark-fly 820ms var(--p-snappy) forwards;
}

@keyframes stage-burst-ring {
  0%   { transform: scale(0.25); opacity: 0.95; }
  100% { transform: scale(1.85); opacity: 0; border-width: 1px; }
}

@keyframes stage-burst-float {
  0%   { opacity: 0; transform: translateY(10px) scale(0.65) rotate(-4deg); }
  24%  { opacity: 1; transform: translateY(-8px) scale(1.08) rotate(2deg); }
  72%  { opacity: 1; transform: translateY(-28px) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translateY(-48px) scale(0.92); }
}

@keyframes stage-spark-fly {
  0%   { opacity: 1; transform: translate(0, 0) scale(0.6); }
  100% { opacity: 0; transform: translate(var(--dx, 0px), var(--dy, -48px)) scale(1.18); }
}

/* Cast Rose🌹 / Catharsis🔥 / Tomato🍅 Cheer Pill Rail */
.ivd-cheer-dock {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 23;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 5px;
  border-radius: 999px;
  background: rgba(10, 13, 22, 0.62);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.48);
  transition: opacity 200ms ease, transform 220ms var(--p-spring);
}

.ivd-player.has-choices .ivd-cheer-dock,
.ivd-player.has-interaction .ivd-cheer-dock,
.ivd-player.is-bad-end .ivd-cheer-dock {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(18px);
}

.ivd-cheer-btn {
  position: relative;
  width: 40px;
  min-height: 44px;
  padding: 4px 2px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(20, 24, 38, 0.78);
  color: #F8FAFC;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  transition: transform 140ms var(--p-pop), border-color 140ms ease, background 140ms ease;
}
.ivd-cheer-btn:hover {
  transform: scale(1.08);
  border-color: rgba(255, 196, 92, 0.72);
  background: rgba(34, 40, 60, 0.92);
}
.ivd-cheer-btn.is-popping {
  animation: cheer-btn-pop 280ms var(--p-pop);
}
@keyframes cheer-btn-pop {
  0%   { transform: scale(0.86); }
  55%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.ivd-cheer-emoji {
  font-size: 17px;
  line-height: 1.05;
}
.ivd-cheer-label {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.05;
  color: #E2E8F0;
  transform: scale(0.86);
}
.ivd-cheer-count {
  position: absolute;
  top: -5px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: linear-gradient(135deg, #FF6B2C, #E8492F);
  color: #FFFFFF;
  font: 800 12px/18px var(--p-num);
  font-variant-numeric: tabular-nums;
  text-align: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}

/* 3s Pre-Interaction Interactive Mode HUD Indicator */
.ivd-upcoming-hud {
  position: absolute;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 27;
  max-width: calc(100% - 24px);
  padding: 7px 14px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(16, 20, 34, 0.92), rgba(34, 22, 16, 0.92));
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 196, 92, 0.74);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.62),
    0 0 22px rgba(255, 140, 44, 0.34);
  color: #FFF7E6;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  cursor: pointer;
  white-space: nowrap;
  animation: upcoming-radar-in 260ms var(--p-spring);
}
.ivd-upcoming-hud.is-imminent {
  border-color: #FF7A45;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.68), 0 0 26px rgba(232, 73, 47, 0.55);
}
@keyframes upcoming-radar-in {
  from { opacity: 0; transform: translate(-50%, -10px) scale(0.92); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.ivd-upcoming-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #FFB545;
  box-shadow: 0 0 10px #FF6B2C;
  flex-shrink: 0;
  animation: choice-bolt-pulse 0.85s ease-in-out infinite;
}
.ivd-upcoming-text {
  font: 800 12px/1.2 var(--p-font);
  color: #FFF8EB;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ivd-upcoming-sec {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 181, 69, 0.22);
  color: #FFE3A3;
  font: 800 12px/1.2 var(--p-num);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.ivd-upcoming-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, #FF6B2C, #FFE3A3);
  transition: width 80ms linear;
}


/* --------------------------------------------------------------------------
   11. SLIDE-UP DRAWERS: GIFT BOOST (送礼助力) & 命运图谱 (FATE TREE)
   -------------------------------------------------------------------------- */
.player-drawer-backdrop {
  position: absolute;
  inset: 0;
  z-index: var(--z-drawer-backdrop, 48);
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(4px);
}

.gift-drawer,
.fate-drawer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-drawer, 52);
  max-height: 80%;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-radius: 22px 22px 0 0;
  background: var(--p-bg-glass-heavy);
  backdrop-filter: blur(26px);
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 -20px 54px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: drawer-slide-up 360ms var(--p-spring);
}
.fate-drawer {
  height: 78%;
}

@keyframes drawer-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.drawer-head {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--p-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.drawer-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: #FFFFFF;
}

/* Gift Boost Cards */
.gift-grid {
  padding: 14px 16px 20px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  overflow-y: auto;
}
.gift-card {
  padding: 12px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--p-border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 100ms ease;
}
.gift-card:hover {
  border-color: var(--p-gold);
  background: rgba(255, 181, 69, 0.1);
}
.gift-card:active {
  transform: scale(0.96);
}
.gift-emoji {
  font-size: 26px;
  line-height: 1.1;
}
.gift-name {
  font-size: 12px;
  font-weight: 700;
  color: #FFFFFF;
}
.gift-effect {
  font: 600 12px/1.2 var(--p-num);
  color: var(--p-emerald);
}
.gift-cost {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 181, 69, 0.2);
  color: var(--p-gold-light);
  font: 700 12px/1.3 var(--p-num);
  font-variant-numeric: tabular-nums;
}

/* Fate Tree Constellation Map */
.fate-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fate-node-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--p-border-subtle);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}
.fate-node-row:hover,
.fate-node-row.is-current {
  border-color: var(--p-flame);
  background: rgba(255, 107, 44, 0.12);
}
.fate-node-row.is-locked {
  opacity: 0.55;
  border-style: dashed;
  cursor: default;
}
.fate-node-thumb {
  width: 36px;
  aspect-ratio: 9 / 16;
  border-radius: 5px;
  object-fit: cover;
  background: #141722;
  flex-shrink: 0;
}
.fate-node-meta {
  flex: 1;
  min-width: 0;
}
.fate-node-meta b {
  display: block;
  font-size: 13px;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fate-node-meta span {
  font-size: 12px;
  color: var(--p-fg-muted);
}

/* --------------------------------------------------------------------------
   12. COMPACT SIMULATOR CONTAINER QUERIES & MOBILE EDGE-TO-EDGE
   -------------------------------------------------------------------------- */
@container player (max-width: 290px) {
  .player-topbar {
    padding: 8px 8px 6px;
  }
  .hud-capsule {
    height: 26px;
    padding: 0 7px;
  }
  .interaction-dock,
  .choice-overlay {
    padding: 16px 8px 10px;
    gap: 6px;
    max-height: 84%;
  }
  .choice-header-block {
    gap: 5px;
  }
  .choice-style-badge {
    display: none;
  }
  .choice-prompt-title {
    font-size: 13.5px;
  }
  .choice-card {
    min-height: 48px;
    padding: 7px 9px 9px;
    border-radius: 11px;
    gap: 4px;
  }
  .choice-thumb-wrap {
    width: 32px;
    height: 43px;
  }
  .choice-label {
    font-size: 12.5px;
  }
  .choice-label-en {
    display: none;
  }
  .countdown-ring {
    width: 32px;
    height: 32px;
  }
  .ivd-cheer-dock {
    right: 6px;
    padding: 4px 3px;
    gap: 5px;
  }
  .ivd-cheer-btn {
    width: 32px;
    min-height: 34px;
  }
  .ivd-cheer-label {
    display: none;
  }
  .ivd-upcoming-hud {
    top: 48px;
    padding: 5px 10px 7px;
  }
  .cinema-subtitle > span,
  .ivd-sub-en {
    font-size: 12.5px;
  }
}

@media (max-width: 900px) {
  .theater-side-hud {
    display: none;
  }
}

@media (max-width: 560px) {
  .player-theater {
    padding: 0;
  }
  .player-theater > .ivd-player {
    width: 100vw;
    height: 100dvh;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
  }
  .theater-exit-bar {
    top: max(10px, env(safe-area-inset-top));
    left: 12px;
    right: 12px;
  }
}

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


/* Cinema Accessibility Focus & Clean Stage Enhancements (v6) */
.ivd-player .ivd-qte-root .ivd-choice-card:focus-visible,
.ivd-player .ivd-pill-btn:focus-visible {
  outline: 2px solid #F6DC92;
  outline-offset: -3px;
}
/* Disable cliffhanger zoom during AR spatial_anchors so reticle pins stay pixel-locked */
.ivd-player.is-cliffhanger.is-spatial-choice .video-slot.is-active {
  transform: translateZ(0) scale(1);
}
/* Prominent one-tap sound unlock capsule when autoplay starts muted */
.ivd-stage-root .ivd-aux-pills .ivd-sound-pill {
  background: linear-gradient(135deg, rgba(255, 181, 69, 0.26), rgba(20, 18, 14, 0.86));
  border: 1px solid rgba(255, 209, 102, 0.78);
  color: #FFF4D4;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.52), 0 0 14px rgba(255, 181, 69, 0.28);
}
.ivd-stage-root .ivd-aux-pills .ivd-sound-pill:hover {
  background: linear-gradient(135deg, rgba(255, 181, 69, 0.42), rgba(28, 22, 16, 0.92));
  border-color: #FFE3A3;
}
/* Hide redundant PLAY/PAUSE pill while playing on standalone theater (keep SOUND, EP badge & ↺ 5s visible!) */
#playerStage .ivd-aux-pills .ivd-play-pill.is-playing {
  display: none;
}
#playerStage .ivd-stage-root.has-choices .ivd-aux-pills,
#playerStage .ivd-stage-root.has-interaction .ivd-aux-pills,
#playerStage .ivd-stage-root.is-ending .ivd-aux-pills,
#playerStage .ivd-stage-root.is-bad-end .ivd-aux-pills,
#playerStage.has-choices .ivd-aux-pills,
#playerStage.is-bad-end .ivd-aux-pills {
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}
@media (hover: hover) and (pointer: fine) {
  #playerStage:not(.has-choices):hover .ivd-aux-pills .ivd-play-pill.is-playing {
    display: inline-flex;
    opacity: 0.78;
    pointer-events: auto;
  }
}

/* ==========================================================================
   13. PURE PLAYER MODE (?mode=player / #theaterRoot.is-player-mode)
   Pure Netflix Stories × ReelShort 9:16 Centered Immersion · Zero Dev Chrome
   ========================================================================== */
#theaterRoot.is-player-mode .theater-side-hud,
#theaterRoot.is-player-mode #exitStudioLink,
#theaterRoot.is-player-mode #theaterGenreSelect,
#theaterRoot.is-player-mode #btnLangToggle,
.is-player-mode #btnLangToggle,
#theaterRoot.is-player-mode #btnTriggerNow,
#theaterRoot.is-player-mode #btnLanQrPreview,
#theaterRoot.is-player-mode #showcaseBadge,
#theaterRoot.is-player-mode #mtpTriggerNow,
#theaterRoot.is-player-mode #mtpGenreSelect,
#theaterRoot.is-player-mode #mtpLanQr,
#theaterRoot.is-player-mode #mtpStudioLink {
  display: none !important;
}

/* Smooth Auto-Fading Cinema OSD (Idle Fade) */
.theater-exit-bar,
.ivd-aux-pills,
.ivd-top-hud {
  transition: opacity 0.35s ease;
}
.is-osd-idle .theater-exit-bar,
.is-osd-idle .ivd-aux-pills,
.is-osd-idle .ivd-top-hud {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.is-osd-idle .theater-exit-bar:has(:focus-visible) {
  opacity: 1;
  pointer-events: auto;
}

#theaterRoot.player-theater.is-player-mode {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-template-columns: none;
  gap: 0;
  padding: 14px 20px;
  background: radial-gradient(circle at 50% 42%, #0c0e16 0%, #030407 78%);
}

#theaterRoot.is-player-mode .theater-exit-bar {
  left: 20px;
  right: 20px;
  top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

#theaterRoot.is-player-mode .theater-title-pill {
  opacity: 0.72;
  max-width: clamp(120px, 24vw, 280px);
  transition: opacity 180ms ease;
}
#theaterRoot.is-player-mode .theater-title-pill:hover {
  opacity: 1;
}

#theaterRoot.is-player-mode .theater-exit-bar .theater-pill-btn {
  background: rgba(14, 16, 24, 0.56);
  border-color: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 999px;
  opacity: 0.78;
  transition: opacity 160ms ease, background 160ms ease, border-color 160ms ease;
}
#theaterRoot.is-player-mode .theater-exit-bar .theater-pill-btn:hover {
  opacity: 1;
  background: rgba(22, 26, 38, 0.88);
  border-color: color-mix(in srgb, var(--th-accent, #FFB545) 58%, transparent);
}

#theaterRoot.player-theater.is-player-mode > #playerStage {
  margin-top: 0;
  height: min(calc(100dvh - 28px), 960px);
  width: auto;
  max-width: calc(100vw - 24px);
  aspect-ratio: 9 / 16;
  border-radius: 26px;
  box-shadow:
    0 36px 104px rgba(0, 0, 0, 0.92),
    0 0 0 1px rgba(255, 255, 255, 0.13),
    0 0 64px color-mix(in srgb, var(--th-accent, #FFB545) 14%, transparent);
}

.theater-pill-btn.player-mode-pill {
  border-color: color-mix(in srgb, var(--th-accent, #FFB545) 45%, var(--p-border-glass));
}
#theaterRoot.is-player-mode .theater-pill-btn.player-mode-pill {
  opacity: 0.74;
  font-size: 12px;
}
#theaterRoot.is-player-mode .theater-pill-btn.player-mode-pill:hover {
  opacity: 1;
}

@media (max-width: 900px) {
  #theaterRoot.player-theater.is-player-mode {
    display: block;
    padding: 0;
  }
  #theaterRoot.player-theater.is-player-mode > #playerStage {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
  }
  #theaterRoot.is-player-mode .theater-exit-bar {
    top: 0;
    left: 0;
    right: 0;
  }
  #theaterRoot.is-player-mode #btnPlayerModeToggle {
    display: inline-flex !important;
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }
}

/* Pure IAA Mode: strictly hide unused Coins / Topup / Gifts surfaces */
#theaterRoot.is-pure-iaa #btnGiftDrawer,
#theaterRoot.is-pure-iaa #mtpGiftDrawer,
#theaterRoot.is-pure-iaa #walletRow,
#theaterRoot.is-pure-iaa #giftDrawer {
  display: none !important;
}
