/* General Body and Font Styles */
body {
  font-family: Arial, Helvetica, sans-serif;
  text-align: center;
  margin: 0;
  background: url("../../bg.webp");
  background-position: center;
  background-size: contain;
  font-size: 1.2em; /* Slightly smaller base font for better responsiveness */
  position: relative;
  font-family: "Press Start 2P", cursive; /* Retro game font */
  color: #574908; /* Light color for text */
  overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Game Fonts */
.game-font {
  font-family: "Fredoka", sans-serif;
}
.game-title {
  font-family: "Fredoka", sans-serif;
  color: #574908; /* Bright yellow for title */
  margin-top: 10px;
  margin-bottom: 20px;
  font-size: 2em; /* Adjust for responsiveness */
}

/* Dashboard Styles */
#dashboard {
  padding: 15px;
  margin-bottom: 20px;
}

.dashboard-panel {
  padding: 10px 15px;
  background-color: rgba(44, 62, 80, 0.8); /* Dark blue-gray background */
  border-radius: 8px;
  display: inline-block; /* For assist icons to stay inline */
  margin: 5px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.score-panel {
  color: #ffeb3b; /* Yellow for score */
  font-size: 1.1em;
}
#highscore {
  color: #f39c12; /* Orange for highscore */
}

.assist-panel {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.assist-icon {
  max-width: 40px;
  height: auto;
  margin: 0 5px;
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
  transition: transform 0.2s ease-in-out;
}
.assist-icon:hover {
  transform: scale(1.1);
  cursor: pointer;
}
.assist-count {
  font-size: 0.9em;
  color: #ecf0f1;
  margin-right: 15px;
}

/* Time Bar Progress */
.game-progress-bar {
  height: 30px;
  border-radius: 15px;
  background-color: #b99d27;
  margin: 0;
}
#time-bar {
  border-radius: 12px;
  background-color: #2ecc71; /* Green by default */
  transition: width 0.3s ease-in-out, background-color 0.3s ease-in-out;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.3);
}
#time-bar.progress-bar-warning {
  background-color: #f39c12; /* Orange for warning */
}
#time-bar.progress-bar-danger {
  background-color: #e74c3c; /* Red for critical */
}

/* Game Stage (Images Area) */
#images-area {
  padding: 0 15px;
}

#game-stage {
  display: flex;
  flex-wrap: wrap; /* Allow wrapping for responsiveness */
  justify-content: center;
  gap: 20px; /* Space between images */
  margin: 20px auto;
  max-width: 1280px; /* Max width for the game stage */
}

.tight-fit {
  position: relative;
  width: 100%;
  height: auto;
  max-width: 610px; /* Base width for coordinate system */
  aspect-ratio: 675 / 527; /* Maintain aspect ratio */
  overflow: visible; /* Allow wood frame to show */
  /* Wood frame styling */
  background-image: url("../img/wood-frame.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  padding: 12px;
  box-sizing: border-box;
  border-radius: 16px;
}

/* Inner game image content */
.game-image-content {
  position: absolute;
  top: 12px;
  left: 12px;
  width: calc(100% - 24px); /* Full width minus padding */
  height: calc(100% - 24px); /* Full height minus padding */
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 0;
  border-radius: 25px;
}

canvas {
  position: absolute;
  top: 12px;
  left: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  z-index: 2; /* Above background image and game-image-content */
  cursor: crosshair; /* More game-like cursor */
  border-radius: 25px;
}

#countdown-timer {
  font-size: 10em; /* Reduced for better fit */
  color: #e74c3c; /* Red for urgency */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%); /* Center perfectly */
  z-index: 10;
  background-color: rgba(0, 0, 0, 0.7); /* Darker, more solid background */
  border: 3px solid #f39c12; /* Orange border */
  border-radius: 15px;
  padding: 20px 40px;
  box-shadow: 0 0 30px rgba(231, 76, 60, 0.7); /* Red glow */
  animation-duration: 1s; /* Faster pulse */
}

/* Success/Game Over Modal Styles */
.success-modal {
  width: min(400px, 90vw);
  background: #f8f7eb;
  border-radius: 20px;
  padding: 40px 30px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  border: 1px solid #e8e6d4;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.success-title {
  font-family: "Fredoka", sans-serif;
  font-size: clamp(28px, 6vw, 36px);
  font-weight: 500;
  color: #574908;
  margin: 0;
}

.stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.star {
  filter: drop-shadow(0 2px 4px rgba(255, 215, 0, 0.3));
}

.star.small {
  font-size: 48px;
}

.star.large {
  font-size: 72px;
}

.points-display {
  display: flex;
  align-items: center;
  gap: 4px;
}

.points-number {
  font-family: "Fredoka", sans-serif;
  font-size: clamp(40px, 8vw, 56px);
  font-weight: 500;
  color: #574908;
}

.points-label {
  font-family: "Fredoka", sans-serif;
  font-size: clamp(20px, 4vw, 24px);
  font-weight: 400;
  color: #574908;
}

.restart-btn {
  padding: 14px 100px;
  background: linear-gradient(180deg, #b99d27 0%, #c7b052 100%);
  border: 2px solid #b99d27;
  border-radius: 50px;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.restart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

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

/* Lose Modal Styles */
.lose-modal .success-title {
  color: #c44536;
}

.lose-icon {
  font-size: 64px;
  line-height: 1;
}

/* Gameplay Image Backgrounds (No change needed here, assuming paths are correct) */
.img1a {
  background-image: url("../img/img1a.jpg");
}
.img1b {
  background-image: url("../img/img1b.jpg");
}
.img2a {
  background-image: url("../img/img2a.jpg");
}
.img2b {
  background-image: url("../img/img2b.jpg");
}
.img3a {
  background-image: url("../img/img3a.jpg");
}
.img3b {
  background-image: url("../img/img3b.jpg");
}
.img4a {
  background-image: url("../img/img4a.jpg");
}
.img4b {
  background-image: url("../img/img4b.jpg");
}
.img5a {
  background-image: url("../img/img5a.jpg");
}
.img5b {
  background-image: url("../img/img5b.jpg");
}

.modal-dialog {
  display: flex;
  justify-content: center;
}

/* Responsive Adjustments */
@media (max-width: 991px) {
  /* For medium devices and below */
  .game-title {
    font-size: 2em;
    margin-bottom: 15px;
  }
  .dashboard-panel {
    padding: 8px 10px;
    font-size: 0.9em;
  }
  .assist-panel {
    justify-content: center;
  }
  .assist-icon {
    max-width: 35px;
  }
  .assist-count {
    margin-right: 10px;
  }
  #game-stage {
    gap: 15px;
    margin-top: 15px;
  }
  .tight-fit {
    max-width: 90%; /* Take up more width on smaller screens */
    margin: auto;
  }
  #countdown-timer {
    font-size: 8em;
    padding: 15px 30px;
  }
}

@media (max-width: 767px) {
  /* For small devices and below (mobile) */
  .game-title {
    font-size: 1.5em;
    margin-top: 5px;
    margin-bottom: 10px;
  }
  #dashboard .row .col-xs-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }
  #dashboard .row .col-xs-12 {
    flex: 0 0 100%;
    max-width: 100%;
    order: -1; /* Push title to the top on mobile */
  }
  .dashboard-panel {
    font-size: 0.8em;
    margin: 3px;
  }
  .assist-icon {
    max-width: 30px;
  }
  .assist-count {
    margin-right: 8px;
  }
  .game-progress-bar {
    height: 25px;
  }
  #game-stage {
    gap: 10px;
    margin-top: 10px;
  }
  .tight-fit {
    max-width: 95%; /* Even wider on very small screens */
  }
  #countdown-timer {
    font-size: 6em;
    padding: 10px 20px;
    width: 80%; /* Allow more text on a single line */
  }
}

@media (max-width: 575px) {
  /* Extra small devices (portrait phones) */
  body {
    font-size: 1em;
  }
  .game-title {
    font-size: 1.2em;
  }
  .score-panel,
  .assist-panel {
    font-size: 0.7em;
    padding: 5px 8px;
  }
  .assist-icon {
    max-width: 25px;
  }
  #countdown-timer {
    font-size: 4em;
    padding: 8px 15px;
  }
  #videoPopUp .modal-dialog {
    margin: 10px;
  }
  #restartGameBtn {
    padding: 10px 20px;
    font-size: 1em;
  }

  #dashboard {
    margin-bottom: 0px;
  }

  #game-stage {
    margin: 0px auto;
    max-width: 1280px;
    display: grid;
    grid-template-columns: 1fr;
  }

  .restart-btn {
    padding: 14px 50px;
  }
}
