/* General Setup */
:root {
  --green: #7e9a7f;
  --teal: #85c9c8;
  --coral: #e88c7d;
  --brown: #8a6a59;
  --cream: #f7f3e8;
  --font: "Fredoka One", cursive;
}

body {
  margin: 0;
  font-family: "Rock Salt", cursive;
  background-color: var(--cream);
  background-image: url("assets/jungle-bg.png");
  background-size: cover;
  background-position: center center;
  background-attachment: fixed;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 100vh;
  width: 100%;
  color: var(--brown);
}

/* --- KEY IMAGE SIZING RULE --- */
/* This is a general rule for all images to make them responsive */
img {
  max-width: 100%; /* Ensures image never overflows its container's width */
  height: auto; /* Maintains the image's aspect ratio */
  display: block; /* Removes extra space below the image */
}

/* Screen Management */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-direction: column;
  padding: 20px;
  box-sizing: border-box;
  transition: opacity 0.5s;
  overflow-y: auto;
}

.screen.active {
  display: flex;
}

.content {
  background: rgba(255, 255, 255, 0.7);
  padding: 20px;
  border-radius: 25px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

h1,
h2 {
  font-family: var(--font);
  color: var(--green);
  font-size: clamp(2rem, 8vw, 3.5rem);
  margin: 10px 0;
}

p {
  font-size: clamp(1rem, 4vw, 1.5rem);
}

/* Welcome & Thank You Screens */
.main-welcome-img {
  width: 60%;
  max-width: 300px; /* Will not get bigger than 300px */
}
.thank-you-img {
  width: 50%;
  max-width: 250px; /* Will not get bigger than 250px */
}
.signature {
  font-family: var(--font);
  color: var(--green);
  margin-top: 10px;
}

button {
  font-family: var(--font);
  font-size: 1.5rem;
  padding: 15px 30px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  background-color: var(--coral);
  color: white;
  box-shadow: 0 4px 0px #c06c5e;
  transition: all 0.1s ease-in-out;
}

button:active {
  transform: translateY(4px);
  box-shadow: none;
}

.pulsing-button {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* Game Hub */
.game-hub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  width: 100%;
  max-width: 600px;
}

.game-choice {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  padding: 15px;
  cursor: pointer;
  transition: transform 0.2s;
  display: flex; /* Helps vertically align content */
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.game-choice:hover {
  transform: scale(1.05);
}
.game-choice img {
  height: 80px; /* Set a fixed height for the image area */
  width: auto; /* Width will scale automatically */
  max-width: 100px;
  object-fit: contain; /* Ensures the image fits inside the height without stretching */
}
.game-choice p {
  font-family: var(--font);
  margin: 5px 0 0 0;
  color: var(--brown);
  font-size: clamp(0.9rem, 3.5vw, 1.2rem);
}
.hub-button {
  margin-top: 25px;
  background-color: var(--teal);
  box-shadow: 0 4px 0px #67a2a1;
}

/* Game Screen & Back Button */
.back-button {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1000;
  font-size: 1.2rem;
  padding: 10px 20px;
  background-color: var(--green);
  box-shadow: 0 4px 0px #5d7e5e;
}

#game-container {
  width: 100%;
  height: 100%;
  min-height: 80vh;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  padding-top: 60px; /* Space for back button */
  box-sizing: border-box;
}

/* Memory Game Sizing */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 400px;
  margin: auto;
}
.memory-card {
  width: 100px;
  height: 100px;
  perspective: 1000px; /* For 3D flip effect */
}
.memory-card .card-face img {
  width: 90%;
  height: 90%;
  object-fit: contain; /* Ensures dino images fit perfectly inside the card */
}

/* Fossil Dig & Sticker Book Canvas Sizing */
#fossil-dig-canvas,
#sticker-book-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 95vw;
  max-height: 90vh;
  border-radius: 20px;
  cursor: crosshair;
}

/* Sticker Book Tray Sizing */
#sticker-tray {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 500px;
  background: rgba(255, 255, 255, 0.8);
  padding: 10px;
  border-radius: 15px 15px 0 0;
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  height: 70px; /* Set a fixed height for the tray */
  box-sizing: border-box;
  overflow-x: auto;
}

#sticker-tray img {
  height: 100%; /* Image will fill the height of the tray */
  width: auto; /* Width will scale to maintain aspect ratio */
  cursor: grab;
}

#sticker-tray img:active {
  cursor: grabbing;
}

/* This class will be added by JS to stickers dragged onto the canvas */
.placed-sticker {
  position: absolute;
  z-index: 1000;
  width: 100px; /* Set a default size for placed stickers */
  height: auto;
  cursor: grab;
}
.placed-sticker:active {
  cursor: grabbing;
}

/* -- CSS TAMBAHAN UNTUK DINO EGG HATCH -- */

.hatched-dino {
  position: absolute;
  width: 25vw;
  max-width: 100px;
  animation: dino-pop-fade 1.5s forwards;
}

@keyframes dino-pop-fade {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

/* -- PUZZLE GAME STYLES -- */
.puzzle-container {
  width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  margin-bottom: 30px;
}

.puzzle-board {
  width: 90%;
  max-width: 500px;
  aspect-ratio: 1 / 1;
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  position: relative;
  display: grid;
  padding: 10px;
  box-sizing: border-box;
  margin-bottom: 20px;
}

.puzzle-controls {
  width: 90%;
  max-width: 500px;
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  padding: 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: center;
  align-items: center;
}

.puzzle-controls label {
  font-family: var(--font);
  color: var(--brown);
  margin-right: 5px;
}

.puzzle-controls select {
  font-family: var(--font);
  padding: 5px 10px;
  border-radius: 10px;
  border: 2px solid var(--teal);
  background-color: white;
  color: var(--brown);
}

.puzzle-start-btn {
  font-size: 1.2rem;
  padding: 8px 15px;
  background-color: var(--teal);
  box-shadow: 0 3px 0px #67a2a1;
}

.puzzle-preview {
  width: 100%;
  max-width: 150px;
  margin: 10px auto 0;
}

.puzzle-preview img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 2px solid var(--teal);
}

.puzzle-piece {
  position: relative;
  background-size: cover;
  background-position: center;
  cursor: grab;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: transform 0.1s;
  aspect-ratio: 1 / 1;
}

.puzzle-piece:hover {
  transform: scale(1.05);
  z-index: 10;
}

.puzzle-piece.dragging {
  opacity: 0.8;
  z-index: 1000;
}

@media (max-width: 768px) {
  .puzzle-container {
    flex-direction: column-reverse;
    padding: 10px;
    margin-bottom: 50px;
  }

  .puzzle-board {
    width: 95%;
    margin-top: 20px;
    max-width: 90vmin;
  }

  .puzzle-controls {
    width: 95%;
    padding: 10px;
    margin-bottom: 15px;
  }

  .puzzle-preview {
    max-width: 100px;
  }

  .back-button {
    top: 10px;
    left: 10px;
    font-size: 1rem;
    padding: 8px 15px;
  }

  .game-hub-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  #game-container {
    padding-top: 50px;
  }
}
