/* --- Unified Game UI Wrapper --- */
.game-ui-wrapper {
  position: fixed;
  bottom: 3rem;
  right: 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  z-index: 6000;
  pointer-events: none;
  
  /* Initial State */
  opacity: 0;
  transform: translateY(60px);
  
  /* Transition Properties */
  transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), 
              opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.bin-dock {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1.2rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.08);
  opacity: 0.8;
  pointer-events: auto;
  transition: all 0.5s var(--transit-smooth);
  will-change: transform, opacity;
}

.bin-dock.active {
  opacity: 1;
  transform: scale(1.08);
  background: white;
}

/* --- Scroll Top Button --- */
.scroll-top-btn {
  width: 32px;
  height: 32px;
  background: var(--clr-bg);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 50%;
  color: var(--clr-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  opacity: 0;
  visibility: hidden;
  max-width: 0;
  margin-right: 0;
  transform: scale(0.5);
  transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
  overflow: hidden;
  flex-shrink: 0;
}

.scroll-top-btn.visible {
  opacity: 1;
  visibility: visible;
  max-width: 50px;
  margin-right: 0rem;
  margin-left: -0.2rem;
  transform: scale(1);
  border-color: rgba(255, 255, 255, 0.6);
}

.scroll-top-btn:hover {
  transform: scale(1.15);
  background: var(--clr-accent) !important;
  color: white !important;
}

.bin-wrapper {
  position: relative;
  width: 26px;
  height: 42px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.bin-wrapper:hover,
.bin-wrapper.target-match {
  transform: translateY(-5px);
}

.bin-wrapper.target-match .wheelie-bin {
  filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.2));
}

/* Wheelie Bin SVG Styling */
.wheelie-bin {
  width: 100%;
  height: 100%;
}

.bin-body {
  transition: fill 0.3s ease;
}
.bin-lid {
  filter: brightness(0.9);
}
.bin-lid-handle {
  filter: brightness(0.7);
}
.bin-wheel {
  fill: #333;
}

/* Bin Color Classes - Vibrant & Prominent */
.fill-green .bin-body,
.fill-green .bin-lid,
.fill-green .bin-lid-top {
  fill: #2e7d32;
}
.fill-blue .bin-body,
.fill-blue .bin-lid,
.fill-blue .bin-lid-top {
  fill: #1565c0;
}
.fill-red .bin-body,
.fill-red .bin-lid,
.fill-red .bin-lid-top {
  fill: #c62828;
}
.fill-e-waste .bin-body,
.fill-e-waste .bin-lid,
.fill-e-waste .bin-lid-top {
  fill: #f9a825;
}
.fill-black .bin-body,
.fill-black .bin-lid,
.fill-black .bin-lid-top {
  fill: #212121;
}

.bin-wheel-outer {
  fill: #111;
}
.bin-wheel-inner {
  fill: #424242;
}
.bin-lid {
  filter: brightness(1.15);
}
.bin-lid-top {
  filter: brightness(1.3);
}

/* Animated Lid Logic */
.bin-lid-group {
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-origin: 20% 20%;
}

.bin-wrapper.target-match .bin-lid-group {
  transform: rotate(-35deg) translateY(-5px);
}

.bin-icon-group {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Bin Info Cards */
.bin-info-card {
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  width: 160px;
  padding: 0.6rem 0.8rem;
  background: white;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
  text-align: center;
  pointer-events: none;
  z-index: 2200;
}

.bin-info-card::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: white;
}

/* --- Footer Visibility Logic (Hide Bins, Show Scroll) --- */
.bin-dock.dock-hidden {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    border: none !important;
    /* Do NOT use pointer-events: none here, or it kills the child button */
}

.bin-dock.dock-hidden .bin-wrapper {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.bin-dock.dock-hidden .scroll-top-btn {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    background: #FFFFFF !important;
    border: none !important;
    color: var(--clr-accent) !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    max-width: 50px;
    width: 40px;
    height: 40px;
}

.bin-dock.dock-hidden .scroll-top-btn:hover {
    background: #FFFFFF !important;
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
}

.bin-info-card strong {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--clr-text-main);
  margin-bottom: 0.1rem;
}

