/* Tower Defense Game - Main CSS */

/* Custom Properties */
:root {
  --primary-dark: #1a202c;
  --primary: #2d3748;
  --primary-light: #4a5568;
  --accent: #ed8936;
  --accent-dark: #dd6b20;
  --success: #48bb78;
  --danger: #f56565;
  --warning: #ecc94b;
  --info: #4299e1;
  --tower-color: #805ad5;
  --wall-color: #718096;
  --castle-color: #ecc94b;
  --text-light: #f7fafc;
  --panel-bg: rgba(26, 32, 44, 0.9);
  --panel-border: rgba(113, 128, 150, 0.4);
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Exo 2', sans-serif;
  color: var(--text-light);
  background-color: var(--primary-dark);
}

/* Game Container */
#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: var(--primary-dark);
  background-image: radial-gradient(circle at 10% 20%, rgba(90, 90, 90, 0.05) 0%, rgba(0, 0, 0, 0.05) 90%),
                    linear-gradient(to bottom, rgba(80, 80, 80, 0.1) 1px, transparent 1px),
                    linear-gradient(to right, rgba(80, 80, 80, 0.1) 1px, transparent 1px);
  background-size: 100% 100%, 30px 30px, 30px 30px;
  overflow: hidden;
}

/* Castle */
.castle {
  position: absolute;
  width: 75px;
  height: 75px;
  border-radius: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
}

.castle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.4);
}

/* Стили для системы улучшения замка */
.castle-upgrade-indicator {
  position: absolute;
  top: -8px;
  right: -12px;
  font-size: 20px;
  animation: bounce 0.8s infinite alternate;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.7));
  pointer-events: none;
}

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

.castle-upgrade-panel {
  background-color: rgba(0, 0, 0, 0.85);
  border: 2px solid #f39c12;
  border-radius: 8px;
  padding: 15px;
  width: 300px;
  color: white;
  z-index: 100;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}

.castle-panel-header {
  text-align: center;
  margin-bottom: 15px;
  border-bottom: 1px solid #f39c12;
  padding-bottom: 5px;
}

.castle-panel-header h3 {
  margin: 0;
  color: #f39c12;
}

.castle-info-section {
  margin-bottom: 15px;
}

.castle-info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.castle-info-row .can-afford {
  color: #2ecc71;
}

.castle-info-row .cannot-afford {
  color: #e74c3c;
}

.castle-button-section {
  display: flex;
  justify-content: space-between;
}

.castle-upgrade-button {
  background-color: #f39c12;
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  width: 100%;
}

.castle-upgrade-button:hover:not(:disabled) {
  background-color: #e67e22;
}

.castle-upgrade-button:disabled {
  background-color: #7f5409;
  cursor: not-allowed;
  opacity: 0.7;
}

.castle i {
  font-size: 40px;
  color: var(--primary-dark);
}

.castle.damage-100 {
  background-color: var(--castle-color);
}

.castle.damage-75 {
  background-color: #d6b846;
}

.castle.damage-50 {
  background-color: #c0a940;
}

.castle.damage-25 {
  background-color: #aa973a;
}

.castle.damage-0 {
  background-color: #938333;
  opacity: 0.8;
}

