/* ==========================================
   VinhForest Wildlife Rescue CSS Stylesheet
   ========================================== */

/* --- Fonts & CSS Variables --- */
:root {
  --primary-green: #4CAF50;
  --dark-green: #2E7D32;
  --light-green: #81C784;
  --wood-brown: #8D6E63;
  --dark-wood: #5D4037;
  --gold: #FFD700;
  --bright-gold: #FFE082;
  --accent-red: #E53935;
  --bg-dark: #121A13;
  --text-light: #FFFFFF;
  --text-dark: #2E1A0F;
  --font-playful: "Fredoka", "Outfit", "Segoe UI", sans-serif;
  --transition-speed: 0.3s;
}

/* --- Universal Reset --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-playful);
  background: radial-gradient(circle at center, #1b3d22 0%, #0a140d 100%);
  color: var(--text-light);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  padding: 20px;
}

/* --- Page Wrapper & Responsiveness --- */
.page-wrapper {
  width: 100%;
  max-width: 1024px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* --- Main Dashboard Container --- */
#game-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1024 / 682;
  background-image: url('assets/background.jpg');
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8),
              0 0 40px rgba(76, 175, 80, 0.2);
  overflow: hidden;
  user-select: none;
  border: 4px solid #3d2314; /* Wooden outer frame */
}

/* --- Audio Control Overlay --- */
.audio-controls {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  z-index: 1000;
}

.audio-controls button {
  background: rgba(46, 125, 50, 0.85);
  border: 2px solid var(--gold);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transition: all 0.2s ease;
}

.audio-controls button:hover {
  transform: scale(1.1);
  background: var(--dark-green);
}

.audio-controls button.muted {
  background: rgba(141, 110, 99, 0.8);
  border-color: #757575;
}

/* --- Logo Click Zone & Paw Badge --- */
.logo-click-zone {
  position: absolute;
  left: 29.5%;
  top: 1%;
  width: 41%;
  height: 20%;
  cursor: pointer;
  z-index: 50;
  border-radius: 20px;
}

.paw-badge-zone {
  position: absolute;
  left: 47%;
  top: 17%;
  width: 6%;
  height: 10%;
  cursor: pointer;
  z-index: 55;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.paw-badge-zone::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.6);
  animation: pulse-ring 2s infinite;
  opacity: 0;
  transition: opacity 0.3s;
}

.paw-badge-zone:hover::before {
  opacity: 1;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.7);
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
  }
  70% {
    transform: scale(1.3);
    box-shadow: 0 0 0 12px rgba(76, 175, 80, 0);
  }
  100% {
    transform: scale(1.3);
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
  }
}

/* --- Wooden Sign (Team Up) floating animation --- */
.interactive-sign {
  position: absolute;
  cursor: pointer;
  z-index: 60;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.sign-teamup {
  left: 1.5%;
  top: 1.5%;
  width: 22%;
  height: 25%;
  border-radius: 12px;
  animation: float-sign 4s ease-in-out infinite alternate;
}

@keyframes float-sign {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(6px) rotate(1deg); }
}

.sign-teamup:hover {
  filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.6));
}

.sign-glow {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  border-radius: inherit;
  box-shadow: inset 0 0 15px rgba(255, 255, 255, 0);
  transition: box-shadow 0.3s;
}

.interactive-sign:hover .sign-glow {
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.3);
}

/* --- Today's Rescues Checklist Overlays --- */
.rescues-board {
  position: absolute;
  left: 83.3%;
  top: 29.5%;
  width: 15.3%;
  height: 44.5%;
  z-index: 60;
}

.checklist-container {
  position: relative;
  width: 100%;
  height: 100%;
  padding-top: 12%; /* Offset down to line up with list items */
  display: flex;
  flex-direction: column;
}

