/* ==========================================================================
   GANESHA'S SACRED TUSK PEN GAME - STYLESHEET
   Pure Vanilla CSS - 3D Claymorphism & 16:9 Responsive Landscape Stage
   ========================================================================== */

:root {
  /* Color Tokens */
  --clay-red: #FF5A5F;
  --clay-red-shadow: #D13B40;
  --clay-gold: #FFB800;
  --clay-gold-glow: #FFE082;
  --clay-gold-shadow: #D48800;
  --clay-green: #43A047;
  --clay-green-shadow: #2E7D32;
  --clay-cream: #FFFDF5;
  --clay-parchment: #FFF8E7;
  --clay-dark: #2C1810;
  --clay-blue: #1E88E5;

  /* Typography */
  --font-heading: 'Fredoka', 'Comic Sans MS', cursive, sans-serif;
  --font-body: 'Nunito', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #0d0b14;
  font-family: var(--font-body);
}

/* ==========================================
   16:9 RESPONSIVE GAME STAGE
   ========================================== */

#game-stage-wrapper {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(circle at center, #1b1528 0%, #08060d 100%);
}

#game-stage {
  position: relative;
  width: 100vw;
  height: calc(100vw * 9 / 16);
  max-width: calc(100vh * 16 / 9);
  max-height: 100vh;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.9), 0 0 100px rgba(255, 184, 0, 0.1);
  border-radius: 12px;
  container-type: size;
  container-name: stage;
}

@media (max-aspect-ratio: 16/9) {
  #game-stage {
    width: 100vw;
    height: calc(100vw * 9 / 16);
  }
}

@media (min-aspect-ratio: 16/9) {
  #game-stage {
    height: 100vh;
    width: calc(100vh * 16 / 9);
  }
}

/* Base Stage Layers */
.stage-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.pointer-through {
  pointer-events: none;
}

.pointer-auto {
  pointer-events: auto;
}

/* ==========================================
   LAYER 1: BACKGROUND
   ========================================== */

#bg-layer {
  z-index: 1;
}

#forest-bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==========================================
   LAYER 2: CHARACTERS (SEATED NATURALLY ON SACRED MATS)
   ========================================== */

#character-layer {
  z-index: 10;
  pointer-events: none;
}

.character-anchor {
  position: absolute;
  filter: drop-shadow(0 18px 24px rgba(26, 15, 6, 0.65)) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Ganesha seated on the left sacred red carpet mat */
#ganesha-wrap {
  width: 35.1342%;
  left: 7.48036%;
  bottom: 14.4737%;
  aspect-ratio: 1024 / 935;
  filter: drop-shadow(0 20px 26px rgba(28, 16, 4, 0.72)) drop-shadow(0 0 25px rgba(255, 179, 0, 0.18));
}

/* Sage Ved Vyasa seated on the right sacred red carpet mat */
#vyasa-wrap {
  width: 29.3538%;
  right: 6.81829%;
  bottom: 13.5789%;
  aspect-ratio: 907 / 1024;
  filter: drop-shadow(0 20px 26px rgba(28, 16, 4, 0.72)) drop-shadow(0 0 25px rgba(255, 179, 0, 0.18));
  animation: vyasaBreathe 4s infinite ease-in-out;
}

/* Character Images: Strict Right Hand preservation, NO horizontal flip */
.character-img {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease-in-out;
  pointer-events: none;
}

.character-img.active-character {
  opacity: 1;
  visibility: visible;
}

/* Playful "Trying it!" Notification Badge */
.trying-badge {
  position: absolute;
  top: -14px;
  left: 45%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #FFF9C4 0%, #FFD54F 100%);
  color: #5D4037;
  font-family: var(--font-heading);
  font-size: clamp(0.75rem, 2cqw, 1.15rem);
  font-weight: 800;
  padding: clamp(4px, 1cqh, 8px) clamp(10px, 2cqw, 18px);
  border-radius: 30px;
  border: 3px solid #FFF;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35), 0 0 15px rgba(255, 215, 0, 0.5);
  z-index: 25;
  pointer-events: none;
  animation: tryingPopIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  white-space: nowrap;
}

@keyframes tryingPopIn {
  0% { transform: translateX(-50%) scale(0.4) translateY(12px); opacity: 0; }
  100% { transform: translateX(-50%) scale(1) translateY(0); opacity: 1; }
}