.castle.shake {
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

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

.grid-cell {
  position: absolute;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  background-color: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background-color 0.2s;
}

.grid-cell:hover {
  background-color: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
}

.tower-selection-menu {
  position: absolute;
  width: 300px;
  background-color: rgba(0, 0, 0, 0.8);
  border: 2px solid #555;
  border-radius: 8px;
  padding: 10px;
  z-index: 100;
  color: white;
}

.selection-title {
  text-align: center;
  font-size: 18px;
  margin-bottom: 10px;
  border-bottom: 1px solid #555;
  padding-bottom: 5px;
}

.tower-option {
  padding: 8px;
  margin-bottom: 8px;
  border: 1px solid #444;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.tower-option:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.tower-option.cannot-afford {
  opacity: 0.5;
  cursor: not-allowed;
}

.tower-icon-name {
  display: flex;
  align-items: center;
  font-size: 16px;
  margin-bottom: 5px;
}

.tower-icon-name span {
  margin-left: 8px;
}

.tower-cost {
  margin-left: auto;
  color: gold;
}

.tower-description {
  font-size: 12px;
  color: #aaa;
  margin-bottom: 5px;
}

.tower-stats {
  font-size: 11px;
  color: #8af;
}

.close-selection-button {
  width: 100%;
  padding: 5px;
  margin-top: 5px;
  background-color: #333;
  border: 1px solid #555;
  color: white;
  cursor: pointer;
}

.close-selection-button:hover {
  background-color: #444;
}

.tower-build-effect {
  color: #2ecc71;
  font-size: 20px;
  font-weight: bold;
  text-shadow: 0 0 5px black;
  z-index: 15;
  animation: buildAnimation 1s ease-out forwards;
}

@keyframes buildAnimation {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

.tower-damager {
  background-color: #e74c3c;
  border: 2px solid #c0392b;
}

.tower-multishot {
  background-color: #3498db;
  border: 2px solid #2980b9;
}

.tower-dpm {
  background-color: #2ecc71;
  border: 2px solid #27ae60;
}

.tower-type {
  position: absolute;
  bottom: -20px;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 10px;
  color: white;
  text-shadow: 1px 1px 1px black;
}

.projectile-damager {
  background-color: #e74c3c;
}

.projectile-multishot {
  background-color: #090ddd;
}

.projectile-dpm {
  background-color: #2ecc71;
}

.damage-effect.critical {
  color: #c40000;
  font-size: 18px;
  text-shadow: 0 0 5px #ffff00;
}

.splash-effect {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(231,76,60,0.5) 0%, rgba(231,76,60,0) 70%);
  pointer-events: none;
  z-index: 10;
  animation: splashAnimation 0.3s ease-out forwards;
}

@keyframes splashAnimation {
  0% { transform: scale(0.2); opacity: 0.8; }
  100% { transform: scale(1); opacity: 0; }
}

.castle-upgrade-effect {
  color: gold;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 0 0 5px black;
  z-index: 15;
  animation: castleUpgradeAnimation 2s ease-out forwards;
}

@keyframes castleUpgradeAnimation {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

.castle-limit-warning {
  color: #e74c3c;
  font-weight: bold;
}

#castle-upgrade-btn {
  background-color: #f39c12;
  color: white;
  border: 2px solid #d35400;
}

#castle-level {
  color: #f39c12;
  font-weight: bold;
  margin-right: 10px;
}

/* Towers */
.tower {
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  cursor: pointer;
  z-index: 8;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tower:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.4);
}

.tower.destroyed {
  background: #4c1d95;
  opacity: 0.6;
  border: 2px solid #3c1361;
}

