/* ============================================================ */
/* SNAPCODE GAME THEME & 3D GRAPHICS STYLESHEET               */
/* MXIA Platform Modular Component System                       */
/* ============================================================ */

/* Global Font and Base Defaults */
body {
  font-family: 'Prompt', 'Kanit', sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

h1, h2, h3, h4, .font-heading {
  font-family: 'Kanit', sans-serif;
}

/* SPEECH LOCK SYSTEM (Disables interactions during Bitto's voice explanation) */
.speech-locked {
  pointer-events: none !important;
  opacity: 0.5 !important;
  filter: grayscale(0.2) !important;
  transition: opacity 0.25s ease, filter 0.25s ease;
  cursor: not-allowed !important;
}

/* ============================================================ */
/* 1. 3D TACTILE WOODEN TRAY CONSOLE & RECESSED SOCKETS         */
/* ============================================================ */
.toy-wood-frame {
  background: linear-gradient(180deg, #c7772c 0%, #9a4c11 35%, #683009 100%);
  border: 4px solid #4a1f04;
  border-radius: 26px;
  box-shadow: 
    inset 0 2px 4px rgba(255, 255, 255, 0.45),
    inset 0 -3px 6px rgba(0, 0, 0, 0.5),
    0 10px 28px rgba(0, 0, 0, 0.65),
    0 0 25px rgba(217, 119, 6, 0.25);
  position: relative;
}

.toy-slot-socket {
  background: radial-gradient(circle at center, rgba(35, 17, 7, 0.9) 0%, rgba(18, 9, 3, 0.98) 100%);
  border: 2px dashed rgba(255, 204, 0, 0.3);
  border-radius: 18px;
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.85), inset 0 0 6px rgba(0, 0, 0, 0.95);
  position: relative;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toy-slot-socket:hover {
  border-color: rgba(255, 204, 0, 0.6);
}

/* TRAY RUNNING SPOTLIGHT SYSTEM */
.tray-running .toy-card-token {
  opacity: 0.5;
  transition: opacity 0.2s ease, transform 0.2s ease, filter 0.2s ease;
}

.tray-running .toy-loop-container {
  opacity: 0.9;
  border-style: solid;
  border-color: rgba(244, 114, 182, 0.4) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) !important;
  transform: none !important;
  animation: none !important;
}

/* TOP SLOT EXECUTING */
.toy-slot-socket.executing {
  border-color: #00f2fe !important;
  border-style: solid !important;
  border-width: 3.5px !important;
  background: radial-gradient(circle at center, rgba(0, 242, 254, 0.4) 0%, rgba(3, 105, 161, 0.7) 100%) !important;
  box-shadow: 0 0 30px #00f2fe, 0 0 15px #00f2fe, inset 0 0 14px #00f2fe !important;
  transform: scale(1.15) translateY(-6px) !important;
  z-index: 50 !important;
}
.toy-slot-socket.executing .toy-card-token {
  opacity: 1 !important;
  filter: brightness(1.25) drop-shadow(0 0 12px #00f2fe) !important;
}
.toy-slot-socket.executing::after {
  content: '▼';
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  color: #00f2fe;
  font-size: 16px;
  font-weight: 900;
  text-shadow: 0 0 12px #00f2fe, 0 0 24px #0284c7;
  animation: pointerArrowBounce 0.35s ease-in-out infinite alternate;
  z-index: 60;
}

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

/* ============================================================ */
/* 2. 3D GLOSSY CARD TOKENS (PURE VISUAL - NO TEXT)             */
/* ============================================================ */
.toy-card-token {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  padding: 3.5px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  display: flex;
  flex-direction: column;
}

.toy-card-token:hover {
  transform: translateY(-3px) scale(1.03);
  filter: brightness(1.1);
}

.toy-card-token:active {
  transform: translateY(2px) scale(0.97);
}

/* Outer Bezel Colors & Luminous Glows */
.card-bezel-cyan {
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 65%, #0369a1 100%);
  border-bottom: 4px solid #075985;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.6), 0 5px 10px rgba(0, 0, 0, 0.35);
}
.card-bezel-cyan:hover {
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.9), 0 7px 14px rgba(0, 0, 0, 0.4);
}

.card-bezel-green {
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 65%, #15803d 100%);
  border-bottom: 4px solid #14532d;
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.6), 0 5px 10px rgba(0, 0, 0, 0.35);
}
.card-bezel-green:hover {
  box-shadow: 0 0 22px rgba(74, 222, 128, 0.9), 0 7px 14px rgba(0, 0, 0, 0.4);
}

