@import url('https://fonts.googleapis.com/css2?family=Afacad:ital,wght@0,400..700;1,400..700&display=swap');

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: #000;
  color: #fff;
  overflow: hidden;
  height: 100vh;
}

#app {
  width: 100vw;
  height: 100vh;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-content {
  text-align: center;
  color: white;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-content h2 {
  margin-bottom: 20px;
  font-size: 24px;
  font-weight: 300;
}

.progress-container {
  margin: 20px 0;
}

.progress-bar {
  width: 300px;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #45a049);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
}

.loading-status {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 10px;
}

/* Player Container */
.player-container {
  width: 100vw;
  height: 100vh;
  position: relative;
  background: #000;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  /* Ensure proper centering */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  /* Ensure touch events work */
  touch-action: manipulation;
  pointer-events: auto;
}

/* Stage */
.stage {
  /* Fixed dimensions - will be scaled by JavaScript */
  width: 960px;
  height: 540px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  position: relative;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  /* Ensure proper centering */
  margin: 0 auto;
  flex-shrink: 0;
  /* Ensure touch events work */
  touch-action: manipulation;
  pointer-events: auto;
}


/* Responsive scaling logic */
:root {
  --stage-width: 960;
  --stage-height: 540;
}

@media (min-aspect-ratio: 16/9) {
  :root {
    --stage-scale: calc(100vh / var(--stage-height));
  }
}
@media (max-aspect-ratio: 16/9) {
  :root {
    --stage-scale: calc(100vw / var(--stage-width));
  }
}

/* Controls */
.controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.4));
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.control-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
  min-width: 50px;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.control-btn:active {
  transform: scale(0.95);
}

.timeline-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.timeline-slider {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
}

.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #4caf50;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.timeline-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #4caf50;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.time-display {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.timeline-cursor {
  position: absolute;
  left: 0%; /* Will be updated by JS */
  top: -4px; /* Adjust to align with slider track */
  width: 2px;
  height: calc(100% + 8px); /* Extend slightly above/below slider */
  background-color: red;
  z-index: 10;
  pointer-events: none; /* So it doesn't interfere with slider interaction */
}

.timeline-markers-container {
  position: absolute;
  top: 0; /* Align with the top of the slider */
  left: 0;
  width: 100%;
  height: 100%; /* Cover the slider area */
  pointer-events: none; /* Allow clicks to pass through to slider */
}

.timeline-marker {
  position: absolute;
  top: 50%; /* Center vertically on the slider track */
  transform: translateY(-50%) translateX(-50%); /* Center the marker itself */
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: orange; /* Default for event triggers */
  z-index: 5; /* Below cursor but above slider track */
}

.timeline-marker.end-flag {
  background-color: red; /* Red color for slide end flags */
  width: 12px;
  height: 12px;
  border: 2px solid white;
  box-shadow: 0 0 8px rgba(255, 0, 0, 0.6);
}

.timeline-marker.end-flag.main {
  background-color: darkred; /* Darker red for main timeline end flag */
  width: 14px;
  height: 14px;
  border: 2px solid white;
  box-shadow: 0 0 10px rgba(139, 0, 0, 0.8);
}

/* Language FAB */
.language-fab {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 100;
}

.fab-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.fab-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.language-menu {
  position: absolute;
  top: 70px;
  right: 0;
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 8px 0;
  min-width: 150px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.language-option {
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: 14px;
  color: white;
}

.language-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

.language-option.active {
  background: rgba(76, 175, 80, 0.3);
  color: #4caf50;
}

/* Fullscreen Player Styles */
.player-container.fullscreen-active {
    /* CSS-based fullscreen for iOS (no native Fullscreen API support) */
    /* Also serves as fallback for any browser that rejects requestFullscreen */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    background-color: #000 !important;
}

/* .player-container.fullscreen-active .stage {
    width: 100vw !important;
    height: 100vh !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background-color: #000 !important;
    z-index: 2000 !important;
} */

.player-container.fullscreen-active #grid-canvas-container {
    width: 100% !important; /* Fill the stage */
    height: 100% !important;
    border: none !important;
    top: 0 !important; /* Align to top-left of stage */
    left: 0 !important;
    position: absolute !important; /* Ensure it's positioned within stage */
    background: transparent !important; 
    padding: 0 !important; /* Remove padding in fullscreen */
    border-radius: 0 !important; /* Remove border-radius in fullscreen */
}