.tower-level {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: var(--info);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  z-index: 9;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tower-health {
  position: absolute;
  bottom: -5px;
  left: 0;
  height: 5px;
  width: 50px;
  background-color: var(--success);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Enemies */
.enemy {
  position: absolute;
  border-radius: 50%;
  z-index: 7;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s ease;
}

.enemy.small {
  background-color: #f56565;
}

.enemy.small::before {
  content: '👾';
  font-size: 16px;
}

.enemy.medium {
  background-color: #e53e3e;
}

.enemy.medium::before {
  content: '👹';
  font-size: 20px;
}

.enemy.large {
  background-color: #c53030;
}

.enemy.large::before {
  content: '👺';
  font-size: 26px;
}

.enemy.boss {
  background-color: #822727;
  box-shadow: 0 0 10px rgba(229, 62, 62, 0.5);
}

.enemy.boss::before {
  content: '💀';
  font-size: 32px;
}

.health-bar {
  position: absolute;
  bottom: -6px;
  left: 0;
  height: 4px;
  background-color: var(--success);
  border-radius: 2px;
  transition: width 0.2s ease;
}

/* Projectiles */
.projectile {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  z-index: 6;
  box-shadow: 0 0 5px #ffffff;
}

/* Tower Range Display */
.tower-range {
  position: absolute;
  border-radius: 50%;
  border: 2px dashed #3182ce;
  background-color: rgba(49, 130, 206, 0.1);
  z-index: 4;
  pointer-events: none;
}

/* Effects */
.damage-effect {
  position: absolute;
  animation: damageFade 0.8s ease forwards;
  z-index: 15;
  pointer-events: none;
}

@keyframes damageFade {
  0% { 
    opacity: 1;
    transform: translateY(0);
  }
  100% { 
    opacity: 0;
    transform: translateY(-20px);
  }
}

.kill-animation {
  position: absolute;
  animation: killEffect 1s ease-out forwards;
  z-index: 15;
  pointer-events: none;
  font-size: 24px;
}

@keyframes killEffect {
  0% { 
    opacity: 1;
    transform: scale(0.5);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
  100% { 
    opacity: 0;
    transform: scale(1.5);
  }
}

.acid-effect {
  position: absolute;
  animation: acidFade 0.6s ease forwards;
  z-index: 12;
  pointer-events: none;
}

@keyframes acidFade {
  0% { 
    opacity: 1;
    transform: scale(0.8);
  }
  100% { 
    opacity: 0;
    transform: scale(1.5);
  }
}

/* UI Bar */
#ui {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70px;
  background-color: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
  font-family: 'Orbitron', sans-serif;
}

.ui-section {
  display: flex;
  align-items: center;
  gap: 15px;
}

.ui-section:nth-child(2) { /*  stat */
  display: flex;
  justify-content: center; 
  align-items: center; 
  max-width: 550px;
  min-width: 300px;
}

.stat {
  display: flex;
  align-items: center;
  padding-right: 10px;
  gap: 10px;
  font-size: 16px;
}

.stat i {
  font-size: 18px;
  color: var(--accent);
}

/* Game Buttons */
.game-button {
  background: linear-gradient(to bottom, var(--primary-light), var(--primary));
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 5px;
  font-family: 'Exo 2', sans-serif;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: all 0.2s;
  min-width: 100px;
  outline: none;
}

.game-button:hover {
  background: linear-gradient(to bottom, var(--primary-light), var(--primary-dark));
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.game-button:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.game-button:disabled {
  background: #718096;
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

/* Auto Start Toggle */
.auto-start-container {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

#auto-start-toggle {
  appearance: none;
  width: 40px;
  height: 20px;
  background-color: var(--primary-dark);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: all 0.3s;
}

#auto-start-toggle::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  background-color: white;
  transition: all 0.3s;
}

#auto-start-toggle:checked {
  background-color: var(--success);
}

#auto-start-toggle:checked::before {
  left: 22px;
}

/* Speed Control */
.speed-control {
  display: flex;
  gap: 8px;
  background-color: var(--primary-dark);
  padding: 5px;
  border-radius: 15px;
}

.speed-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: var(--primary-light);
  cursor: pointer;
  transition: all 0.2s;
}

.speed-dot:hover {
  background-color: var(--accent);
  transform: scale(1.1);
}

.speed-dot.active {
  background-color: var(--success);
}

/* Settings Button */
.settings-btn {
  min-width: 40px;
  padding: 8px;
}

.settings-btn i {
  font-size: 18px;
}

/* Upgrade Panel */
#upgrade-panel {
  position: absolute; 
  width: 280px;
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 20px;
  z-index: 101;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
  display: none;
  font-family: 'Exo 2', sans-serif;
  overflow: visible;
}

#upgrade-title {
  text-align: center;
  margin-bottom: 15px;
  font-family: 'Orbitron', sans-serif;
  color: var(--accent);
  font-size: 1.2rem;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 24px;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  line-height: 1;
}

.structure-info {
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--primary-light);
}

.info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

.stats-section {
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--primary-light);
}

.action-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
}

.cost {
  display: flex;
  align-items: center;
  gap: 5px;
}

.cost i {
  color: var(--accent);
}

.upgrade-btn {
  background: linear-gradient(to bottom, #805ad5, #6b46c1);
}

.upgrade-btn:hover {
  background: linear-gradient(to bottom, #9f7aea, #805ad5);
}

.repair-btn {
  background: linear-gradient(to bottom, #4299e1, #3182ce);
}

.repair-btn:hover {
  background: linear-gradient(to bottom, #63b3ed, #4299e1);
}

.build-btn {
  background: linear-gradient(to bottom, #48bb78, #38a169);
}

.build-btn:hover {
  background: linear-gradient(to bottom, #68d391, #48bb78);
}


.sell-icon {
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 40px;
  background: #fd2d2d;
  border-radius: 22% 0 35% 0%; 
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  z-index: 10;
}

.sell-icon i {
  font-size: 16px; /* Розмір іконки trash */
}

.sell-panel {
  position: absolute;
  top: 0;
  left: 25px;
  height: 40px;
  width: 0; 
  max-width: calc(100%);
  background: var(--panel-bg);
  border: 2px solid #fd2d2d;
  border-radius: 0 10px 0 0;
  display: flex;
  align-items: center;
  color: #ffffff;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  transition: width 0.3s ease; 
  z-index: 9;
}

.sell-icon:hover {
  background: #ff5151;
}

@keyframes sellFade {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-30px); }
}

.tower-sell-effect {
  animation: sellFade 1s ease forwards;
}

/* Game Over Panel */
#game-over {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 30px;
  z-index: 102;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
  text-align: center;
  display: none;
  font-family: 'Press Start 2P', cursive;
}

#game-over h2 {
  color: var(--danger);
  margin-bottom: 20px;
  font-size: 24px;
  text-shadow: 0 0 10px rgba(245, 101, 101, 0.5);
}

.final-score {
  font-size: 18px;
  margin-bottom: 25px;
}

#final-score {
  color: var(--accent);
  font-weight: bold;
}

#game-over .game-button {
  margin-top: 15px;
  width: 100%;
}

