:root {
  --ink: #173042;
  --muted: #5d7484;
  --green: #48b96b;
  --blue: #3b9be9;
  --yellow-paper: #d8aa50;
  --danger: #ef5d5d;
  --yellow: #ffd15f;
  --orange: #ff9851;
  --shadow: 0 12px 30px rgba(40, 66, 78, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-family: 'Nunito', sans-serif;
  color: var(--ink);
  background: #f0f8ff;
  /* Fallback */
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* ==========================================
   SCREEN ARCHITECTURE
   ========================================== */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.screen.active {
  display: flex;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.hidden-global {
  display: none !important;
}

/* ==========================================
   THEMES (Backgrounds)
   ========================================== */
#menuScreen {
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
  align-items: center;
  justify-content: center;
}

.theme-park {
  background: linear-gradient(180deg, #9ee7f2 0%, #d8f5dc 100%);
}

.theme-factory {
  background: linear-gradient(180deg, #747d8c 0%, #2f3542 100%);
  color: white;
}

.theme-factory .header-info p {
  color: #ced6e0;
}

.theme-boss {
  background: radial-gradient(circle at top, #eb4d4b, #130f40);
  color: white;
}

.theme-boss .header-info p {
  color: #ffcccc;
}

/* ==========================================
   UI COMPONENTS
   ========================================== */
.panel.glass {
  background: rgba(255, 255, 255, 0.95);
  padding: 35px;
  border-radius: 30px;
  text-align: center;
  max-width: 550px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  color: var(--ink);
}

.menu-panel h2 {
  font-size: 2.5rem;
  margin-top: 0;
  color: var(--green);
}

.menu-panel p {
  font-size: 1.2rem;
  color: var(--muted);
  margin-bottom: 30px;
}

.menu-options {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.menu-btn {
  display: flex;
  align-items: center;
  gap: 20px;
  background: white;
  border: 2px solid var(--muted);
  border-radius: 20px;
  padding: 15px 25px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.menu-btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.menu-icon {
  font-size: 3rem;
}

.menu-text strong {
  display: block;
  font-size: 1.4rem;
  color: var(--ink);
  margin-bottom: 5px;
}

.menu-text small {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.santai-btn {
  border-color: var(--green);
}

.santai-btn:hover {
  background: #f0fdf4;
}

.ekstrem-btn {
  border-color: var(--orange);
}

.ekstrem-btn:hover {
  background: #fff7ed;
}

.boss-btn {
  border-color: var(--danger);
}

.boss-btn:hover {
  background: #fef2f2;
}

/* In-Game HUD */
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 25px;
  font-size: 1.5rem;
  font-weight: 900;
  z-index: 10;
}

.score-box,
.level-indicator,
.hearts {
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 20px;
  border-radius: 99px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  color: var(--ink);
}

.level-indicator {
  font-size: 1.2rem;
  color: var(--green);
  letter-spacing: 2px;
}

.combo-text {
  color: var(--orange);
  font-size: 1rem;
  font-weight: 900;
}

.hearts {
  letter-spacing: 4px;
}

.back-btn {
  font-size: 1rem;
  padding: 10px 20px;
}

.header-info {
  text-align: center;
  z-index: 10;
}

.header-info h1 {
  margin: 0;
  font-size: 2.2rem;
  text-shadow: 0 2px 4px rgba(255, 255, 255, 0.3);
}

.header-info p {
  margin: 5px 0 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 1.1rem;
}

/* Bins */
.bins-container {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 25px;
  z-index: 10;
  flex-wrap: wrap;
}

.trash-bin {
  width: 120px;
  height: 140px;
  border: 4px dashed var(--muted);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.7);
  transition: transform 0.1s, background 0.1s;
  box-shadow: var(--shadow);
  color: var(--ink);
}

.trash-bin .bin-icon {
  font-size: 3rem;
}

.trash-bin .bin-label {
  font-weight: 900;
  font-size: 1rem;
  margin-top: 5px;
}

.trash-bin.organik {
  border-color: var(--green);
  color: var(--green);
}

.trash-bin.anorganik {
  border-color: var(--blue);
  color: var(--blue);
}

.trash-bin.kertas {
  border-color: var(--yellow-paper);
  color: var(--yellow-paper);
}

.trash-bin.b3 {
  border-color: var(--danger);
  color: var(--danger);
}

.trash-bin.drag-over {
  transform: scale(1.15);
  border-style: solid;
  background: rgba(255, 255, 255, 0.9);
}

/* Play Areas */
.items-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.picnic-area {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 300px;
  background: radial-gradient(ellipse at bottom, rgba(72, 185, 107, 0.4) 0%, transparent 70%);
}

.conveyor-area {
  position: absolute;
  bottom: 8%;
  width: 100%;
  height: 150px;
}

.conveyor-belt {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 70px;
  background: #555;
  border-top: 6px solid #444;
  border-bottom: 6px solid #333;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
  background-image: repeating-linear-gradient(90deg, transparent, transparent 50px, rgba(0, 0, 0, 0.2) 50px, rgba(0, 0, 0, 0.2) 100px);
  animation: beltMove 1.5s linear infinite;
}

@keyframes beltMove {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 100px 0;
  }
}

.danger-zone {
  position: absolute;
  right: -20px;
  bottom: 0;
  width: 120px;
  height: 150px;
  background: linear-gradient(90deg, transparent, rgba(239, 93, 93, 0.6));
  pointer-events: none;
}

/* Boss Area */
.boss-arena {
  position: absolute;
  top: 20%;
  width: 100%;
  height: 300px;
  pointer-events: none;
}

.moving-boss {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.boss-sprite {
  font-size: 8rem;
  filter: drop-shadow(0 20px 20px rgba(0, 0, 0, 0.8));
  transition: filter 0.2s, transform 0.2s;
}

.boss-monster.hurt .boss-sprite {
  filter: hue-rotate(90deg) brightness(2) drop-shadow(0 0 30px white);
}

.boss-monster.attacking .boss-sprite {
  transform: scale(1.3) translateY(-10px);
  filter: hue-rotate(-30deg) brightness(1.5) drop-shadow(0 20px 40px red);
}

.boss-name {
  font-weight: 900;
  font-size: 1.5rem;
  color: white;
  background: var(--danger);
  padding: 5px 15px;
  border-radius: 12px;
  margin-top: 10px;
  border: 2px solid white;
}

.boss-hp-bar-bg {
  width: 300px;
  height: 30px;
  background: #222;
  border-radius: 99px;
  margin-bottom: 10px;
  border: 4px solid white;
  overflow: hidden;
}

.boss-hp-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff416c, #ff4b2b);
  transition: width 0.2s;
}

.pollution-cloud {
  position: absolute;
  top: 0;
  font-size: 4rem;
  filter: brightness(0.2) opacity(0.8);
  cursor: pointer;
  pointer-events: auto;
  transform: translateX(-50%);
  animation: cloudWobble 1s ease-in-out infinite alternate;
  transition: filter 0.2s, transform 0.2s;
  z-index: 100;
}

.pollution-cloud:active {
  filter: brightness(2) sepia(1);
  transform: translateX(-50%) scale(1.2);
}

@keyframes cloudWobble {
  from { margin-left: -10px; }
  to { margin-left: 10px; }
}

.ammo-station {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 150px;
}

.ammo-belt {
  position: absolute;
  bottom: 20px;
  width: 100%;
  height: 60px;
  background: #333;
  border-top: 4px solid #555;
  background-image: repeating-linear-gradient(90deg, transparent, transparent 30px, rgba(255, 255, 255, 0.1) 30px, rgba(255, 255, 255, 0.1) 60px);
  animation: beltMove 2s linear infinite reverse;
}

/* Items */
.trash-item {
  position: absolute;
  bottom: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: white;
  padding: 10px 15px;
  border-radius: 16px;
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  transform: translate(-50%, 0);
  color: var(--ink);
}

#santaiScreen .trash-item {
  bottom: auto;
  transform: translate(-50%, -50%);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from {
    transform: translate(-50%, -50%) scale(0);
  }

  to {
    transform: translate(-50%, -50%) scale(1);
  }
}

.trash-item.bomb {
  background: #ffdbdb;
  border: 2px solid var(--danger);
  animation: pulseBomb 0.5s infinite alternate;
}

.trash-item.powerup {
  background: #fffde0;
  border: 2px solid var(--yellow);
  animation: pulsePower 0.5s infinite alternate;
}

@keyframes pulseBomb {
  to {
    filter: brightness(1.2);
    transform: translate(-50%, 0) scale(1.05);
    box-shadow: 0 0 15px var(--danger);
  }
}

@keyframes pulsePower {
  to {
    filter: brightness(1.2);
    transform: translate(-50%, 0) scale(1.1);
    box-shadow: 0 0 20px var(--yellow);
  }
}

.trash-item.dragging {
  cursor: grabbing !important;
  position: fixed !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) scale(1.2) !important;
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.5) !important;
  z-index: 9999 !important;
  animation: none !important;
}

.trash-item .trash-icon {
  font-size: 2.8rem;
  pointer-events: none;
}

.trash-item small {
  font-weight: 800;
  font-size: 0.8rem;
  pointer-events: none;
  margin-top: 4px;
  text-align: center;
  line-height: 1.1;
  max-width: 80px;
}

/* Overlays & Effects */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.button-group {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 20px;
}

.btn {
  padding: 15px 30px;
  border-radius: 16px;
  border: none;
  font-weight: 900;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.1s;
}

.btn:active {
  transform: scale(0.95);
}

.btn.primary {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: var(--ink);
  box-shadow: 0 10px 20px rgba(255, 152, 81, 0.3);
}

.btn.secondary {
  background: #e0e0e0;
  color: var(--ink);
}

.final-score {
  font-size: 1.5rem;
  margin: 20px 0;
  color: var(--muted);
}

.final-score strong {
  color: var(--ink);
  font-size: 3rem;
  display: block;
}

.weather-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
}

.weather-layer.rain {
  opacity: 1;
  background: repeating-linear-gradient(160deg, transparent, transparent 10px, rgba(255, 255, 255, 0.1) 10px, rgba(255, 255, 255, 0.2) 20px);
  animation: rainAnim 0.3s linear infinite;
}

.freeze-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 105;
  background: radial-gradient(circle, transparent 40%, rgba(17, 181, 209, 0.5) 100%);
  opacity: 1;
  transition: opacity 0.5s;
}