.card-bezel-royal {
  background: linear-gradient(180deg, #60a5fa 0%, #2563eb 65%, #1d4ed8 100%);
  border-bottom: 4px solid #1e3a8a;
  box-shadow: 0 0 14px rgba(96, 165, 250, 0.6), 0 5px 10px rgba(0, 0, 0, 0.35);
}
.card-bezel-royal:hover {
  box-shadow: 0 0 22px rgba(96, 165, 250, 0.9), 0 7px 14px rgba(0, 0, 0, 0.4);
}

.card-bezel-purple {
  background: linear-gradient(180deg, #c084fc 0%, #9333ea 65%, #7e22ce 100%);
  border-bottom: 4px solid #581c87;
  box-shadow: 0 0 14px rgba(192, 132, 252, 0.6), 0 5px 10px rgba(0, 0, 0, 0.35);
}
.card-bezel-purple:hover {
  box-shadow: 0 0 22px rgba(192, 132, 252, 0.9), 0 7px 14px rgba(0, 0, 0, 0.4);
}

.card-bezel-orange {
  background: linear-gradient(180deg, #fbbf24 0%, #ea580c 65%, #c2410c 100%);
  border-bottom: 4px solid #9a3412;
  box-shadow: 0 0 14px rgba(251, 146, 60, 0.6), 0 5px 10px rgba(0, 0, 0, 0.35);
}
.card-bezel-orange:hover {
  box-shadow: 0 0 22px rgba(251, 146, 60, 0.9), 0 7px 14px rgba(0, 0, 0, 0.4);
}

.card-bezel-teal {
  background: linear-gradient(180deg, #2dd4bf 0%, #0d9488 65%, #115e59 100%);
  border-bottom: 4px solid #134e4a;
  box-shadow: 0 0 14px rgba(45, 212, 191, 0.6), 0 5px 10px rgba(0, 0, 0, 0.35);
}
.card-bezel-teal:hover {
  box-shadow: 0 0 22px rgba(45, 212, 191, 0.9), 0 7px 14px rgba(0, 0, 0, 0.4);
}

.card-bezel-pink {
  background: linear-gradient(180deg, #f472b6 0%, #db2777 65%, #9d174d 100%);
  border-bottom: 4px solid #831843;
  box-shadow: 0 0 14px rgba(244, 114, 182, 0.6), 0 5px 10px rgba(0, 0, 0, 0.35);
}
.card-bezel-pink:hover {
  box-shadow: 0 0 22px rgba(244, 114, 182, 0.9), 0 7px 14px rgba(0, 0, 0, 0.4);
}

.card-bezel-red {
  background: linear-gradient(180deg, #f87171 0%, #ef4444 65%, #b91c1c 100%);
  border-bottom: 4px solid #7f1d1d;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.6), 0 5px 10px rgba(0, 0, 0, 0.35);
}
.card-bezel-red:hover {
  box-shadow: 0 0 22px rgba(239, 68, 68, 0.9), 0 7px 14px rgba(0, 0, 0, 0.4);
}

.card-bezel-amber {
  background: linear-gradient(180deg, #fde047 0%, #d97706 65%, #b45309 100%);
  border-bottom: 4px solid #78350f;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.6), 0 5px 10px rgba(0, 0, 0, 0.35);
}
.card-bezel-amber:hover {
  box-shadow: 0 0 22px rgba(245, 158, 11, 0.9), 0 7px 14px rgba(0, 0, 0, 0.4);
}

/* Inner Cream Canvas of the card */
.toy-card-inner {
  background: linear-gradient(180deg, #fffef5 0%, #fef3c7 100%);
  border-radius: 12px;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.9), inset 0 -2px 4px rgba(180, 83, 9, 0.18);
}

/* Specular White Gloss Bubble at Top-Left of Card */
.toy-card-gloss {
  position: absolute;
  top: 3px;
  left: 4px;
  width: 8px;
  height: 5px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  filter: blur(0.3px);
  pointer-events: none;
  z-index: 5;
}

.card-snap-in {
  animation: cardSnapInAnim 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes cardSnapInAnim {
  0% { transform: scale(0.4) translateY(-24px); opacity: 0; }
  70% { transform: scale(1.15) translateY(2px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.card-eject-pop {
  animation: cardEjectPopAnim 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes cardEjectPopAnim {
  0% { transform: scale(1) translateY(0); opacity: 1; }
  40% { transform: scale(1.2) translateY(-18px) rotate(-8deg); opacity: 0.9; }
  100% { transform: scale(0.2) translateY(-40px) rotate(15deg); opacity: 0; }
}

/* ============================================================ */
/* 2.5 3D CONTAINER LOOP BLOCK & PARENT-CHILD BRACKET SYSTEM    */
/* ============================================================ */
/* Default: INACTIVE / RESTING STATE (Clean, subtle, not shouting) */
.toy-loop-container {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(22, 10, 36, 0.7);
  border: 2px dashed rgba(244, 114, 182, 0.4);
  border-radius: 20px;
  box-shadow: 
    inset 0 2px 6px rgba(0, 0, 0, 0.6),
    0 2px 6px rgba(0, 0, 0, 0.35);
  position: relative;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 52px;
  opacity: 0.85;
}

.toy-loop-container:hover {
  opacity: 1;
  border-color: rgba(244, 114, 182, 0.7);
}

.toy-loop-container.loop-purple {
  background: rgba(20, 10, 42, 0.7);
  border-color: rgba(192, 132, 252, 0.4);
}

/* ACTIVE STATE: FOCUSED LOOP (Glowing Gold Radiant Enclosure) */
.toy-loop-container.loop-active-target {
  opacity: 1 !important;
  border: 3px solid #facc15 !important;
  background: linear-gradient(135deg, rgba(112, 26, 117, 0.8) 0%, rgba(30, 10, 50, 0.95) 100%) !important;
  box-shadow: 
    0 0 28px rgba(250, 204, 21, 0.9),
    inset 0 0 12px rgba(250, 204, 21, 0.45),
    0 6px 16px rgba(0, 0, 0, 0.6) !important;
  transform: scale(1.03) translateY(-1px);
  animation: loopActivePulse 1.2s ease-in-out infinite alternate !important;
  z-index: 20;
}

.toy-loop-container.loop-purple.loop-active-target {
  background: linear-gradient(135deg, rgba(88, 28, 135, 0.85) 0%, rgba(35, 12, 60, 0.95) 100%) !important;
}

@keyframes loopActivePulse {
  0% {
    box-shadow: 0 0 16px rgba(250, 204, 21, 0.75), inset 0 0 8px rgba(250, 204, 21, 0.35);
    border-color: #fbbf24;
  }
  100% {
    box-shadow: 0 0 32px rgba(250, 204, 21, 1), inset 0 0 16px rgba(250, 204, 21, 0.6);
    border-color: #fef08a;
  }
}

/* LOOP BADGE EXECUTING (LOOP HEADER TICK) */
.toy-loop-badge.executing {
  border: 3px solid #00f2fe !important;
  border-radius: 16px;
  box-shadow: 0 0 28px #00f2fe, inset 0 0 12px #00f2fe !important;
  transform: scale(1.15) translateY(-4px) !important;
  z-index: 50 !important;
}
.toy-loop-badge.executing .toy-card-token {
  opacity: 1 !important;
  filter: brightness(1.25) drop-shadow(0 0 12px #00f2fe) !important;
}
.toy-loop-badge.executing::after {
  content: '▼';
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  color: #00f2fe;
  font-size: 16px;
  font-weight: 900;
  text-shadow: 0 0 12px #00f2fe, 0 0 24px #0284c7;
  animation: pointerArrowBounce 0.35s ease-in-out infinite alternate;
  z-index: 60;
}

.toy-loop-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  position: relative;
}

@media (min-width: 640px) {
  .toy-loop-badge {
    width: 56px;
    height: 56px;
  }
}

.toy-loop-body {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px 6px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 16px;
  border: 1.5px dashed rgba(255, 255, 255, 0.2);
  min-width: 48px;
  min-height: 48px;
  transition: all 0.2s ease;
}

.toy-loop-container.loop-active-target .toy-loop-body {
  border: 2px dashed rgba(250, 204, 21, 0.8) !important;
  background: rgba(0, 0, 0, 0.6) !important;
}

.toy-loop-container.loop-purple .toy-loop-body {
  border-color: rgba(192, 132, 252, 0.3);
}

.toy-loop-child-socket {
  width: 44px;
  height: 44px;
  position: relative;
  flex-shrink: 0;
  border-radius: 14px;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (min-width: 640px) {
  .toy-loop-child-socket {
    width: 48px;
    height: 48px;
  }
}

/* Active Loop Child Socket Glow */
.toy-loop-child-socket.insert-target {
  border: 2.5px solid #facc15 !important;
  box-shadow: 0 0 22px rgba(250, 204, 21, 0.95), inset 0 0 8px rgba(250, 204, 21, 0.5) !important;
  transform: scale(1.08) translateY(-2px);
  border-radius: 14px;
  z-index: 25;
  animation: activeSlotPulse 1.2s ease-in-out infinite alternate;
}

/* LOOP CHILD SOCKET EXECUTING */
.toy-loop-child-socket.executing {
  border-color: #00f2fe !important;
  border-style: solid !important;
  border-width: 3.5px !important;
  background: radial-gradient(circle at center, rgba(0, 242, 254, 0.4) 0%, rgba(3, 105, 161, 0.7) 100%) !important;
  box-shadow: 0 0 30px #00f2fe, 0 0 15px #00f2fe, inset 0 0 14px #00f2fe !important;
  transform: scale(1.2) translateY(-6px) !important;
  border-radius: 14px;
  z-index: 50 !important;
}
.toy-loop-child-socket.executing .toy-card-token {
  opacity: 1 !important;
  filter: brightness(1.25) drop-shadow(0 0 12px #00f2fe) !important;
}
.toy-loop-child-socket.executing::after {
  content: '▼';
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  color: #00f2fe;
  font-size: 16px;
  font-weight: 900;
  text-shadow: 0 0 12px #00f2fe, 0 0 24px #0284c7;
  animation: pointerArrowBounce 0.35s ease-in-out infinite alternate;
  z-index: 60;
}

.toy-loop-add-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toy-loop-add-btn:hover,
.toy-loop-add-btn.active-target {
  background: rgba(250, 204, 21, 0.25);
  color: #facc15;
  border-color: #facc15;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.8);
  transform: scale(1.08);
}

/* ============================================================ */
/* WORLD 3: 3D CONDITION BRACKET CONTAINERS                     */
/* ============================================================ */
.toy-condition-container {
  display: flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(180deg, rgba(30, 27, 75, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 2.5px solid #f59e0b;
  border-radius: 18px;
  padding: 4px 6px;
  box-shadow: 
    inset 0 2px 6px rgba(0, 0, 0, 0.6),
    0 0 16px rgba(245, 158, 11, 0.35);
  position: relative;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 52px;
  opacity: 0.92;
}

.toy-condition-container:hover {
  opacity: 1;
  border-color: #fbbf24;
  box-shadow: 0 0 22px rgba(251, 191, 36, 0.6), inset 0 0 12px rgba(251, 191, 36, 0.2);
}

.toy-condition-container.condition-active-target {
  opacity: 1 !important;
  border: 3px solid #facc15 !important;
  background: linear-gradient(135deg, rgba(120, 53, 15, 0.8) 0%, rgba(30, 10, 50, 0.95) 100%) !important;
  box-shadow: 
    0 0 28px rgba(250, 204, 21, 0.9),
    inset 0 0 12px rgba(250, 204, 21, 0.45),
    0 6px 16px rgba(0, 0, 0, 0.6) !important;
  transform: scale(1.03) translateY(-1px);
  animation: conditionActivePulse 1.2s ease-in-out infinite alternate !important;
  z-index: 20;
}

@keyframes conditionActivePulse {
  0% {
    box-shadow: 0 0 16px rgba(250, 204, 21, 0.75), inset 0 0 8px rgba(250, 204, 21, 0.35);
    border-color: #fbbf24;
  }
  100% {
    box-shadow: 0 0 32px rgba(250, 204, 21, 1), inset 0 0 16px rgba(250, 204, 21, 0.6);
    border-color: #fef08a;
  }
}

.toy-condition-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  position: relative;
}

@media (min-width: 640px) {
  .toy-condition-badge {
    width: 56px;
    height: 56px;
  }
}

.toy-condition-badge.executing {
  border: 3px solid #00f2fe !important;
  border-radius: 16px;
  box-shadow: 0 0 28px #00f2fe, inset 0 0 12px #00f2fe !important;
  transform: scale(1.15) translateY(-4px) !important;
  z-index: 50 !important;
}
.toy-condition-badge.executing .toy-card-token {
  opacity: 1 !important;
  filter: brightness(1.25) drop-shadow(0 0 12px #00f2fe) !important;
}
.toy-condition-badge.executing::after {
  content: '▼';
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  color: #00f2fe;
  font-size: 16px;
  font-weight: 900;
  text-shadow: 0 0 12px #00f2fe, 0 0 24px #0284c7;
  animation: pointerArrowBounce 0.35s ease-in-out infinite alternate;
  z-index: 60;
}

.toy-condition-body {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px 6px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 16px;
  border: 1.5px dashed rgba(245, 158, 11, 0.5);
  min-width: 48px;
  min-height: 48px;
  transition: all 0.2s ease;
}

.toy-condition-container.condition-active-target .toy-condition-body {
  border: 2px dashed rgba(250, 204, 21, 0.8) !important;
  background: rgba(0, 0, 0, 0.6) !important;
}

.toy-condition-child-socket {
  width: 44px;
  height: 44px;
  position: relative;
  flex-shrink: 0;
  border-radius: 14px;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (min-width: 640px) {
  .toy-condition-child-socket {
    width: 48px;
    height: 48px;
  }
}

.toy-condition-child-socket.insert-target {
  border: 2px solid #facc15 !important;
  background: rgba(250, 204, 21, 0.35) !important;
  box-shadow: 0 0 18px rgba(250, 204, 21, 0.85) !important;
  transform: scale(1.08);
}

.toy-condition-child-socket.executing {
  border: 3px solid #00f2fe !important;
  border-radius: 14px;
  box-shadow: 0 0 24px #00f2fe, inset 0 0 10px #00f2fe !important;
  transform: scale(1.15) translateY(-3px) !important;
  z-index: 45 !important;
}
.toy-condition-child-socket.executing .toy-card-token {
  opacity: 1 !important;
  filter: brightness(1.25) drop-shadow(0 0 10px #00f2fe) !important;
}
.toy-condition-child-socket.executing::after {
  content: '▼';
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  color: #00f2fe;
  font-size: 16px;
  font-weight: 900;
  text-shadow: 0 0 12px #00f2fe, 0 0 24px #0284c7;
  animation: pointerArrowBounce 0.35s ease-in-out infinite alternate;
  z-index: 60;
}

.toy-condition-add-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 2px dashed rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.1);
  color: rgba(251, 191, 36, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toy-condition-add-btn:hover,
.toy-condition-add-btn.active-target {
  background: rgba(250, 204, 21, 0.25);
  color: #facc15;
  border-color: #facc15;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.8);
  transform: scale(1.08);
}

/* ============================================================ */
/* WORLD 3: NESTED CONDITION (SCAN) SCOPE INSIDE A LOOP         */
/* High-tech Cyan/Amber border & background distinct from 4x    */
/* ============================================================ */
.toy-condition-nested-container {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: linear-gradient(135deg, rgba(8, 51, 68, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
  border: 2px solid #00f2fe;
  border-radius: 16px;
  padding: 3px 5px;
  box-shadow: 
    inset 0 2px 5px rgba(0, 0, 0, 0.6),
    0 0 14px rgba(0, 242, 254, 0.45);
  position: relative;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 46px;
}

.toy-condition-nested-container:hover {
  border-color: #38bdf8;
  box-shadow: 0 0 20px rgba(0, 242, 254, 0.65), inset 0 0 8px rgba(0, 242, 254, 0.25);
}

.toy-condition-nested-container.executing {
  border: 2.5px solid #00f2fe !important;
  box-shadow: 0 0 28px #00f2fe, inset 0 0 12px #00f2fe !important;
  transform: scale(1.1) translateY(-3px);
  z-index: 45;
}
.toy-condition-nested-container.executing::after {
  content: '▼';
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  color: #00f2fe;
  font-size: 15px;
  font-weight: 900;
  text-shadow: 0 0 12px #00f2fe, 0 0 20px #0284c7;
  animation: pointerArrowBounce 0.35s ease-in-out infinite alternate;
  z-index: 60;
}

.toy-condition-nested-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  position: relative;
}

@media (min-width: 640px) {
  .toy-condition-nested-badge {
    width: 46px;
    height: 46px;
  }
}

.toy-condition-nested-child-socket {
  width: 40px;
  height: 40px;
  position: relative;
  flex-shrink: 0;
  border-radius: 12px;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (min-width: 640px) {
  .toy-condition-nested-child-socket {
    width: 46px;
    height: 46px;
  }
}

.toy-condition-nested-child-socket.executing {
  border: 2.5px solid #38bdf8 !important;
  box-shadow: 0 0 20px #38bdf8, inset 0 0 8px #0284c7 !important;
  transform: scale(1.12);
}

/* ============================================================ */
/* WORLD 3: 3D IF-ELSE DUAL-BRANCH CONTAINER (STAGE 3-2)        */
/* ============================================================ */
.toy-ifelse-container {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(20, 24, 52, 0.95) 0%, rgba(10, 14, 32, 0.98) 100%);
  border: 2.5px solid #f59e0b;
  border-radius: 20px;
  padding: 5px 7px;
  box-shadow: 
    inset 0 2px 6px rgba(0, 0, 0, 0.6),
    0 0 16px rgba(245, 158, 11, 0.35);
  position: relative;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 96px;
}

.toy-ifelse-container:hover {
  border-color: #fbbf24;
  box-shadow: 0 0 22px rgba(251, 191, 36, 0.55), inset 0 0 10px rgba(251, 191, 36, 0.2);
}

.toy-ifelse-header-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  position: relative;
}

@media (min-width: 640px) {
  .toy-ifelse-header-badge {
    width: 52px;
    height: 52px;
  }
}

.toy-ifelse-header-badge.executing {
  border: 3px solid #00f2fe !important;
  border-radius: 16px;
  box-shadow: 0 0 28px #00f2fe, inset 0 0 12px #00f2fe !important;
  transform: scale(1.12) translateY(-2px) !important;
  z-index: 50 !important;
}
.toy-ifelse-header-badge.executing::after {
  content: '▼';
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  color: #00f2fe;
  font-size: 16px;
  font-weight: 900;
  text-shadow: 0 0 12px #00f2fe, 0 0 24px #0284c7;
  animation: pointerArrowBounce 0.35s ease-in-out infinite alternate;
  z-index: 60;
}

.toy-ifelse-branches {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.toy-ifelse-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 5px;
  border-radius: 14px;
  transition: all 0.2s ease;
  min-height: 44px;
  position: relative;
  cursor: pointer;
}

.toy-ifelse-row.if-row {
  background: rgba(245, 158, 11, 0.1);
  border: 1.5px dashed rgba(245, 158, 11, 0.45);
}

.toy-ifelse-row.else-row {
  background: rgba(14, 165, 233, 0.1);
  border: 1.5px dashed rgba(14, 165, 233, 0.45);
}

.toy-ifelse-row.active-branch {
  border: 2px solid #facc15 !important;
  background: rgba(250, 204, 21, 0.2) !important;
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.6) !important;
}

.toy-ifelse-row.executing {
  border: 2.5px solid #00f2fe !important;
  background: rgba(0, 242, 254, 0.15) !important;
  box-shadow: 0 0 24px #00f2fe, inset 0 0 10px #00f2fe !important;
  transform: scale(1.02);
  z-index: 40;
}

.toy-ifelse-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  position: relative;
}

@media (min-width: 640px) {
  .toy-ifelse-badge {
    width: 44px;
    height: 44px;
  }
}

.toy-ifelse-badge.executing {
  border: 2px solid #00f2fe !important;
  border-radius: 12px;
  box-shadow: 0 0 16px #00f2fe !important;
  transform: scale(1.08);
}

.toy-ifelse-body {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 38px;
  min-height: 38px;
}

.toy-ifelse-child-socket {
  width: 38px;
  height: 38px;
  position: relative;
  flex-shrink: 0;
  border-radius: 12px;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (min-width: 640px) {
  .toy-ifelse-child-socket {
    width: 42px;
    height: 42px;
  }
}

.toy-ifelse-child-socket.executing {
  border: 2.5px solid #00f2fe !important;
  box-shadow: 0 0 20px #00f2fe, inset 0 0 8px #0284c7 !important;
  transform: scale(1.12) translateY(-2px);
  z-index: 45;
}

.toy-ifelse-add-btn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1.5px dashed rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toy-ifelse-add-btn:hover,
.toy-ifelse-add-btn.active-target {
  background: rgba(250, 204, 21, 0.25);
  color: #facc15;
  border-color: #facc15;
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.8);
  transform: scale(1.08);
}

/* Nested If-Else Container inside Loop Body */
.toy-ifelse-nested {
  padding: 4px 6px !important;
  min-height: 98px !important;
  border-width: 2.5px !important;
  gap: 6px !important;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.96) 0%, rgba(8, 14, 28, 0.99) 100%) !important;
  border-radius: 18px !important;
}

.toy-ifelse-nested .toy-ifelse-header-badge {
  width: 44px !important;
  height: 44px !important;
}

@media (min-width: 640px) {
  .toy-ifelse-nested .toy-ifelse-header-badge {
    width: 50px !important;
    height: 50px !important;
  }
}

.toy-ifelse-nested .toy-ifelse-row {
  min-height: 44px !important;
  padding: 3px 6px !important;
  gap: 4px !important;
  border-radius: 14px !important;
}

.toy-ifelse-nested .toy-ifelse-badge {
  width: 38px !important;
  height: 38px !important;
}

@media (min-width: 640px) {
  .toy-ifelse-nested .toy-ifelse-badge {
    width: 44px !important;
    height: 44px !important;
  }
}

.toy-ifelse-nested .toy-ifelse-body {
  min-width: 38px !important;
  min-height: 38px !important;
  gap: 4px !important;
}

.toy-ifelse-nested .toy-ifelse-child-socket {
  width: 38px !important;
  height: 38px !important;
}

@media (min-width: 640px) {
  .toy-ifelse-nested .toy-ifelse-child-socket {
    width: 44px !important;
    height: 44px !important;
  }
}

.toy-ifelse-nested .toy-ifelse-add-btn {
  width: 32px !important;
  height: 32px !important;
  font-size: 16px !important;
  border-radius: 10px !important;
}

@media (min-width: 640px) {
  .toy-ifelse-nested .toy-ifelse-add-btn {
    width: 36px !important;
    height: 36px !important;
  }
}

/* Active Slot Glowing Effect */
.toy-slot-socket.insert-target {
  border: 2.5px solid #facc15 !important;
  border-style: solid !important;
  background: radial-gradient(circle at center, rgba(250, 204, 21, 0.35) 0%, rgba(180, 83, 9, 0.5) 100%) !important;
  box-shadow: 0 0 26px rgba(250, 204, 21, 0.95), inset 0 0 10px rgba(250, 204, 21, 0.6) !important;
  transform: scale(1.08) translateY(-2px);
  opacity: 1 !important;
  z-index: 30;
  animation: activeSlotPulse 1.2s ease-in-out infinite alternate;
}

@keyframes activeSlotPulse {
  0% {
    box-shadow: 0 0 14px rgba(250, 204, 21, 0.75), inset 0 0 6px rgba(250, 204, 21, 0.4);
    border-color: #fbbf24;
  }
  100% {
    box-shadow: 0 0 30px rgba(250, 204, 21, 1), inset 0 0 14px rgba(250, 204, 21, 0.75);
    border-color: #fef08a;
  }
}

/* ============================================================ */
/* DRAG AND DROP & INTER-SLOT INSERTION INDICATORS              */
/* ============================================================ */
.toy-card-token[draggable="true"],
.toy-slot-socket[draggable="true"],
.toy-slot-socket .toy-card-token {
  cursor: grab;
}
.toy-card-token[draggable="true"]:active,
.toy-slot-socket[draggable="true"]:active,
.toy-slot-socket .toy-card-token:active {
  cursor: grabbing;
}

.is-dragging {
  opacity: 0.35 !important;
  transform: scale(0.92) !important;
}

body.is-drag-active .toy-slot-socket {
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

/* Drop hover on slot */
.toy-slot-socket.drop-hover-slot {
  border-color: #00f2fe !important;
  border-style: solid !important;
  background: radial-gradient(circle at center, rgba(0, 242, 254, 0.25) 0%, rgba(3, 105, 161, 0.4) 100%) !important;
  box-shadow: 0 0 20px #00f2fe, inset 0 0 8px #00f2fe !important;
  transform: scale(1.06) translateY(-2px);
}

/* Vertical glowing insertion line on the left of slot */
.toy-slot-socket.drop-insert-left::before,
.toy-loop-child-socket.drop-insert-left::before,
.toy-condition-child-socket.drop-insert-left::before {
  content: '';
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: -5px;
  width: 5px;
  background: linear-gradient(180deg, #fef08a 0%, #00f2fe 50%, #fef08a 100%);
  border-radius: 4px;
  box-shadow: 0 0 14px #00f2fe, 0 0 6px #fef08a;
  z-index: 50;
  animation: insertBeamPulse 0.6s infinite alternate ease-in-out;
}

/* Vertical glowing insertion line on the right of slot */
.toy-slot-socket.drop-insert-right::after,
.toy-loop-child-socket.drop-insert-right::after,
.toy-condition-child-socket.drop-insert-right::after {
  content: '';
  position: absolute;
  top: -4px;
  bottom: -4px;
  right: -5px;
  width: 5px;
  background: linear-gradient(180deg, #fef08a 0%, #00f2fe 50%, #fef08a 100%);
  border-radius: 4px;
  box-shadow: 0 0 14px #00f2fe, 0 0 6px #fef08a;
  z-index: 50;
  animation: insertBeamPulse 0.6s infinite alternate ease-in-out;
}

@keyframes insertBeamPulse {
  0% { transform: scaleY(0.92); opacity: 0.8; box-shadow: 0 0 8px #00f2fe; }
  100% { transform: scaleY(1.08); opacity: 1; box-shadow: 0 0 20px #00f2fe, 0 0 10px #fef08a; }
}

.toy-loop-container.loop-drop-target,
.toy-condition-container.condition-drop-target {
  border-color: #f59e0b !important;
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.9), inset 0 0 12px rgba(245, 158, 11, 0.5) !important;
  transform: scale(1.02);
}

/* Speech Bubble Pop-In */
@keyframes popInBubble {
  0% { transform: scale(0.5) translateY(-6px); opacity: 0; }
  70% { transform: scale(1.05) translateY(0); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.animate-pop-in {
  animation: popInBubble 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Particles & Floating Popups */
.dirt-clod {
  position: absolute;
  pointer-events: none;
  z-index: 62;
  animation: dirtFly 0.6s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes dirtFly {
  0% { transform: translate(0, 0) scale(0.4); opacity: 1; }
  50% { transform: translate(var(--dx, 12px), var(--dy, -20px)) scale(1.1); opacity: 1; }
  100% { transform: translate(var(--dx, 20px), var(--dy, 8px)) scale(0.3); opacity: 0; }
}

.carrot-popup, .water-popup {
  position: absolute;
  font-weight: 900;
  font-size: 16px;
  pointer-events: none;
  z-index: 70;
  animation: floatUpFade 0.9s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
.carrot-popup { color: #ea580c; }
.water-popup { color: #0284c7; text-shadow: 0 0 10px rgba(56, 189, 248, 0.8), 0 2px 4px rgba(0, 0, 0, 0.5); }

@keyframes floatUpFade {
  0% { transform: translateY(0) scale(0.5); opacity: 1; }
  50% { transform: translateY(-38px) scale(1.25); opacity: 1; }
  100% { transform: translateY(-65px) scale(1); opacity: 0; }
}

.sparkle-particle {
  position: absolute;
  pointer-events: none;
  z-index: 60;
  animation: sparkleFade 0.7s ease-out forwards;
}
@keyframes sparkleFade {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(0deg); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.3) rotate(90deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.8) rotate(180deg); opacity: 0; }
}

.water-particle {
  position: absolute;
  pointer-events: none;
  z-index: 60;
  animation: waterSpray 0.65s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes waterSpray {
  0% { transform: translate(0, 0) scale(0.3); opacity: 1; }
  50% { transform: translate(var(--dx, 10px), var(--dy, -25px)) scale(1.15); opacity: 0.9; }
  100% { transform: translate(var(--dx, 16px), var(--dy, 12px)) scale(0.35); opacity: 0; }
}

/* WATER DROP PARTICLE (100% Faithful to studios/carrot.html) */
.water-splash {
  position: absolute;
  pointer-events: none;
  z-index: 60;
  animation: waterSplashPop 0.65s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes waterSplashPop {
  0% { transform: translate(0, 0) scale(0.5); opacity: 1; }
  100% { transform: translate(var(--tx, 15px), var(--ty, -25px)) scale(1.1); opacity: 0; }
}

/* BOG GAS BUBBLE PARTICLE (Overwatered Rotten Carrot state) */
.bog-bubble {
  position: absolute;
  pointer-events: none;
  z-index: 60;
  animation: bogBubbleFloat 0.9s ease-out forwards;
}
@keyframes bogBubbleFloat {
  0% { transform: translateY(0) scale(0.4); opacity: 0.9; }
  50% { transform: translateY(-20px) scale(1.1); opacity: 0.8; }
  100% { transform: translateY(-40px) scale(1.4); opacity: 0; }
}

/* ============================================================ */
/* 2.7 2.5D CARROT ENTITY & ELASTIC PULL HARVEST ANIMATION       */
/* ============================================================ */
.carrot-entity, .fruit-entity {
  position: absolute;
  width: 70px;
  height: 85px;
  pointer-events: auto;
  cursor: pointer;
  transform-origin: 35px 56px;
  z-index: 10;
}

.hanging-fruit {
  transform-origin: 35px 34px;
  animation: fruitBreeze 2.2s ease-in-out infinite alternate;
}
@keyframes fruitBreeze {
  0% { transform: rotate(-4deg); }
  100% { transform: rotate(5deg); }
}

.carrot-root {
  transform-origin: 35px 54px;
  transition: transform var(--carrot-speed, 0.35s) cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 1. STATE IDLE (Buried snugly in soil mound, gentle breathing bounce) */
.carrot-idle .carrot-root {
  animation: carrotBuriedIdle 1.8s ease-in-out infinite alternate;
}
@keyframes carrotBuriedIdle {
  0% { transform: translateY(0px) scale(1, 1); }
  50% { transform: translateY(-4px) scale(0.97, 1.03); }
  100% { transform: translateY(2px) scale(1.03, 0.97); }
}

/* 1.1 STATE WITHERED (ผักเหี่ยวขาดน้ำ: ดินแตกระแหง, ตัวเหี่ยวคอตก) */
.carrot-withered .carrot-root {
  animation: carrotWitheredIdle 2.5s ease-in-out infinite alternate;
}
@keyframes carrotWitheredIdle {
  0% { transform: translateY(0px) rotate(0deg) scale(0.96, 0.98); }
  50% { transform: translateY(2px) rotate(-1.5deg) scale(0.94, 0.95); }
  100% { transform: translateY(1px) rotate(1deg) scale(0.96, 0.97); }
}

/* 1.2 STATE HYDRATED (ผักเปียกชุ่มฉ่ำ สะท้อนเงาวับ) */
.carrot-hydrated .carrot-root {
  animation: carrotHydratedBounce 1.4s ease-in-out infinite alternate;
}
@keyframes carrotHydratedBounce {
  0% { transform: translateY(0px) scale(1.04, 1.04); filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.5)); }
  50% { transform: translateY(-6px) scale(1.08, 1.02); filter: drop-shadow(0 0 16px rgba(56, 189, 248, 0.95)); }
  100% { transform: translateY(-2px) scale(1.02, 1.06); filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.7)); }
}

/* 1.3 STATE ROTTEN (รดน้ำซ้ำจนรากเน่าตาย น้ำท่วมขัง) */
.carrot-rotten .carrot-root {
  animation: carrotRottenSink 2s ease-in-out infinite alternate;
}
@keyframes carrotRottenSink {
  0% { transform: translateY(3px) rotate(0deg) scale(1.06, 0.92); }
  30% { transform: translateY(6px) rotate(-3deg) scale(1.08, 0.88); }
  70% { transform: translateY(4px) rotate(3deg) scale(1.05, 0.94); }
  100% { transform: translateY(7px) rotate(0deg) scale(1.1, 0.86); }
}

/* 2. STATE TAP-TO-SPEAK (Pops up from soil hole, squishes, then ducks back) */
.carrot-tap .carrot-root {
  animation: carrotPopFromSoil 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes carrotPopFromSoil {
  0% { transform: translateY(0) scale(1, 1); }
  20% { transform: translateY(3px) scale(1.18, 0.82); }
  50% { transform: translateY(-18px) scale(0.92, 1.18); }
  75% { transform: translateY(-4px) scale(1.06, 0.96); }
  100% { transform: translateY(0) scale(1, 1); }
}

/* 3. STATE WATERED (Soil darkens, carrot expands and glows with sunlight sparkles) */
.carrot-watered .carrot-root {
  animation: carrotWateredGrowth 1s ease-in-out forwards;
}
.carrot-watered .soil-mound-front {
  animation: soilDarkenWet 1s ease-in-out forwards;
}
@keyframes carrotWateredGrowth {
  0% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 0 rgba(56, 189, 248, 0)); }
  35% { transform: translateY(-12px) scale(1.18); filter: drop-shadow(0 0 16px rgba(56, 189, 248, 0.95)); }
  70% { transform: translateY(-6px) scale(1.12); filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.9)); }
  100% { transform: translateY(-2px) scale(1.08); filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.6)); }
}
@keyframes soilDarkenWet {
  0% { filter: brightness(1); }
  50% { filter: brightness(0.65) saturate(1.4); }
  100% { filter: brightness(0.8) saturate(1.2); }
}

/* 4. STATE HARVESTED: FAST & SNAPPY ELASTIC PULL & POP (0.6s) FROM STUDIOS/CARROT.HTML */
.carrot-harvested .carrot-root {
  transform-origin: 35px 70px;
  animation: carrotHarvestTrajectory 0.6s cubic-bezier(0.2, 0.9, 0.3, 1) forwards !important;
}

.carrot-harvested .carrot-leaves {
  transform-origin: 35px 25px;
  animation: leavesToughPull 0.6s ease-in-out forwards !important;
}

.carrot-harvested .carrot-body-cone {
  transform-origin: 35px 76px;
  animation: carrotBodyElasticStretch 0.6s cubic-bezier(0.25, 1, 0.35, 1) forwards !important;
}

.carrot-harvested .carrot-face {
  transform-origin: 35px 38px;
  animation: faceStrainedPull 0.6s ease-in-out forwards !important;
}

.carrot-harvested .carrot-sweat {
  animation: sweatDropPop 0.6s ease-in-out forwards !important;
}

.carrot-harvested .soil-mound-front {
  animation: soilTugShake 0.6s ease-in-out forwards !important;
}

@keyframes carrotHarvestTrajectory {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  12% { transform: translateY(-4px) rotate(-6deg); }
  24% { transform: translateY(-8px) rotate(8deg); }
  36% { transform: translateY(-12px) rotate(-8deg); }
  44% { transform: translateY(-16px) rotate(6deg); }
  50% { transform: translateY(-65px) rotate(14deg); opacity: 1; }
  68% { transform: translateY(-135px) rotate(-30deg); opacity: 1; }
  82% { transform: translate(-50px, -190px) scale(0.65) rotate(140deg); opacity: 0.95; }
  94% { transform: translate(-80px, -230px) scale(0.25) rotate(240deg); opacity: 0.5; }
  100% { transform: translate(-90px, -245px) scale(0.05) rotate(280deg); opacity: 0; }
}

@keyframes leavesToughPull {
  0% { transform: scale(1, 1) translateY(0); }
  12% { transform: scale(0.85, 1.35) translateY(-6px) rotate(-5deg); }
  24% { transform: scale(0.75, 1.5) translateY(-10px) rotate(7deg); }
  36% { transform: scale(0.7, 1.65) translateY(-14px) rotate(-7deg); }
  46% { transform: scale(0.62, 1.85) translateY(-20px) rotate(5deg); }
  52% { transform: scale(1.35, 0.7) translateY(4px) rotate(-12deg); }
  60% { transform: scale(0.9, 1.15) translateY(-2px); }
  75% { transform: scale(1.05, 0.95) translateY(0); }
  100% { transform: scale(1, 1); }
}

@keyframes carrotBodyElasticStretch {
  0% { transform: scale(1, 1); }
  12% { transform: scale(0.88, 1.25); }
  24% { transform: scale(0.78, 1.45); }
  36% { transform: scale(0.70, 1.65); }
  46% { transform: scale(0.58, 1.95); }
  52% { transform: scale(1.45, 0.65); }
  62% { transform: scale(0.86, 1.22); }
  72% { transform: scale(1.08, 0.94); }
  85% { transform: scale(1, 1); }
  100% { transform: scale(1, 1); }
}

@keyframes faceStrainedPull {
  0% { transform: scale(1, 1); }
  12%, 46% { transform: scale(0.85, 0.8) translateY(2px); }
  52% { transform: scale(1.3, 1.25) translateY(-2px); }
  65% { transform: scale(1, 1); }
  100% { transform: scale(1, 1); }
}

@keyframes sweatDropPop {
  0%, 10% { opacity: 0; transform: scale(0); }
  15%, 46% { opacity: 1; transform: scale(1.1); }
  50%, 100% { opacity: 0; transform: scale(1.6) translateY(-10px); }
}

@keyframes soilTugShake {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  10% { transform: translateY(-1px) scale(0.98, 1.02); }
  25% { transform: translateY(1px) scale(1.03, 0.97) rotate(-2deg); }
  38% { transform: translateY(-2px) scale(0.96, 1.04) rotate(2deg); }
  46% { transform: translateY(-4px) scale(1.08, 0.94); }
  52% { transform: translateY(3px) scale(1.1, 0.9); }
  65% { transform: translateY(0) scale(1, 1); }
}

.carrot-leaves {
  transform-origin: 35px 24px;
  animation: leavesSway 2.2s ease-in-out infinite alternate;
}
@keyframes leavesSway {
  0% { transform: rotate(-6deg); }
  100% { transform: rotate(7deg); }
}

@keyframes gateShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
.animate-shake {
  animation: gateShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ============================================================ */
/* 2.8 2.5D ROCK OBSTACLE ENTITY & IMPACT ANIMATION             */
/* ============================================================ */
.rock-entity {
  position: absolute;
  width: 70px;
  height: 70px;
  pointer-events: auto;
  cursor: pointer;
  transform-origin: 35px 56px;
  z-index: 20;
}

.rock-sprite {
  transform-origin: 35px 56px;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rock-idle .rock-sprite {
  animation: rockIdleGrounded 3s ease-in-out infinite alternate;
}
@keyframes rockIdleGrounded {
  0% { transform: translateY(0px) scale(1, 1); }
  100% { transform: translateY(-1.5px) scale(1.01, 0.99); }
}

.rock-bump-impact .rock-sprite {
  animation: rockBumpTremor 0.55s ease-out both;
}
@keyframes rockBumpTremor {
  0% { transform: translateX(0) scale(1); filter: drop-shadow(0 0 0 rgba(239, 68, 68, 0)); }
  15% { transform: translate(6px, -2px) rotate(5deg) scale(1.12, 0.9); filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.8)); }
  35% { transform: translate(-5px, 1px) rotate(-4deg) scale(0.94, 1.06); filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.5)); }
  55% { transform: translate(3px, -1px) rotate(2deg); }
  75% { transform: translate(-1.5px, 0) rotate(-1deg); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1); filter: drop-shadow(0 0 0 rgba(239, 68, 68, 0)); }
}


/* ============================================================ */
/* 2.6 2.5D ISOMETRIC PLAYFIELD & TILE BOARD                    */
/* ============================================================ */
.iso-stage {
  position: relative;
  width: 100%;
  height: 100%;
  flex: 1 1 0%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

.iso-board {
  position: relative;
  width: 440px;
  height: 340px;
  transform-style: preserve-3d;
  flex-shrink: 0;
  will-change: transform;
  transform-origin: center center;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.iso-tile {
  position: absolute;
  width: 80px;
  height: 40px;
  cursor: pointer;
  transition: filter 0.15s ease-out;
}

.iso-tile:hover {
  filter: brightness(1.22);
}

.island-cosmic-glow {
  position: absolute;
  width: 480px;
  height: 250px;
  left: -20px;
  top: 95px;
  background: radial-gradient(ellipse at center, rgba(44, 88, 232, 0.4) 0%, rgba(138, 43, 226, 0.25) 50%, rgba(12, 18, 54, 0) 75%);
  border-radius: 50%;
  filter: blur(28px);
  pointer-events: none;
  z-index: 1;
}

.goal-portal-glow {
  animation: goalGlow 2s infinite ease-in-out;
}

.goal-celebration {
  animation: goalCelebrateBurst 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.goal-star-float {
  animation: goalStarFloat 1.6s ease-in-out infinite alternate;
  transform-origin: 40px 5px;
}

@keyframes goalStarFloat {
  0% { transform: translateY(0px) scale(1); filter: drop-shadow(0 2px 4px rgba(250, 204, 21, 0.6)); }
  100% { transform: translateY(-5px) scale(1.1); filter: drop-shadow(0 4px 10px rgba(250, 204, 21, 0.95)); }
}

@keyframes goalGlow {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(0, 229, 163, 0.7)) brightness(1); }
  50% { filter: drop-shadow(0 0 24px rgba(0, 229, 163, 0.95)) brightness(1.3); }
}

@keyframes goalCelebrateBurst {
  0% { transform: scale(1); filter: drop-shadow(0 0 10px #00e5a3); }
  40% { transform: scale(1.4) translateY(-12px); filter: drop-shadow(0 0 30px #ffcc00) brightness(1.5); }
  100% { transform: scale(1.1); filter: drop-shadow(0 0 15px #00e5a3); }
}

/* ============================================================ */
/* 3. 3D CANDY BUTTONS & ONBOARDING POINTERS                    */
/* ============================================================ */
.candy-btn {
  transition: all 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  user-select: none;
}
.candy-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}
.candy-btn:active {
  transform: translateY(2px);
  filter: brightness(0.95);
}

.gold-pointer-container {
  position: absolute;
  pointer-events: none;
  z-index: 100;
  transition: left 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), top 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.gold-pointer-hand {
  animation: goldHandPoint 1.2s ease-in-out infinite;
  filter: drop-shadow(0 6px 16px rgba(234, 179, 8, 0.6)) drop-shadow(0 0 10px rgba(250, 204, 21, 0.8));
  transform-origin: 20% 20%;
}
@keyframes goldHandPoint {
  0%, 100% { transform: translate(0, 0) rotate(-10deg) scale(1); }
  50% { transform: translate(8px, 12px) rotate(0deg) scale(1.12); }
}
.pointer-ripple {
  position: absolute;
  top: -12px;
  left: -12px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #facc15;
  background: radial-gradient(circle, rgba(250, 204, 21, 0.4) 0%, rgba(250, 204, 21, 0) 70%);
  animation: pointerRippleAnim 1.2s cubic-bezier(0.1, 0.8, 0.3, 1) infinite;
  pointer-events: none;
}
@keyframes pointerRippleAnim {
  0% { transform: scale(0.2); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* ============================================================ */
/* 4. COSMIC STARS & AMBIENT GLOWS                              */
/* ============================================================ */
@keyframes starTwinkle {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}
.star-twinkle-1 { animation: starTwinkle 2.5s infinite ease-in-out; }
.star-twinkle-2 { animation: starTwinkle 3.2s infinite ease-in-out 1s; }
.star-twinkle-3 { animation: starTwinkle 4s infinite ease-in-out 2s; }

/* ============================================================ */
/* 5. BITTO MASCOT 2.5D ANIMATION SUITE (EXACT character.html)   */
/* ============================================================ */

#robotEntity {
  position: absolute;
  width: 100px;
  height: 125px;
  pointer-events: none;
  transform-origin: 50px 106px;
  transform: scale(var(--robot-scale, 0.70));
  transition: left var(--move-duration, 0.38s) cubic-bezier(0.34, 1.56, 0.64, 1),
              top var(--move-duration, 0.38s) cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 50;
}

.robot-shadow-iso {
  position: absolute;
  bottom: 2px;
  left: 15px;
  width: 70px;
  height: 24px;
  background: radial-gradient(ellipse at center, rgba(12, 18, 54, 0.65) 0%, rgba(12, 18, 54, 0.2) 60%, rgba(12, 18, 54, 0) 80%);
  border-radius: 50%;
  transform-origin: center;
  transition: transform var(--move-duration, 0.38s) ease-out, opacity var(--move-duration, 0.38s) ease-out;
}

.robot-sprite-iso {
  position: absolute;
  bottom: 8px;
  left: 0;
  width: 100px;
  height: 120px;
  transform-origin: bottom center;
  transition: transform var(--move-duration, 0.38s) ease-out;
}

/* 1. IDLE (Clean, Normal Eyes, Gentle 3/4 Breathing) */
.state-idle .robot-sprite-iso {
  animation: isoIdle 1.8s ease-in-out infinite alternate;
}
.state-idle .robot-shadow-iso {
  animation: isoIdleShadow 1.8s ease-in-out infinite alternate;
}
@keyframes isoIdle {
  0% { transform: translateY(0) scale(1, 1); }
  50% { transform: translateY(-5px) scale(0.98, 1.02); }
  100% { transform: translateY(2px) scale(1.02, 0.98); }
}
@keyframes isoIdleShadow {
  0% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(0.9); opacity: 0.55; }
  100% { transform: scale(1.05); opacity: 0.95; }
}

/* 2. WALK STEPPING (Bouncy 2.5D Trot) */
.state-walk .robot-sprite-iso {
  animation: isoWalk 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) infinite alternate;
}
.state-walk .robot-shadow-iso {
  animation: isoWalkShadow 0.35s ease-in-out infinite alternate;
}
@keyframes isoWalk {
  0% { transform: translateY(0) rotate(-3deg) scale(1.03, 0.97); }
  50% { transform: translateY(-14px) rotate(0deg) scale(0.97, 1.04); }
  100% { transform: translateY(0) rotate(3deg) scale(1.03, 0.97); }
}
@keyframes isoWalkShadow {
  0% { transform: scale(1.08, 0.92) translateX(-3px); opacity: 0.9; }
  50% { transform: scale(0.82, 0.82); opacity: 0.45; }
  100% { transform: scale(1.08, 0.92) translateX(3px); opacity: 0.9; }
}

/* 3. JUMP OVER TILE (3D Parabolic Arc) */
.state-jump .robot-sprite-iso {
  animation: isoJump 0.85s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
.state-jump .robot-shadow-iso {
  animation: isoJumpShadow 0.85s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes isoJump {
  0% { transform: translateY(0) scale(1, 1); }
  15% { transform: translateY(12px) scale(1.22, 0.78); }
  45% { transform: translateY(-75px) scale(0.9, 1.15); }
  75% { transform: translateY(0) scale(1.18, 0.82); }
  90% { transform: translateY(-6px) scale(0.98, 1.02); }
  100% { transform: translateY(0) scale(1, 1); }
}
@keyframes isoJumpShadow {
  0% { transform: scale(1); opacity: 0.8; }
  15% { transform: scale(1.3); opacity: 1; }
  45% { transform: scale(0.3); opacity: 0.15; }
  75% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

/* 3.1 LEAP ACROSS OBSTACLE (3D Parabolic Forward Arc + Jet Thruster Flare) */
.state-leap .robot-sprite-iso {
  animation: isoLeapBody 0.95s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.state-leap .robot-shadow-iso {
  animation: isoLeapShadow 0.95s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.state-leap #leapThrusterGroup {
  opacity: 1 !important;
}
.state-leap #jetFlameL,
.state-leap #jetFlameR {
  animation: leapJetFlame 0.95s ease-out forwards;
}
.state-leap #jetCoreL,
.state-leap #jetCoreR {
  animation: leapJetCore 0.95s ease-out forwards;
}
.state-leap #speedStreak1,
.state-leap #speedStreak2,
.state-leap #speedStreak3 {
  animation: leapSpeedStreak 0.95s ease-out forwards;
}
.state-leap #handLeft {
  animation: handLeapTuckL 0.95s ease-in-out forwards;
}
.state-leap #handRight {
  animation: handLeapTuckR 0.95s ease-in-out forwards;
}
.state-leap #antennaGroup {
  animation: antennaLeapWind 0.95s ease-in-out forwards;
}

@keyframes isoLeapBody {
  0% { transform: translateY(0) rotate(0deg) scale(1, 1); }
  14% { transform: translateY(16px) rotate(-6deg) scale(1.28, 0.72); }
  35% { transform: translateY(-75px) rotate(14deg) scale(0.9, 1.18); }
  55% { transform: translateY(-105px) rotate(8deg) scale(0.94, 1.12); }
  75% { transform: translateY(-40px) rotate(-4deg) scale(1.02, 0.98); }
  86% { transform: translateY(6px) rotate(0deg) scale(1.22, 0.78); }
  94% { transform: translateY(-3px) scale(0.98, 1.02); }
  100% { transform: translateY(0) rotate(0deg) scale(1, 1); }
}

@keyframes isoLeapShadow {
  0% { transform: scale(1); opacity: 0.85; }
  14% { transform: scale(1.4); opacity: 1; }
  35% { transform: scale(0.35) translateY(-8px); opacity: 0.2; }
  55% { transform: scale(0.18) translateY(-14px); opacity: 0.1; }
  75% { transform: scale(0.4) translateY(-6px); opacity: 0.25; }
  86% { transform: scale(1.45); opacity: 1; }
  100% { transform: scale(1); opacity: 0.85; }
}

@keyframes leapJetFlame {
  0%, 10% { opacity: 0; transform: scaleY(0.2); }
  25%, 55% { opacity: 1; transform: scaleY(1.4); }
  75% { opacity: 0.6; transform: scaleY(0.8); }
  86%, 100% { opacity: 0; transform: scaleY(0.1); }
}

@keyframes leapJetCore {
  0%, 10% { opacity: 0; }
  25%, 55% { opacity: 1; }
  80%, 100% { opacity: 0; }
}

@keyframes leapSpeedStreak {
  0%, 15% { opacity: 0; transform: translateY(-15px); }
  35%, 65% { opacity: 0.95; transform: translateY(0); }
  80%, 100% { opacity: 0; transform: translateY(15px); }
}

@keyframes handLeapTuckL {
  0% { transform: translate(16px, 64px); }
  14% { transform: translate(12px, 72px) rotate(15deg); }
  45%, 65% { transform: translate(4px, 46px) rotate(-35deg) scale(1.1); }
  86% { transform: translate(14px, 68px) rotate(10deg); }
  100% { transform: translate(16px, 64px); }
}

@keyframes handLeapTuckR {
  0% { transform: translate(84px, 64px); }
  14% { transform: translate(88px, 72px) rotate(-15deg); }
  45%, 65% { transform: translate(96px, 46px) rotate(35deg) scale(1.1); }
  86% { transform: translate(86px, 68px) rotate(-10deg); }
  100% { transform: translate(84px, 64px); }
}

@keyframes antennaLeapWind {
  0% { transform: translate(50px, 10px) rotate(0deg); }
  14% { transform: translate(50px, 10px) rotate(12deg); }
  45%, 65% { transform: translate(50px, 10px) rotate(-18deg); filter: drop-shadow(0 0 10px #00f2fe); }
  86% { transform: translate(50px, 10px) rotate(6deg); }
  100% { transform: translate(50px, 10px) rotate(0deg); }
}

/* 4. WATERING */
.state-water .robot-sprite-iso {
  animation: isoWater 0.6s ease-in-out infinite alternate;
}
@keyframes isoWater {
  0% { transform: rotate(-4deg) translateY(0); }
  100% { transform: rotate(4deg) translateY(-3px); }
}

/* 5. HARVEST (Circular Arm Arc Reach & Pull Motion) */
.state-harvest .robot-sprite-iso {
  animation: isoHarvestBody 1.1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.state-harvest #handRight {
  animation: armCircularReach 1.1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
.state-harvest #handLeft {
  animation: armCircularReachL 1.1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes isoHarvestBody {
  0% { transform: translateY(0) rotate(0deg); }
  20% { transform: translateY(8px) rotate(8deg) scale(1.06, 0.94); }
  45% { transform: translateY(4px) rotate(-6deg) scale(0.96, 1.04); }
  65% { transform: translateY(-16px) rotate(4deg) scale(0.92, 1.08); }
  85% { transform: translateY(2px) rotate(0deg); }
  100% { transform: translateY(0) rotate(0deg); }
}
@keyframes armCircularReach {
  0% { transform: translate(84px, 64px) scale(1); }
  25% { transform: translate(96px, 88px) rotate(45deg) scale(1.3); }
  50% { transform: translate(88px, 72px) rotate(20deg) scale(1.2); }
  75% { transform: translate(72px, 42px) rotate(-25deg) scale(1.1); }
  100% { transform: translate(84px, 64px) scale(1); }
}
@keyframes armCircularReachL {
  0% { transform: translate(16px, 64px) scale(1); }
  25% { transform: translate(26px, 82px) rotate(-30deg) scale(1.2); }
  50% { transform: translate(22px, 68px) rotate(-15deg) scale(1.15); }
  75% { transform: translate(18px, 45px) scale(1.1); }
  100% { transform: translate(16px, 64px) scale(1); }
}

/* 6. BUMP (Clean Normal Eyes, Surprise Shake) */
.state-bump .robot-sprite-iso {
  animation: isoBump 0.75s ease-in-out forwards;
}
.state-bump .robot-shadow-iso {
  animation: isoBumpShadow 0.75s ease-in-out forwards;
}
@keyframes isoBump {
  0% { transform: translateX(0); }
  15% { transform: translate(-18px, -8px) rotate(-10deg) scale(0.92, 1.08); }
  35% { transform: translate(12px, 4px) rotate(6deg); }
  55% { transform: translate(-6px, -2px) rotate(-3deg); }
  75% { transform: translate(3px, 1px) rotate(1deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}
@keyframes isoBumpShadow {
  0% { transform: translateX(0); }
  15% { transform: translate(-18px, -8px); }
  35% { transform: translate(12px, 4px); }
  100% { transform: translate(0, 0); }
}

/* 7. VICTORY: HIGH JUMP + MID-AIR BALLERINA PIROUETTE SPIN (Exact character.html 1.8s) */
.state-victory .robot-sprite-iso {
  animation: jumpBallerinaSpin 1.8s cubic-bezier(0.25, 1, 0.35, 1) forwards !important;
}
.state-victory .robot-shadow-iso {
  animation: jumpBallerinaShadow 1.8s cubic-bezier(0.25, 1, 0.35, 1) forwards !important;
}
.state-victory #handLeft {
  animation: ballerinaArmsL 1.8s ease-in-out forwards !important;
}
.state-victory #handRight {
  animation: ballerinaArmsR 1.8s ease-in-out forwards !important;
}
@keyframes jumpBallerinaSpin {
  0% { transform: translateY(0) scale(1, 1) rotate(0deg); }
  12% { transform: translateY(14px) scale(1.25, 0.75) rotate(0deg); }
  35% { transform: translateY(-95px) scale(0.88, 1.18) rotate(90deg); }
  50% { transform: translateY(-100px) scale(0.92, 1.1) rotate(360deg); }
  70% { transform: translateY(-85px) scale(0.92, 1.1) rotate(720deg); }
  88% { transform: translateY(4px) scale(1.2, 0.8) rotate(720deg); }
  95% { transform: translateY(-4px) scale(0.98, 1.02) rotate(720deg); }
  100% { transform: translateY(0) scale(1, 1) rotate(720deg); }
}
@keyframes jumpBallerinaShadow {
  0% { transform: scale(1); opacity: 0.8; }
  12% { transform: scale(1.35); opacity: 1; }
  35% { transform: scale(0.22); opacity: 0.12; }
  50% { transform: scale(0.2); opacity: 0.1; }
  70% { transform: scale(0.25); opacity: 0.15; }
  88% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}
@keyframes ballerinaArmsL {
  0% { transform: translate(16px, 64px); }
  20% { transform: translate(6px, 14px) rotate(-55deg) scale(1.1); }
  75% { transform: translate(6px, 14px) rotate(-55deg) scale(1.1); }
  90% { transform: translate(16px, 64px) scale(1); }
  100% { transform: translate(16px, 64px); }
}
@keyframes ballerinaArmsR {
  0% { transform: translate(84px, 64px); }
  20% { transform: translate(94px, 14px) rotate(55deg) scale(1.1); }
  75% { transform: translate(94px, 14px) rotate(55deg) scale(1.1); }
  90% { transform: translate(84px, 64px) scale(1); }
  100% { transform: translate(84px, 64px); }
}

/* 8. TALKING / VOICE NARRATION (Lively Lip-sync, Body tilt, Antenna Cyan Glow & Gestures) */
.state-talk .robot-sprite-iso {
  animation: isoTalkBody 0.4s ease-in-out infinite alternate;
}
.state-talk .robot-shadow-iso {
  animation: isoTalkShadow 0.4s ease-in-out infinite alternate;
}
.state-talk #antennaGroup {
  animation: antennaTalkPulse 0.3s ease-in-out infinite alternate;
}
.state-talk #handRight {
  animation: talkGestureR 0.6s ease-in-out infinite alternate;
}
.state-talk #handLeft {
  animation: talkGestureL 0.6s ease-in-out infinite alternate;
}
.state-talk #robotMouth {
  transform-box: fill-box !important;
  transform-origin: center center !important;
  animation: mouthTalking 0.16s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate !important;
  stroke: #ffffff !important;
  stroke-width: 2.6px !important;
  stroke-linecap: round !important;
}

@keyframes isoTalkBody {
  0% { transform: translateY(0) rotate(-1.5deg) scale(1, 1); }
  50% { transform: translateY(-4px) rotate(1.2deg) scale(0.98, 1.02); }
  100% { transform: translateY(-1px) rotate(-1deg) scale(1.02, 0.98); }
}
@keyframes isoTalkShadow {
  0% { transform: scale(1); opacity: 0.85; }
  100% { transform: scale(0.92); opacity: 0.65; }
}
@keyframes mouthTalking {
  0% { transform: scaleY(0.35) scaleX(0.85); stroke-width: 2px; }
  50% { transform: scaleY(1.9) scaleX(1.18) translateY(1px); stroke-width: 2.8px; }
  100% { transform: scaleY(0.95) scaleX(0.95); stroke-width: 2.4px; }
}
@keyframes antennaTalkPulse {
  0% { transform: translate(50px, 10px) rotate(-8deg); filter: drop-shadow(0 0 4px rgba(251,191,36,0.6)); }
  100% { transform: translate(50px, 10px) rotate(8deg); filter: drop-shadow(0 0 14px rgba(0, 210, 255, 1)); }
}
@keyframes talkGestureR {
  0% { transform: translate(84px, 64px) rotate(0deg); }
  50% { transform: translate(92px, 50px) rotate(28deg) scale(1.2); }
  100% { transform: translate(86px, 58px) rotate(12deg); }
}
@keyframes talkGestureL {
  0% { transform: translate(16px, 64px) rotate(0deg); }
  50% { transform: translate(10px, 54px) rotate(-18deg) scale(1.1); }
  100% { transform: translate(14px, 60px) rotate(-6deg); }
}

/* 9. SCAN & DIAGNOSTIC ANALYSIS (Holographic Laser Sweep & HUD Scanner) */
.state-scan .robot-sprite-iso {
  animation: isoScanBody 0.8s ease-in-out infinite alternate;
}
.state-scan .robot-shadow-iso {
  animation: isoScanShadow 0.8s ease-in-out infinite alternate;
}
.state-scan #antennaGroup {
  animation: antennaScanPulse 0.4s ease-in-out infinite alternate;
}
.state-scan #handRight {
  animation: handScanPointR 0.8s ease-in-out infinite alternate;
}
.state-scan #handLeft {
  animation: handScanStabilizeL 0.8s ease-in-out infinite alternate;
}
.state-scan #scanBeamGroup {
  opacity: 1 !important;
  animation: scanBeamSweep 1.2s ease-in-out infinite alternate;
}
.state-scan #scanHudVisor {
  opacity: 1 !important;
  animation: scanHudOscillate 0.5s ease-in-out infinite alternate;
}
.state-scan #scanSweepLine {
  animation: laserSweepTraverse 0.9s ease-in-out infinite alternate;
}
.state-scan #antennaScanPulseRing {
  animation: antennaPulseRingExpand 0.7s ease-out infinite;
}

@keyframes isoScanBody {
  0% { transform: translateY(-2px) rotate(-1deg) scale(1, 1); filter: drop-shadow(0 0 6px rgba(0, 242, 254, 0.45)); }
  50% { transform: translateY(-8px) rotate(1.5deg) scale(0.98, 1.02); filter: drop-shadow(0 0 16px rgba(0, 242, 254, 0.9)); }
  100% { transform: translateY(-4px) rotate(-0.5deg) scale(1.02, 0.98); filter: drop-shadow(0 0 10px rgba(0, 242, 254, 0.6)); }
}
@keyframes isoScanShadow {
  0% { transform: scale(0.95); opacity: 0.75; }
  50% { transform: scale(0.82); opacity: 0.45; }
  100% { transform: scale(0.9); opacity: 0.65; }
}
@keyframes antennaScanPulse {
  0% { transform: translate(50px, 10px) rotate(-6deg); filter: drop-shadow(0 0 6px #00f2fe); }
  100% { transform: translate(50px, 10px) rotate(6deg); filter: drop-shadow(0 0 22px #00f2fe) drop-shadow(0 0 35px #38bdf8); }
}
@keyframes handScanPointR {
  0% { transform: translate(84px, 64px) rotate(0deg); }
  50% { transform: translate(96px, 52px) rotate(35deg) scale(1.25); filter: drop-shadow(0 0 8px #00f2fe); }
  100% { transform: translate(90px, 58px) rotate(20deg) scale(1.15); }
}
@keyframes handScanStabilizeL {
  0% { transform: translate(16px, 64px); }
  50% { transform: translate(12px, 48px) rotate(-25deg) scale(1.15); filter: drop-shadow(0 0 6px #38bdf8); }
  100% { transform: translate(14px, 56px) rotate(-12deg); }
}
@keyframes scanBeamSweep {
  0% { opacity: 0.65; transform: scaleX(0.88) rotate(-4deg); }
  50% { opacity: 1; transform: scaleX(1.18) rotate(4deg); }
  100% { opacity: 0.8; transform: scaleX(0.95) rotate(-2deg); }
}
@keyframes scanHudOscillate {
  0% { transform: translateY(0); opacity: 0.85; }
  50% { transform: translateY(2px); opacity: 1; filter: drop-shadow(0 0 4px #00f2fe); }
  100% { transform: translateY(-1px); opacity: 0.9; }
}
@keyframes laserSweepTraverse {
  0% { transform: translateY(-25px); opacity: 0.5; }
  50% { transform: translateY(0px); opacity: 1; }
  100% { transform: translateY(25px); opacity: 0.6; }
}
@keyframes antennaPulseRingExpand {
  0% { r: 6px; opacity: 1; stroke-width: 2px; }
  100% { r: 24px; opacity: 0; stroke-width: 0.5px; }
}

/* ============================================================ */
/* 10. BITTO HORN & KLAXON BLAST (บีบแตรไล่สิ่งกีดขวาง)            */
/* ============================================================ */
.state-horn .robot-sprite-iso {
  animation: isoHornBody 0.85s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.state-horn .robot-shadow-iso {
  animation: isoHornShadow 0.85s ease-in-out forwards;
}
.state-horn #hornGroup {
  opacity: 1 !important;
}
.state-horn #hornBulb {
  transform-origin: 28px 18px;
  animation: hornBulbSqueeze 0.85s ease-in-out forwards;
}
.state-horn #hornWave1 {
  animation: hornShockwaveBlast 0.85s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}
.state-horn #hornWave2 {
  animation: hornShockwaveBlast 0.85s cubic-bezier(0.1, 0.8, 0.3, 1) forwards 0.16s;
}
.state-horn #hornWave3 {
  animation: hornShockwaveBlast 0.85s cubic-bezier(0.1, 0.8, 0.3, 1) forwards 0.28s;
}
.state-horn #hornNote1 {
  animation: hornNoteFly 0.85s ease-out forwards 0.08s;
}
.state-horn #hornNote2 {
  animation: hornNoteFly 0.85s ease-out forwards 0.22s;
}
.state-horn #hornSpark1 {
  animation: hornSparklePop 0.85s ease-out forwards 0.14s;
}
.state-horn #antennaGroup {
  animation: antennaHornVibrate 0.85s ease-in-out forwards;
}
.state-horn #handRight {
  animation: handHornHoldR 0.85s ease-in-out forwards;
}

@keyframes isoHornBody {
  0% { transform: translateY(0) rotate(0deg); }
  15% { transform: translateY(-8px) rotate(-3deg) scale(1.08, 0.94); }
  30% { transform: translateY(-2px) rotate(1deg) scale(0.96, 1.04); }
  45% { transform: translateY(-12px) rotate(-4deg) scale(1.12, 0.92); }
  75% { transform: translateY(-3px) rotate(0deg) scale(1, 1); }
  100% { transform: translateY(0) rotate(0deg); }
}

@keyframes isoHornShadow {
  0% { transform: scale(1); opacity: 0.85; }
  15% { transform: scale(0.88); opacity: 0.55; }
  30% { transform: scale(1.02); opacity: 0.8; }
  45% { transform: scale(0.82); opacity: 0.45; }
  100% { transform: scale(1); opacity: 0.85; }
}

@keyframes hornBulbSqueeze {
  0% { transform: scale(1, 1); }
  15% { transform: scale(0.65, 1.3); }
  30% { transform: scale(1.05, 0.95); }
  45% { transform: scale(0.55, 1.4); }
  70% { transform: scale(1.02, 0.98); }
  100% { transform: scale(1, 1); }
}

@keyframes hornShockwaveBlast {
  0% { opacity: 0; transform: scale(0.6) translateX(0); }
  20% { opacity: 1; transform: scale(1.1) translateX(-6px); }
  60% { opacity: 0.85; transform: scale(1.6) translateX(-18px); }
  100% { opacity: 0; transform: scale(2.2) translateX(-32px); }
}

@keyframes hornNoteFly {
  0% { opacity: 0; transform: translate(0, 0) scale(0.5); }
  25% { opacity: 1; transform: translate(-8px, -10px) scale(1.2) rotate(-15deg); }
  80% { opacity: 0.9; transform: translate(-22px, -28px) scale(1.1) rotate(15deg); }
  100% { opacity: 0; transform: translate(-32px, -44px) scale(0.5) rotate(30deg); }
}

@keyframes hornSparklePop {
  0% { opacity: 0; transform: scale(0); }
  30% { opacity: 1; transform: scale(1.4); }
  80% { opacity: 0.7; transform: scale(1) translate(-10px, -6px); }
  100% { opacity: 0; transform: scale(0); }
}

@keyframes antennaHornVibrate {
  0% { transform: translate(50px, 10px) rotate(0deg); }
  15%, 45% { transform: translate(50px, 10px) rotate(-10deg); filter: drop-shadow(0 0 12px #fbbf24) drop-shadow(0 0 20px #00f2fe); }
  25%, 55% { transform: translate(50px, 10px) rotate(10deg); filter: drop-shadow(0 0 16px #facc15); }
  100% { transform: translate(50px, 10px) rotate(0deg); }
}

@keyframes handHornHoldR {
  0% { transform: translate(84px, 64px); }
  15%, 70% { transform: translate(88px, 62px) scale(1.1); }
  100% { transform: translate(84px, 64px); }
}

/* ============================================================ */
/* 10.1 BITTO WRENCH & LOGIC SWITCH ANIMATIONS                  */
/* ============================================================ */
.state-wrench .robot-sprite-iso {
  animation: isoWrenchBody 1.1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.state-wrench .robot-shadow-iso {
  animation: isoWrenchShadow 1.1s ease-in-out forwards;
}
.state-wrench #wrenchGroup {
  opacity: 1 !important;
}
.state-wrench #wrenchTool {
  animation: wrenchTorqueCycle 1.1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
.state-wrench #wrenchSpark1 {
  animation: wrenchSparkBurst 1.1s ease-out forwards 0.2s;
}
.state-wrench #wrenchSpark2 {
  animation: wrenchSparkBurst 1.1s ease-out forwards 0.5s;
}
.state-wrench #wrenchElectricArc {
  animation: wrenchArcFlicker 1.1s ease-in-out forwards;
}
.state-wrench #antennaGroup {
  animation: antennaWrenchJolt 1.1s ease-in-out forwards;
}
.state-wrench #handRight {
  animation: handWrenchHoldR 1.1s ease-in-out forwards;
}

@keyframes isoWrenchBody {
  0% { transform: translateY(0) rotate(0deg); }
  15% { transform: translateY(6px) rotate(8deg) scale(1.04, 0.96); }
  35% { transform: translateY(-4px) rotate(-10deg) scale(0.96, 1.04); }
  55% { transform: translateY(8px) rotate(12deg) scale(1.06, 0.94); }
  75% { transform: translateY(-6px) rotate(-12deg) scale(0.94, 1.06); }
  90% { transform: translateY(2px) rotate(2deg); }
  100% { transform: translateY(0) rotate(0deg); }
}
@keyframes isoWrenchShadow {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  25%, 65% { transform: scale(1.15, 0.9) translateX(4px); opacity: 0.95; }
  45%, 80% { transform: scale(0.85, 1.1) translateX(-4px); opacity: 0.65; }
}
@keyframes wrenchTorqueCycle {
  0% { transform: rotate(0deg); }
  20% { transform: rotate(-35deg); }
  35% { transform: rotate(45deg); }
  50% { transform: rotate(-25deg); }
  70% { transform: rotate(50deg); }
  85% { transform: rotate(10deg); }
  100% { transform: rotate(0deg); }
}
@keyframes wrenchSparkBurst {
  0% { opacity: 0; transform: scale(0.2) translate(0, 0); }
  30% { opacity: 1; transform: scale(1.5) translate(-6px, -8px); }
  70% { opacity: 0.8; transform: scale(1.2) translate(-14px, -14px); }
  100% { opacity: 0; transform: scale(0.3) translate(-20px, -20px); }
}
@keyframes wrenchArcFlicker {
  0%, 100% { opacity: 0; }
  25%, 35%, 60%, 75% { opacity: 1; filter: drop-shadow(0 0 6px #00f2fe); }
  30%, 40%, 70% { opacity: 0.2; }
}
@keyframes antennaWrenchJolt {
  0% { transform: translate(50px, 10px) rotate(0deg); }
  20%, 60% { transform: translate(50px, 10px) rotate(12deg); filter: drop-shadow(0 0 10px #38bdf8); }
  35%, 75% { transform: translate(50px, 10px) rotate(-14deg); filter: drop-shadow(0 0 14px #facc15); }
  100% { transform: translate(50px, 10px) rotate(0deg); }
}
@keyframes handWrenchHoldR {
  0% { transform: translate(84px, 64px); }
  20%, 60% { transform: translate(92px, 58px) rotate(25deg) scale(1.15); }
  35%, 75% { transform: translate(78px, 70px) rotate(-20deg) scale(1.1); }
  100% { transform: translate(84px, 64px); }
}

/* 10.2 BITTO LOGIC SWITCH TOGGLE ANIMATION */
.state-switch .robot-sprite-iso {
  animation: isoSwitchBody 0.75s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.state-switch #handRight {
  animation: handSwitchFlick 0.75s ease-in-out forwards;
}
@keyframes isoSwitchBody {
  0% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-8px) rotate(6deg) scale(1.05, 0.95); }
  50% { transform: translateY(-12px) rotate(-4deg) scale(0.98, 1.02); }
  75% { transform: translateY(2px) rotate(2deg); }
  100% { transform: translateY(0) rotate(0deg); }
}
@keyframes handSwitchFlick {
  0% { transform: translate(84px, 64px); }
  35% { transform: translate(96px, 46px) rotate(35deg) scale(1.25); filter: drop-shadow(0 0 8px #f59e0b); }
  70% { transform: translate(90px, 52px) rotate(15deg); }
  100% { transform: translate(84px, 64px); }
}

/* 10.3 BITTO TROWEL DIGGING & FURROWING ANIMATION (ขุดดิน พรวนแปลง) */
.state-dig .robot-sprite-iso {
  animation: isoDigBody 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.state-dig .robot-shadow-iso {
  animation: isoDigShadow 1s ease-in-out forwards;
}
.state-dig #trowelGroup {
  opacity: 1 !important;
}
.state-dig #trowelTool {
  animation: trowelScoopCycle 1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
.state-dig #trowelDirt1 {
  animation: digDirtFly 1s ease-out forwards 0.22s;
}
.state-dig #trowelDirt2 {
  animation: digDirtFly 1s ease-out forwards 0.35s;
}
.state-dig #trowelDirt3 {
  animation: digDirtFly 1s ease-out forwards 0.55s;
}
.state-dig #digSpadeDust {
  animation: digDustPuff 1s ease-out forwards 0.25s;
}
.state-dig #antennaGroup {
  animation: antennaDigWobble 1s ease-in-out forwards;
}
.state-dig #handRight {
  animation: handTrowelHoldR 1s ease-in-out forwards;
}

@keyframes isoDigBody {
  0% { transform: translateY(0) rotate(0deg); }
  18% { transform: translateY(10px) rotate(14deg) scale(1.08, 0.92); }
  38% { transform: translateY(-8px) rotate(-8deg) scale(0.94, 1.06); }
  58% { transform: translateY(12px) rotate(16deg) scale(1.1, 0.9); }
  78% { transform: translateY(-6px) rotate(-6deg) scale(0.96, 1.04); }
  92% { transform: translateY(2px) rotate(1deg); }
  100% { transform: translateY(0) rotate(0deg); }
}
@keyframes isoDigShadow {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  18%, 58% { transform: scale(1.2, 0.85) translateX(6px); opacity: 0.95; }
  38%, 78% { transform: scale(0.85, 1.15) translateX(-4px); opacity: 0.6; }
}
@keyframes trowelScoopCycle {
  0% { transform: rotate(0deg); }
  18% { transform: rotate(55deg) translate(-4px, 6px); }
  38% { transform: rotate(-35deg) translate(2px, -8px); }
  58% { transform: rotate(60deg) translate(-6px, 8px); }
  78% { transform: rotate(-25deg) translate(0px, -4px); }
  100% { transform: rotate(0deg); }
}
@keyframes digDirtFly {
  0% { opacity: 0; transform: scale(0.2) translate(0, 0); }
  30% { opacity: 1; transform: scale(1.4) translate(-10px, -14px); }
  70% { opacity: 0.8; transform: scale(1.1) translate(-22px, -24px); }
  100% { opacity: 0; transform: scale(0.2) translate(-32px, -32px); }
}
@keyframes digDustPuff {
  0% { opacity: 0; transform: scale(0.5); }
  40% { opacity: 0.9; transform: scale(1.3) translateY(-4px); }
  100% { opacity: 0; transform: scale(1.8) translateY(-10px); }
}
@keyframes antennaDigWobble {
  0% { transform: translate(50px, 10px) rotate(0deg); }
  18%, 58% { transform: translate(50px, 10px) rotate(16deg); filter: drop-shadow(0 0 10px #f59e0b); }
  38%, 78% { transform: translate(50px, 10px) rotate(-12deg); }
  100% { transform: translate(50px, 10px) rotate(0deg); }
}
@keyframes handTrowelHoldR {
  0% { transform: translate(84px, 64px); }
  18%, 58% { transform: translate(96px, 72px) rotate(35deg) scale(1.2); }
  38%, 78% { transform: translate(78px, 48px) rotate(-20deg) scale(1.1); }
  100% { transform: translate(84px, 64px); }
}

/* 10.4 BITTO SEED SOWING & PLANTING ANIMATION (หยอดเมล็ดพันธุ์) */
.state-plant .robot-sprite-iso {
  animation: isoPlantBody 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.state-plant .robot-shadow-iso {
  animation: isoPlantShadow 0.9s ease-in-out forwards;
}
.state-plant #seedPlantGroup {
  opacity: 1 !important;
}
.state-plant #seedDrop1 {
  animation: seedSprinkleDrop 0.9s ease-out forwards 0.15s;
}
.state-plant #seedDrop2 {
  animation: seedSprinkleDrop 0.9s ease-out forwards 0.28s;
}
.state-plant #seedDrop3 {
  animation: seedSprinkleDrop 0.9s ease-out forwards 0.42s;
}
.state-plant #plantSparkle1 {
  animation: seedSparkleTwinkle 0.9s ease-out forwards 0.2s;
}
.state-plant #plantSparkle2 {
  animation: seedSparkleTwinkle 0.9s ease-out forwards 0.4s;
}
.state-plant #handRight {
  animation: handPlantSprinkleR 0.9s ease-in-out forwards;
}

@keyframes isoPlantBody {
  0% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(6px) rotate(6deg) scale(1.05, 0.95); }
  50% { transform: translateY(-4px) rotate(-3deg) scale(0.98, 1.02); }
  75% { transform: translateY(2px) rotate(1deg); }
  100% { transform: translateY(0) rotate(0deg); }
}
@keyframes isoPlantShadow {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  25% { transform: scale(1.12, 0.92) translateX(3px); opacity: 0.95; }
  50% { transform: scale(0.92, 1.05); opacity: 0.7; }
}
@keyframes seedSprinkleDrop {
  0% { opacity: 0; transform: translateY(0) scale(0.4); }
  35% { opacity: 1; transform: translateY(8px) scale(1.3); }
  80% { opacity: 0.9; transform: translateY(22px) scale(1); }
  100% { opacity: 0; transform: translateY(32px) scale(0.4); }
}
@keyframes seedSparkleTwinkle {
  0% { opacity: 0; transform: scale(0.2); }
  50% { opacity: 1; transform: scale(1.4) rotate(25deg); }
  100% { opacity: 0; transform: scale(0.4) rotate(50deg); }
}
@keyframes handPlantSprinkleR {
  0% { transform: translate(84px, 64px); }
  25% { transform: translate(92px, 54px) rotate(25deg) scale(1.2); filter: drop-shadow(0 0 8px #fbbf24); }
  60% { transform: translate(88px, 62px) rotate(10deg); }
  100% { transform: translate(84px, 64px); }
}

/* ============================================================ */
/* 11. MUNCHER ALIEN ENTITY & SCARED FLEE ANIMATIONS (เอเลี่ยน)  */
/* ============================================================ */
.alien-entity {
  position: absolute;
  width: 70px;
  height: 75px;
  pointer-events: auto;
  cursor: pointer;
  transform-origin: 35px 65px;
  z-index: 25;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s ease;
}

.alien-shadow {
  position: absolute;
  bottom: 2px;
  left: 14px;
  width: 42px;
  height: 14px;
  background: radial-gradient(ellipse at center, rgba(15, 23, 42, 0.45) 0%, rgba(15, 23, 42, 0) 75%);
  border-radius: 50%;
  pointer-events: none;
  transform-origin: center;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.alien-sprite {
  position: absolute;
  bottom: 6px;
  left: 0;
  width: 70px;
  height: 70px;
  transform-origin: bottom center;
}

/* Alien State 1: Munching Idle (Chewing crops happily) */
.alien-munching .alien-body-group {
  animation: alienMunchChew 0.8s ease-in-out infinite alternate;
}
.alien-munching .alien-held-fruit {
  animation: alienFruitChewBounce 0.8s ease-in-out infinite alternate;
}
.alien-munching .alien-crumbs {
  animation: alienCrumbsPop 0.8s ease-out infinite;
}
.alien-munching .alien-antenna {
  animation: alienAntennaWobble 1.2s ease-in-out infinite alternate;
}

@keyframes alienMunchChew {
  0% { transform: translateY(0) scale(1, 1); }
  50% { transform: translateY(-4px) scale(1.05, 0.95); }
  100% { transform: translateY(-1px) scale(0.97, 1.03); }
}

@keyframes alienFruitChewBounce {
  0% { transform: translate(35px, 48px) scale(1) rotate(-5deg); }
  50% { transform: translate(35px, 44px) scale(1.1) rotate(5deg); }
  100% { transform: translate(35px, 48px) scale(1) rotate(-5deg); }
}

@keyframes alienCrumbsPop {
  0% { opacity: 0; transform: translateY(0) scale(0.4); }
  40% { opacity: 1; transform: translateY(-8px) scale(1); }
  100% { opacity: 0; transform: translateY(-18px) scale(0.2); }
}

@keyframes alienAntennaWobble {
  0% { transform: rotate(-8deg); }
  100% { transform: rotate(10deg); }
}

/* Alien State 2: Scared Flee (When honked by Bitto) */
.alien-scared {
  animation: alienPanicJump 0.85s cubic-bezier(0.25, 1, 0.35, 1) forwards !important;
}

@keyframes alienPanicJump {
  0% { transform: translateY(0) scale(1, 1); opacity: 1; }
  15% { transform: translateY(4px) scale(1.25, 0.75); }
  35% { transform: translateY(-50px) rotate(18deg) scale(0.85, 1.25); filter: drop-shadow(0 0 16px rgba(239, 68, 68, 0.8)); }
  55% { transform: translateY(-35px) rotate(-15deg) scale(1.1, 0.9); }
  75% { transform: translate(60px, -80px) rotate(30deg) scale(0.65); opacity: 0.9; }
  100% { transform: translate(140px, -120px) rotate(60deg) scale(0.1); opacity: 0; }
}

/* Alien State 3: Stubborn Blocking Path */
.alien-stubborn .alien-sprite {
  animation: alienStubbornShake 0.45s ease-in-out 2;
}
@keyframes alienStubbornShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px) rotate(-6deg); }
  75% { transform: translateX(6px) rotate(6deg); }
}

/* ============================================================ */
/* 12. FRUIT TREE & ORCHARD CROPS (แอปเปิ้ล & ส้ม)               */
/* ============================================================ */
.fruit-tree-entity {
  position: absolute;
  width: 70px;
  height: 85px;
  pointer-events: auto;
  cursor: pointer;
  transform-origin: 35px 72px;
  z-index: 20;
}

.hanging-fruit {
  transform-origin: 35px 34px;
  animation: fruitGentleSway 2.5s ease-in-out infinite alternate;
}

@keyframes fruitGentleSway {
  0% { transform: rotate(-4deg); }
  100% { transform: rotate(5deg); }
}

.tree-canopy {
  transform-origin: 35px 38px;
  animation: canopyBreeze 3.2s ease-in-out infinite alternate;
}

@keyframes canopyBreeze {
  0% { transform: scale(1, 1) rotate(0deg); }
  50% { transform: scale(1.02, 0.98) rotate(1.2deg); }
  100% { transform: scale(0.98, 1.02) rotate(-1deg); }
}

/* HOLOGRAPHIC DIAGNOSTIC HUD POPUP */
.diagnostic-hud-pop {
  position: absolute;
  bottom: 135px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(8, 47, 73, 0.95) 100%);
  border: 2px solid #00f2fe;
  box-shadow: 0 0 25px rgba(0, 242, 254, 0.6), inset 0 0 15px rgba(0, 242, 254, 0.2);
  color: #e0f2fe;
  padding: 8px 14px;
  border-radius: 18px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  z-index: 85;
  animation: diagPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}
.diagnostic-hud-pop::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #00f2fe;
}
@keyframes diagPop {
  0% { transform: translateX(-50%) scale(0.4) translateY(15px); opacity: 0; }
  100% { transform: translateX(-50%) scale(1) translateY(0); opacity: 1; }
}

/* VOICE WAVE EXPAND RIPPLE */
.voice-wave {
  position: absolute;
  border: 2px solid #00d2ff;
  border-radius: 50%;
  pointer-events: none;
  z-index: 65;
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.8), inset 0 0 6px rgba(0, 210, 255, 0.4);
  animation: waveExpand 0.75s ease-out forwards;
}
@keyframes waveExpand {
  0% { width: 12px; height: 12px; opacity: 1; transform: translate(-50%, -50%) scale(0.6); }
  100% { width: 70px; height: 70px; opacity: 0; transform: translate(-50%, -50%) scale(2.2); }
}

/* ============================================================ */
/* 13. 2.5D EMERGENCY WATER VALVE & DRAINAGE WHIRLPOOL (STAGE 3-5 BOSS) */
/* ============================================================ */
.valve-entity {
  position: absolute;
  width: 80px;
  height: 95px;
  pointer-events: auto;
  cursor: pointer;
  transform-origin: 40px 80px;
  z-index: 22;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.valve-entity:hover {
  transform: scale(1.05);
}

.valve-shadow {
  position: absolute;
  bottom: 2px;
  left: 15px;
  width: 50px;
  height: 18px;
  background: radial-gradient(ellipse at center, rgba(15, 23, 42, 0.6) 0%, rgba(15, 23, 42, 0) 75%);
  border-radius: 50%;
  pointer-events: none;
}

.valve-sprite {
  position: absolute;
  bottom: 4px;
  left: 0;
  width: 80px;
  height: 90px;
  transform-origin: bottom center;
}

/* Rotary Wheel Spin Animation */
.valve-turning .valve-wheel-group {
  animation: valveWheelSpin 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  transform-origin: 40px 32px;
}
@keyframes valveWheelSpin {
  0% { transform: rotate(0deg); }
  30% { transform: rotate(240deg); }
  60% { transform: rotate(540deg); }
  100% { transform: rotate(720deg); }
}

/* Pressure Gauge Needle */
.valve-pressure-dial {
  transform-origin: 59px 43px;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.valve-closed .valve-pressure-dial {
  transform: rotate(55deg); /* High Red Zone */
}
.valve-open .valve-pressure-dial {
  transform: rotate(-50deg); /* Normal Green Safe Zone */
}

/* Alarm Beacon Strobes */
.valve-closed .valve-strobe-red {
  animation: alarmBeaconRed 0.6s ease-in-out infinite alternate;
}
@keyframes alarmBeaconRed {
  0% { opacity: 0.3; filter: drop-shadow(0 0 2px #ef4444); }
  100% { opacity: 1; filter: drop-shadow(0 0 16px #ef4444) drop-shadow(0 0 24px #ff0000); }
}

.valve-open .valve-strobe-green {
  animation: beaconGreenGlow 1.5s ease-in-out infinite alternate;
}
@keyframes beaconGreenGlow {
  0% { opacity: 0.6; filter: drop-shadow(0 0 4px #22c55e); }
  100% { opacity: 1; filter: drop-shadow(0 0 16px #22c55e) drop-shadow(0 0 28px #4ade80); }
}

/* Logic Bug Shake (When wrong logic toggle triggers error) */
.valve-bug-shake {
  animation: valveBugRecoil 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@keyframes valveBugRecoil {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  15% { transform: translate(-8px, -2px) rotate(-6deg); filter: drop-shadow(0 0 12px #ef4444); }
  30% { transform: translate(8px, 2px) rotate(6deg); }
  45% { transform: translate(-6px, -1px) rotate(-4deg); }
  60% { transform: translate(5px, 1px) rotate(3deg); }
  75% { transform: translate(-2px, 0) rotate(-1deg); }
}

/* Flooded Isometric Water Overlay on Ground */
.flooded-water-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 80px;
  height: 48px;
  pointer-events: none;
  z-index: 5;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(14, 165, 233, 0.65) 0%, rgba(6, 182, 212, 0.45) 50%, rgba(2, 132, 199, 0.15) 75%, transparent 100%);
  animation: waterCausticPulse 2.4s ease-in-out infinite alternate;
}
@keyframes waterCausticPulse {
  0% { opacity: 0.55; transform: scale(0.95, 0.9); }
  50% { opacity: 0.9; transform: scale(1.05, 1.02); filter: drop-shadow(0 0 8px #00f2fe); }
  100% { opacity: 0.65; transform: scale(1, 0.95); }
}

/* Whirlpool Drainage Vortex */
.water-whirlpool {
  position: absolute;
  width: 76px;
  height: 40px;
  top: 4px;
  left: 2px;
  pointer-events: none;
  z-index: 6;
  transform-origin: center center;
}
.whirlpool-spin {
  animation: whirlpoolRotate 1.2s linear infinite;
  transform-origin: 38px 20px;
}
@keyframes whirlpoolRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.whirlpool-sink {
  animation: whirlpoolDrainDown 1.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes whirlpoolDrainDown {
  0% { opacity: 1; transform: scale(1); }
  70% { opacity: 0.9; transform: scale(0.65) translateY(6px); }
  100% { opacity: 0; transform: scale(0.1) translateY(16px); }
}

/* Stage 3-5 Logic Condition Switch Console */
.logic-switch-box {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.98) 100%);
  border: 2px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 0 15px rgba(56, 189, 248, 0.15);
  border-radius: 16px;
  transition: all 0.25s ease;
}
.logic-switch-box.active-true {
  border-color: #22c55e;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.4), inset 0 0 15px rgba(34, 197, 94, 0.2);
}
.logic-switch-box.active-false {
  border-color: #ef4444;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.4), inset 0 0 15px rgba(239, 68, 68, 0.2);
}

/* ============================================================ */
/* 14. CARROT TILLED SOIL & SPROUT SEEDLING ANIMATIONS (WORLD 4) */
/* ============================================================ */
.carrot-tilled .seed-cluster {
  animation: seedGlowPulse 2.2s ease-in-out infinite alternate;
}
@keyframes seedGlowPulse {
  0% { filter: drop-shadow(0 0 2px rgba(250, 204, 21, 0.5)); transform: scale(1); }
  100% { filter: drop-shadow(0 0 8px rgba(250, 204, 21, 0.95)) drop-shadow(0 0 14px rgba(251, 191, 36, 0.8)); transform: scale(1.08); }
}

.carrot-sprout .sprout-growth {
  animation: sproutSwayBreeze 2.5s ease-in-out infinite alternate;
  transform-origin: 35px 56px;
}
@keyframes sproutSwayBreeze {
  0% { transform: rotate(-3deg) scale(1, 1); }
  50% { transform: rotate(0deg) scale(1.04, 0.98); }
  100% { transform: rotate(3.5deg) scale(0.98, 1.03); }
}

.carrot-sprout .sprout-leaf-left {
  animation: leafLeftWobble 2.5s ease-in-out infinite alternate;
  transform-origin: 35px 36px;
}
@keyframes leafLeftWobble {
  0% { transform: rotate(-4deg); }
  100% { transform: rotate(5deg); }
}

.carrot-sprout .sprout-leaf-right {
  animation: leafRightWobble 2.5s ease-in-out infinite alternate 0.2s;
  transform-origin: 35px 36px;
}
@keyframes leafRightWobble {
  0% { transform: rotate(4deg); }
  100% { transform: rotate(-5deg); }
}

/* ============================================================ */
/* 6. HUB & GALAXY BACKGROUND STYLES                            */
/* ============================================================ */
.galaxy-bg-container {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  transition: background-image 0.5s ease-in-out;
  background-image: url('../images/bg_desktop.jpg');
}
@media (max-width: 640px) {
  .galaxy-bg-container { background-image: url('../images/bg_mobile.jpg'); }
}
@media (min-width: 641px) and (max-width: 1024px) {
  .galaxy-bg-container { background-image: url('../images/bg_desktop.jpg'); }
}
@media (min-width: 1025px) {
  .galaxy-bg-container { background-image: url('../images/bg_widescreen.jpg'); }
}

.cosmic-stars-layer {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(79, 70, 229, 0.15) 0%, rgba(13, 7, 36, 0.6) 80%);
  pointer-events: none;
}

.floating-planet-1 {
  animation: planetFloat1 7s ease-in-out infinite alternate;
}
@keyframes planetFloat1 {
  0% { transform: translateY(0px) rotate(0deg); }
  100% { transform: translateY(-14px) rotate(6deg); }
}

.floating-ufo {
  animation: ufoDrift 5s ease-in-out infinite alternate;
}
@keyframes ufoDrift {
  0% { transform: translate(0, 0) rotate(-6deg); }
  100% { transform: translate(14px, -18px) rotate(10deg); }
}

.twinkle-star {
  animation: starTwinkleHub 2.5s ease-in-out infinite alternate;
}
@keyframes starTwinkleHub {
  0% { opacity: 0.3; transform: scale(0.7); }
  100% { opacity: 1; transform: scale(1.25); filter: drop-shadow(0 0 6px #fde047); }
}

.title-galaxy {
  font-family: 'Fredoka', cursive, sans-serif;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffffff 0%, #f472b6 40%, #c084fc 70%, #60a5fa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 #7e22ce) drop-shadow(0 8px 16px rgba(168, 85, 247, 0.7));
}
.title-puzzle {
  font-family: 'Fredoka', cursive, sans-serif;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffffff 0%, #fbbf24 35%, #f97316 70%, #ef4444 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 #b45309) drop-shadow(0 8px 16px rgba(245, 158, 11, 0.7));
}

.jigsaw-svg-board {
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 25px rgba(168, 85, 247, 0.3));
  user-select: none;
}
.jigsaw-piece-group {
  cursor: pointer;
  transition: filter 0.2s ease, opacity 0.2s ease;
}
.jigsaw-piece-group:hover {
  filter: brightness(1.15) drop-shadow(0 0 12px rgba(255, 255, 255, 0.45));
}
.jigsaw-piece-group:active {
  filter: brightness(0.92);
}

.piece-1-active {
  animation: piece1GlowPulse 2s ease-in-out infinite alternate;
}
@keyframes piece1GlowPulse {
  0% { filter: drop-shadow(0 0 10px rgba(217, 70, 239, 0.8)) drop-shadow(0 0 20px rgba(99, 102, 241, 0.6)); }
  100% { filter: drop-shadow(0 0 24px rgba(217, 70, 239, 1)) drop-shadow(0 0 40px rgba(234, 179, 8, 0.85)); }
}

.piece-2-active {
  animation: piece2GlowPulse 2s ease-in-out infinite alternate;
}
@keyframes piece2GlowPulse {
  0% { filter: drop-shadow(0 0 10px rgba(249, 115, 22, 0.8)) drop-shadow(0 0 20px rgba(234, 88, 12, 0.6)); }
  100% { filter: drop-shadow(0 0 24px rgba(249, 115, 22, 1)) drop-shadow(0 0 40px rgba(251, 191, 36, 0.85)); }
}

.piece-3-active {
  animation: piece3GlowPulse 2s ease-in-out infinite alternate;
}
@keyframes piece3GlowPulse {
  0% { filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.8)) drop-shadow(0 0 20px rgba(109, 40, 217, 0.6)); }
  100% { filter: drop-shadow(0 0 24px rgba(139, 92, 246, 1)) drop-shadow(0 0 40px rgba(168, 85, 247, 0.85)); }
}

.robot-mascot-bobbing {
  animation: inGameRobotBounce 2.4s ease-in-out infinite alternate;
  transform-origin: 50px 80px;
}
@keyframes inGameRobotBounce {
  0% { transform: translateY(0px) rotate(-1.5deg); }
  50% { transform: translateY(-4px) rotate(0deg) scale(1.02); }
  100% { transform: translateY(-7px) rotate(1.5deg) scale(1.03); }
}

.piece-inner-shake {
  animation: lockInnerShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  transform-box: fill-box;
  transform-origin: center center;
}
@keyframes lockInnerShake {
  0% { transform: translate(0, 0) rotate(0deg); }
  20% { transform: translate(-6px, -1px) rotate(-3deg); }
  40% { transform: translate(6px, 1px) rotate(3deg); }
  60% { transform: translate(-4px, -1px) rotate(-2deg); }
  80% { transform: translate(3px, 1px) rotate(1deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

.nav-candy-btn {
  font-family: 'Fredoka', cursive, sans-serif;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.18s ease;
  cursor: pointer;
}
.nav-candy-btn:hover {
  transform: translateY(-4px) scale(1.05);
  filter: brightness(1.12);
}
.nav-candy-btn:active {
  transform: translateY(2px) scale(0.96);
}

/* ============================================================ */
/* 7. STAGE SELECT & MISSION BRIEFING HERO CARDS                */
/* ============================================================ */
.trophy-glow-card {
  background: linear-gradient(180deg, rgba(30, 41, 115, 0.95) 0%, rgba(15, 23, 68, 0.98) 100%);
  border: 3px solid rgba(251, 191, 36, 0.55);
  box-shadow: 0 0 35px rgba(245, 158, 11, 0.35), inset 0 0 25px rgba(251, 191, 36, 0.15);
}

.title-world-mastery {
  font-family: 'Fredoka', 'Kanit', sans-serif;
  font-weight: 900;
  background: linear-gradient(180deg, #ffffff 0%, #fef08a 40%, #f59e0b 80%, #d97706 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #78350f) drop-shadow(0 6px 12px rgba(245, 158, 11, 0.6));
}

.stage-card {
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.stage-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45), 0 0 20px rgba(99, 102, 241, 0.4);
}

.hero-glow-card {
  background: linear-gradient(180deg, rgba(28, 37, 102, 0.95) 0%, rgba(15, 20, 60, 0.98) 100%);
  border: 3px solid rgba(129, 140, 248, 0.5);
  box-shadow: 0 0 35px rgba(99, 102, 241, 0.35), inset 0 0 20px rgba(129, 140, 248, 0.2);
}

.title-stage {
  font-family: 'Fredoka', 'Kanit', sans-serif;
  font-weight: 900;
  background: linear-gradient(180deg, #ffffff 0%, #fef08a 40%, #f59e0b 80%, #d97706 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #78350f) drop-shadow(0 6px 12px rgba(245, 158, 11, 0.6));
}

.launch-btn {
  animation: launchPulse 2s ease-in-out infinite;
}
@keyframes launchPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(74, 222, 128, 0.6), 0 8px 0 #15803d; }
  50% { box-shadow: 0 0 36px rgba(74, 222, 128, 0.95), 0 8px 0 #15803d; transform: translateY(-2px); }
}

/* ============================================================ */
/* 8. WORLD MASTERY CELEBRATION (DUO MASCOT + BOSS MODAL)       */
/* ============================================================ */
.world-mastery-modal {
  background: radial-gradient(circle at 50% 10%, rgba(30, 27, 75, 0.98) 0%, rgba(15, 23, 42, 0.99) 100%);
  border: 4px solid #f59e0b;
  box-shadow: 
    0 0 50px rgba(245, 158, 11, 0.5),
    0 0 100px rgba(99, 102, 241, 0.35),
    inset 0 0 35px rgba(245, 158, 11, 0.2);
  position: relative;
  overflow: hidden;
}

.world-mastery-modal::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg at 50% 50%, rgba(245, 158, 11, 0.12) 0deg, transparent 60deg, rgba(236, 72, 153, 0.12) 120deg, transparent 180deg, rgba(59, 130, 246, 0.12) 240deg, transparent 300deg, rgba(245, 158, 11, 0.12) 360deg);
  animation: cosmicRotate 16s linear infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes cosmicRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.duo-bounce-bitto {
  animation: duoBittoAnim 1.6s ease-in-out infinite;
  transform-origin: bottom center;
}

@keyframes duoBittoAnim {
  0%, 100% { transform: translateY(0) scale(1) rotate(0deg); }
  25% { transform: translateY(-12px) scale(1.04, 0.96) rotate(-3deg); }
  50% { transform: translateY(0) scale(0.98, 1.02) rotate(0deg); }
  75% { transform: translateY(-8px) scale(1.02, 0.98) rotate(3deg); }
}

.duo-bounce-carrot {
  animation: duoCarrotAnim 1.6s ease-in-out infinite 0.2s;
  transform-origin: bottom center;
}

@keyframes duoCarrotAnim {
  0%, 100% { transform: translateY(0) scale(1, 1) rotate(0deg); }
  20% { transform: translateY(4px) scale(1.15, 0.85) rotate(0deg); }
  45% { transform: translateY(-16px) scale(0.9, 1.12) rotate(4deg); }
  70% { transform: translateY(-6px) scale(1.02, 0.98) rotate(-3deg); }
  85% { transform: translateY(2px) scale(1.05, 0.95) rotate(0deg); }
}

.crown-float-anim {
  animation: crownFloat 2s ease-in-out infinite;
}

@keyframes crownFloat {
  0%, 100% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.8)); }
  50% { transform: translateY(-6px) scale(1.08); filter: drop-shadow(0 0 20px rgba(251, 191, 36, 1)); }
}

.btn-world-next-glow {
  min-height: 56px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 40%, #ec4899 100%);
  border-bottom: 5px solid #9a3412;
  box-shadow: 0 0 25px rgba(249, 115, 22, 0.6), 0 8px 16px rgba(0, 0, 0, 0.4);
  animation: worldBtnPulse 1.8s ease-in-out infinite;
}

.btn-world-next-glow:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 35px rgba(249, 115, 22, 0.85), 0 10px 20px rgba(0, 0, 0, 0.5);
}

.btn-world-next-glow:active {
  transform: translateY(2px) scale(0.98);
  border-bottom-width: 2px;
}

@keyframes worldBtnPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(249, 115, 22, 0.6), 0 6px 12px rgba(0, 0, 0, 0.4); }
  50% { box-shadow: 0 0 32px rgba(236, 72, 153, 0.85), 0 6px 16px rgba(0, 0, 0, 0.4); }
}

.speech-bubble-pop {
  animation: speechPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes speechPop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================================ */
/* 8. WORLD 4 GRAND FINALE EXPANSION CARD ANIMATIONS            */
/* ============================================================ */
.world4-card-active {
  animation: world4CardGlowPulse 2.2s ease-in-out infinite alternate;
}
@keyframes world4CardGlowPulse {
  0% {
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.6), 0 8px 20px rgba(0, 0, 0, 0.5);
    border-color: rgba(34, 211, 238, 0.85);
  }
  100% {
    box-shadow: 0 0 24px rgba(6, 182, 212, 1), 0 0 35px rgba(251, 191, 36, 0.75), 0 8px 24px rgba(0, 0, 0, 0.7);
    border-color: rgba(253, 224, 71, 0.95);
  }
}
.world4-card-mastered {
  animation: world4CardMasteredPulse 2.2s ease-in-out infinite alternate;
}
@keyframes world4CardMasteredPulse {
  0% {
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.7), 0 8px 20px rgba(0, 0, 0, 0.5);
    border-color: rgba(251, 191, 36, 0.9);
  }
  100% {
    box-shadow: 0 0 28px rgba(245, 158, 11, 1), 0 0 40px rgba(16, 185, 129, 0.8), 0 8px 24px rgba(0, 0, 0, 0.7);
    border-color: rgba(250, 204, 21, 1);
  }
}

/* ============================================================ */
/* 9. FUNCTION BUILDER, COLLAPSE ANIMATION & TOOLTIP STYLES      */
/* ============================================================ */
.card-collapse-anim {
  animation: cardCollapseAnim 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes cardCollapseAnim {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.6) translateY(-10px); opacity: 0.7; }
  100% { transform: scale(0.05); opacity: 0; }
}

.function-tooltip-bubble {
  animation: tooltipPopIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  filter: drop-shadow(0 10px 25px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 15px rgba(6, 182, 212, 0.4));
}
@keyframes tooltipPopIn {
  0% { transform: scale(0.7) translateY(8px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.palette-func-wrapper {
  position: relative;
}
.palette-func-trash-btn {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 19px;
  height: 19px;
  border-radius: 9999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.6);
  border: 1.5px solid #ffffff;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  z-index: 30;
}
.palette-func-trash-btn:hover {
  transform: scale(1.18);
  background: #dc2626;
}
.palette-func-trash-btn:active {
  transform: scale(0.9);
}

.btn-save-func-pulse {
  animation: saveFuncGlowPulse 1.8s ease-in-out infinite alternate;
}
@keyframes saveFuncGlowPulse {
  0% {
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.6), 0 4px 8px rgba(0, 0, 0, 0.4);
    transform: scale(1);
  }
  100% {
    box-shadow: 0 0 20px rgba(6, 182, 212, 1), 0 0 30px rgba(56, 189, 248, 0.7), 0 4px 12px rgba(0, 0, 0, 0.5);
    transform: scale(1.03);
  }
}

/* ============================================================ */
/* 15. ELECTRIC FENCE & LASER BARRIER 2.5D ISOMETRIC SUITE      */
/* ============================================================ */
.fence-entity {
  position: absolute;
  width: 80px;
  height: 70px;
  pointer-events: none;
  transform-origin: 40px 45px;
  z-index: 20;
}

.electric-fence-entity {
  width: 80px;
  height: 70px;
  transform-origin: bottom center;
}

.fence-active .emitter-node-pulse {
  animation: emitterNodeGlow 1.2s ease-in-out infinite alternate;
}
@keyframes emitterNodeGlow {
  0% {
    filter: drop-shadow(0 0 4px #00f2fe);
    transform: scale(1);
  }
  100% {
    filter: drop-shadow(0 0 12px #00f2fe) drop-shadow(0 0 20px #facc15);
    transform: scale(1.15);
  }
}

.fence-active .laser-aura-pulse {
  animation: laserAuraPulse 0.8s ease-in-out infinite alternate;
}
@keyframes laserAuraPulse {
  0% {
    opacity: 0.35;
    stroke-width: 6;
  }
  100% {
    opacity: 0.75;
    stroke-width: 10;
  }
}

.fence-active .lightning-arc-fast {
  animation: lightningFlickerFast 0.18s linear infinite alternate;
}
@keyframes lightningFlickerFast {
  0% {
    opacity: 0.3;
    stroke-dasharray: 2 4;
  }
  50% {
    opacity: 1;
    stroke-dasharray: 6 2;
    transform: translateY(-1px);
  }
  100% {
    opacity: 0.8;
    stroke-dasharray: 4 4;
    transform: translateY(1px);
  }
}

.fence-active .lightning-arc-slow {
  animation: lightningFlickerSlow 0.35s ease-in-out infinite alternate;
}
@keyframes lightningFlickerSlow {
  0% {
    opacity: 0.4;
    stroke-dasharray: 4 4;
    transform: scaleY(0.85);
  }
  100% {
    opacity: 1;
    stroke-dasharray: 8 3;
    transform: scaleY(1.15);
  }
}

.fence-active .cross-spark-anim {
  animation: crossSparkCycle 0.6s ease-in-out infinite alternate;
}
@keyframes crossSparkCycle {
  0% {
    opacity: 0.2;
    stroke-dashoffset: 0;
  }
  100% {
    opacity: 0.9;
    stroke-dashoffset: 12;
  }
}

.fence-active .fence-spark-1 {
  animation: sparkOrbit1 0.9s ease-out infinite;
}
@keyframes sparkOrbit1 {
  0% { transform: scale(0.2) translate(0, 0); opacity: 0; }
  40% { transform: scale(1.4) translate(-2px, -3px); opacity: 1; }
  100% { transform: scale(0.4) translate(-6px, -8px); opacity: 0; }
}

.fence-active .fence-spark-2 {
  animation: sparkOrbit2 1.1s ease-out infinite 0.3s;
}
@keyframes sparkOrbit2 {
  0% { transform: scale(0.2) translate(0, 0); opacity: 0; }
  40% { transform: scale(1.5) translate(3px, -2px); opacity: 1; }
  100% { transform: scale(0.4) translate(8px, -6px); opacity: 0; }
}

.fence-active .ground-hazard-pulse {
  animation: groundHazardPulse 1.4s ease-in-out infinite alternate;
}
@keyframes groundHazardPulse {
  0% {
    stroke-opacity: 0.45;
    fill-opacity: 0.12;
    stroke-dashoffset: 0;
  }
  100% {
    stroke-opacity: 0.95;
    fill-opacity: 0.32;
    stroke-dashoffset: 12;
  }
}

.fence-shock-recoil {
  animation: fenceShockShake 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}
@keyframes fenceShockShake {
  0% { transform: translate(0, 0) scale(1); }
  15% { transform: translate(-8px, -4px) scale(1.08) rotate(-4deg); }
  30% { transform: translate(8px, 4px) scale(1.12) rotate(4deg); }
  45% { transform: translate(-6px, 2px) scale(1.04) rotate(-2deg); }
  60% { transform: translate(4px, -2px) scale(1.02) rotate(2deg); }
  75% { transform: translate(-2px, 0) scale(1.01); }
  100% { transform: translate(0, 0) scale(1); }
}

.fence-svg-flash {
  animation: fenceFlashCycle 0.6s ease-out forwards;
}
@keyframes fenceFlashCycle {
  0% { filter: drop-shadow(0 0 35px #ffffff) drop-shadow(0 0 60px #00f2fe) brightness(2.5); }
  40% { filter: drop-shadow(0 0 25px #facc15) drop-shadow(0 0 45px #00f2fe) brightness(1.8); }
  100% { filter: drop-shadow(0 0 8px #00f2fe) brightness(1); }
}

/* ============================================================ */
/* 16. CHARGING STATION & BITTO BATTERY STATES (WORLD 4-4)      */
/* ============================================================ */

/* 16.1 CHARGING STATION ENTITY & ISOMETRIC ENERGY PAD */
.charger-entity {
  position: absolute;
  width: 80px;
  height: 65px;
  pointer-events: none;
  z-index: 10;
}

.charging-station-entity {
  position: relative;
  width: 80px;
  height: 65px;
  transform-origin: 40px 34px;
  pointer-events: none;
}

.charger-ready .charger-ground-aura {
  animation: chargerGroundAuraPulse 2.2s ease-in-out infinite alternate;
}
@keyframes chargerGroundAuraPulse {
  0% { opacity: 0.2; transform: scale(0.9); }
  100% { opacity: 0.55; transform: scale(1.1); }
}

.charger-ready .energy-ring-1 {
  animation: energyRingRotateClockwise 4s linear infinite;
  transform-origin: 40px 34px;
}
.charger-ready .energy-ring-2 {
  animation: energyRingRotateCounter 3s linear infinite;
  transform-origin: 40px 34px;
}
@keyframes energyRingRotateClockwise {
  0% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -40; }
}
@keyframes energyRingRotateCounter {
  0% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: 40; }
}

.charger-ready .charger-core-pulse {
  animation: chargerCoreBreathing 1.4s ease-in-out infinite alternate;
}
@keyframes chargerCoreBreathing {
  0% { transform: scale(0.85); opacity: 0.7; }
  100% { transform: scale(1.25); opacity: 1; }
}

.charger-ready .charger-bolt-icon {
  animation: chargerBoltHover 1.6s ease-in-out infinite alternate;
  transform-origin: 40px 32px;
}
@keyframes chargerBoltHover {
  0% { transform: translateY(0px) scale(0.95); filter: drop-shadow(0 0 4px #fbbf24); }
  100% { transform: translateY(-4px) scale(1.08); filter: drop-shadow(0 0 10px #00f2fe) drop-shadow(0 0 16px #facc15); }
}

.charger-ready .charger-led {
  animation: chargerLedTwinkle 1.8s ease-in-out infinite alternate;
}
@keyframes chargerLedTwinkle {
  0% { opacity: 0.5; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1.2); }
}

.charger-ready .charger-holo-battery {
  animation: chargerHoloHover 2s ease-in-out infinite alternate;
}
@keyframes chargerHoloHover {
  0% { transform: translate(40px, 4px) scale(0.95); }
  100% { transform: translate(40px, 0px) scale(1.05); }
}

/* 16.2 ACTIVE CHARGING STATE (Surging Plasma Beam & Upward Photon Flow) */
.charger-charging .charger-beam-group {
  opacity: 1 !important;
}
.charger-charging .charging-beam-pulse {
  animation: chargingBeamSurge 0.5s ease-in-out infinite alternate;
}
@keyframes chargingBeamSurge {
  0% { opacity: 0.6; transform: scaleX(0.9); }
  100% { opacity: 1; transform: scaleX(1.15); filter: drop-shadow(0 0 12px #00f2fe); }
}

.charger-charging .energy-ring-1 {
  animation: energyRingRotateClockwise 0.8s linear infinite;
  transform-origin: 40px 34px;
}
.charger-charging .energy-ring-2 {
  animation: energyRingRotateCounter 0.6s linear infinite;
  transform-origin: 40px 34px;
}

.charger-charging .beam-spark-1 {
  animation: beamSparkRise1 0.7s ease-out infinite;
}
.charger-charging .beam-spark-2 {
  animation: beamSparkRise2 0.85s ease-out infinite 0.2s;
}
.charger-charging .beam-spark-3 {
  animation: beamSparkRise3 0.65s ease-out infinite 0.35s;
}
@keyframes beamSparkRise1 {
  0% { transform: translateY(18px) scale(0.4); opacity: 0; }
  30% { opacity: 1; transform: translateY(6px) scale(1.4); }
  100% { transform: translateY(-24px) scale(0.2); opacity: 0; }
}
@keyframes beamSparkRise2 {
  0% { transform: translateY(22px) scale(0.4); opacity: 0; }
  30% { opacity: 1; transform: translateY(8px) scale(1.5); }
  100% { transform: translateY(-26px) scale(0.2); opacity: 0; }
}
@keyframes beamSparkRise3 {
  0% { transform: translateY(16px) scale(0.4); opacity: 0; }
  30% { opacity: 1; transform: translateY(4px) scale(1.3); }
  100% { transform: translateY(-28px) scale(0.2); opacity: 0; }
}

.charger-charging .beam-ring-1 {
  animation: beamRingAscend1 0.9s cubic-bezier(0.2, 0.8, 0.4, 1) infinite;
  transform-origin: 40px 12px;
}
.charger-charging .beam-ring-2 {
  animation: beamRingAscend2 0.9s cubic-bezier(0.2, 0.8, 0.4, 1) infinite 0.45s;
  transform-origin: 40px -4px;
}
@keyframes beamRingAscend1 {
  0% { transform: translateY(20px) scale(0.5); opacity: 0; }
  40% { opacity: 0.9; }
  100% { transform: translateY(-16px) scale(1.3); opacity: 0; }
}
@keyframes beamRingAscend2 {
  0% { transform: translateY(20px) scale(0.5); opacity: 0; }
  40% { opacity: 0.8; }
  100% { transform: translateY(-18px) scale(1.3); opacity: 0; }
}

.battery-charge-popup {
  position: absolute;
  pointer-events: none;
  z-index: 70;
  animation: batteryChargePop 1.1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes batteryChargePop {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  25% { transform: translateY(-15px) scale(1.2); opacity: 1; }
  75% { transform: translateY(-32px) scale(1.05); opacity: 1; }
  100% { transform: translateY(-50px) scale(0.85); opacity: 0; }
}

/* ============================================================ */
/* 16.3 BITTO STATE-CHARGE (Power Surge, Plasma Aura, Battery HUD) */
/* ============================================================ */
.state-charge .robot-sprite-iso {
  animation: isoChargeBody 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.state-charge .robot-shadow-iso {
  animation: isoChargeShadow 1s ease-in-out forwards;
}
.state-charge #antennaGroup {
  animation: antennaChargeGlow 1s ease-in-out forwards;
}
.state-charge #chargeAuraGroup {
  opacity: 1 !important;
}
.state-charge #chargeRing1 {
  animation: chargeRingExpand 0.7s ease-out infinite;
  transform-origin: 50px 85px;
}
.state-charge #chargeRing2 {
  animation: chargeRingExpand 0.85s ease-out infinite 0.3s;
  transform-origin: 50px 55px;
}
.state-charge #chargeSpark1,
.state-charge #chargeSpark2,
.state-charge #chargeSpark3,
.state-charge #chargeSpark4 {
  animation: chargeSparkFlicker 0.4s ease-in-out infinite alternate;
}
.state-charge #batteryHudVisor {
  opacity: 1 !important;
}
.state-charge #visorBatteryBars {
  opacity: 1 !important;
}
.state-charge #visorBatBar1 {
  animation: visorBatBarFill 1s ease-out forwards;
}
.state-charge #visorBatBar2 {
  animation: visorBatBarFill 1s ease-out forwards 0.15s;
}
.state-charge #visorBatBar3 {
  animation: visorBatBarFill 1s ease-out forwards 0.3s;
}
.state-charge #visorBatBar4 {
  animation: visorBatBarFill 1s ease-out forwards 0.45s;
}
.state-charge #visorChargeBolt {
  animation: visorChargeBoltPop 1s ease-in-out forwards;
}
.state-charge circle[cx="50"][cy="86"] {
  animation: bellyBadgeEnergySurge 1s ease-in-out forwards;
}

@keyframes isoChargeBody {
  0% { transform: translateY(0) rotate(0deg) scale(1, 1); }
  15% { transform: translateY(-4px) rotate(-2deg) scale(0.98, 1.02); }
  35% { transform: translateY(-12px) rotate(2deg) scale(1.05, 0.95); filter: drop-shadow(0 0 16px #00f2fe) drop-shadow(0 0 24px #facc15); }
  65% { transform: translateY(-10px) rotate(-1deg) scale(1.02, 0.98); filter: drop-shadow(0 0 20px #00f2fe) drop-shadow(0 0 30px #4ade80); }
  85% { transform: translateY(-2px) scale(0.98, 1.02); }
  100% { transform: translateY(0) rotate(0deg) scale(1, 1); }
}

@keyframes isoChargeShadow {
  0% { transform: scale(1); opacity: 0.85; }
  35%, 65% { transform: scale(0.75); opacity: 0.45; }
  100% { transform: scale(1); opacity: 0.85; }
}

@keyframes antennaChargeGlow {
  0% { transform: translate(50px, 10px) rotate(0deg); }
  25%, 75% { transform: translate(50px, 10px) rotate(8deg); filter: drop-shadow(0 0 15px #00f2fe) drop-shadow(0 0 25px #facc15); }
  50% { transform: translate(50px, 10px) rotate(-8deg); filter: drop-shadow(0 0 20px #4ade80); }
  100% { transform: translate(50px, 10px) rotate(0deg); }
}

@keyframes chargeRingExpand {
  0% { transform: scale(0.4); opacity: 0; stroke-width: 3; }
  40% { opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; stroke-width: 0.5; }
}

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

@keyframes visorBatBarFill {
  0% { opacity: 0; transform: scaleY(0.2); }
  40%, 100% { opacity: 1; transform: scaleY(1); }
}

@keyframes visorChargeBoltPop {
  0% { opacity: 0; transform: scale(0.4); }
  25%, 75% { opacity: 1; transform: scale(1.3); }
  100% { opacity: 0.8; transform: scale(1); }
}

@keyframes bellyBadgeEnergySurge {
  0% { filter: drop-shadow(0 0 0 rgba(34, 197, 94, 0)); }
  30%, 75% { filter: drop-shadow(0 0 12px #22c55e) drop-shadow(0 0 20px #facc15); }
  100% { filter: drop-shadow(0 0 0 rgba(34, 197, 94, 0)); }
}

/* ============================================================ */
/* 16.4 BITTO STATE-BATTERY-LOW (Exhausted, Warning Blink, Tired) */
/* ============================================================ */
.state-battery-low .robot-sprite-iso {
  animation: isoLowBatteryBody 1.6s ease-in-out infinite alternate;
}
.state-battery-low .robot-shadow-iso {
  animation: isoLowBatteryShadow 1.6s ease-in-out infinite alternate;
}
.state-battery-low #antennaGroup {
  animation: antennaWarningFlicker 0.6s ease-in-out infinite alternate;
}
.state-battery-low #batteryHudVisor {
  opacity: 1 !important;
}
.state-battery-low #visorBatteryBars {
  display: none !important;
}
.state-battery-low #visorBatteryLowSign {
  opacity: 1 !important;
  animation: visorLowBatteryBlink 0.6s ease-in-out infinite alternate;
}
.state-battery-low #handLeft {
  animation: handLowBatteryDroopL 1.6s ease-in-out infinite alternate;
}
.state-battery-low #handRight {
  animation: handLowBatteryDroopR 1.6s ease-in-out infinite alternate;
}

@keyframes isoLowBatteryBody {
  0% { transform: translateY(2px) rotate(-3deg) scale(0.96, 1.04); }
  50% { transform: translateY(6px) rotate(1deg) scale(1.02, 0.98); }
  100% { transform: translateY(3px) rotate(-2deg) scale(0.97, 1.03); }
}

@keyframes isoLowBatteryShadow {
  0% { transform: scale(1.05, 0.95); opacity: 0.9; }
  100% { transform: scale(0.95, 1.05); opacity: 0.75; }
}

@keyframes antennaWarningFlicker {
  0% { filter: drop-shadow(0 0 2px #f59e0b); opacity: 0.6; }
  100% { filter: drop-shadow(0 0 14px #ef4444) drop-shadow(0 0 22px #facc15); opacity: 1; }
}

@keyframes visorLowBatteryBlink {
  0% { opacity: 0.3; }
  100% { opacity: 1; filter: drop-shadow(0 0 6px #ef4444); }
}

@keyframes handLowBatteryDroopL {
  0% { transform: translate(14px, 72px) rotate(15deg); }
  100% { transform: translate(16px, 76px) rotate(22deg); }
}
@keyframes handLowBatteryDroopR {
  0% { transform: translate(86px, 72px) rotate(-15deg); }
  100% { transform: translate(84px, 76px) rotate(-22deg); }
}

/* ============================================================ */
/* 16.5 BITTO STATE-BATTERY-EMPTY (Collapsed, Dark Visor, Shutdown) */
/* ============================================================ */
.state-battery-empty .robot-sprite-iso {
  animation: isoShutdownBody 1.2s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
.state-battery-empty .robot-shadow-iso {
  animation: isoShutdownShadow 1.2s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
.state-battery-empty #antennaGroup {
  animation: antennaShutdownDark 1s ease-out forwards;
}
.state-battery-empty #eyesGroup {
  opacity: 0 !important;
}
.state-battery-empty #offlineEyesGroup {
  opacity: 1 !important;
}
.state-battery-empty #batteryHudVisor {
  opacity: 1 !important;
}
.state-battery-empty #visorBatteryBars {
  display: none !important;
}
.state-battery-empty #visorBatteryLowSign {
  display: none !important;
}
.state-battery-empty #visorBatteryDeadSign {
  opacity: 1 !important;
  animation: visorDeadSignFlash 1.2s ease-out forwards;
}
.state-battery-empty #handLeft {
  animation: handShutdownDropL 1.2s ease-out forwards;
}
.state-battery-empty #handRight {
  animation: handShutdownDropR 1.2s ease-out forwards;
}

@keyframes isoShutdownBody {
  0% { transform: translateY(0) rotate(0deg) scale(1, 1); }
  35% { transform: translateY(6px) rotate(-4deg) scale(0.96, 1.04); }
  65% { transform: translateY(14px) rotate(6deg) scale(1.18, 0.82); filter: grayscale(0.5) brightness(0.85); }
  85% { transform: translateY(11px) rotate(4deg) scale(1.12, 0.88); }
  100% { transform: translateY(12px) rotate(4deg) scale(1.15, 0.85); filter: grayscale(0.6) brightness(0.75); }
}

@keyframes isoShutdownShadow {
  0% { transform: scale(1); opacity: 0.85; }
  100% { transform: scale(1.35, 0.8) translateX(3px); opacity: 0.95; }
}

@keyframes antennaShutdownDark {
  0% { filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.8)); }
  60% { filter: drop-shadow(0 0 2px #475569) brightness(0.5); }
  100% { filter: none brightness(0.35); }
}

@keyframes visorDeadSignFlash {
  0% { opacity: 0; transform: scale(0.5); }
  30% { opacity: 1; transform: scale(1.3); filter: drop-shadow(0 0 8px #ef4444); }
  70% { opacity: 0.8; transform: scale(1); }
  100% { opacity: 0.6; transform: scale(0.95); }
}

@keyframes handShutdownDropL {
  0% { transform: translate(16px, 64px); }
  100% { transform: translate(12px, 86px) rotate(35deg) scale(0.9); }
}
@keyframes handShutdownDropR {
  0% { transform: translate(84px, 64px); }
  100% { transform: translate(88px, 86px) rotate(-35deg) scale(0.9); }
}


.fence-disabled {
  opacity: 0.45 !important;
  filter: grayscale(0.7) brightness(0.85);
}

/* ============================================================ */
/* SECTION 17: 2.5D MOTHERSHIP ROCKET & LAUNCHPAD (STAGE 4-5)    */
/* ============================================================ */
.rocket-cargo-wrapper {
  position: absolute;
  pointer-events: none;
  z-index: 45;
  transition: transform 0.3s ease-out;
}

.rocket-cargo-entity {
  position: relative;
  width: 84px;
  height: 105px;
  transform-origin: 42px 85px;
}

/* 1. Launchpad Gantry Light Chase */
.launchpad-runway-light {
  animation: padLightPulse 1.8s ease-in-out infinite alternate;
}
@keyframes padLightPulse {
  0% { opacity: 0.4; filter: drop-shadow(0 0 2px #00f2fe); }
  100% { opacity: 1; filter: drop-shadow(0 0 8px #00f2fe) drop-shadow(0 0 14px #38bdf8); }
}

/* 2. Pre-launch Countdown Rumble Vibration */
.rocket-rumble {
  animation: rocketPrelaunchRumble 0.12s linear infinite alternate !important;
}
@keyframes rocketPrelaunchRumble {
  0% { transform: translate(-1px, 0.5px) rotate(-0.5deg); }
  50% { transform: translate(1px, -0.5px) rotate(0.5deg); }
  100% { transform: translate(-0.5px, -1px) rotate(-0.25deg); }
}

/* 3. Thruster Flame Pulse */
.rocket-flame-active {
  animation: rocketFlameSurge 0.18s ease-in-out infinite alternate;
}
@keyframes rocketFlameSurge {
  0% { transform: scale(0.92, 0.88); opacity: 0.85; filter: drop-shadow(0 0 8px #f97316); }
  50% { transform: scale(1.05, 1.15); opacity: 1; filter: drop-shadow(0 0 16px #facc15) drop-shadow(0 0 24px #00f2fe); }
  100% { transform: scale(1, 1.25); opacity: 0.95; filter: drop-shadow(0 0 20px #ef4444); }
}

/* 4. Rocket Launch Liftoff & Blastoff Ascension (Parabolic Surge into Orbit) */
.rocket-launching {
  animation: rocketAscentSequence 2.6s cubic-bezier(0.3, 0, 0.2, 1) forwards !important;
}
@keyframes rocketAscentSequence {
  0% {
    transform: translateY(0) scale(1, 1);
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
  }
  15% {
    /* Ignition lift hover */
    transform: translateY(-16px) scale(1.04, 0.96) rotate(-1deg);
    filter: drop-shadow(0 15px 25px rgba(250, 204, 21, 0.7));
  }
  30% {
    /* First stage thrust surge */
    transform: translateY(-65px) scale(0.98, 1.05) rotate(1deg);
    filter: drop-shadow(0 25px 35px rgba(0, 242, 254, 0.8));
  }
  55% {
    /* Sonic acceleration */
    transform: translateY(-220px) scale(0.92, 1.15) rotate(-2deg);
    opacity: 1;
  }
  80% {
    /* High stratosphere */
    transform: translateY(-480px) scale(0.75, 1.3) rotate(3deg);
    opacity: 0.85;
  }
  100% {
    /* Deep space orbit */
    transform: translateY(-750px) scale(0.35, 1.5) rotate(5deg);
    opacity: 0;
  }
}

/* 5. Base Exhaust Smoke Cloud Blast */
.rocket-exhaust-smoke {
  position: absolute;
  pointer-events: none;
  z-index: 35;
  border-radius: 50%;
  animation: smokeCloudExpand 1.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
@keyframes smokeCloudExpand {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0.9;
    background: radial-gradient(circle, rgba(254, 240, 138, 0.9) 0%, rgba(249, 115, 22, 0.8) 40%, rgba(100, 116, 139, 0.4) 80%, transparent 100%);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.6);
    opacity: 0.7;
    background: radial-gradient(circle, rgba(248, 250, 252, 0.8) 0%, rgba(148, 163, 184, 0.5) 50%, rgba(71, 85, 105, 0.2) 80%, transparent 100%);
  }
  100% {
    transform: translate(-50%, -50%) scale(2.6);
    opacity: 0;
    background: radial-gradient(circle, rgba(203, 213, 225, 0.3) 0%, transparent 70%);
  }
}

/* 6. Cargo Bounty Star Glow in Rocket Hull */
.rocket-cargo-glow {
  animation: cargoStarGlowPulse 1.4s ease-in-out infinite alternate;
}
@keyframes cargoStarGlowPulse {
  0% { opacity: 0.6; filter: drop-shadow(0 0 3px #facc15); }
  100% { opacity: 1; filter: drop-shadow(0 0 10px #fbbf24) drop-shadow(0 0 16px #4ade80); }
}

/* 7. Bitto Cockpit Pilot Idle / Cheer */
.bitto-cockpit-pilot {
  transform-origin: 42px 35px;
  animation: bittoPilotCheer 1.8s ease-in-out infinite alternate;
}
@keyframes bittoPilotCheer {
  0% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-2px) rotate(-2deg); }
  100% { transform: translateY(1px) rotate(2deg); }
}

/* ============================================================ */
/* ZERO-FLICKER MODAL OVERLAYS (Guarantees no flash on refresh)  */
/* ============================================================ */
#compassModal,
#parentGateModal,
#victoryModal,
#helpModal,
#resetModal,
.snapcode-modal-overlay {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

#compassModal.active-modal,
#parentGateModal.active-modal,
#victoryModal.active-modal,
#helpModal.active-modal,
#resetModal.active-modal,
.snapcode-modal-overlay.active-modal {
  display: flex !important;
}

#compassModal.active-modal.modal-visible,
#parentGateModal.active-modal.modal-visible,
#victoryModal.active-modal.modal-visible,
#helpModal.active-modal.modal-visible,
#resetModal.active-modal.modal-visible,
.snapcode-modal-overlay.active-modal.modal-visible {
  opacity: 1;
  pointer-events: auto;
}



@media (max-width: 639px) {
  #gameplayViewport .sc-stage-toolbar { top: 76px; left: 12px; right: 12px; justify-content: flex-end; }
  #gameplayViewport #commandPaletteContainer { justify-content: flex-start; overflow-x: auto; padding: 6px 2px; scroll-snap-type: x proximity; }
  #gameplayViewport #commandPaletteContainer > button,
  #gameplayViewport #commandPaletteContainer > .palette-func-wrapper { flex: 0 0 52px; min-width: 52px; min-height: 52px; scroll-snap-align: start; }
}

/* Reviewed mobile deck: bounded scrolling leaves the board visible. */
.sc-menu-toggle{display:none}
.sc-bottom-hud:empty{display:none}
.sc-bottom-hud{display:flex;justify-content:center;flex-shrink:0}
.sc-next-label{display:flex;flex-direction:column;align-items:center;justify-content:center;line-height:1.25;gap:3px;min-width:0}
.sc-next-label>span:last-child{font-size:.75em}
.btn-world-next-glow{background:linear-gradient(135deg,#fbbf24,#fb923c,#f472b6);min-height:68px;height:68px;padding:8px 12px}
@media(max-width:639px){
 html,body,#gameApp,#gameplayViewport{min-width:0;width:100%;max-width:100%}
 body:has(#gameplayViewport){padding:5px;overflow:hidden;height:100dvh}
 #gameplayViewport{gap:4px;justify-content:flex-start}
 #gameplayViewport .sc-playfield{min-height:180px;flex:1 1 0;overflow:hidden}
 #gameplayViewport .sc-stage-hud{top:8px;left:8px;max-width:calc(100% - 58px)}
 #gameplayViewport .sc-stage-hud>div{max-width:100%;gap:5px;padding:5px;font-size:10px}
 #gameplayViewport .sc-stage-hud .tracking-wider{font-size:9px;letter-spacing:0}
 #gameplayViewport .sc-menu-toggle{display:flex;position:absolute;top:8px;right:8px;z-index:45;width:40px;height:40px;align-items:center;justify-content:center;background:#0f172a;border:1px solid #6366f1;border-radius:12px;color:#a5f3fc;font-size:24px}
 #gameplayViewport .sc-stage-toolbar{display:none;position:fixed;top:59px;right:15px;left:auto;flex-direction:column;align-items:stretch;padding:6px;background:#0f172af5;border:1px solid #6366f1;border-radius:16px;gap:5px;max-height:calc(100dvh - 74px);overflow-y:auto;min-width:48px}
 #gameplayViewport .sc-stage-toolbar.sc-menu-open{display:flex}
 #gameplayViewport .sc-stage-toolbar>*{min-height:40px;display:flex;justify-content:center;align-items:center}
 #gameplayViewport .toy-wood-frame{padding:5px;border-radius:16px}
 #slotTrayWrapper>div:first-child{gap:3px;padding:0;flex-wrap:nowrap;min-height:28px}
 #slotTrayWrapper>div:first-child>div{gap:3px;flex-wrap:nowrap;min-width:0}
 #slotTrayHeaderHUD{flex-wrap:nowrap;overflow-x:auto}
 #slotTrayHeaderHUD button{font-size:10px;padding:3px 6px;white-space:nowrap}
 #slotTrayHeaderHUD .func-slot-chip{flex-shrink:0}
 #slotCountText{padding:2px 4px;font-size:11px}
 #btnParentGate,#btnClearTray,#btnFlag{min-width:28px;min-height:28px;padding:4px}
 #insertModePill{position:absolute;z-index:41;right:5px;bottom:5px;max-width:200px}
 #slotTrayContainer{align-content:flex-start;align-items:center;max-height:105px;min-height:52px;overflow-y:auto;overflow-x:hidden;gap:5px;padding:5px;scrollbar-width:thin;overscroll-behavior:contain}
 #slotTrayContainer>.toy-slot-socket{width:44px;height:44px;flex:0 0 44px}
 #slotTrayContainer .toy-loop-container,#slotTrayContainer .toy-ifelse-container{min-width:0;max-width:100%;width:auto;flex-shrink:1;padding:4px;gap:4px}
 #slotTrayContainer .toy-loop-body,#slotTrayContainer .toy-ifelse-body{min-width:0;max-width:100%;flex-wrap:wrap;gap:4px;padding:3px}
 #slotTrayContainer .toy-ifelse-branches{min-width:0;flex:1}
 #slotTrayContainer .toy-ifelse-row{min-width:0;padding:3px;gap:3px;flex-wrap:nowrap}
 #slotTrayContainer .toy-ifelse-header-badge,#slotTrayContainer .toy-loop-badge{width:40px;height:40px;flex:0 0 40px}
 #slotTrayContainer .toy-ifelse-badge{width:30px;height:30px;flex:0 0 30px}
 #slotTrayContainer .toy-ifelse-child-socket,#slotTrayContainer .toy-loop-child-socket{width:40px;height:40px;flex:0 0 40px}
 #slotTrayContainer .toy-ifelse-nested{min-width:0;max-width:100%;width:100%;flex-basis:100%}
 #gameplayViewport #commandPaletteContainer{display:grid;grid-template-columns:repeat(auto-fill,minmax(44px,1fr));gap:5px;justify-content:start;max-height:101px;overflow-y:auto;overflow-x:hidden;padding:4px 2px;scroll-snap-type:none;overscroll-behavior:contain}
 #gameplayViewport #commandPaletteContainer>button,#gameplayViewport #commandPaletteContainer>.palette-func-wrapper{width:44px;height:44px;min-width:44px;min-height:44px;justify-self:center}
 #gameplayViewport #commandPaletteContainer>.palette-func-wrapper>button:not(.palette-func-trash-btn){width:44px;height:44px}
 #gameplayViewport #commandPaletteContainer>.palette-func-wrapper>.palette-func-trash-btn{width:20px;height:20px;min-width:20px;min-height:20px;top:-3px;right:-3px;font-size:10px;padding:0}
 #i18n_cmdEjectHint{display:none}
 #i18n_cmdPaletteTitle{font-size:10px}
 #gameplayViewport #btnRun,#gameplayViewport #btnStep,#gameplayViewport #btnOnScreenNext{height:44px;min-height:44px;padding:5px 12px;border-radius:14px}
 #gameplayViewport #btnRun svg{width:25px;height:25px}
 #gameplayViewport .sc-speech-row{left:7px;right:7px;bottom:7px;gap:5px;align-items:flex-end}
 #gameplayViewport #speechIconBtn{width:34px;height:34px;flex:0 0 34px}
 #gameplayViewport #bittoSpeechBubble{width:calc(100% - 39px);min-width:0;max-width:none;padding:6px;gap:4px;font-size:11px}
 #gameplayViewport #bittoSpeechBubble>span:first-child{display:none}
 #gameplayViewport #bittoSpeechText{min-width:0;line-height:16px;max-height:32px;overflow:hidden;overflow-wrap:anywhere}
 #gameplayViewport .sc-bottom-hud #batteryHudBadge{padding:3px 9px;font-size:10px}
 #gameplayViewport>div:last-of-type{min-width:0}
}

/* Stage 1-3: isolated, touch-friendly watering lesson. */
.water-action-lesson { box-sizing:border-box; width:min(440px,calc(100vw - 24px)); max-height:calc(100dvh - 24px); overflow-y:auto; border:2px solid #22d3ee; border-radius:24px; padding:20px; background:#101737; color:#f8fafc; text-align:center; font-family:inherit; box-shadow:0 20px 60px #0008; }
.water-action-lesson::backdrop { background:#020617cc; }
.water-action-lesson h2 { margin:0 0 10px; font-size:22px; font-weight:900; color:#67e8f9; }
.water-action-lesson p { margin:8px 0; font-size:15px; line-height:1.6; }
.water-lesson-scene { position:relative; width:min(280px,100%); height:180px; margin:12px auto; }
.water-lesson-ground { position:absolute; width:210px; height:90px; left:50%; bottom:16px; transform:translateX(-50%) rotate(-8deg); background:linear-gradient(#4ade80,#15803d); border-radius:50%; border-bottom:10px solid #14532d; }
.water-lesson-bitto { position:absolute; width:100px; height:125px; left:40px; top:20px; transform:none; pointer-events:none; }
#waterLessonPlant { position:absolute; width:80px; height:98px; left:147px; top:63px; }
.water-lesson-drops { position:absolute; left:125px; top:66px; opacity:0; font-size:24px; pointer-events:none; }
.is-watering .water-lesson-drops { animation:waterLessonDrops .5s linear 2; }
@keyframes waterLessonDrops { from { opacity:1; transform:translateY(-12px); } to { opacity:0; transform:translateY(35px); } }
.water-action-lesson button { min-height:48px; border-radius:14px; border:2px solid #22d3ee; font:inherit; font-weight:800; padding:10px 14px; cursor:pointer; }
.water-action-lesson button:focus-visible { outline:3px solid #facc15; outline-offset:3px; }
.water-action-lesson button:disabled { opacity:.45; cursor:default; }
.water-lesson-action { display:inline-flex; align-items:center; gap:10px; background:#cffafe; color:#155e75; }
.water-lesson-action > span:first-child { font-size:32px; }
.water-lesson-buttons { display:flex; flex-wrap:wrap; gap:10px; margin-top:16px; }
.water-lesson-buttons button { flex:1 1 130px; background:#1e293b; color:#fff; }
#waterLessonDone { background:#10b981; color:#022c22; border-color:#34d399; }
@media (max-height:600px) { .water-action-lesson { padding:12px; } .water-lesson-scene { height:155px; margin:0 auto; } }

/* Stage 1-4 reuses lesson layout; harvest motion stays inside the demo. */
#harvestLessonPlant { position:absolute; width:80px; height:98px; left:147px; top:63px; }
#harvestLessonDone { background:#10b981; color:#022c22; border-color:#34d399; }
.harvest-action-lesson.is-watering .water-lesson-drops { animation:none; opacity:1; left:195px; top:108px; }
.harvest-action-lesson.is-watering #harvestLessonPlant { animation:harvestLessonPull .9s ease-in-out forwards; }
.harvest-lesson-basket { display:block; font-size:36px; padding-top:24px; white-space:nowrap; }
@keyframes harvestLessonPull { 0% { transform:translateY(0); } 45% { transform:translateY(-25px) rotate(-8deg); } 100% { transform:translate(28px,10px) scale(.6); opacity:0; } }

/* Stage 2-1: show both commands during each of four loop rounds. */
.loop-action-lesson h2 { font-size:20px; }
.loop-action-lesson .water-lesson-scene { height:175px; }
.loop-action-lesson .water-lesson-bitto { top:0; transform:scale(.75); transform-origin:bottom left; transition:left .5s ease; }
#loopLessonPlant { position:absolute; left:5px; right:5px; bottom:4px; display:flex; gap:4px; }
.loop-demo-plot { width:52px; height:70px; flex:none; }
.loop-action-lesson .water-lesson-ground { width:260px; bottom:0; }
.loop-lesson-code { padding:8px; border:2px solid #f472b6; border-radius:12px; color:#fbcfe8; font-weight:900; font-size:22px; }
#loopLessonDone { background:#10b981; color:#022c22; border-color:#34d399; }

/* Stage 2-4: condition-controlled movement stops on the goal tile. */
#whileLessonPlant { position:absolute; left:8px; right:8px; bottom:20px; display:flex; gap:4px; }
.while-demo-tile { width:42px; height:38px; flex:none; display:grid; place-items:center; background:#16a34a; border-bottom:6px solid #14532d; border-radius:8px; color:#bbf7d0; font-size:22px; }
.while-action-lesson .water-lesson-drops { display:none; }
.while-action-lesson .water-lesson-bitto { top:18px; }
.while-action-lesson .loop-lesson-code { font-size:17px; }
#whileLessonDone { background:#10b981; color:#022c22; border-color:#34d399; }

/* Stage 3-1: highlight exactly one condition branch at a time. */
#ifLessonPlant { position:absolute; width:80px; height:98px; left:147px; top:63px; }
.if-action-lesson .water-lesson-scene { height:155px; margin:4px auto; }
.if-lesson-branches { display:grid; gap:6px; text-align:left; font-size:15px; font-weight:800; }
.if-lesson-branches > div { padding:8px 10px; border:2px solid #475569; border-radius:12px; background:#1e293b; }
.if-lesson-branches .chosen-branch { border-color:#facc15; background:#4d3b11; color:#fef08a; }
#ifLessonDone { background:#10b981; color:#022c22; border-color:#34d399; }

#alienLessonPlant { position:absolute; width:80px; height:98px; left:147px; top:63px; }
#alienLessonDone { background:#10b981; color:#022c22; border-color:#34d399; }
.alien-demo-flee > svg { animation:alienLessonFlee .9s ease-in forwards; }
.alien-lesson-clear { display:block; padding-top:25px; font-size:36px; }
@keyframes alienLessonFlee { to { transform:translate(45px,-35px) scale(.2); opacity:0; } }
.alien-action-lesson .water-lesson-drops { display:none; }

#valveLessonPlant { position:absolute; width:80px; height:98px; left:147px; top:63px; }
.valve-demo-wheel { display:block; font-size:54px; color:#fbbf24; }
.valve-turned { transform:rotate(90deg); }
.valve-action-lesson .water-lesson-drops { opacity:1; left:80px; top:125px; font-size:36px; }
.valve-action-lesson.is-watered .water-lesson-drops { opacity:0; transition:opacity .5s; }
#valveLessonDone { background:#10b981; color:#022c22; border-color:#34d399; }

#functionLessonPlant { position:absolute; width:80px; height:98px; left:147px; top:63px; }
#functionLessonIcon { display:block; width:44px; height:44px; }
#functionLessonIcon svg { width:100%; height:100%; }
.function-action-lesson .water-lesson-drops { display:none; }
.function-action-lesson .water-lesson-bitto { transition:left .7s ease; }
#functionLessonDone { background:#10b981; color:#022c22; border-color:#34d399; }

#jumpLessonPlant { position:absolute; width:30px; height:90px; left:145px; top:68px; }
.jump-demo-fence { display:grid; place-items:center; height:65px; border:4px solid #22d3ee; border-radius:8px; color:#fde047; font-size:30px; }
.jump-action-lesson .water-lesson-drops { display:none; }
.jump-action-lesson .water-lesson-bitto { transition:left .8s ease-in-out; }
#jumpLessonDone { background:#10b981; color:#022c22; border-color:#34d399; }

#chargeLessonPlant { position:absolute; width:100px; height:85px; left:145px; top:90px; }
.charge-action-lesson .water-lesson-bitto { z-index:4; transition:left .6s ease; }
.charge-action-lesson .water-lesson-drops { display:none; }
.charge-lesson-battery { display:flex; align-items:center; justify-content:center; gap:8px; color:#6ee7b7; font-weight:800; }
.charge-lesson-battery progress { width:130px; height:20px; accent-color:#10b981; }
#chargeLessonDone { background:#10b981; color:#022c22; border-color:#34d399; }
.charge-demo-dock { position:absolute; left:5px; bottom:0; padding:4px 8px; border:2px solid #f87171; border-radius:50%; color:#fecaca; background:#7f1d1d; font-size:12px; }

.charge-action-lesson #chargeLessonPlant { left:180px; top:80px; width:80px; }
.charge-action-lesson .charge-demo-dock { left:140px; bottom:26px; z-index:3; }

.sc-replay-lesson { position:absolute; left:0; bottom:52px; width:40px; height:40px; display:flex; align-items:center; justify-content:center; border-radius:16px; border:2px solid #67e8f9; background:linear-gradient(to top right,#4f46e5,#0ea5e9,#22d3ee); color:white; font-size:20px; box-shadow:0 10px 15px -3px #06b6d466; transition:transform .15s; }
.sc-replay-lesson:active { transform:scale(.95); }
@media(min-width:640px) { .sc-replay-lesson { width:44px; height:44px; } }
@media(max-width:639px) { #gameplayViewport .sc-replay-lesson { width:34px; height:34px; bottom:46px; font-size:18px; } }
#slotTrayWrapper > div:first-child { min-width:0; gap:6px; }
#slotTrayWrapper > div:first-child > div:first-child { flex:1; min-width:0; }
#slotTrayWrapper > div:first-child > div:last-child { flex-shrink:0; }
#slotTrayHeaderHUD { max-width:100%; overflow-x:auto; flex-wrap:nowrap; }
#slotTrayHeaderHUD > * { flex-shrink:0; }

.sc-victory-canvas { position:fixed; inset:0; width:100vw; height:100dvh; pointer-events:none; z-index:2000; }


