body {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #1a1a1a;
  font-family: Arial, sans-serif;
  color: white;
  touch-action: manipulation;
  padding-bottom: 120px;
}

#game-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
  margin-left: 120px;
  align-items: center;
  width: 100%;
  max-width: 90vmin;
}

#stats {
  display: flex;
  justify-content: space-between;
  font-size: 1.2em;
}

#grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  background: #333;
  padding: 2px;
  border-radius: 4px;
  width: 90vmin;
  height: 90vmin;
  max-width: calc(100vw - 40px);
  max-height: calc(100vw - 40px);
  margin: 0 auto;
}

.cell {
  background: #222;
  position: relative;
  border-radius: 2px;
}

.path {
  background: #444;
}

.tower {
  background: #0066cc;
  border-radius: 50%;
  width: 80%;
  height: 80%;
  position: absolute;
  top: 10%;
  left: 10%;
  transition: filter 0.2s;
}

.tower:hover {
  filter: brightness(1.2);
}

.enemy {
  background: #cc0000;
  border-radius: 50%;
  width: 60%;
  height: 60%;
  position: absolute;
  top: 20%;
  left: 20%;
  transition: all 0.3s linear;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
}

.health-bar {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.health-fill {
  width: 100%;
  height: 100%;
  background: #00ff00;
  transition: width 0.2s ease-in-out;
}

.tower-basic {
  background: #0066cc;
}

.tower-sniper {
  background: #cc00cc;
}

.tower-splash {
  background: #00cc00;
}

.tower-rapid {
  background: #cccc00;
}

.tower-laser {
  background: #00ffff;
}

.tower-frost {
  background: #99ccff;
}

.tower-poison {
  background: #33cc33;
}

.tower-chain {
  background: #ffcc00;
}

.tower-artillery {
  background: #ff4400;
}

.tower-tesla {
  background: #6600ff;
}

.tower-vortex {
  background: #9933ff;
}

.tower-nano {
  background: #00ff99;
}

.tower-plasma {
  background: #ff33cc;
}

.tower-ember {
  background: #ff6600;
}

.tower-quantum {
  background: #00ffcc;
}

.tower-void {
  background: #6600cc;
}

.tower-storm {
  background: #3366ff;
}

.tower-cosmic {
  background: #ff33ff;
}

.tower-omega {
  background: #ff0000;
  box-shadow: 0 0 15px #ff0000;
}

.laser {
  position: fixed;
  height: 2px;
  background: #00ffff;
  transform-origin: left center;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 0 5px #00ffff;
}

#controls {
  display: none;
}

button {
  padding: 10px 20px;
  font-size: 1em;
  background: #444;
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
}

button:hover {
  background: #555;
}

button.active {
  background: #0066cc;
}

.projectile {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 0 5px currentColor;
}

@keyframes poison-pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

.enemy[data-poisoned="true"] {
  animation: poison-pulse 1s infinite;
}

#tower-list {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 120px;
  background: #222;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 2px 0 5px rgba(0,0,0,0.3);
  z-index: 1000;
}

.tower-option {
  background: #333;
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.tower-option .preview {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  position: static;
}

.tower-option .description {
  font-size: 0.8em;
  opacity: 0.8;
  text-align: center;
  margin-top: 2px;
}

#difficulty-select {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 1001;
  background: #333;
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #555;
  color: white;
  font-size: 1em;
  cursor: pointer;
}

#difficulty-select option {
  background: #333;
  color: white;
}

.enemy[data-difficulty="casual"] { 
  background: #99ff99; 
}
.enemy[data-difficulty="easy"] { 
  background: #99cc99; 
}
.enemy[data-difficulty="normal"] { 
  background: #cc0000; 
}
.enemy[data-difficulty="hard"] { 
  background: #990000; 
}
.enemy[data-difficulty="very-hard"] { 
  background: #660000; 
}
.enemy[data-difficulty="extreme"] { 
  background: #330000; 
}
.enemy[data-difficulty="insane"] { 
  background: #000000; 
}
.enemy[data-difficulty="crazy"] { 
  background: linear-gradient(45deg, #ff0000, #000000);
  box-shadow: 0 0 10px #ff0000;
}

@media (max-width: 600px) {
  #stats {
    font-size: 1em;
  }
  
  button {
    padding: 8px 16px;
    font-size: 0.9em;
  }
}

@media (max-width: 800px) {
  body {
    padding-bottom: 120px;
  }

  #game-container {
    margin-left: 0;
    margin-bottom: 0;
    padding-bottom: 20px;
    margin-top: 60px;
  }

  #tower-list {
    position: fixed;
    left: 0;
    top: initial;
    bottom: 0;
    width: 100%;
    height: auto;
    min-height: 100px;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px;
    box-sizing: border-box;
    gap: 15px;
  }

  .tower-option {
    min-width: 90px;
    padding: 8px;
    flex-shrink: 0;
    justify-content: center;
  }

  .tower-option .preview {
    width: 35px;
    height: 35px;
  }

  .tower-option .description {
    max-width: 80px;
    font-size: 0.75em;
    line-height: 1.2;
  }

  #stats {
    width: 100%;
    justify-content: space-around;
    padding: 0 10px;
    box-sizing: border-box;
  }
  
  #start-wave {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
  }

  #difficulty-select {
    top: 10px;
    right: 10px;
    font-size: 0.9em;
    padding: 6px;
  }
}