/* ==========================================
   INTERACTIVE BROKEN TUSK ON GANESHA'S FACE
   ========================================== */

.ganesha-tusk-clickable {
  position: absolute;
  left: 58%;
  top: 40%;
  width: 14%;
  height: 14%;
  border-radius: 50%;
  cursor: pointer;
  z-index: 28;
  pointer-events: auto;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  outline: none;
}

.ganesha-tusk-clickable:hover {
  transform: scale(1.18);
}

.ganesha-tusk-clickable:active {
  transform: scale(0.92);
}

/* Sacred golden aura inviting interaction */
.tusk-sparkle-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 110%;
  height: 110%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.4) 0%, rgba(245, 158, 11, 0.15) 50%, transparent 75%);
  animation: tuskGlowPulse 2.4s infinite ease-in-out;
  pointer-events: none;
}

@keyframes tuskGlowPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(0.85); opacity: 0.35; }
  50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.85; }
}

.ganesha-tusk-clickable.tusk-pulsing {
  animation: tuskShockPulse 0.4s ease;
}

@keyframes tuskShockPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.28); filter: drop-shadow(0 0 12px #FFD700); }
}

/* Sacred Tusk Warning Notification Badge */
.sacred-tusk-warning {
  position: absolute;
  top: 20%;
  left: 54%;
  transform: translate(-50%, 0);
  background: linear-gradient(135deg, rgba(28, 20, 8, 0.96) 0%, rgba(46, 30, 8, 0.94) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid #F59E0B;
  box-shadow: 
    0 10px 25px rgba(0, 0, 0, 0.65),
    0 0 20px rgba(245, 158, 11, 0.45),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  padding: clamp(5px, 1cqh, 8px) clamp(10px, 2cqw, 18px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #FEF3C7;
  font-family: var(--font-heading);
  font-size: clamp(0.75rem, 1.8cqw, 1.05rem);
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
  z-index: 50;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.sacred-tusk-warning .warning-icon {
  font-size: 1.15em;
  filter: drop-shadow(0 0 4px #F59E0B);
}

.sacred-tusk-warning.hidden {
  opacity: 0;
  transform: translate(-50%, 8px) scale(0.85);
  pointer-events: none;
}

.sacred-tusk-warning.animate-pop-warning {
  animation: popWarning 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popWarning {
  0% { transform: translate(-50%, 12px) scale(0.6); opacity: 0; }
  60% { transform: translate(-50%, -4px) scale(1.06); opacity: 1; }
  100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

/* Pen Writing scribble shake */
.ganesha-scribble {
  animation: ganeshaWriteMotion 0.18s infinite alternate ease-in-out;
}

@keyframes ganeshaWriteMotion {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-3px) rotate(0.8deg); }
}

/* Pen Breaking shock reaction */
.ganesha-shock {
  animation: ganeshaShockHop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes ganeshaShockHop {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-16px) scale(1.04); }
  60% { transform: translateY(0) scale(0.98); }
  80% { transform: translateY(-4px) scale(1.01); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes vyasaBreathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Divine Pen Breaking Sparks Overlay */
.spark-burst {
  position: absolute;
  top: 38%;
  left: 31%;
  width: 90px;
  height: 90px;
  background: radial-gradient(circle, #FFF 0%, #FFE082 40%, #FF9800 70%, transparent 100%);
  border-radius: 50%;
  filter: blur(2px) drop-shadow(0 0 15px #FFD700);
  animation: sparkBurstFlash 0.6s forwards ease-out;
  pointer-events: none;
  z-index: 15;
}

@keyframes sparkBurstFlash {
  0% { transform: scale(0.2); opacity: 0; }
  30% { transform: scale(1.4); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ==========================================
   LAYER 3: INTERACTIVE FOREST OBJECTS
   ========================================== */

#forest-items-layer {
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

/* Only show interactive forest items on Screen 2 (Exploration) */
.show-exploration-items #forest-items-layer {
  opacity: 1;
  visibility: visible;
  pointer-events: none; /* Children (.forest-item) have pointer-events: auto */
}

.forest-item {
  position: absolute;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
  pointer-events: auto;
}

.forest-item:hover {
  transform: scale(1.15);
}

.forest-item:active {
  transform: scale(0.95);
}

.item-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.45));
  transition: filter 0.3s ease;
}

/* 1. Twig - Nestled near the leafy rock base / left stone inscription */
.twig-item,
#item-twig {
  width: 9.2886%;
  left: 7.87479%;
  top: 32.5684%;
  aspect-ratio: 1241 / 1268;
  animation: gentleSway 3.2s infinite ease-in-out;
}

/* 2. Peacock Feather - Near upper right cave arch vines */
.feather-item,
#item-feather {
  width: 8.04491%;
  left: 84.2269%;
  top: 7.92715%;
  aspect-ratio: 1281 / 1227;
  animation: gentleFloat 3.6s infinite ease-in-out;
}

/* 3. Lotus Stem - Emerging from mountain river seen through cave opening */
.lotus-item,
#item-lotus {
  width: 6.50123%;
  left: 53.2058%;
  bottom: 24.4756%;
  aspect-ratio: 1024 / 1536;
  animation: gentleBob 3s infinite ease-in-out;
}

@keyframes gentleSway {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(4deg); }
}

@keyframes gentleFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(-3deg); }
}

