/* ===== Design Tokens ===== */
:root {
  --font-primary: 'Outfit', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* Background */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);

  /* Bin colours */
  --green: #22c55e;
  --green-glow: rgba(34, 197, 94, 0.3);
  --blue: #3b82f6;
  --blue-glow: rgba(59, 130, 246, 0.3);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.3);
  --black-bin: #6b7280;
  --black-glow: rgba(107, 114, 128, 0.3);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Accent */
  --accent: #a78bfa;
  --accent-glow: rgba(167, 139, 250, 0.25);

  /* Misc */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow-card: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-popup: 0 12px 48px rgba(0,0,0,0.6);
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* Animated background mesh */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 20% 10%, rgba(34,197,94,0.08), transparent),
    radial-gradient(ellipse 500px 500px at 80% 20%, rgba(59,130,246,0.08), transparent),
    radial-gradient(ellipse 400px 300px at 50% 80%, rgba(167,139,250,0.06), transparent);
  pointer-events: none;
  z-index: 0;
}

/* ===== Screen Management ===== */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1;
}
.screen.active {
  display: flex;
}

/* ===== START SCREEN ===== */
#start-screen {
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.start-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 48px 36px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(20px);
  max-width: 460px;
  width: 90%;
  animation: fadeUpIn 0.7s ease-out;
}

@keyframes fadeUpIn {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.start-icon {
  font-size: 72px;
  animation: bounce 2s infinite;
  filter: drop-shadow(0 4px 12px rgba(34,197,94,0.3));
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.start-title {
  font-family: var(--font-primary);
  font-size: 2.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--green), var(--blue), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.start-subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  text-align: center;
  line-height: 1.5;
}

/* Legend */
.bin-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
  margin: 8px 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-dot.green  { background: var(--green); box-shadow: 0 0 8px var(--green-glow); }
.legend-dot.blue   { background: var(--blue); box-shadow: 0 0 8px var(--blue-glow); }
.legend-dot.red    { background: var(--red); box-shadow: 0 0 8px var(--red-glow); }
.legend-dot.black  { background: var(--black-bin); box-shadow: 0 0 8px var(--black-glow); }

/* Primary Button */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  font-family: var(--font-primary);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(124,58,237,0.35);
  letter-spacing: 0.2px;
  margin-top: 8px;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(124,58,237,0.5);
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}
.btn-primary:active {
  transform: translateY(0);
}

/* ===== GAME SCREEN ===== */
#game-screen {
  flex-direction: column;
  background: var(--bg-primary);
}

/* HUD */
#game-hud {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 14px 16px 8px;
  flex-shrink: 0;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  padding: 8px 18px;
  min-width: 72px;
  transition: var(--transition);
}

.hud-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}

.hud-value {
  font-family: var(--font-primary);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Progress Bar */
#progress-bar-container {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.05);
  flex-shrink: 0;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--accent));
  border-radius: 0 4px 4px 0;
  transition: width 0.4s ease;
}

/* Waste Area */
#waste-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}

.waste-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 160px;
  height: 160px;
  background: var(--bg-card);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  cursor: grab;
  transition: var(--transition);
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  animation: cardAppear 0.4s ease-out;
  box-shadow: var(--shadow-card);
}

@keyframes cardAppear {
  from { opacity: 0; transform: scale(0.7) rotate(-8deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}

.waste-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--accent-glow);
  transform: scale(1.05);
}

.waste-card.dragging {
  opacity: 0.8;
  cursor: grabbing;
  transform: scale(1.1) rotate(3deg);
  border-color: var(--accent);
  box-shadow: 0 0 32px var(--accent-glow);
}

.waste-emoji {
  font-size: 3.5rem;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}

.waste-name {
  font-family: var(--font-primary);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  padding: 0 8px;
}

.drag-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ===== BINS ===== */
#bins-area {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 12px 12px 20px;
  flex-shrink: 0;
}

.bin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 6px 14px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--bg-card);
}

.bin .bin-glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

/* Bin colours */
.bin[data-category="wet"] {
  border-color: rgba(34,197,94,0.2);
}
.bin[data-category="wet"] .bin-glow {
  background: radial-gradient(ellipse at center, var(--green-glow), transparent 70%);
}

.bin[data-category="dry"] {
  border-color: rgba(59,130,246,0.2);
}
.bin[data-category="dry"] .bin-glow {
  background: radial-gradient(ellipse at center, var(--blue-glow), transparent 70%);
}

.bin[data-category="sanitary"] {
  border-color: rgba(239,68,68,0.2);
}
.bin[data-category="sanitary"] .bin-glow {
  background: radial-gradient(ellipse at center, var(--red-glow), transparent 70%);
}