/* Difficulty Settings Panel */
#difficulty-settings {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 30px;
  z-index: 103;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
  display: none;
}

#difficulty-settings h2 {
  text-align: center;
  margin-bottom: 20px;
  color: var(--accent);
  font-family: 'Orbitron', sans-serif;
  font-size: 1.5rem;
}

.preset-buttons {
  display: flex;
  justify-content: space-between;
  margin-bottom: 25px;
}

.difficulty-btn {
  flex: 1;
  margin: 0 5px;
  padding: 10px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-family: 'Exo 2', sans-serif;
  font-weight: bold;
  transition: all 0.2s;
}

#easy-preset {
  background-color: #68d391;
  color: #1a202c;
}

#medium-preset {
  background-color: #f6ad55;
  color: #1a202c;
}

#hard-preset {
  background-color: #fc8181;
  color: #1a202c;
}

.active-difficulty {
  transform: scale(1.05);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.settings-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 25px;
}

@media (max-width: 600px) {
  .settings-container {
    grid-template-columns: 1fr;
  }
}

.setting {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-control {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--primary-dark);
  outline: none;
}

.slider-control::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: all 0.2s;
}

.slider-control::-webkit-slider-thumb:hover {
  background: var(--accent-dark);
  transform: scale(1.2);
}

.settings-buttons {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.settings-buttons .game-button {
  flex: 1;
}

.pause-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.pause-text {
  font-size: 48px;
  color: white;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
  animation: pulse 1.5s infinite;
}

.mode-indicator {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 20px;
  color: white;
  font-weight: bold;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.tower-highlight {
  border-radius: 50%;
  z-index: 10;
  pointer-events: auto;
}

.repair-highlight.can-afford {
  border: 3px solid #008b05;
  background-color: rgba(76, 175, 80, 0.2);
}

.upgrade-highlight.can-afford {
  border: 3px solid #086bbd;
  background-color: rgba(33, 150, 243, 0.2);
}

.repair-highlight.cannot-afford,
.upgrade-highlight.cannot-afford {
  border: 3px solid #9e9e9e;
  background-color: rgba(158, 158, 158, 0.2);
  opacity: 0.5;
}

.cost-label {
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 2px 5px;
  border-radius: 10px;
  font-size: 10px;
  white-space: nowrap;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Debug Panel */
#debug-panel {
  position: fixed;
  top: 20px;
  right: 280px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 10px;
  border-radius: 5px;
  z-index: 1000;
  font-size: 12px;
  max-width: 300px;
  max-height: 80vh;
  overflow-y: auto;
  display: none;
}

/* Tower stats button */
.tower-stats-button {
  background-color: #9b59b6;
  margin-left: 10px;
}

/* Tower stats panel */
.tower-stats-panel {
  position: absolute;
  background-color: rgba(0, 0, 0, 0.85);
  border: 2px solid #555;
  border-radius: 8px;
  padding: 15px;
  z-index: 1000;
  color: white;
  min-width: 300px;
  cursor: default;
}

/* Panel header */
.stats-panel-header {
  padding: 5px;
  margin-bottom: 10px;
  border-bottom: 1px solid #555;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
  background-color: rgba(85, 85, 85, 0.3);
  border-radius: 4px;
}

/* Header title */
.stats-panel-title {
  margin: 0;
  pointer-events: none;
}

/* Close button */
.stats-panel-close {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 0 5px;
}

/* Drag handle */
.stats-panel-drag {
  margin-right: 8px;
  font-size: 14px;
  color: #aaa;
  pointer-events: none;
}

/* Content container */
.stats-content {
  pointer-events: auto;
}

/* Tower stats section */
.tower-stats-section {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #555;
}

/* Tower header with icon and name */
.tower-stats-header {
  display: flex;
  align-items: center;
}

/* Tower icon */
.tower-icon {
  font-size: 24px;
  margin-right: 10px;
}

/* Tower name */
.tower-name {
  margin: 0;
}

/* Damage info with help icon */
.damage-info {
  position: relative;
  cursor: help;
}

/* Help icon */
.help-icon {
  position: absolute;
  top: -25px;
  right: 20px;
  color: #aaa;
  font-size: 12px;
}

/* Tower count */
.tower-count {
  color: #aaa;
}

/* Total damage section */
.total-damage-section {
  margin-top: 20px;
  padding-top: 10px;
  border-top: 2px solid #777;
}

/* Total damage title */
.total-damage-title {
  margin: 0;
}

/* Tooltip styles */
.tower-stats-tooltip {
  position: absolute;
  background-color: rgba(0, 0, 0, 0.9);
  border: 1px solid #777;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
  color: white;
  z-index: 1100;
  pointer-events: none;
  transition: opacity 0.2s;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  max-width: 250px;
}

.tower-stats-tooltip h4 {
  margin: 0 0 5px 0;
  border-bottom: 1px solid #555;
  padding-bottom: 3px;
}

.tower-stats-tooltip p {
  margin: 4px 0;
}

.tower-stats-tooltip .damage-percent {
  color: #aaa;
  font-size: 12px;
}

.tower-stats-tooltip .damage-direct {
  color: #ff7675;
}

.tower-stats-tooltip .damage-splash {
  color: #fdcb6e;
}

.tower-stats-tooltip .damage-normal {
  color: #74b9ff;
}

.tower-stats-tooltip .damage-critical {
  color: #ff6b81;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  /* UI Bar Adjustments */
  #ui {
    height: 60px;
    padding: 0 10px;
  }
  
  .ui-section {
    gap: 8px;
  }
  
  .stat {
    font-size: 13px;
  }
  
  .stat i {
    font-size: 16px;
  }
  
  /* Button Adjustments */
  .game-button {
    padding: 6px 10px;
    min-width: 70px;
    font-size: 13px;
  }
  
  /* Speed Controls */
  .speed-control {
    padding: 4px;
  }
  
  .speed-dot {
    width: 16px;
    height: 16px;
  }
  
  /* Panels */
  
  .info-row {
    font-size: 14px;
  }
  
  #difficulty-settings {
    width: 95vw;
    padding: 20px;
  }
  
  .settings-container {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .setting {
    font-size: 14px;
  }
  
  #game-over {
    width: 280px;
    padding: 20px;
  }
  
  #game-over h2 {
    font-size: 20px;
  }
  
  .final-score {
    font-size: 16px;
  }
  
  /* Game Elements */
  .castle {
    width: 65px;
    height: 65px;
  }
  
  .castle i {
    font-size: 35px;
  }
  
  .tower, .wall-slot {
    width: 45px;
    height: 45px;
  }
  
  .tower-health, .wall-health {
    width: 45px;
  }
  
  /* Debug Panel */
  #debug-panel {
    right: 10px;
    top: 10px;
    max-width: 200px;
    font-size: 11px;
  }
}