@keyframes gentleBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.item-hint {
  margin-top: 4px;
  background: rgba(0, 0, 0, 0.68);
  color: #FFF;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(4px);
  pointer-events: none;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Tried & Inactive State */
.forest-item.tried {
  opacity: 0.4;
  filter: grayscale(0.5);
  cursor: default;
  pointer-events: none;
  animation: none;
  transform: scale(0.88);
}

.tried-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--clay-green);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.85rem;
  border: 2px solid white;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Failure Animations */
.item-animating {
  z-index: 50;
  transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1) !important;
}

.animate-fail-snap {
  animation: itemFailSnap 0.8s forwards ease-in-out;
}

.animate-fail-poof {
  animation: itemFailPoof 0.8s forwards ease-in-out;
}

.animate-fail-bendy {
  animation: itemFailBendy 0.8s forwards ease-in-out;
}

@keyframes itemFailSnap {
  0% { transform: rotate(0deg) scale(1); }
  40% { transform: rotate(-20deg) scale(1.1); }
  70% { transform: rotate(35deg) scale(0.9); }
  100% { transform: rotate(45deg) translateY(20px) scale(0.85); opacity: 0.5; }
}

@keyframes itemFailPoof {
  0% { transform: scale(1); }
  35% { transform: scale(1.2) rotate(15deg); filter: sepia(1) hue-rotate(300deg); }
  100% { transform: scale(0.7) translateY(-20px); opacity: 0.4; }
}

@keyframes itemFailBendy {
  0% { transform: scale(1); }
  25% { transform: skewX(-20deg) scale(1.1); }
  50% { transform: skewX(20deg) scale(1.1); }
  75% { transform: skewX(-10deg) scale(0.95); }
  100% { transform: skewX(0deg) scale(0.85); opacity: 0.5; }
}

/* ==========================================
   LAYER 4: DIVINE GLOWING TUSK
   ========================================== */

#tusk-layer {
  z-index: 25;
}

.divine-tusk {
  position: absolute;
  bottom: 25%;
  left: 38%;
  width: 16%;
  aspect-ratio: 1181 / 1331;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: tuskFloating 1.6s infinite ease-in-out;
  pointer-events: auto;
  transition: transform 0.3s ease;
}

.divine-tusk:hover {
  transform: scale(1.15);
}

.tusk-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 20px #FFD700) drop-shadow(0 0 40px #FFA000);
}

.tusk-sunburst {
  position: absolute;
  width: 180%;
  height: 180%;
  background: radial-gradient(circle, rgba(255, 235, 59, 0.45) 0%, rgba(255, 160, 0, 0.25) 45%, transparent 70%);
  border-radius: 50%;
  animation: tuskGlowPulse 1.4s infinite alternate ease-in-out;
  pointer-events: none;
}

