body {
  background: #f4efe6;
  font-family: Arial, sans-serif;
}

#gameBox {
  width: 100%;
  max-width: 950px;
  height: 560px;
  background: #d8c3a5;
  border: 4px solid #7a5c3a;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

#fullscreenBtn {
  right: 15px;
  bottom: 15px;
  z-index: 100;
}

.menu-animal-card {
  width: 220px;
  background: white;
  border: 3px solid #555;
  border-radius: 14px;
  overflow: hidden;
}

.menu-animal-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
}

.menu-animal-card p {
  margin: 8px;
  font-weight: bold;
}

.habitat {
  height: 100%;
  padding-top: 20px;
  color: white;
  border: 2px solid black;
}

.forest {
  background-image: url("../images/forest-bg.png");
  background-size: cover;
  background-position: center;
}

.ocean {
  background-image: url("../images/ocean-bg.png");
  background-size: cover;
  background-position: center;
}

#gameTimer {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  color: black;
  padding: 8px 22px;
  border-radius: 20px;
  font-size: 1.6rem;
  font-weight: bold;
  z-index: 50;
  border: 3px solid black;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 55px 15px 15px;
  height: 100%;
  overflow-y: auto;
}

.preview-card {
  border-radius: 10px;
  padding: 6px;
  color: white;
  font-weight: bold;
  font-size: 0.8rem;
}

.preview-card img {
  width: 100%;
  height: 70px;
  object-fit: cover;
  border-radius: 8px;
}

.rescue-slots {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  gap: 6px;
  z-index: 40;
}

.slot {
  width: 42px;
  height: 42px;
  background: white;
  border: 3px solid black;
  border-radius: 8px;
}

.slot.busy {
  background: gray;
}





.score {
  font-size: 1.3rem;
  font-weight: bold;
}

.animalCard {
  position: absolute;
  width: 170px;
  min-height: 180px;
  padding: 10px;
  border: 4px solid white;
  border-radius: 14px;
  color: black;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3);
}

.animalCard img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
}

.modal-box {
  position: absolute;
  width: 85%;
  max-width: 650px;
  background: white;
  color: black;
  padding: 25px;
  border: 3px solid black;
  border-radius: 16px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: left;
  z-index: 200;
}

.close-btn {
  position: absolute;
  top: 25px;
  right: 15px;
}

#countdown {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 100px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 300;
}

#endScreen {
  position: absolute;
  inset: 0;
  background: white;
  z-index: 400;
}

#retryBtn {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
}

.end-half {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 2px solid black;
}

.end-half p {
  font-size: 4rem;
  font-weight: bold;
}

#credit p {
  margin: 3px;
  font-size: 1.1rem;
}

/* Phone layout */
@media (max-width: 767px) {
  #gameBox {
    height: 720px;
  }

  .habitat {
    height: 50%;
  }

  .animalCard {
    width: 140px;
    min-height: 160px;
    font-size: 0.85rem;
  }

  .animalCard img {
    height: 75px;
  }

  .modal-box {
    width: 92%;
    max-height: 85%;
    overflow-y: auto;
    font-size: 0.9rem;
  }

  #countdown {
    font-size: 70px;
  }

  .end-half {
    height: 50%;
  }
}



#gameTimer {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  color: black;
  padding: 8px 25px;
  border-radius: 25px;
  border: 3px solid black;
  font-size: 1.7rem;
  font-weight: bold;
  z-index: 80;
}

.forest {
  background-image: url("../images/forest-bg.jpg");
  background-size: cover;
  background-position: center;
}

.ocean {
  background-image: url("../images/ocean-bg.jpg");
  background-size: cover;
  background-position: center;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 60px 12px 12px;
}

.preview-card {
  color: white;
  font-size: 0.75rem;
  font-weight: bold;
  border-radius: 8px;
  padding: 5px;
}

.preview-card img {
  width: 100%;
  height: 65px;
  object-fit: cover;
  border-radius: 6px;
}

.rescue-slots {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  gap: 6px;
  z-index: 50;
}

.slot {
  width: 42px;
  height: 42px;
  background: white;
  border: 3px solid black;
  border-radius: 8px;
}

.slot.busy {
  background: gray;
}

.animalCard {
  background: #bdbdbd !important;
}

.animalCard {
  position: absolute;
  transition: transform 1.2s linear;
  z-index: 30;
}


#forestSide {
  background-image: url("../images/forest-bg.jpg") !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

#oceanSide {
  background-image: url("../images/ocean-bg.jpg") !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

#eventNotice {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: gold;
  color: black;
  border: 3px solid black;
  border-radius: 16px;
  padding: 15px 30px;
  font-size: 1.4rem;
  font-weight: bold;
  z-index: 350;
  text-align: center;
}

.winner-title {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;

  background: gold;
  color: black;

  border: 4px solid black;
  border-radius: 20px;

  padding: 12px 30px;

  font-size: 2rem;
  font-weight: bold;

  animation: winnerPop 0.5s ease;
}

@keyframes winnerPop {
  from {
    transform: translateX(-50%) scale(0);
  }

  to {
    transform: translateX(-50%) scale(1);
  }
}


#settingsBtn {
  right: 15px;
  bottom: 70px;
  z-index: 100;

  width: 48px;
  height: 48px;

  padding: 0;

  font-size: 24px;
}


#settingsPopup {
  position: absolute;
  inset: 0;

  display: flex;
  justify-content: center;
  align-items: center;

  background: rgba(0,0,0,.4);

  z-index: 1000;
}

.settings-content {
  background: white;
  width: 450px;
  min-height: 240px;

  border: 3px solid black;
  border-radius: 16px;

  padding: 30px;
  text-align: center;
}

.hidden {
  display: none !important;
}



#settingsBtn,
#fullscreenBtn {
  width: 48px;
  height: 48px;
  padding: 0;
  font-size: 24px;
}

#settingsBtn {
  right: 15px;
  bottom: 75px;
  z-index: 100;
}

#fullscreenBtn {
  right: 15px;
  bottom: 15px;
  z-index: 100;
}


#settingsBtn {
  position: absolute !important;
  right: 15px !important;
  bottom: 75px !important;
  z-index: 3000 !important;

  width: 48px !important;
  height: 48px !important;
  padding: 0 !important;

  font-size: 24px !important;
  line-height: 48px !important;

  pointer-events: auto !important;
  touch-action: manipulation;
}

#fullscreenBtn {
  z-index: 1100 !important;
}

#settingsPopup {
  position: absolute !important;
  inset: 0 !important;
  z-index: 2000 !important;
}

.settings-content {
  max-width: 90%;
}

#settingsBtn {
  touch-action: manipulation !important;
  pointer-events: auto !important;
  z-index: 5000 !important;
}

#settingsPopup {
  pointer-events: auto !important;
  z-index: 6000 !important;
}

.settings-content {
  pointer-events: auto !important;
}