.bin-info-card span {
  display: block;
  font-size: 0.65rem;
  color: var(--clr-text-muted);
  line-height: 1.2;
}

.bin-wrapper.show-info .bin-info-card {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Game Hidden State */
.game-hidden .trash-item,
body.is-loading .trash-item,
body.reveal-active .trash-item {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: none !important;
}

/* --- Trash Item Styles (Image Based) --- */
.trash-item {
  position: absolute;
  width: 36px; /* Smaller Trash */
  height: 36px;
  z-index: 2050; /* Below header (99999) */
  cursor: grab;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.15));
  transition:
    opacity 0.3s ease,
    transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.trash-item.dragging {
  cursor: grabbing;
  z-index: 999999;
}

.trash-item.picked {
  outline: 2px solid var(--clr-accent);
  outline-offset: 5px;
  border-radius: 50%;
  animation: pulseBorder 1.5s infinite;
  z-index: 999999;
}

.trash-item.disposed {
  opacity: 0;
  transform: scale(0) translateY(50px);
}

.trash-item.locked-dim {
  opacity: 0.1;
  pointer-events: none;
  filter: grayscale(1);
}

@keyframes pulseBorder {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(0, 109, 91, 0.4);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(0, 109, 91, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(0, 109, 91, 0);
  }
}

/* --- Session Score --- */
.session-score-dock {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: white;
  background: var(--clr-accent);
  padding: 0.6rem 1.4rem;
  border-radius: 100px;
  box-shadow: 0 10px 30px rgba(0, 109, 91, 0.25);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 2400;
  pointer-events: auto;
  white-space: nowrap;
  transition: all 0.3s ease;
  margin-top: 1rem;
}

.session-score-dock:hover {
  background: white;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

/* Floating Feedback Animation */
.game-feedback {
  position: fixed;
  pointer-events: none;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  color: var(--clr-accent);
  z-index: 2100;
  animation: feedbackUp 1.2s ease-out forwards;
}

@keyframes feedbackUp {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: translateY(-60px);
    opacity: 0;
  }
}

/* Floating Hint */
.game-hint {
  position: fixed;
  pointer-events: none;
  background: #ff4b2b;
  color: white;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 999999; /* Stay on top */
  box-shadow: 0 8px 25px rgba(255, 75, 43, 0.4);
  animation: hintFadeCentered 2.5s ease-out forwards;
  white-space: nowrap;
  transform-origin: center bottom;
}

@keyframes hintFadeCentered {
  0% {
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
  }
  15% {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
  85% {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) translateY(-20px);
    opacity: 0;
  }
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
  .game-ui-wrapper {
    left: auto;
    right: 0;
    top: 20%;
    bottom: auto;
    width: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    transform: none;
  }

  .bin-dock {
    flex-direction: column;
    width: auto;
    max-width: none;
    gap: 1.2rem;
    padding: 1.5rem 0.8rem;
    border-radius: 30px 0 0 30px;
    border-right: none;
    transform: translateX(45px);
    opacity: 0.5;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .bin-dock.active,
  .bin-dock:hover {
    transform: translateX(0);
    opacity: 0.85;
    background: rgba(255, 255, 255, 0.6);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.08);
  }

  .bin-wrapper {
    width: 36px;
    height: 50px;
  }

  .bin-info-card {
    right: 120%;
    left: auto;
    bottom: 50%;
    transform: translateY(50%) translateX(10px);
    width: 120px;
  }

  .bin-info-card::after {
    top: 50%;
    left: 100%;
    transform: translateY(-50%);
    border-top-color: transparent;
    border-left-color: white;
  }

  .bin-wrapper.show-info .bin-info-card {
    transform: translateY(50%) translateX(0);
  }

  .session-score-dock {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0;
    z-index: 999999;
  }

  .game-hint {
    left: 50% !important;
    top: auto !important;
    bottom: 4.5rem !important; /* Closely stacked above the score */
    transform: translateX(-50%) !important;
  }

  /* Ensure scroll-top is fully visible when dock is hidden on mobile */
  .bin-dock.dock-hidden {
    transform: translateX(-15px) !important;
  }
}