.tusk-tap-prompt {
  position: absolute;
  bottom: clamp(-28px, -4cqh, -14px);
  background: linear-gradient(135deg, #FFF9C4 0%, #FFD54F 100%);
  color: var(--clay-dark);
  font-family: var(--font-heading);
  font-size: clamp(0.75rem, 1.8cqw, 1rem);
  font-weight: 800;
  padding: clamp(3px, 0.8cqh, 6px) clamp(8px, 1.8cqw, 14px);
  border-radius: 20px;
  border: 2px solid #FFF;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3), 0 0 15px rgba(255, 215, 0, 0.6);
  white-space: nowrap;
  animation: promptBob 0.8s infinite alternate ease-in-out;
}

@keyframes tuskFloating {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes tuskGlowPulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  100% { transform: scale(1.2); opacity: 1; }
}

@keyframes promptBob {
  0% { transform: translateY(0); }
  100% { transform: translateY(-4px); }
}

/* ==========================================
   LAYER 5 & 6: UI & SCREEN OVERLAYS
   ========================================== */

#ui-layer {
  z-index: 30;
}

.screen-ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  pointer-events: none;
}

.screen-ui.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* 1. Title Banner Asset (Screen 1: Help Ganesha Write the Mahabharata) */
.title-banner-wrap {
  position: absolute;
  top: 4.02325%;
  left: 34.6649%;
  width: 30.8775%;
  max-width: 490px;
  aspect-ratio: 1942 / 809;
  z-index: 35;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.title-banner-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* 2. Instruction Banner Asset (Screen 2: Find something to write with!) */
.instruction-banner-wrap {
  position: absolute;
  top: 3.92471%;
  left: 35.0118%;
  width: 30%;
  max-width: 430px;
  aspect-ratio: 2172 / 724;
  z-index: 35;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.instruction-banner-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* 3. 3D Golden Play Button Asset (Screen 1) */
.asset-btn {
  background: none;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.2s ease;
}

.play-btn {
  position: absolute;
  bottom: 16.4991%;
  left: 52.9901%;
  transform: translateX(-50%);
  width: 17.0693%;
  max-width: 235px;
  aspect-ratio: 2024 / 777;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.6));
  z-index: 35;
}

.play-btn:hover {
  transform: translateX(-50%) scale(1.08);
  filter: drop-shadow(0 14px 26px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 20px rgba(255, 200, 0, 0.6));
}

.play-btn:active {
  transform: translateX(-50%) scale(0.94);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
}

.play-btn-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Badges (Claymorphism) */
.clay-badge {
  display: inline-flex;
  align-items: center;
  gap: clamp(6px, 1.2cqw, 10px);
  background: linear-gradient(135deg, #FFFFFF 0%, var(--clay-cream) 100%);
  padding: clamp(6px, 1.5cqh, 12px) clamp(12px, 3cqw, 28px);
  border-radius: 40px;
  border: 3px solid #FFF;
  box-shadow: 
    0 10px 24px rgba(0, 0, 0, 0.3),
    inset 0 3px 6px rgba(255, 255, 255, 0.9),
    inset 0 -3px 6px rgba(0, 0, 0, 0.08);
  color: var(--clay-dark);
  font-family: var(--font-heading);
  font-size: clamp(0.85rem, 2.2cqw, 1.35rem);
  font-weight: 700;
  text-align: center;
  pointer-events: auto;
}

.badge-icon {
  font-size: clamp(1.1rem, 2.6cqw, 1.6rem);
}

/* Buttons (Claymorphism 3D) */
.clay-btn {
  position: relative;
  border: none;
  outline: none;
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.btn-large {
  padding: clamp(8px, 2cqh, 16px) clamp(16px, 3.8cqw, 44px);
  font-size: clamp(0.85rem, 2.3cqw, 1.4rem);
  border-radius: 40px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--clay-gold) 0%, var(--clay-gold-shadow) 100%);
  color: #FFF;
  box-shadow: 
    0 8px 0 var(--clay-gold-shadow),
    0 14px 25px rgba(0, 0, 0, 0.4),
    inset 0 3px 6px rgba(255, 255, 255, 0.6);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 
    0 11px 0 var(--clay-gold-shadow),
    0 18px 30px rgba(0, 0, 0, 0.45),
    inset 0 3px 6px rgba(255, 255, 255, 0.7);
}

.btn-primary:active {
  transform: translateY(6px);
  box-shadow: 
    0 2px 0 var(--clay-gold-shadow),
    0 6px 12px rgba(0, 0, 0, 0.3),
    inset 0 3px 6px rgba(0, 0, 0, 0.2);
}

