* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.game-container {
  max-width: 1200px;
  width: 100%;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.game-header {
  background: linear-gradient(135deg, #0f4c75 0%, #3282b8 100%);
  color: white;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.back-link {
  color: white;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.back-link:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateX(-3px);
}

.game-header h1 {
  font-size: 1.75rem;
  margin: 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.game-hud {
  display: flex;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
  border-bottom: 3px solid #3282b8;
  flex-wrap: wrap;
  gap: 1.5rem;
  overflow: visible;
  min-height: fit-content;
}

.hud-section {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1rem;
  padding: 0.5rem 1rem;
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  min-width: 120px;
}

.hud-icon {
  font-size: 1.5rem;
}

.hud-label {
  color: #666;
  font-weight: 600;
}

.hud-value {
  color: #0f4c75;
  font-weight: 700;
  font-size: 1.1rem;
  margin-left: auto;
}

.toolbar {
  display: flex;
  gap: 1rem;
  padding: 1rem 2rem;
  background: #f8f9fa;
  border-bottom: 2px solid #e0e0e0;
  flex-wrap: wrap;
  justify-content: center;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem 1.5rem;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  font-size: 0.9rem;
  color: #333;
  min-width: 120px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.tool-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: #3282b8;
}

.tool-btn.active {
  background: linear-gradient(135deg, #0f4c75 0%, #3282b8 100%);
  color: white;
  border-color: #0f4c75;
  box-shadow: 0 4px 12px rgba(15, 76, 117, 0.3);
}

.tool-icon {
  font-size: 1.5rem;
}

#gameCanvas {
  display: block;
  width: 100%;
  background: linear-gradient(to bottom, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  cursor: crosshair;
  image-rendering: pixelated;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.instructions {
  padding: 1rem 2rem;
  background: #f8f9fa;
  text-align: center;
  color: #666;
  font-size: 0.9rem;
  line-height: 1.6;
}

.version-info {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: #999;
  font-weight: 400;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 2.5rem;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-content h2 {
  color: #0f4c75;
  margin-bottom: 1.5rem;
  font-size: 2rem;
}

.final-stats {
  margin: 1.5rem 0;
}

.final-stats p {
  margin: 1rem 0;
  font-size: 1.2rem;
  color: #666;
}

.final-stats span {
  font-weight: 700;
  color: #0f4c75;
  font-size: 1.4rem;
}

.restart-btn {
  margin-top: 1.5rem;
  padding: 1rem 2.5rem;
  background: linear-gradient(135deg, #0f4c75 0%, #3282b8 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(15, 76, 117, 0.3);
}

.restart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(15, 76, 117, 0.4);
}

.restart-btn:active {
  transform: translateY(0);
}

/* Shop Modal */
.shop-modal {
  max-width: 700px;
}

.shop-items {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1.5rem 0;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 12px;
  border: 2px solid #e0e0e0;
  transition: all 0.2s ease;
  cursor: pointer;
}

.shop-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: #3282b8;
}

.shop-icon {
  font-size: 2.5rem;
}

.shop-info {
  flex: 1;
  text-align: left;
}

.shop-info h3 {
  color: #333;
  margin-bottom: 0.25rem;
  font-size: 1.1rem;
}

.shop-info p {
  color: #666;
  font-size: 0.9rem;
  margin: 0.25rem 0;
}

.shop-benefit {
  color: #0f4c75 !important;
  font-weight: 600;
  font-size: 0.85rem !important;
}

.shop-cost {
  color: #d32f2f !important;
  font-weight: 700;
  font-size: 0.9rem !important;
  margin-top: 0.5rem !important;
}

.shop-btn {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #0f4c75 0%, #3282b8 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.shop-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(15, 76, 117, 0.3);
}

.shop-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.close-btn {
  margin-top: 1rem;
  padding: 0.75rem 2rem;
  background: #e0e0e0;
  color: #333;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.close-btn:hover {
  background: #d0d0d0;
  transform: translateY(-2px);
}

.plant-option.selected {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border-color: #3282b8;
}

@media (max-width: 768px) {
  body {
    padding: 0;
    align-items: flex-start;
    overflow-x: hidden;
  }

  .game-container {
    max-width: 100%;
    border-radius: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .game-header {
    flex-direction: row;
    gap: 0.5rem;
    padding: 1rem;
    flex-wrap: wrap;
    flex-shrink: 0;
  }

  .game-header h1 {
    font-size: 1.25rem;
  }

  .back-link {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
  }

  .game-hud {
    flex-direction: column;
    padding: 0.75rem;
    gap: 0.75rem;
    overflow: visible;
  }

  .hud-section {
    width: 100%;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .hud-item {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    gap: 0.3rem;
  }

  .hud-icon {
    font-size: 1.2rem;
  }

  .hud-label {
    font-size: 0.8rem;
  }

  .hud-value {
    font-size: 0.95rem;
  }

  .toolbar {
    padding: 0.5rem;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
  }

  .tool-btn {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
    padding: 0.75rem 0.5rem;
    font-size: 0.75rem;
    min-height: 60px;
  }

  .tool-icon {
    font-size: 1.3rem;
  }

  #gameCanvas {
    flex: 1;
    min-height: 300px;
    max-height: none;
    height: auto;
  }

  .instructions {
    padding: 0.75rem;
    font-size: 0.8rem;
    line-height: 1.5;
    flex-shrink: 0;
  }

  .version-info {
    font-size: 0.7rem;
    margin-top: 0.5rem;
  }

  .modal-content {
    padding: 1.5rem;
    max-width: 95%;
    max-height: 85vh;
    margin: 1rem;
  }

  .modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  .shop-items {
    gap: 0.75rem;
  }

  .shop-item {
    padding: 0.75rem;
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }

  .shop-icon {
    font-size: 2rem;
  }

  .shop-info {
    text-align: center;
  }

  .shop-info h3 {
    font-size: 1rem;
  }

  .shop-info p {
    font-size: 0.85rem;
  }

  .shop-btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  .close-btn {
    width: 100%;
    padding: 0.75rem;
    margin-top: 0.5rem;
  }

  .final-stats p {
    font-size: 1rem;
    margin: 0.75rem 0;
  }

  .final-stats span {
    font-size: 1.2rem;
  }

  .restart-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .game-header {
    padding: 0.75rem;
  }

  .game-header h1 {
    font-size: 1.1rem;
  }

  .hud-item {
    padding: 0.35rem 0.5rem;
    font-size: 0.75rem;
  }

  .tool-btn {
    flex: 1 1 100%;
    min-height: 55px;
    padding: 0.6rem 0.4rem;
    font-size: 0.7rem;
  }

  .tool-icon {
    font-size: 1.2rem;
  }

  #gameCanvas {
    max-height: 45vh;
  }

  .modal-content {
    padding: 1rem;
    max-width: 98%;
  }

  .modal-content h2 {
    font-size: 1.25rem;
  }
}