/* Dragging Utilities */
body.game-dragging,
body.game-dragging * {
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  cursor: grabbing !important;
}

/* Game UI Entrance Animation */
body.hero-active .game-ui-wrapper {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
  transition-delay: 1.8s; /* Start after cards finish */
}

@media (max-width: 768px) {
  /* Prevent transform context on mobile so fixed score is viewport-relative */
  body.hero-active .game-ui-wrapper {
    transform: none !important;
  }
}
/* --- Dump Truck Reward Animation --- */
.dump-truck-container {
    position: fixed;
    bottom: 2.5rem; /* Aligned with bins */
    right: -300px;  /* Start off-screen */
    width: 220px;   /* Smaller truck */
    height: auto;
    z-index: 5500;
    pointer-events: none;
    will-change: transform, right;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dump-truck {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 8px 15px rgba(0,0,0,0.15));
}

.truck-smoke {
    position: absolute;
    bottom: 8px;
    right: 30px;
    width: 8px;
    height: 8px;
    background: rgba(120, 120, 120, 0.5);
    border-radius: 50%;
    pointer-events: none;
    z-index: 5400;
    filter: blur(4px);
}

@keyframes smoke-fade {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 0.5;
    }
    100% {
        transform: translate(25px, -35px) scale(2.5);
        opacity: 0;
    }
}

/* Bin Unload Animation */
@keyframes bin-unload {
    0% { transform: translateY(0) rotate(0); }
    30% { transform: translateY(-30px) rotate(-15deg); }
    70% { transform: translateY(-30px) rotate(-15deg); }
    100% { transform: translateY(0) rotate(0); }
}

.bin-unloading {
    animation: bin-unload 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
}

/* Suspensions & Motion */
.truck-driving {
    /* Reduced frequency and intensity */
    animation: truck-vibration 0.15s infinite alternate;
}

@keyframes truck-vibration {
    from { transform: translateY(0) rotate(0deg); }
    to { transform: translateY(-1px) rotate(0.2deg); }
}

.truck-idle {
    /* Removed rumble for a cleaner stop as requested */
    animation: none;
}

@media (max-width: 768px) {
    .dump-truck-container {
        width: 140px;
        bottom: 12%; 
    }
}

/* --- Drag Hint System --- */
.trash-item.hint-active {
    filter: drop-shadow(0 0 12px rgba(0, 109, 91, 0.45));
    animation: hint-bounce 2s infinite ease-in-out;
    cursor: grab;
}

@keyframes hint-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08) translateY(-5px); }
}

.game-onboarding-tooltip {
    position: fixed;
    padding: 8px 14px;
    background: white;
    color: var(--clr-text-main);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
    z-index: 999999;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(0, 109, 91, 0.1);
    animation: tooltip-float 2.5s ease-out forwards;
}

.game-onboarding-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: white;
}

@keyframes tooltip-float {
    0% {
        opacity: 0;
        transform: translate(-50%, 15px);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, 0);
    }
    85% {
        opacity: 1;
        transform: translate(-50%, 0);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -15px);
    }
}

.game-feedback.negative {
    color: #e74c3c !important;
    text-shadow: 0 0 10px rgba(231, 76, 60, 0.3);
}

.bin-wrapper.fail-shake {
    animation: bin-fail-shake 0.5s ease-in-out;
}

@keyframes bin-fail-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.trash-item.disposed-fail {
    opacity: 0;
    transform: scale(0.5) translateY(20px);
    transition: all 0.5s ease-in;
    pointer-events: none;
}