.btn-success {
  background: linear-gradient(135deg, var(--clay-green) 0%, var(--clay-green-shadow) 100%);
  color: #FFF;
  box-shadow: 
    0 8px 0 var(--clay-green-shadow),
    0 14px 25px rgba(0, 0, 0, 0.4),
    inset 0 3px 6px rgba(255, 255, 255, 0.6);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.btn-success:hover {
  transform: translateY(-3px);
  box-shadow: 
    0 11px 0 var(--clay-green-shadow),
    0 18px 30px rgba(0, 0, 0, 0.45);
}

.btn-success:active {
  transform: translateY(6px);
  box-shadow: 
    0 2px 0 var(--clay-green-shadow),
    0 6px 12px rgba(0, 0, 0, 0.3);
}

.btn-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: skewX(-25deg);
  animation: buttonShine 3s infinite;
}

@keyframes buttonShine {
  0%, 70% { left: -100%; }
  100% { left: 160%; }
}

/* Sage Vyasa Speech Bubble Asset (Screen 1: Write without pause, Ganesha!) */
.vyasa-bubble-wrap,
.vyasa-bubble {
  position: absolute;
  top: 26.6484%;
  right: 0.763265%;
  width: 16.0285%;
  max-width: 310px;
  aspect-ratio: 1024 / 437;
  z-index: 36;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.55));
  pointer-events: none;
  background: none;
  border: none;
  padding: 0;
  box-shadow: none;
  transition: transform 0.25s ease;
}

.vyasa-bubble-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.animate-float-gentle {
  animation: floatGentle 3s infinite ease-in-out;
}

@keyframes floatGentle {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* Start Button Bottom Placement */
#btn-start {
  margin-bottom: 24px;
}

/* Feedback Speech Bubble (Screen 2) */
.clay-bubble {
  position: absolute;
  bottom: 50%;
  left: 23%;
  transform: translate(-50%, 0);
  background: #FFF;
  color: #D32F2F;
  font-family: var(--font-heading);
  font-size: clamp(0.78rem, 2.2cqw, 1.35rem);
  font-weight: 800;
  padding: clamp(6px, 1.2cqh, 10px) clamp(10px, 2.5cqw, 22px);
  border-radius: 24px;
  border: 3px solid var(--clay-gold);
  box-shadow: 0 10px 25px rgba(0,0,0,0.35);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 40;
}

.clay-bubble::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 12px 10px 0;
  border-style: solid;
  border-color: var(--clay-gold) transparent;
  display: block;
  width: 0;
}

.clay-bubble.hidden {
  opacity: 0;
  transform: translate(-50%, 10px) scale(0.7);
}

/* Screen 3: Writing Scroll & Stars */
.scroll-card {
  margin-top: clamp(10px, 4.5cqh, 50px);
  width: clamp(260px, 68cqw, 650px);
  background: linear-gradient(135deg, #FFF8E7 0%, #FFEFC2 100%);
  border-radius: clamp(12px, 2cqw, 20px);
  border: 3px solid #D4A373;
  padding: clamp(8px, 1.8cqh, 16px) clamp(12px, 2.5cqw, 24px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5), inset 0 2px 8px rgba(255, 255, 255, 0.8);
  text-align: center;
}

.scroll-header {
  font-family: var(--font-heading);
  font-size: clamp(0.85rem, 2.2cqw, 1.3rem);
  font-weight: 800;
  color: #8C531B;
  margin-bottom: clamp(4px, 1.2cqh, 10px);
  border-bottom: 2px dashed rgba(140, 83, 27, 0.3);
  padding-bottom: 4px;
}

.scroll-lines {
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1cqh, 8px);
}

.scroll-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.scroll-line.hidden {
  opacity: 0;
  transform: translateY(10px);
  display: none;
}

.scroll-line.show {
  display: flex;
  opacity: 1;
  transform: translateY(0);
  animation: lineReveal 0.5s ease-out;
}

