* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: 'Noto Sans', sans-serif;
  background: #f5f5f5;
  overflow: hidden;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: white;
}

#hud {
  display: flex;
  gap: 20px;
  padding: 16px;
  background: #333;
  color: white;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
}

.label {
  font-size: 14px;
  opacity: 0.8;
}

#score, #combo {
  font-size: 24px;
  font-weight: bold;
}

#conveyor {
  flex: 1;
  background: #e0e0e0;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

#boxes-container {
  position: absolute;
  width: 100%;
  height: 100%;
  padding: 20px;
  transition: opacity 0.2s ease;
}

.box {
  width: 120px;
  height: 120px;
  background: #d4a574;
  border: 3px solid #8b5a3c;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  cursor: pointer;
  transition: transform 0.2s;
  position: relative;
}

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

.box.selected {
  border-color: #4CAF50;
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
}

.product {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  margin: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  cursor: pointer;
  transition: transform 0.2s;
  position: relative;
}

.product:active {
  transform: scale(0.9);
}

.product-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  margin-bottom: 8px;
  z-index: 1000;
}

.product:hover .product-tooltip {
  opacity: 1;
}

.product-tooltip-name {
  font-weight: bold;
  margin-bottom: 4px;
}

.product-tooltip-desc {
  font-size: 11px;
  opacity: 0.9;
  margin-bottom: 4px;
}

.product-tooltip-price {
  color: #4CAF50;
  font-weight: bold;
}





#storage {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: #fafafa;
  border-top: 2px solid #e0e0e0;
}

#product-area {
  flex: 1;
  min-height: 80px;
  position: relative;
}

#upgrades-area {
  width: 200px;
  min-height: 80px;
}

.area-label {
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
}

#products {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  position: relative;
}

#products.collapsed .product:nth-child(n+6) {
  display: none;
}

#expand-products {
  background: white;
  border: 2px solid #ddd;
  border-radius: 6px;
  padding: 4px 12px;
  margin-top: 4px;
  font-size: 11px;
  cursor: pointer;
  display: inline-block;
  transition: all 0.2s;
}

#expand-products:hover {
  border-color: #4CAF50;
  transform: translateY(-1px);
}

@keyframes spawn {
  from {
    transform: scale(0) rotate(180deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes despawn {
  from {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  to {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
}

.spawn {
  animation: spawn 0.15s ease-out;
}

.despawn {
  animation: despawn 0.3s ease-out;
}

.upgrade {
  background: white;
  border: 2px solid #ddd;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.upgrade:hover {
  border-color: #4CAF50;
  transform: translateY(-2px);
}

.upgrade.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.upgrade.disabled:hover {
  transform: none;
  border-color: #ddd;
}

.upgrade-name {
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 4px;
}

.upgrade-cost {
  font-size: 11px;
  color: #666;
}

.upgrade-level {
  font-size: 10px;
  color: #999;
  margin-top: 4px;
}

#badges-panel {
  position: fixed;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 8px;
  max-width: 160px;
  max-height: 200px;
  overflow-y: auto;
  backdrop-filter: blur(4px);
}

.panel-header {
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 6px;
  text-align: center;
}

#badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
  border: 2px solid #ccc;
  position: relative;
  transition: all 0.3s;
}

.badge.unlocked {
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  border-color: #FF8C00;
  animation: badgeUnlock 0.5s ease-out;
}

.badge.locked {
  filter: grayscale(100%);
  opacity: 0.4;
}

@keyframes badgeUnlock {
  0% {
    transform: scale(0) rotate(-180deg);
  }
  50% {
    transform: scale(1.3) rotate(10deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

.badge-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  margin-bottom: 4px;
}

.badge:hover .badge-tooltip {
  opacity: 1;
}