

.animation-container {
  height: 109vh;
  background-color: #0a0a0a; /* Dark base */
  background-image:
    /* Main grid lines */
    linear-gradient(#00ffea 1px, transparent 1px),
    linear-gradient(90deg, #00ffea 1px, transparent 1px),
    /* Diagonal glowing lines */
    linear-gradient(45deg, rgba(0,255,234,0.1) 1px, transparent 1px),
    linear-gradient(-45deg, rgba(0,255,234,0.1) 1px, transparent 1px),
    /* Subtle horizontal neon lines */
    repeating-linear-gradient(0deg, rgba(0,255,234,0.05), rgba(0,255,234,0.05) 2px, transparent 2px, transparent 10px);
    
    background-position: 0 0, 0 0, 0 0, 0 0, 0 0;
  background-repeat: repeat;
  color: #00ffea; /* HUD-style text color for popups or labels */
  
  position: relative;
  overflow: hidden;



}
@keyframes hudGlow {
  0% { background-position: 0 0, 0 0, 0 0, 0 0, 0 0; }
  50% { background-position: 5px 5px, 5px 5px, 10px 10px, 10px 10px, 0 5px; }
  100% { background-position: 0 0, 0 0, 0 0, 0 0, 0 0; }
}



.scene {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  perspective: 1500px;
  transform-style: preserve-3d;
}

/* SHELVES */
.shelf {
  position: absolute;
  top: 22%;
  left: 62%;
  transform-style: preserve-3d;
  transform: translate(var(--x,0), var(--y,0)) rotateX(0deg);
}
.shelf .body {
  width: 40px;
  height: 450px;
  background: linear-gradient(#8b5e3c, #5a3e20);
  border-radius: 4px;
  box-shadow: 0 6px 10px rgba(0,0,0,0.5);
}
.shelf .books {
  position: absolute;
  top: 20px;
  left: -10px;
}
.shelf .books .book {
  width: 12px;
  height: 20px;
  background: linear-gradient(#c88, #933);
  margin: 3px 0;
  border-radius: 2px;
  transform: translateZ(var(--z)) rotateY(var(--rotate));
}

/* TABLES */
.table {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-style: preserve-3d;
  transform: translate(var(--x,0), var(--y,0)) rotateX(0deg);
  z-index: 3;
}
.table .top {
  width: 120px;
  height: 60px;
  background: #3a2c20;
  border-radius: 4px;
  box-shadow: 0 6px 10px rgba(0,0,0,0.5);
}
.table .leg {
  width: 8px;
  height: 40px;
  background: #000;
  position: absolute;
  transform-origin: top center;
  opacity: 0;
  transform: translateY(0) scaleY(0);
  border-radius: 0 0 20px 20px; 
}
.table .leg-front-left { bottom: -40px; left: 10px; }
.table .leg-front-right {
  bottom: -40px;
  left: 100px; /* same as left leg */
  transform: translateX(104px); /* offset by width of table minus margin */
}


.table .books-on-table {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
}
.table .books-on-table .book {
  width: 15px;
  height: 25px;
  background: linear-gradient(#88c, #336);
  margin-right: 5px;
  border-radius: 2px;
  transform: rotate(var(--rotate));
}

/* PROPS ON TABLE */
.props-on-table {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 8px;
  transform-style: preserve-3d;
}
.scroll { width: 8px; height: 20px; background: #e0d3a5; border-radius: 50%; transform: rotate(var(--rotate)); box-shadow: 0 1px 2px rgba(0,0,0,0.5);}
.globe { width: 15px; height: 15px; background: radial-gradient(circle at 30% 30%, #0d6, #036); border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.5);}
.plant { width: 8px; height: 10px; background: #7b5; border-radius: 0 0 2px 2px; position: relative;}
.plant::after { content: ''; position: absolute; top: -6px; left: 50%; transform: translateX(-50%); width: 10px; height: 6px; background: #0a3; border-radius: 50%;}

/* CARPET */
.carpet {
  position: absolute;
  top: 30%;
  left: 37%;
  transform-style: preserve-3d;
  transform: translate(var(--x,0), var(--y,0)) rotateX(0deg) translateZ(-30px);
  width: 650px;
  height: 312px;
  background: radial-gradient(circle, #964b00, #5a2c00);
  border-radius: 10px;
  z-index: 1;
}

/* LAMPS ON CEILING */
.lamp {
  position: absolute;
  top: 48%;
  left: 63%;
  transform-style: preserve-3d;
  transform: translate(var(--x,0), var(--y,0)) rotateX(0deg);
  z-index: 5;
}
.lamp .stand { width: 4px; height: 80px; background: #333; margin: 0 auto; }
.lamp .light { width: 20px; height: 20px; background: radial-gradient(circle, #ffffcc, #ffaa00); border-radius: 50%; margin-top: -10px; box-shadow: 0 0 20px #ffaa00; }

/* RESPONSIVE */
@media (max-width: 768px) {
  .table .top { width: 60vw; height: 30vw; }
  .table .leg { height: 15vw; width: 2vw; }
  .shelf .body { width: 6vw; height: 50vw; }
  .shelf .books .book { width: 3vw; height: 5vw; }
  .table .books-on-table .book { width: 4vw; height: 6vw; }
  .props-on-table .scroll { width: 2vw; height: 4vw; }
  .props-on-table .globe { width: 5vw; height: 5vw; }
  .props-on-table .plant { width: 3vw; height: 4vw; }
  .carpet { width: 80vw; height: 40vw; }
  .lamp .stand { height: 20vw; width: 1vw; }
  .lamp .light { width: 5vw; height: 5vw; }
}
.character.librarian {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-style: preserve-3d;
  transform: translate(var(--x,0), var(--y,0)) rotateX(0deg);
  transform-origin: center center;
  z-index: 99;
}

/* Head */
.character.librarian .head {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(-68px); /* adjust -68px if needed */
  width: 26px;
  height: 26px;
  background: radial-gradient(circle at 30% 30%, #f1c27d, #c68642);
  border-radius: 50%;
  z-index: 3;
}

/* Hair */
.character.librarian .hair {
  width: 26px;
  height: 12px;
  background: linear-gradient(#3b2c20, #000);
  border-radius: 50% 50% 0 0;
  position: absolute;
  top: 0;
}

/* Eyes */
.character.librarian .eye {
  width: 4px;
  height: 4px;
  background: #000;
  border-radius: 50%;
  position: absolute;
  top: 10px;
}
.character.librarian .eye.left {
  left: 5px;
}
.character.librarian .eye.right {
  right: 5px;
}

/* Glasses */
.character.librarian .glasses {
  width: 14px;
  height: 4px;
  border: 1px solid #333;
  position: absolute;
  top: 9px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 2px;
}

/* Mouth */
.character.librarian .mouth {
  width: 8px;
  height: 2px;
  background: #800000;
  border-radius: 1px;
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
}

/* Neck */
.character.librarian .neck {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(-44px); /* adjust -44px if needed */
  width: 8px;
  height: 10px;
  background: radial-gradient(circle at 50% 50%, #f5d1aa, #c68b4f 80%);
  border-radius: 2px;
  transform-origin: top center;
  z-index: 2;
}

/* Torso */
.character.librarian .torso {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(-32px); /* adjust -32px if needed */
  width: 26px;
  height: 44px;
  background: linear-gradient(135deg, #6677aa, #223366);
  border-radius: 3px;
  transform-origin: top center;
  box-shadow: 0 3px 6px rgba(0,0,0,0.3), inset 0 2px 4px rgba(255,255,255,0.1);
  z-index: 1;
  animation: breathe 4s ease-in-out infinite alternate;
}

/* Arms */
.character.librarian .arm-left,
.character.librarian .arm-right {
  position: absolute;
  top: -30px;
  width: 6px;
  height: 24px;
  background: #224499;
  transform-origin: top center;
  z-index: 0;
}

.character.librarian .arm-left {
  left: -16px;
}

.character.librarian .arm-right {
  right: -16px;
}

/* Forearms */
.character.librarian .forearm {
  width: 6px;
  height: 18px;
  background: #224499;
  transform-origin: top center;
  position: absolute;
  top: 24px;
}

/* Hands */
.character.librarian .hand {
  width: 6px;
  height: 6px;
  background: #f1c27d;
  border-radius: 2px;
  position: absolute;
  bottom: -6px;
}

/* Legs */
.character.librarian .leg-left,
.character.librarian .leg-right {
  position: absolute;
  top: 14px;
  width: 6px;
  height: 32px;
  background: #224499;
  transform-origin: top center;
  z-index: 0;
}

.character.librarian .leg-left {
  left: -6px;
}

.character.librarian .leg-right {
  right: -6px;
}

/* Feet */
.character.librarian .foot {
  width: 8px;
  height: 4px;
  background: #333;
  position: absolute;
  bottom: -4px;
  border-radius: 2px;
}

/* Breathing Animation */
@keyframes breathe {
  from {
    transform: translateX(-50%) translateY(-32px) scaleY(1);
  }
  to {
    transform: translateX(-50%) translateY(-32px) scaleY(1.03);
  }
}
.arrow-controls {
  position: absolute;
  bottom: 50px;
  left: 14%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(2, 60px);
  gap: 8px;
  z-index: 999;
  perspective: 800px; /* adds depth for 3D effect */
}

.arrow-controls button {
  font-size: 24px;
  font-weight: bold;
  background: linear-gradient(145deg, #4a4a4a, #1f1f1f);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  opacity: 0.9;
  box-shadow: 0 6px 12px rgba(0,0,0,0.3), 0 0 10px rgba(255,255,255,0.05) inset;
  transition: all 0.3s ease;
  transform-style: preserve-3d;
}

.arrow-controls button:hover {
  opacity: 1;
  transform: rotateX(15deg) translateY(-2px);
  box-shadow: 0 12px 20px rgba(0,0,0,0.4), 0 0 15px rgba(255,255,255,0.1) inset;
  background: linear-gradient(145deg, #5e5e5e, #2a2a2a);
}

/* Grid positions */
#up { grid-column: 2; grid-row: 1; }
#left { grid-column: 1; grid-row: 2; }
#down { grid-column: 2; grid-row: 2; }
#right { grid-column: 3; grid-row: 2; }

/* Optional: Arrow icon rotation for style */


.arrow-controls button::after {
  display: block;
  font-size: 28px;
  line-height: 60px;
  text-align: center;
}


/* Active walking class */
.walking .arm.left { animation: walkArm 0.5s infinite alternate; }
.walking .arm.right { animation: walkArm 0.5s infinite alternate-reverse; }
.walking .leg.left { animation: walkLeg 0.5s infinite alternate; }
.walking .leg.right { animation: walkLeg 0.5s infinite alternate-reverse; }

#instruction-text {
  position: absolute;
  top: 20px;
  left: 6%;
  width: 100%;
  text-align: center;
  font-size: 50px;
  font-weight: bold;
  color: rgb(0, 0, 0); /* neon cyan */
  z-index: 10;
  font-family: 'Arial Black', sans-serif;
  letter-spacing: 1px;
  text-shadow: 
    0 0 3px rgb(255, 255, 255),
    0 0 4px rgb(255, 255, 255),
    0 0 5px rgb(255, 255, 255);

  animation: flicker 1.2s infinite;
}
#instruction-text2 {
  position: absolute;
  bottom: 34px;
  left: 9%;
  width: 100%;
  text-align: center;
  font-size: 20px;
  font-weight: bold;
  color: rgb(112, 21, 21); /* neon cyan */
  z-index: 10;
  font-family: 'Arial Black', sans-serif;
  letter-spacing: 1px;
  text-shadow: 
    0 0 3px rgb(255, 255, 255),
    0 0 4px rgb(255, 255, 255),
    0 0 5px rgb(255, 255, 255);

  animation: flicker 1.2s infinite;
}

/* Subtle flicker for neon effect */
@keyframes flicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; }
  20%, 22%, 24%, 55% { opacity: 0.7; }
}


/* Floating text above tables */
.table-label {
  position: absolute;
  
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 5px black;
  pointer-events: none;
  transform: translate(-3%, -100%);
  z-index: 555; /* always above everything */
}


#popup-card {
  position: fixed;       /* stays on screen */
  top: 45%;
  left: 14%;
  width: 240px;          /* slightly bigger for game UI */
  height: 350px;
  max-width: 90vw;
  padding: 30px;
  border-radius: 10px;
  background: #1a1a1a;  /* dark, game-style background */
  border: 2px solid #00ffea; /* neon-style border */
  box-shadow: 0 0 10px #00ffea, 0 0 20px #00ffea, 0 0 30px #00ffea;
  color: #fff;
  text-align: center;
  font-family: 'Press Start 2P', monospace; /* pixel/game font */
  text-shadow: 0 0 0px #00ffea, 0 0 0px #00ffea;
  transform: translate(-50%, -50%);
  z-index: 999;         /* stays on top of everything */
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#popup-card.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -60%) scale(0.9);
}

#popup-card.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

#popup-card h2 {
  margin-bottom: 10px;
  font-size: 16px;
  color: #00ffea;
}

#popup-card p {
  font-size: 12px;
  color: #fff;
}

/* Existing styles remain as you provided. Below are additions and improvements for responsiveness */

/* Adjust instruction text for smaller screens */
@media (max-width: 768px) {
  #instruction-text {
    font-size: 18px;
    padding: 0 10px;
  }
  

  .table-label {
    font-size: 16px;
  }

  #popup-card {
    top: 30%;
    left: 50%;
    width: 90%;
    height: auto;
    max-height: 80vh;
    padding: 20px;
    border-radius: 8px;
  }

  #popup-card h2 {
    font-size: 14px;
  }

  #popup-card p {
    font-size: 10px;
  }
}

/* Additional rules for smaller phones */
@media (max-width: 480px) {
  #instruction-text {
    font-size: 16px;
  }

  .table-label {
    font-size: 14px;
  }

  #popup-card {
    width: 95%;
    top: 25%;
    padding: 15px;
  }

  #popup-card h2 {
    font-size: 12px;
  }

  #popup-card p {
    font-size: 10px;
  }
}

/* Ensuring the arrow controls adapt */
@media (max-width: 768px) {
  .arrow-controls {
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(2, 40px);
    gap: 4px;
    bottom: 10px;
  }
  .arrow-controls button {
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .arrow-controls {
    grid-template-columns: repeat(3, 35px);
    grid-template-rows: repeat(2, 35px);
    gap: 3px;
  }
  .arrow-controls button {
    font-size: 16px;
  }
}

/* General body responsiveness */
@media (max-width: 768px) {
  body, html {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  body, html {
    font-size: 12px;
  }
}