.checklist-item {
  position: relative;
  width: 90%;
  height: 14%;
  margin-left: 5%;
  margin-bottom: 7%;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.custom-checkbox {
  position: absolute;
  left: 1%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: all 0.25s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.checklist-item:hover .custom-checkbox {
  background: rgba(76, 175, 80, 0.3);
  border-color: var(--primary-green);
  box-shadow: 0 0 8px var(--primary-green);
}

/* Checked state overlay */
.checklist-item.checked .custom-checkbox {
  background: rgba(76, 175, 80, 0.7);
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(76, 175, 80, 0.8);
}

.checklist-item.checked .custom-checkbox::after {
  content: '✓';
  color: var(--gold);
  font-weight: bold;
  font-size: 14px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* --- Character Hitboxes --- */
.char-zone {
  position: absolute;
  cursor: pointer;
  z-index: 40;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.char-zone:hover {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 25px 6px rgba(255, 255, 255, 0.65), 
              inset 0 0 15px rgba(255, 255, 255, 0.3);
  transform: scale(1.05) translateY(-5px);
  z-index: 45;
}

/* Character Specific Coordinates (percentages of 1024x682) */
.char-fox {
  left: 22.3%;
  top: 34.5%;
  width: 11.5%;
  height: 23%;
  border-radius: 35% 35% 50% 50%;
}

.char-owl-doc {
  left: 32.5%;
  top: 32.2%;
  width: 14%;
  height: 35.8%;
  border-radius: 40% 40% 45% 45%;
}

.char-panda {
  left: 46%;
  top: 35%;
  width: 12.8%;
  height: 32%;
  border-radius: 40% 40% 45% 45%;
}

.char-rabbit {
  left: 58.2%;
  top: 37.3%;
  width: 10.5%;
  height: 25.5%;
  border-radius: 35% 35% 50% 50%;
}

.char-cat {
  left: 69.5%;
  top: 33%;
  width: 11%;
  height: 16%;
  border-radius: 40%;
}

.char-deer {
  left: 16.5%;
  top: 51.5%;
  width: 16%;
  height: 21%;
  border-radius: 50% 50% 40% 40%;
}

.char-raccoon {
  left: 33.5%;
  top: 56.5%;
  width: 11.5%;
  height: 17%;
  border-radius: 45%;
}

.char-baby-owl {
  left: 47.8%;
  top: 56.5%;
  width: 11%;
  height: 17%;
  border-radius: 50%;
}

.char-turtle {
  left: 59.2%;
  top: 58.5%;
  width: 13.5%;
  height: 14%;
  border-radius: 45%;
}

.char-crow {
  left: 81.3%;
  top: 48%;
  width: 12%;
  height: 20%;
  border-radius: 40%;
}

/* --- Mid-row signs (Explore & Upgrade descriptions) --- */
.sign-explore {
  left: 2.1%;
  top: 60.1%;
  width: 13.7%;
  height: 13%;
  border-radius: 8px;
}

.sign-upgrade {
  left: 84.1%;
  top: 62.3%;
  width: 13.7%;
  height: 13%;
  border-radius: 8px;
}

.interactive-sign:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

/* --- Bottom Steps Cards --- */
.step-card {
  position: absolute;
  cursor: pointer;
  z-index: 60;
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.step-card:hover {
  box-shadow: 0 0 25px 5px var(--gold),
              inset 0 0 15px rgba(255, 215, 0, 0.5);
  transform: translateY(-5%) scale(1.04);
}

.card-glow {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  border-radius: inherit;
  border: 3px solid transparent;
  transition: all 0.3s;
}

.step-card:hover .card-glow {
  border-color: var(--gold);
}

/* Coordinates for bottom step cards (y = 512 to 640, height = 18.7%) */
.card-explore {
  left: 1.2%;
  top: 75.0%;
  width: 13.0%;
  height: 18.7%;
}

.card-rescue {
  left: 16.0%;
  top: 75.0%;
  width: 13.0%;
  height: 18.7%;
}

.card-treat {
  left: 30.7%;
  top: 75.0%;
  width: 14.4%;
  height: 18.7%;
}

.card-care {
  left: 48.2%;
  top: 75.0%;
  width: 13.5%;
  height: 18.7%;
}

.card-release {
  left: 63.6%;
  top: 75.0%;
  width: 13.4%;
  height: 18.7%;
}

.card-grow {
  left: 78.6%;
  top: 75.0%;
  width: 18.0%;
  height: 18.7%;
}

/* --- Footer Menu bar --- */
.footer-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 5.6%;
  z-index: 70;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 10px;
}

.footer-btn {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.25s;
  padding: 0 8px;
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.footer-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--gold);
  transform: scale(1.08);
}

/* --- Character Tooltip --- */
.character-tooltip {
  position: absolute;
  z-index: 100;
  background: rgba(46, 26, 15, 0.95);
  border: 3px solid #8d6e63;
  border-radius: 12px;
  padding: 12px;
  width: 220px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6),
              0 0 15px rgba(141, 110, 99, 0.3);
  pointer-events: none;
  opacity: 0;
  transform: scale(0.8) translateY(10px);
  transition: opacity 0.2s, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.character-tooltip.active {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.tooltip-header {
  border-bottom: 2px solid #5d4037;
  padding-bottom: 5px;
  margin-bottom: 8px;
}

.tooltip-header h3 {
  font-size: 1.05rem;
  color: var(--gold);
}

.tooltip-header span {
  font-size: 0.75rem;
  color: var(--light-green);
  font-weight: bold;
  text-transform: uppercase;
}

.tooltip-body p {
  font-size: 0.8rem;
  line-height: 1.35;
  color: #f5f5f5;
}

/* --- Modals Styling --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: #f4ece1;
  border: 6px solid #4e342e; /* Hard wood border */
  border-radius: 20px;
  width: 90%;
  max-width: 480px;
  color: var(--text-dark);
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  overflow: hidden;
  position: relative;
  transform: scale(0.7);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-box {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(0,0,0,0.1);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.1rem;
  color: var(--text-dark);
  transition: all 0.2s;
  z-index: 10;
}

.modal-close:hover {
  background: var(--accent-red);
  color: white;
}

.modal-header {
  padding: 20px;
  text-align: center;
  border-bottom: 4px solid #4e342e;
}

.modal-header h2 {
  font-size: 1.8rem;
  color: white;
  text-shadow: 2px 2px 0px rgba(0,0,0,0.4);
}

/* Wood headers colors */
.yellow-wood { background: #fbc02d; }
.green-wood { background: #388e3c; }
.red-wood { background: #d32f2f; }
.orange-wood { background: #f57c00; }
.blue-wood { background: #1976d2; }
.gold-wood { background: #d4af37; }
.dark-wood { background: #5d4037; }

.modal-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-content p {
  font-size: 1rem;
  line-height: 1.5;
  color: #4e342e;
}

.modal-stats {
  background: rgba(141, 110, 99, 0.1);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid rgba(141, 110, 99, 0.2);
}

.stat-box {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
}

.stat-box i {
  color: var(--dark-green);
  width: 20px;
}

.btn-play {
  background: linear-gradient(to bottom, #81c784, #388e3c);
  color: white;
  border: 3px solid #1b5e20;
  border-radius: 12px;
  padding: 12px 24px;
  font-family: var(--font-playful);
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
  box-shadow: 0 6px 0px #1b5e20, 0 10px 15px rgba(0,0,0,0.2);
  transition: all 0.15s ease;
  align-self: center;
  width: 100%;
  max-width: 250px;
  margin-top: 10px;
}

.btn-play:hover {
  background: linear-gradient(to bottom, #a5d6a7, #4caf50);
}

.btn-play:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0px #1b5e20, 0 4px 6px rgba(0,0,0,0.2);
}

/* Signup form in teamup sign modal */
.signup-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.signup-form input {
  padding: 12px;
  border-radius: 8px;
  border: 2px solid #8d6e63;
  font-family: var(--font-playful);
  font-size: 1rem;
}

/* Toast Notifications */
.toast-notification {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark-green);
  color: white;
  border: 3px solid var(--gold);
  border-radius: 20px;
  padding: 12px 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: bold;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  z-index: 3000;
  transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-notification.active {
  bottom: 30px;
}

.animate-spin {
  animation: spin 3s linear infinite;
}

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

/* --- Ranger Account Controls (top-left) --- */
.user-controls {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
}

#auth-open {
  background: rgba(46, 125, 50, 0.85);
  border: 2px solid var(--gold);
  color: white;
  height: 44px;
  padding: 0 18px;
  border-radius: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-playful);
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transition: all 0.2s ease;
}

#auth-open:hover {
  transform: scale(1.05);
  background: var(--dark-green);
}

#auth-open.hidden {
  display: none;
}

.user-chip {
  display: none;
  align-items: center;
  gap: 10px;
  background: rgba(46, 26, 15, 0.9);
  border: 2px solid var(--gold);
  border-radius: 22px;
  height: 44px;
  padding: 0 6px 0 16px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.user-chip.active {
  display: flex;
}

.user-chip-name {
  font-weight: 700;
  color: var(--bright-gold);
  font-size: 0.95rem;
}

.user-chip-points {
  background: rgba(76, 175, 80, 0.25);
  border: 1px solid var(--primary-green);
  color: var(--light-green);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
}

#logout-btn {
  background: rgba(229, 57, 53, 0.2);
  border: 1px solid transparent;
  color: #ef9a9a;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s;
}

#logout-btn:hover {
  background: var(--accent-red);
  color: white;
}

/* --- Auth Modal (tabs + forms) --- */
.auth-tabs {
  display: flex;
  gap: 8px;
  background: rgba(141, 110, 99, 0.15);
  border-radius: 12px;
  padding: 6px;
}

.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 8px;
  font-family: var(--font-playful);
  font-size: 1rem;
  font-weight: 600;
  color: #6d4c41;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--dark-green);
  color: white;
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: flex;
}

.auth-hint {
  font-size: 0.85rem !important;
  text-align: center;
  color: #795548 !important;
}

.form-message {
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 1.2em;
  margin: 0;
}

.form-message.error {
  color: var(--accent-red) !important;
}

.form-message.success {
  color: var(--dark-green) !important;
}

/* Sound Effect Indicator */
.sfx-indicator {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: rgba(0,0,0,0.8);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  z-index: 2500;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.sfx-indicator.show {
  opacity: 1;
}

/* ==========================================
   Mobile Layout (max-width: 767px)
   Desktop (>= 768px) is intentionally untouched.
   ========================================== */
@media (max-width: 767px) {
  html,
  body {
    width: 100%;
    min-height: 100%;
  }

  body {
    display: block;
    padding: 0;
    overflow-x: clip; /* last-resort guard; real overflow fixes are below */
  }

  .page-wrapper {
    width: 100%;
    max-width: none;
    padding: 92px 12px 24px; /* clears the fixed 44px control bars (16px top + 44px + gap) */
    display: block;
  }

  #game-container {
    width: 100%;
    height: auto;
    aspect-ratio: 1024 / 682;
  }

  .user-controls {
    top: 16px;
    left: 16px;
  }

  .audio-controls {
    top: 16px;
    right: 16px;
  }

  /* Real overflow fix: long toast messages exceeded narrow viewports.
     bottom:-150px because wrapped 2-line toasts are taller than the
     default -60px hide offset and were peeking into the viewport. */
  .toast-notification {
    box-sizing: border-box;
    max-width: calc(100vw - 24px);
    font-size: 0.95rem;
    padding: 10px 18px;
    bottom: -150px;
  }

  .toast-notification.active {
    bottom: 16px;
  }

  /* Touch targets: minimum 44x44px */
  .user-chip {
    height: 48px; /* room for a 44px logout button inside the 2px border */
  }

  .user-chip #logout-btn {
    width: 44px;
    height: 44px;
  }

  .modal-box .modal-close {
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
  }

  /* Modals: keep inside viewport, scroll when taller than screen,
     center via auto margins (collapse to 0 when content overflows) */
  .modal-overlay {
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 0;
  }

  .modal-box {
    margin: auto;
    width: calc(100% - 24px);
    max-width: 480px;
  }

  .modal-header h2 {
    font-size: 1.4rem;
  }

  /* iOS: inputs below 16px trigger auto-zoom on focus */
  .signup-form input {
    font-size: 16px;
  }

  /* Footer labels collide at phone widths */
  .footer-btn {
    font-size: 0.5rem;
    letter-spacing: 0;
    padding: 0 4px;
  }
}