@keyframes lineReveal {
  0% { opacity: 0; transform: translateY(8px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.verse-sanskrit {
  font-family: var(--font-heading);
  font-size: clamp(0.85rem, 2.3cqw, 1.4rem);
  font-weight: 700;
  color: #B71C1C;
  text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}

.verse-meaning {
  font-size: clamp(0.68rem, 1.6cqw, 0.95rem);
  font-weight: 800;
  color: #5D4037;
}

.stars-bar {
  display: flex;
  gap: clamp(8px, 2.2cqw, 20px);
  margin-bottom: clamp(8px, 3cqh, 24px);
}

.clay-star {
  width: clamp(38px, 7.5cqw, 65px);
  height: clamp(38px, 7.5cqw, 65px);
  border-radius: 50%;
  border: 3px solid #FFF;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 900;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.active-star {
  background: linear-gradient(135deg, #FFF176 0%, #FFB300 100%);
  color: var(--clay-dark);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3), 0 0 20px #FFD700;
  animation: starPulse 1s infinite alternate;
}

.active-star:hover {
  transform: scale(1.15);
}

.active-star:active {
  transform: scale(0.92);
}

.locked-star {
  background: #BDBDBD;
  color: #757575;
  opacity: 0.5;
  cursor: not-allowed;
}

.completed-star {
  background: linear-gradient(135deg, #81C784 0%, #388E3C 100%);
  color: white;
  cursor: default;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.star-icon {
  font-size: clamp(0.8rem, 2.2cqw, 1.3rem);
}

.star-number {
  font-size: clamp(0.55rem, 1.3cqw, 0.85rem);
  line-height: 1;
}

@keyframes starPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.12); }
}

/* Screen 3: Final Game Ending Banner (last_screen_banner.png) */
.completion-banner-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28%;
  aspect-ratio: 2048 / 684;
  z-index: 50;
  pointer-events: none;
  animation: completionBannerPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.last-screen-banner-img {
  width: 100%;
  height: 100%;
  aspect-ratio: 2048 / 684;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 18px rgba(255, 215, 0, 0.25));
}

@keyframes completionBannerPop {
  0% {
    transform: translate(-50%, -46%) scale(0.85);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

/* Ganesha Tusk Writing FX */
.ganesha-tusk-writing {
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 20px rgba(255, 215, 0, 0.55));
}

#ganesha-writing-tusk.active-character {
  animation: tuskWritingShine 2.2s infinite alternate ease-in-out;
}

@keyframes tuskWritingShine {
  0% { filter: drop-shadow(0 0 6px #FFD700); }
  100% { filter: drop-shadow(0 0 18px #FFA000) drop-shadow(0 0 28px #FFD54F); }
}

/* Universal Center-Alignment for all titles and headings */
h1, h2, h3, h4,
.title-banner-wrap,
.instruction-banner-wrap,
.clay-badge,
.clay-bubble {
  text-align: center !important;
}

/* Petal Shower Layer */
.petal-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  z-index: 35;
}

.petal {
  position: absolute;
  top: -30px;
  width: 16px;
  height: 22px;
  opacity: 0.85;
  animation: petalFall linear forwards;
}

@keyframes petalFall {
  0% {
    transform: translateY(0) rotate(0deg) translateX(0);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(540deg) translateX(80px);
    opacity: 0;
  }
}

/* General Utilities */
.hidden {
  display: none !important;
}

.animate-bounce-gentle {
  animation: bounceGentle 2s infinite ease-in-out;
}

.animate-bounce-victory {
  animation: bounceVictory 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bounceGentle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes bounceVictory {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   DEVELOPER MENU & LAYOUT EDITOR STYLING
   ========================================================================== */

/* Toggle Button */
#dev-menu-toggle-btn.dev-toggle-pill {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 10001;
  background: rgba(17, 24, 39, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 9999px;
  padding: 8px 16px;
  color: #f3f4f6;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
  user-select: none;
}

#dev-menu-toggle-btn.dev-toggle-pill:hover {
  transform: translateY(-2px);
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(99, 102, 241, 0.6);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

/* Main Dev Panel */
#dev-menu-panel.dev-panel {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 310px;
  max-height: calc(100vh - 80px);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 10000;
  overflow-y: auto;
  color: #f1f5f9;
  font-family: system-ui, -apple-system, sans-serif;
  display: block;
}

.dev-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(30, 41, 59, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.dev-panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dev-header-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.15s ease;
}

.dev-header-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.5);
}

.dev-panel-content {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dev-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dev-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  padding-left: 2px;
}

.dev-btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.dev-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dev-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  transform: translateY(-1px);
}

.dev-btn:active {
  transform: translateY(0);
}

.dev-highlight-btn {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.5);
  color: #c7d2fe;
}

.dev-highlight-btn:hover {
  background: rgba(99, 102, 241, 0.4);
  border-color: rgba(99, 102, 241, 0.7);
  color: #ffffff;
}

.dev-action-btn {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

.dev-action-btn:hover {
  background: rgba(245, 158, 11, 0.3);
  border-color: rgba(245, 158, 11, 0.6);
  color: #ffffff;
}

.dev-btn-danger {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.dev-btn-danger:hover {
  background: rgba(239, 68, 68, 0.35);
  border-color: rgba(239, 68, 68, 0.6);
  color: #ffffff;
}

/* ==========================================================================
   LAYOUT EDITOR OVERLAY & PANEL STYLING
   ========================================================================== */

/* Stage Alignment Grid */
#layout-grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 900;
}

.grid-line {
  position: absolute;
}

.grid-v-third-1 {
  left: 33.333%;
  top: 0;
  bottom: 0;
  border-left: 1px dashed rgba(255, 255, 255, 0.25);
}

.grid-v-third-2 {
  left: 66.666%;
  top: 0;
  bottom: 0;
  border-left: 1px dashed rgba(255, 255, 255, 0.25);
}

.grid-h-third-1 {
  top: 33.333%;
  left: 0;
  right: 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.25);
}

.grid-h-third-2 {
  top: 66.666%;
  left: 0;
  right: 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.25);
}