.player-container.fullscreen-active .controls {
    display: none; /* Hidden by default */
    position: fixed; /* Make controls fixed for overlay */
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2001; /* Above the stage */
    background: rgba(0,0,0,0.7); /* Semi-transparent background */
    padding: 10px;
    border-radius: 8px;
}

.player-container.fullscreen-active .controls.controls-visible-in-fullscreen {
    display: flex; /* Shown when class is added */
}

.player-container.fullscreen-active #language-fab {
    display: none;
}

/* Text Rendering Optimization for Complex Scripts */
.text-element p,
.text-content-actual {
  /* Font rendering optimizations */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  
  /* Complex script support */
  font-variant-ligatures: common-ligatures;
  font-feature-settings: "liga" 1, "clig" 1;
  
  /* Prevent text breaking issues in complex scripts */
  word-break: keep-all;
  line-break: strict;
  
  /* Unicode bidirectional text support */
  unicode-bidi: embed;
}

/* Language-specific text adjustments */
.text-element[lang="ta"] p,
.text-element[lang="ml"] p,
.text-element[lang="hi"] p,
.text-element[lang="bn"] p,
.text-element[lang="te"] p,
.text-element[lang="kn"] p,
.text-element[lang="gu"] p,
.text-element[lang="pa"] p,
.text-element[lang="or"] p,
.text-element[lang="mr"] p,
.text-element[lang="ne"] p {
  /* Additional spacing for complex scripts */
  letter-spacing: 0.02em;
  line-height: 1.4;
}

/* Stage Elements */
.stage-element {
  position: absolute;
  box-sizing: border-box;
  z-index: 10;
  transition: opacity 0.3s ease;
  /* Ensure touch events work on stage elements */
  pointer-events: auto;
  touch-action: manipulation;
}

.group-element {
  position: absolute;
  box-sizing: border-box;
  overflow: visible;
}

