@keyframes bounce {
  0% { 
    opacity: 0; 
    transform: scale(0.3) translateY(10px); 
  }
  50% { 
    opacity: 1; 
    transform: scale(1.05) translateY(-2px); 
  }
  70% { 
    transform: scale(0.95) translateY(1px); 
  }
  100% { 
    opacity: 1; 
    transform: scale(1) translateY(0); 
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shop-buy-btn {
  background: #fbc02d;
  color: #795548;
  border: none;
  border-radius: 6px;
  padding: 4px 14px;
  font-size: 1em;
  font-weight: bold;
  margin-left: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.shop-buy-btn:hover {
  background: #ffe082;
}
.shop-item {
  color: #795548;
  font-size: 1em;
  margin-bottom: 16px;
}
#shop-section {
  background: #fffde7;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  padding: 24px 20px 24px 20px;
  min-width: 160px;
  margin-right: 32px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}
.shop-title {
  font-size: 1.2em;
  font-weight: bold;
  color: #fbc02d;
  margin-bottom: 8px;
}
.shop-item {
  color: #795548;
  font-size: 1em;
  margin-bottom: 4px;
}
#stats-section {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 12px 20px;
  margin-top: 8px;
  min-width: 160px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
#stats-section > div:first-child {
  font-weight: bold;
  font-size: 1.1em;
  margin-bottom: 6px;
}
#grow-timer-label {
  margin-top: 8px;
  color: #388e3c;
  font-weight: bold;
}
#money-label {
  margin-top: 0;
  margin-bottom: 4px;
}
#height-label {
  margin-top: 0;
  margin-bottom: 4px;
}
#main-flex {
  display: flex;
  align-items: flex-start;
  gap: 40px;
}
#controls-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  min-width: 220px;
}
#well-container {
  display: flex;
  align-items: center;
  gap: 16px;
}
#well {
  width: 40px;
  height: 40px;
  background: #90caf9;
  border-radius: 50%;
  border: 4px solid #1976d2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5em;
}
#collect-btn {
  background: #1976d2;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 1em;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.2s;
}
#collect-btn:disabled {
  background: #90caf9;
  color: #fff;
  cursor: not-allowed;
}
#collect-timer {
  margin-left: 8px;
  color: #1976d2;
  font-weight: bold;
}
#water-meter-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
#water-btn {
  background: #039be5;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 32px;
  font-size: 1.2em;
  cursor: pointer;
  margin-left: 12px;
  transition: background 0.2s;
}
#water-btn:hover {
  background: #0277bd;
}
#message {
  min-height: 24px;
}
body {
  font-family: Arial, sans-serif;
  background: #e0f7fa;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  margin: 0;
}
h1 {
  color: #388e3c;
}
#game-container {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  padding: 32px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#tree-canvas {
  background: #b2dfdb;
  border-radius: 8px;
  margin-bottom: 24px;
}
#grow-btn {
  display: none;
}
#chop-btn {
  margin-top: 8px;
  background: #795548;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 32px;
  font-size: 1.1em;
  cursor: pointer;
}
#height-label {
  margin-top: 16px;
  font-size: 1.1em;
  color: #388e3c;
}
#money-label {
  margin-top: 8px;
  color: #795548;
  font-weight: bold;
}
#message {
  margin-top: 16px;
  color: #d32f2f;
  font-weight: bold;
}
#cheats-bar {
  position: fixed;
  left: 0;
  bottom: -100px;
  width: 100vw;
  background: rgba(255,255,255,0.97);
  box-shadow: 0 -2px 16px rgba(0,0,0,0.10);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  z-index: 10000;
  transition: bottom 0.3s cubic-bezier(.4,1.4,.6,1);
  padding: 18px 0 24px 0;
  min-height: 60px;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#cheats-bar.open {
  bottom: 0;
}
#cheats-bar input[type="text"] {
  width: 180px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #bbb;
  font-size: 1em;
}
#cheats-bar button {
  padding: 4px 12px;
  border-radius: 6px;
  background: #eee;
  cursor: pointer;
  font-size: 1em;
  margin-left: 8px;
}
#cheats-bar span {
  margin-left: 8px;
  color: #388e3c;
  font-size: 0.95em;
}