/* Extra Small Screens */
@media (max-width: 480px) {
  #ui {
    height: 100px;
    flex-direction: column;
    justify-content: center;
    padding: 5px;
  }
  
  .ui-section {
    width: 100%;
    justify-content: center;
    margin: 5px 0;
  }
  
  .stat {
    font-size: 12px;
    flex: 0 0 auto;
  }
  
  .auto-start-container label {
    font-size: 12px;
  }
  
  #auto-start-toggle {
    width: 36px;
    height: 18px;
  }
  
  #auto-start-toggle::before {
    width: 14px;
    height: 14px;
  }
  
  .tower-level, .wall-level {
    width: 18px;
    height: 18px;
    font-size: 10px;
  }
  
  .upgrade-panel {
    width: 220px;
    font-size: 13px;
  }
  
  .action-section {
    flex-direction: column;
    gap: 8px;
  }
  
  .action-section .game-button {
    width: 100%;
  }
  
  .settings-buttons {
    flex-direction: column;
  }
  
  .settings-buttons .game-button {
    margin-bottom: 5px;
  }
  
  /* Enemy Sizes */
  .enemy.small::before {
    font-size: 14px;
  }
  
  .enemy.medium::before {
    font-size: 18px;
  }
  
  .enemy.large::before {
    font-size: 24px;
  }
  
  .enemy.boss::before {
    font-size: 30px;
  }
}