.bin[data-category="hazardous"] {
  border-color: rgba(107,114,128,0.2);
}
.bin[data-category="hazardous"] .bin-glow {
  background: radial-gradient(ellipse at center, var(--black-glow), transparent 70%);
}

.bin:hover, .bin.drag-over {
  transform: translateY(-4px) scale(1.04);
}
.bin:hover .bin-glow,
.bin.drag-over .bin-glow {
  opacity: 1;
}

.bin.drag-over {
  border-width: 3px;
}
.bin.drag-over[data-category="wet"]       { border-color: var(--green); box-shadow: 0 0 24px var(--green-glow); }
.bin.drag-over[data-category="dry"]       { border-color: var(--blue); box-shadow: 0 0 24px var(--blue-glow); }
.bin.drag-over[data-category="sanitary"]  { border-color: var(--red); box-shadow: 0 0 24px var(--red-glow); }
.bin.drag-over[data-category="hazardous"] { border-color: var(--black-bin); box-shadow: 0 0 24px var(--black-glow); }

.bin-icon {
  font-size: 2rem;
  position: relative;
  z-index: 1;
}

.bin-body {
  position: relative;
  z-index: 1;
}

.bin-label {
  font-family: var(--font-primary);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  text-align: center;
}

/* Bin correct/wrong flash */
.bin.flash-correct {
  animation: flashCorrect 0.5s;
}
.bin.flash-wrong {
  animation: flashWrong 0.5s;
}

@keyframes flashCorrect {
  0%, 100% { background: var(--bg-card); }
  50% { background: rgba(34,197,94,0.2); }
}
@keyframes flashWrong {
  0%, 100% { background: var(--bg-card); }
  50% { background: rgba(239,68,68,0.2); }
}

/* ===== POPUP OVERLAY ===== */
.popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.25s ease-out;
}
.popup-overlay.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.popup-card {
  background: var(--bg-secondary);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-xl);
  padding: 36px 32px 28px;
  max-width: 420px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-popup);
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

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

.popup-title {
  font-family: var(--font-primary);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}

.popup-details {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.popup-item {
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  color: var(--accent);
}

.popup-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.popup-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.popup-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 50px;
  background: rgba(239,68,68,0.15);
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.popup-badge.correct {
  background: rgba(34,197,94,0.15);
  color: var(--green);
}

.popup-explanation {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  margin-top: 4px;
}

/* ===== CORRECT TOAST ===== */
.correct-toast {
  position: fixed;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  padding: 12px 28px;
  background: rgba(34,197,94,0.15);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 50px;
  font-family: var(--font-primary);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(34,197,94,0.2);
  animation: toastIn 0.3s ease-out;
}
.correct-toast.hidden { display: none; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== GAME OVER ===== */
#gameover-screen {
  align-items: center;
  justify-content: center;
}

.gameover-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 44px 36px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(20px);
  max-width: 480px;
  width: 90%;
  animation: fadeUpIn 0.6s ease-out;
}

.gameover-icon {
  font-size: 64px;
}

.gameover-title {
  font-family: var(--font-primary);
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--green), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gameover-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  padding: 14px 6px;
}

.stat-num {
  font-family: var(--font-primary);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
}

.gameover-message {
  color: var(--text-secondary);
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ===== PARTICLES ===== */
#particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

.particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  animation: particleFly 0.8s ease-out forwards;
}

@keyframes particleFly {
  from {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0);
  }
}

/* ===== MOBILE TOUCH DRAG GHOST ===== */
.touch-ghost {
  position: fixed;
  z-index: 999;
  pointer-events: none;
  opacity: 0.9;
  transition: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .start-title {
    font-size: 1.8rem;
  }
  .start-container {
    padding: 32px 24px;
  }
  .waste-card {
    width: 130px;
    height: 130px;
  }
  .waste-emoji {
    font-size: 2.8rem;
  }
  .hud-item {
    padding: 6px 10px;
    min-width: 60px;
  }
  .hud-value {
    font-size: 1.05rem;
  }
  .bin-icon {
    font-size: 1.6rem;
  }
  .bin {
    padding: 12px 4px 10px;
  }
  .bin-label {
    font-size: 0.65rem;
  }
  .gameover-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat-card {
    padding: 12px 8px;
  }
}

@media (min-width: 768px) {
  #bins-area {
    max-width: 700px;
    margin: 0 auto;
    gap: 16px;
    padding: 16px 24px 28px;
  }
  .bin {
    padding: 20px 10px 18px;
    border-radius: var(--radius-xl);
  }
  .bin-icon {
    font-size: 2.5rem;
  }
  .bin-label {
    font-size: 0.85rem;
  }
  .waste-card {
    width: 180px;
    height: 180px;
  }
  .waste-emoji {
    font-size: 4.5rem;
  }
  .waste-name {
    font-size: 1.05rem;
  }
}