#settings-bar {
  position: fixed;
  left: 0;
  top: -250px;
  width: 100vw;
  background: rgba(255,255,255,0.97);
  box-shadow: 0 2px 16px rgba(0,0,0,0.10);
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
  z-index: 10000;
  transition: top 0.3s cubic-bezier(.4,1.4,.6,1);
  padding: 18px 0 24px 0;
  min-height: 60px;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#settings-bar.open {
  top: 0;
}

#pin-bar {
  position: fixed;
  right: -350px;
  top: 50%;
  transform: translateY(-50%);
  width: 280px;
  background: rgba(255,255,255,0.97);
  box-shadow: -2px 0 16px rgba(0,0,0,0.10);
  border-top-left-radius: 18px;
  border-bottom-left-radius: 18px;
  z-index: 10000;
  transition: right 0.3s cubic-bezier(.4,1.4,.6,1);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#pin-bar.open {
  right: 0;
}
#pin-bar h3 {
  margin: 0 0 16px 0;
  color: #795548;
  font-size: 1.1em;
}
#pin-bar #pin-display {
  font-size: 1.5em;
  letter-spacing: 8px;
  margin: 12px 0 20px 0;
  color: #795548;
  min-height: 30px;
}
#pin-bar .pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
#pin-bar .pin-btn {
  width: 50px;
  height: 50px;
  background: #fbc02d;
  color: #795548;
  border: none;
  border-radius: 8px;
  font-size: 1.2em;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}
#pin-bar .pin-btn:hover {
  background: #ffe082;
}
#pin-bar .pin-btn:active {
  background: #f9a825;
}
#pin-bar .pin-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
#pin-bar .pin-clear, #pin-bar .pin-cancel {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.9em;
  transition: background 0.2s;
}
#pin-bar .pin-clear {
  background: #ff9800;
  color: white;
}
#pin-bar .pin-clear:hover {
  background: #f57c00;
}
#pin-bar .pin-cancel {
  background: #f44336;
  color: white;
}
#pin-bar .pin-cancel:hover {
  background: #d32f2f;
}

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

/* Mobile responsive styles */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  
  #main-flex {
    flex-direction: column !important;
    align-items: center !important;
    gap: 12px;
  }
  
  #shop-section {
    margin-right: 0 !important;
    margin-bottom: 12px !important;
    min-width: 90vw !important;
    max-width: 400px !important;
  }
  
  #game-container {
    margin-bottom: 12px !important;
    padding: 12px !important;
  }
  
  #controls-container {
    min-width: 90vw !important;
    max-width: 400px !important;
  }
  
  canvas {
    max-width: 90vw !important;
    height: auto !important;
  }
  
  /* Mobile-specific control sizing */
  #water-btn {
    padding: 8px 16px !important;
    font-size: 1em !important;
    margin-left: 6px !important;
    margin-top: 6px !important;
  }
  
  #chop-btn {
    padding: 8px 16px !important;
    font-size: 1em !important;
    margin-top: 4px !important;
  }
  
  #water-meter-container {
    gap: 4px !important;
    margin-bottom: 8px !important;
  }
  
  #water-meter {
    width: 120px !important;
    height: 20px !important;
  }
  
  #water-meter-container label {
    font-size: 0.9em !important;
  }
  
  #water-meter-label {
    font-size: 0.9em !important;
  }
  
  #collect-btn {
    padding: 6px 12px !important;
    font-size: 0.9em !important;
    margin-top: 2px !important;
  }
  
  #well {
    width: 32px !important;
    height: 32px !important;
    font-size: 1.2em !important;
  }
  
  #well-container {
    gap: 10px !important;
    margin-bottom: 8px !important;
  }
  
  #controls-container {
    padding: 12px !important;
  }
  
  #height-label {
    margin-top: 8px !important;
    font-size: 1em !important;
  }
  
  #grow-timer-label {
    margin-top: 4px !important;
    margin-bottom: 6px !important;
    font-size: 0.95em !important;
  }
  
  #money-label {
    font-size: 0.95em !important;
    margin-bottom: 6px !important;
  }
  
  #win-target-label {
    font-size: 0.9em !important;
    margin-top: 4px !important;
  }
  
  /* Mobile button positioning */
  button[style*="❓"] {
    right: 10px !important;
    left: auto !important;
    bottom: 10px !important;
  }
  
  button[style*="⚙️"]:not([style*="left: 210px"]) {
    right: 10px !important;
    left: auto !important;
    top: 10px !important;
    bottom: auto !important;
  }
  
  button[style*="🌟"] {
    right: 10px !important;
    left: auto !important;
    bottom: 70px !important;
  }
  
  button[style*="💎"] {
    right: 10px !important;
    left: auto !important;
    bottom: 130px !important;
  }
  
  button[style*="/"] {
    right: 10px !important;
    left: auto !important;
    bottom: 190px !important;
  }
}