.grid-center-x {
  left: 50%;
  top: 0;
  bottom: 0;
  border-left: 1px solid rgba(245, 158, 11, 0.45);
}

.grid-center-y {
  top: 50%;
  left: 0;
  right: 0;
  border-top: 1px solid rgba(245, 158, 11, 0.45);
}

.grid-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fbbf24;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* Selected Element Bounding Box */
#layout-selection-box {
  position: absolute;
  border: 2px solid #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5), inset 0 0 8px rgba(56, 189, 248, 0.25);
  pointer-events: none;
  z-index: 950;
  border-radius: 4px;
}

.selection-label {
  position: absolute;
  top: -22px;
  left: 0;
  background: #0284c7;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.selection-coords {
  position: absolute;
  bottom: -20px;
  left: 0;
  background: rgba(15, 23, 42, 0.9);
  color: #38bdf8;
  font-size: 9px;
  font-family: monospace;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

/* Layout Editor Floating Tool Window */
#layout-editor-panel.layout-panel {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 300px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(56, 189, 248, 0.15);
  z-index: 10000;
  color: #f1f5f9;
  font-family: system-ui, -apple-system, sans-serif;
}

.layout-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(30, 41, 59, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  font-weight: 700;
}

.layout-btn-icon {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.layout-btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.layout-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.layout-control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.layout-control-group label {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
}

.layout-select {
  width: 100%;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f8fafc;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.layout-select:focus {
  border-color: #38bdf8;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.control-row input[type="range"] {
  width: 100%;
  accent-color: #38bdf8;
  cursor: pointer;
}

.val-display {
  font-family: monospace;
  color: #38bdf8;
  font-weight: 700;
}

.layout-actions-bar {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.layout-action-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary-act {
  background: #0284c7;
  color: #fff;
}
.btn-primary-act:hover {
  background: #0369a1;
}

.btn-success-act {
  background: #16a34a;
  color: #fff;
}
.btn-success-act:hover {
  background: #15803d;
}

.btn-danger-act {
  background: #dc2626;
  color: #fff;
}
.btn-danger-act:hover {
  background: #b91c1c;
}

.layout-footer-info {
  font-size: 10px;
  color: #64748b;
  text-align: center;
  margin-top: 2px;
}

/* Mobile & Small Screen Responsive Enhancements */
@media (max-width: 768px) {
  #game-stage {
    border-radius: 6px;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.9);
  }
}

@media (max-width: 768px) and (orientation: portrait) {
  #game-stage-wrapper::after {
    content: "📱 Rotate phone to landscape for best experience";
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fbbf24;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid rgba(251, 191, 36, 0.4);
    pointer-events: none;
    z-index: 9999;
    white-space: nowrap;
    backdrop-filter: blur(4px);
  }
}