.floating-text {
  position: absolute;
  font-weight: 900;
  font-size: 2rem;
  pointer-events: none;
  animation: floatUp 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  z-index: 10000;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

@keyframes floatUp {
  0% {
    transform: translate(-50%, 0) scale(0.8);
    opacity: 1;
  }

  20% {
    transform: translate(-50%, -20px) scale(1.2);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -80px) scale(1);
    opacity: 0;
  }
}

.shake {
  animation: shakeAnim 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shakeAnim {

  10%,
  90% {
    transform: translate3d(-4px, 0, 0);
  }

  20%,
  80% {
    transform: translate3d(8px, 0, 0);
  }

  30%,
  50%,
  70% {
    transform: translate3d(-10px, 0, 0);
  }

  40%,
  60% {
    transform: translate3d(10px, 0, 0);
  }
}

.wind-shake {
  animation: windAnim 1s ease-in-out infinite alternate;
}

@keyframes windAnim {
  from {
    transform: translateX(-5px) rotate(-1deg);
  }

  to {
    transform: translateX(5px) rotate(1deg);
  }
}

/* ==========================================
   NEW PREMIUM FEATURES
   ========================================== */

/* 1. Stars & Trivia */
.stars-container {
  display: flex; justify-content: center; gap: 10px; margin: 10px 0 20px;
}
.star-icon {
  font-size: 3.5rem; color: #ccc; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
  transition: all 0.3s;
}
.star-icon.active {
  color: var(--yellow); filter: drop-shadow(0 4px 10px rgba(255, 209, 95, 0.6));
  animation: starPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes starPop { 0% { transform: scale(0); } 80% { transform: scale(1.2); } 100% { transform: scale(1); } }

.trivia-text {
  font-size: 1rem !important; color: var(--ink) !important; background: rgba(72, 185, 107, 0.1);
  padding: 15px; border-radius: 12px; border-left: 5px solid var(--green);
  text-align: left; margin-bottom: 25px !important; font-weight: 700;
}

/* 2. Toxic Barrel (Boss) */
.toxic-barrel {
  filter: brightness(1) opacity(1); animation: barrelFall 1.5s linear infinite;
  font-size: 3.5rem;
}
.toxic-barrel.hurt {
  animation: shakeAnim 0.2s cubic-bezier(.36,.07,.19,.97) both; filter: brightness(2) hue-rotate(90deg);
}
@keyframes barrelFall { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* 3. Night Mode Transition */
.theme-factory { transition: background 2s, color 2s; }
.theme-factory.night-mode {
  background: linear-gradient(180deg, #1a1c29 0%, #2f3542 100%);
}
.theme-factory.night-mode .conveyor-belt {
  background: #2a2a2a; border-top-color: var(--yellow); box-shadow: 0 0 20px rgba(255, 209, 95, 0.2);
}
.theme-factory.night-mode .header-info h1 {
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

/* 4. Avatar Selector */
.avatar-selector { margin: 15px 0 25px; }
.avatar-selector label { display: block; font-weight: 800; color: var(--muted); margin-bottom: 10px; }
.avatar-options { display: flex; justify-content: center; gap: 15px; }
.avatar-btn { font-size: 2.5rem; background: none; border: 3px solid transparent; border-radius: 50%; cursor: pointer; transition: all 0.2s; padding: 5px; filter: grayscale(1); opacity: 0.6; }
.avatar-btn:hover { opacity: 1; transform: scale(1.1); }
.avatar-btn.active { filter: grayscale(0); opacity: 1; border-color: var(--green); background: rgba(72, 185, 107, 0.1); transform: scale(1.15); box-shadow: 0 5px 15px rgba(72, 185, 107, 0.3); }

/* 5. Leaderboard */
.leaderboard-panel { margin-top: 30px; background: rgba(0,0,0,0.03); padding: 15px; border-radius: 20px; text-align: left; }
.leaderboard-panel h3 { margin: 0 0 10px; font-size: 1.1rem; color: var(--ink); text-align: center; }
.leaderboard-panel ol { margin: 0; padding-left: 30px; font-weight: 800; color: var(--muted); }
.leaderboard-panel li { margin-bottom: 5px; font-size: 1.1rem; color: var(--orange); }

/* 6. Quiz Item */
.trash-item.quiz { background: #e0f7fa; border: 2px solid var(--blue); animation: pulseQuiz 1s infinite alternate; }
@keyframes pulseQuiz { to { box-shadow: 0 0 20px var(--blue); transform: translate(-50%, 0) scale(1.1); } }