/* Auto-detect mobile devices with touch */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
  /* Additional touch-specific styles */
  button {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
  }
  
  .shop-buy-btn {
    padding: 8px 16px;
    font-size: 1.1em;
  }
}

/* Mobile Shop Modal */
#mobile-shop-modal {
  font-family: inherit;
}

#mobile-shop-modal .shop-title {
  display: none; /* Hide since we have the modal title */
}

#mobile-shop-modal .shop-item {
  margin-bottom: 20px;
  padding: 15px;
  background: #f9f9f9;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

#mobile-shop-modal .shop-buy-btn {
  margin-left: 0;
  margin-top: 8px;
  width: 100%;
  padding: 10px;
  font-size: 1.1em;
}

/* Mobile mode classes - activated via JavaScript */
.mobile-mode #water-btn {
  padding: 6px 12px;
  font-size: 0.95em;
  margin-left: 6px;
  margin-top: 8px;
}

.mobile-mode #chop-btn {
  padding: 6px 12px;
  font-size: 0.95em;
  margin-top: 4px;
}

.mobile-mode #water-meter-container {
  gap: 4px;
  margin-bottom: 6px;
}

.mobile-mode #water-meter {
  width: 100px;
  height: 18px;
}

.mobile-mode #water-meter-container label,
.mobile-mode #water-meter-label {
  font-size: 0.85em;
}

.mobile-mode #collect-btn {
  padding: 5px 10px;
  font-size: 0.85em;
  margin-top: 2px;
}

.mobile-mode #well {
  width: 28px;
  height: 28px;
  font-size: 1.1em;
}

.mobile-mode #well-container {
  gap: 8px;
  margin-bottom: 8px;
}

.mobile-mode #controls-container {
  padding: 8px;
}

.mobile-mode canvas {
  max-width: 85vw;
}

.mobile-mode #height-label {
  margin-top: 8px;
  font-size: 1em;
}

.mobile-mode #grow-timer-label {
  margin-top: 4px;
  margin-bottom: 4px;
  font-size: 0.9em;
}

.mobile-mode #money-label {
  font-size: 0.9em;
  margin-bottom: 4px;
}

.mobile-mode #win-target-label {
  font-size: 0.85em;
  margin-top: 4px;
}

.mobile-mode #game-container {
  margin-bottom: 8px !important;
  padding: 8px !important;
}

.mobile-mode #main-flex {
  gap: 8px !important;
}

.mobile-mode h1 {
  margin-top: 8px !important;
  margin-bottom: 8px !important;
  font-size: 1.8em !important;
}

.mobile-mode #message {
  min-height: 16px !important;
  font-size: 0.9em !important;
  margin-bottom: 4px !important;
}