.css-shape-element {
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.text-element {
  color: inherit !important; /* Allow text elements to override inherited color */
  top: 0;
  left: 0;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  /* Ensure touch events work on text elements */
  pointer-events: auto;
  touch-action: manipulation;
}

/* Ensure text content can override inherited colors */
.text-element .text-content-actual {
  color: inherit !important;
}

.text-element .text-content-container {
  color: inherit !important;
}


.animated {
  animation-fill-mode: both;
}

.shape-actual {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: border-box;
}

/* Video Elements */
.video-element {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Audio Elements */
.audio-element {
  display: none;
}

/* Image Elements */
.image-element {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Lottie Elements */
.lottie-element {
  width: 100%;
  height: 100%;
}

/* Three.js Elements */
.threejs-element {
  width: 100%;
  height: 100%;
}



/* Interactive Elements */
.interactive-element {
  cursor: pointer;
  transition: transform 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  /* Ensure touch events work on interactive elements */
  pointer-events: auto !important;
  touch-action: manipulation !important;
}

.interactive-element:hover {
  transform: scale(1.02);
}

.interactive-element:active {
  transform: scale(0.98);
}

/* ClickToContinue specific styles for player */
.click-to-continue-button-player {
  /* Base styles are applied by TextRenderer from componentProps */
  transition: all 0.2s ease; /* For smooth hover effects if any */
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  /* Ensure touch events work on click-to-continue buttons */
  pointer-events: auto !important;
  touch-action: manipulation !important;
  cursor: pointer;
}

.timeline-ctc-active {
  cursor: pointer;
  animation: pulse-ctc 1.5s infinite;
  /* Optional: Add a more prominent visual cue when active */
  /* box-shadow: 0 0 15px 5px rgba(59, 130, 246, 0.7); */
}

@keyframes pulse-ctc {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

/* Responsive Design */
@media (max-width: 768px) {
  /* Ensure stage wrapper doesn't block touch events on mobile */
  #stage-wrapper {
    pointer-events: auto !important;
    touch-action: manipulation !important;
  }
  
  #canvas-wrapper {
    pointer-events: auto !important;
    touch-action: manipulation !important;
  }
  
  /* Ensure stage allows touch events */
  .stage {
    pointer-events: auto !important;
    touch-action: manipulation !important;
  }
  
  /* Ensure all stage elements are touchable on mobile */
  .stage-element {
    pointer-events: auto !important;
    touch-action: manipulation !important;
  }
  
  /* Ensure interactive elements work on mobile */
  .interactive-element,
  .click-to-continue-button-player,
  button,
  .control-btn {
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
  }
  
  .controls {
    padding: 10px;
    gap: 8px;
  }
  
  .control-btn {
    padding: 10px 12px;
    min-width: 40px;
    font-size: 14px;
  }
  
  .timeline-slider {
    height: 10px; /* Thicker slider for better touch control */
  }
  
  .timeline-slider::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }
  
  .timeline-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }
  
  .language-fab {
    bottom: 70px;
    right: 15px;
  }
  
  .fab-btn {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
  
  .language-menu {
    bottom: 130px;
    right: 15px;
  }
  
  .language-option {
    padding: 12px 15px;
    font-size: 16px;
  }
  
  /* Improved touch targets for mobile */
  .interactive-element {
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Ensure buttons have adequate touch targets */
  button, 
  .control-btn, 
  .fab-btn, 
  .fab-main, 
  .fab-sub,
  .modal-close-btn {
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Ensure timeline slider has larger hit area */
  .timeline-container {
    padding: 10px 0;
  }
  
  /* Improve modal for mobile */
  .modal-content {
    width: 90%;
    max-width: 400px;
    padding: 15px;
  }
  
  /* Increase size of language list items for better touch */
  .language-list-item {
    padding: 15px;
    font-size: 16px;
  }
}

/* Animation Classes */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}

.fade-out {
  animation: fadeOut 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.slide-in-left {
  animation: slideInLeft 0.3s ease-out;
}

.slide-in-right {
  animation: slideInRight 0.3s ease-out;
}

.slide-in-top {
  animation: slideInTop 0.3s ease-out;
}

.slide-in-bottom {
  animation: slideInBottom 0.3s ease-out;
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideInTop {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideInBottom {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

.pointer-events-none {
  pointer-events: none;
}

.pointer-events-auto {
  pointer-events: auto;
}

/* Copied from domComponents/bubbleText/ShapeStyles.css */

/* HTML: <div class="parallelogram"></div> */
.parallelogram {
  --p: 50px; /* control the shape (can be percentage) */
  height: '100%';
  width: '100%';
  clip-path: polygon(var(--p) 0, 100% 0, calc(100% - var(--p)) 100%, 0 100%);
  background: #d95b43;
}

/* ================================ */

.orenge-pill {
  width: '100%';
  height: '100%';

  background: radial-gradient(
    84.92% 72.16% at 49.54% 12.68%,
    #ff7c17 3%,
    #fe4e0d 100%
  );
  border-top-left-radius: 5px;
  border-top-right-radius: 2.5px;
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 2.5px;

  transform: skewX(-35deg);
}

/* HTML: <div class="tooltip">This is the same as #13 but with more control over the tail</div> */
.speech-bubble-gradient-wit-border-radius {
  color: #fff;
  font-size: 18px;
  text-align: center;
}
.speech-bubble-gradient-wit-border-radius {
  /* tail dimension */
  --b: 2em; /* base */
  --h: 1.5em; /* height */

  --p: 62%; /* main position (0%:left 100%:right) */
  --x: -2em; /* tail position (relative to the main position). Can be percentage */
  --r: 1.2em; /* the radius */

  --_e: max(0%, -1 * var(--x) - var(--p), var(--x) + var(--p) - 100%);
  border-radius: var(--r) var(--r) min(var(--r), 100% - var(--p) - var(--b) / 2)
    min(var(--r), var(--p) - var(--b) / 2) / var(--r);
  background: 50% 0 / calc(100% + 2 * var(--_e)) calc(100% + var(--h))
    linear-gradient(60deg, #cc333f, #4ecdc4); /* the gradient */
  position: relative;
  z-index: 0;
}
.speech-bubble-gradient-wit-border-radius:before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0 calc(-1 * var(--_e)) calc(-1 * var(--h));
  padding-inline: var(--_e);
  background-image: inherit;
  clip-path: polygon(
      clamp(var(--b), var(--p) + var(--b) / 2, 100%) calc(100% - var(--h)),
      calc(var(--p) + var(--x)) 100%,
      clamp(0%, var(--p) - var(--b) / 2, 100% - var(--b)) calc(100% - var(--h))
    )
    content-box;
}

/* HTML: <div class="tooltip">Left-pointing speech bubble with gradient and border radius</div> */
.speech-bubble-gradient-wit-border-radius-left {
  color: #fff;
  font-size: 18px;
  text-align: center;
}
.speech-bubble-gradient-wit-border-radius-left {
  /* tail dimension */
  --b: 2em; /* base */
  --h: 1.5em; /* height */

  --p: 50%; /* main position (0%:top 100%:bottom) */
  --x: 1.8em; /* tail position (relative to the main position). Can be percentage */
  --r: 1.2em; /* the radius */
  --c: #4ecdc4;

  padding: 1em;
  border-radius: var(--r) min(var(--r), var(--p) - var(--b) / 2)
    min(var(--r), 100% - var(--p) - var(--b) / 2) var(--r) / var(--r);
  clip-path: polygon(
    0 0,
    100% 0,
    100% 100%,
    0 100%,
    0 clamp(var(--b), var(--p) + var(--b) / 2, 100%),
    calc(-1 * var(--h)) calc(var(--p) + var(--x)),
    0 clamp(0%, var(--p) - var(--b) / 2, 100% - var(--b))
  );
  background: var(--c);
  border-image: conic-gradient(var(--c) 0 0) 0 0 0 1/0 0 0 var(--h) / 0 999px
    999px var(--h);
}

/* HTML: <div class="tooltip">This is the same as #6 but with more control over the tail</div> */
.speech-bubble-gradient-wit-border-radius-top {
  color: #fff;
  font-size: 18px;
  text-align: center;
}
.speech-bubble-gradient-wit-border-radius-top {
  /* tail dimension */
  --b: 2em; /* base */
  --h: 1.5em; /* height */

  --p: 23%; /* main position (0%:left 100%:right) */
  --x: -1.8em; /* tail position (relative to the main position). Can be percentage */
  --r: 1.2em; /* the radius */
  --c: #6a4a3c;

  padding: 1em;
  border-radius: min(var(--r), var(--p) - var(--b) / 2)
    min(var(--r), 100% - var(--p) - var(--b) / 2) var(--r) var(--r) / var(--r);
  clip-path: polygon(
    0 0,
    0 100%,
    100% 100%,
    100% 0,
    clamp(var(--b), var(--p) + var(--b) / 2, 100%) 0,
    calc(var(--p) + var(--x)) calc(-1 * var(--h)),
    clamp(0%, var(--p) - var(--b) / 2, 100% - var(--b)) 0
  );
  background: var(--c);
  border-image: conic-gradient(var(--c) 0 0) 1 0 0 / var(--h) 0 0 / var(--h)
    999px 0 999px;
}

/* HTML: <div class="tooltip">Right-pointing speech bubble with gradient and border radius</div> */
.speech-bubble-gradient-wit-border-radius-right {
  color: #fff;
  font-size: 18px;
  text-align: center;
}
.speech-bubble-gradient-wit-border-radius-right {
  /* tail dimension */
  --b: 2em; /* base */
  --h: 1.5em; /* height */

  --p: 50%; /* main position (0%:top 100%:bottom) */
  --x: 1.8em; /* tail position (relative to the main position). Can be percentage */
  --r: 1.2em; /* the radius */
  --c: #4ecdc4;

  padding: 1em;
  border-radius: min(var(--r), var(--p) - var(--b) / 2) var(--r) var(--r)
    min(var(--r), 100% - var(--p) - var(--b) / 2) / var(--r);
  clip-path: polygon(
    100% 0,
    0 0,
    0 100%,
    100% 100%,
    100% clamp(var(--b), var(--p) + var(--b) / 2, 100%),
    calc(100% + var(--h)) calc(var(--p) + var(--x)),
    100% clamp(0%, var(--p) - var(--b) / 2, 100% - var(--b))
  );
  background: var(--c);
  border-image: conic-gradient(var(--c) 0 0) 0 1 0 0/0 var(--h) 0 0/999px
    var(--h) 999px 0;
}

/* Ensure background video fills the screen in fullscreen */
.canvas-wrapper-background-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100vh !important;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
}

.player-container.fullscreen-active #canvas-wrapper {
  width: 100vw !important;
  height: 100vh !important;
  position: fixed !important;
  top: 0;
  left: 0;
  z-index: 0;
  background: transparent !important;
}

.player-container.fullscreen-active .stage {
  background: transparent !important;
}

.player-subtitle-display {
    position: absolute;
    left: 50%;
    bottom: 5px; /* Closer to the bottom */
    transform: translateX(-50%);
    width: 70%; /* More compact */
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 150;
    pointer-events: none;
    text-align: center;
}

.player-subtitle-text {
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 6px 18px;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 500;
    text-align: center;
    pointer-events: auto;
    line-height: 1.2;
    max-width: 100%;
    display: inline-block;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
    position: relative;
}


/* New Multi-Language FAB Styles */
.multi-lang-fab-container {
    position: fixed;
    bottom: 100px; /* Adjusted to avoid overlap with existing controls */
    right: 20px;
    z-index: 105; 
    display: flex;
    flex-direction: column-reverse; 
    align-items: center;
}

.fab-main, .fab-sub {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #007bff;
    color: white;
    border: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: transform 0.2s ease-out, opacity 0.2s ease-out, background-color 0.2s;
}

.fab-main:hover, .fab-sub:hover {
    background-color: #0056b3;
    transform: scale(1.1);
}

.sub-fab-options {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    margin-bottom: 10px; 
}

.fab-sub {
    width: 40px;
    height: 40px;
    font-size: 16px;
    margin-top: 8px; 
    background-color: #17a2b8;
}
.fab-sub:hover {
    background-color: #117a8b;
}

/* Professional Glass Effect Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483646; /* Max z-index for fullscreen visibility */
    backdrop-filter: blur(25px) saturate(120%);
    -webkit-backdrop-filter: blur(25px) saturate(120%);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { 
        opacity: 0; 
        backdrop-filter: blur(0px) saturate(100%);
        -webkit-backdrop-filter: blur(0px) saturate(100%);
    }
    to { 
        opacity: 1; 
        backdrop-filter: blur(25px) saturate(120%);
        -webkit-backdrop-filter: blur(25px) saturate(120%);
    }
}

.modal-content {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.08) 0%,
        rgba(255, 255, 255, 0.03) 50%,
        rgba(255, 255, 255, 0.06) 100%);
    color: #fff;
    padding: 0;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    width: 85%;
    max-width: 900px;
    min-height: 70vh;
    text-align: center;
    backdrop-filter: blur(40px) saturate(120%);
    -webkit-backdrop-filter: blur(40px) saturate(120%);
    position: relative;
    overflow: hidden;
    animation: modalSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideIn {
    from { 
        transform: scale(0.95) translateY(20px);
        opacity: 0;
    }
    to { 
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.modal-content::before {
    content: '';
    position: absolute; 
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.05) 0%,
        transparent 50%,
        rgba(255, 20, 147, 0.02) 100%);
    border-radius: 24px;
    pointer-events: none;
    z-index: 0;
}

/* Pink Header Section */
.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(135deg, 
        rgba(255, 20, 147, 0.9) 0%,
        rgba(255, 107, 179, 0.8) 50%,
        rgba(255, 20, 147, 0.9) 100%);
    border-radius: 24px 24px 0 0;
    z-index: 0;
}

.modal-content h3 { 
    margin: 0;
    padding: 24px 40px 0 40px;
    color: #ffffff; 
    font-size: 24px;
    font-weight: 500;
    text-shadow: 0 2px 8px rgba(0,0,0,0.4);
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

/* Content Area with Padding */
.modal-content-body {
    padding: 32px 40px 40px 40px;
    position: relative;
    z-index: 1;
}

.language-list { 
    max-height: 40vh; 
    overflow-y: auto; 
    margin: 24px 0 32px 0; 
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.language-list-item { 
    padding: 24px 20px 24px 60px; 
    cursor: pointer; 
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    color: #ffffff; 
    font-size: 17px;
    font-weight: 400;
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.02) 50%,
        rgba(255, 255, 255, 0.04) 100%);
    position: relative;
    overflow: hidden;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Language Code Badge */
.language-list-item::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: transparent;
    transition: all 0.3s ease;
    z-index: 2;
}

/* Hover Effects */
.language-list-item:hover { 
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.12) 0%,
        rgba(255, 255, 255, 0.06) 50%,
        rgba(255, 255, 255, 0.08) 100%);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 
        0 12px 35px rgba(0, 0, 0, 0.2),
        0 6px 15px rgba(255, 20, 147, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.language-list-item:hover::before {
    background: rgba(255, 20, 147, 0.2);
    color: #ffffff;
}

.language-list-item:active {
    transform: translateY(-2px) scale(1.01);
}

/* Selected State */
.language-list-item.selected { 
    background: linear-gradient(135deg, 
        rgba(255, 20, 147, 0.3) 0%,
        rgba(255, 20, 147, 0.2) 50%,
        rgba(255, 20, 147, 0.25) 100%);
    color: #ffffff; 
    font-weight: 600;
    border-color: rgba(255, 20, 147, 0.6);
    transform: scale(1.03);
    box-shadow: 
        0 8px 30px rgba(255, 20, 147, 0.3),
        0 4px 15px rgba(255, 20, 147, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 0 20px rgba(255, 20, 147, 0.1);
}

.language-list-item.selected::before {
    border-color: rgba(255, 20, 147, 0.8);
    background: linear-gradient(135deg, rgba(255, 20, 147, 0.8), rgba(255, 20, 147, 0.6));
    box-shadow: 
        0 0 10px rgba(255, 20, 147, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Remove tick mark - selection is now handled by circle */

/* Subtle Pattern Overlay */
.language-list-item:not(.selected)::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 20px 20px, 15px 15px;
    opacity: 0.5;
    border-radius: 20px;
    pointer-events: none;
}

@keyframes checkmarkGlow {
    0% { 
        transform: translate(-50%, -50%) scale(0) rotate(180deg);
        opacity: 0;
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.3) rotate(360deg);
        opacity: 1;
    }
    100% { 
        transform: translate(-50%, -50%) scale(1) rotate(360deg);
        opacity: 0.9;
    }
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
    position: relative;
    z-index: 1;
}

.modal-close-btn { 
    background: rgba(255, 255, 255, 0.1); 
    color: rgba(255, 255, 255, 0.9); 
    border: 1px solid rgba(255, 255, 255, 0.2); 
    padding: 12px 24px; 
    border-radius: 12px; 
    cursor: pointer; 
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    min-width: 100px;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.modal-close-btn:hover { 
    background: rgba(255, 255, 255, 0.15); 
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal-close-btn:active {
    transform: translateY(0px);
}

/* Professional Responsive Design */
@media (max-width: 1200px) {
    .language-list {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 14px;
    }
}

@media (max-width: 768px) {
    .modal-content {
        width: 92%;
        min-height: 75vh;
        border-radius: 20px;
    }
    
    .modal-content::before {
        height: 70px;
        border-radius: 20px 20px 0 0;
    }
    
    .modal-content h3 {
        font-size: 20px;
        padding: 20px 24px 0 24px;
        height: 70px;
    }
    
    .modal-content-body {
        padding: 24px 24px 32px 24px;
    }
    
    .language-list {
        grid-template-columns: 1fr;
        gap: 16px;
        max-height: 45vh;
        margin: 20px 0 24px 0;
        padding: 16px;
    }
    
    .language-list-item {
        padding: 20px 16px 20px 50px;
        font-size: 16px;
        min-height: 72px;
        border-radius: 16px;
    }
    
    .language-list-item::before {
        left: 16px;
        width: 14px;
        height: 14px;
        border-width: 2px;
    }
    
    .modal-close-btn {
        padding: 12px 24px;
        font-size: 14px;
        min-width: 100px;
    }
}

/* Professional scrollbar design */
.language-list::-webkit-scrollbar {
    width: 6px;
}

.language-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.language-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    transition: background 0.2s ease;
}

.language-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Timeline tap ripple effect */
.timeline-tap-ripple {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(76, 175, 80, 0.3);
  transform: translate(-50%, -50%);
  animation: ripple-effect 0.5s ease-out;
  pointer-events: none;
  z-index: 10;
}

@keyframes ripple-effect {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(3);
    opacity: 0;
  }
}

/* Make timeline container tappable on mobile */
@media (max-width: 768px) {
  .timeline-container {
    position: relative;
    touch-action: none; /* Prevent browser handling of gestures */
  }
  
  /* Highlight current position better */
  .timeline-cursor {
    width: 16px;
    height: 16px;
    background-color: #4caf50;
    border-radius: 50%;
    transform: translateX(-50%);
    top: 0;
  }
}

/* Mobile Landscape - Same centering as desktop */
@media (max-width: 1024px) and (orientation: landscape) {
  #stage-wrapper {
    overflow: visible !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
  }
  
  #canvas-wrapper {
    overflow: visible !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
  }
  
  .stage {
    transform-origin: center center !important;
    margin: 0 auto !important;
  }
}

/* Timeline preview tooltip */
.timeline-preview {
  position: absolute;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  transform: translateX(-50%);
  bottom: 30px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 20;
}

.timeline-preview.visible {
  opacity: 1;
}

/* Add a small arrow to the tooltip */
.timeline-preview:after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.8) transparent transparent transparent;
}

@media (max-width: 768px) {
  .timeline-preview {
    padding: 8px 12px;
    font-size: 14px;
    bottom: 35px;
  }
}

/* Text Elements - Base styles for all languages */
.text-element {
  box-sizing: border-box !important;
}

/* Non-English Text Elements - Enable proper scaling and wrapping */
.text-element.non-english-text {
  overflow: visible !important;
}

.text-element.non-english-text .text-content-container {
  box-sizing: border-box !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  hyphens: auto !important;
  overflow: visible !important;
}

.text-element.non-english-text .text-content-actual {
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  hyphens: auto !important;
  box-sizing: border-box !important;
  line-height: 1.2 !important;
  white-space: normal !important;
  transform-origin: center !important;
}
