:root {
  --bg: #04050a;
  --surface: #071021;
  --text: #eaf6ff;
  --muted: #99b8d1;
  --accent: #7c5cff;
  --accent-2: #00d4ff;
  --accent-3: #ff58c8;
  --success: #00ff88;
  --danger: #ff4444;
  --warning: #ff9500;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

@media (max-width: 768px) {
  body {
    padding: 10px;
    overflow: auto;
  }
}

@keyframes gradient {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.game-container {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

@media (max-width: 1400px) {
  .game-container {
    padding: 0 10px;
  }
}

.home-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(124,92,255,0.2);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  border: 2px solid rgba(124,92,255,0.4);
  backdrop-filter: blur(10px);
  z-index: 100;
}

@media (max-width: 768px) {
  .home-btn {
    position: relative;
    top: auto;
    left: auto;
    margin-bottom: 10px;
    align-self: flex-start;
  }
}
  transition: all 0.3s;
  z-index: 100;
}

.home-btn:hover {
  background: rgba(124,92,255,0.4);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(124,92,255,0.3);
}

.game-header {
  text-align: center;
  padding: 15px 20px;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .game-header {
    padding: 10px 15px;
  }
}

.game-header h1 {
  font-size: 2rem;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
  text-shadow: 0 0 30px rgba(124,92,255,0.5);
}

@media (max-width: 768px) {
  .game-header h1 {
    font-size: 1.5rem;
  }
}

.stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.stat {
  background: rgba(255,255,255,0.05);
  padding: 8px 15px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
  font-size: 1rem;
  font-weight: 600;
}

@media (max-width: 768px) {
  .stats {
    gap: 10px;
  }
  
  .stat {
    padding: 6px 12px;
    font-size: 0.9rem;
  }
}

.stat .label {
  color: var(--muted);
  margin-right: 5px;
}

/* Gold/UI pulse animation for purchases/sales */
.ui-pulse {
  animation: ui-pulse 420ms ease-in-out;
}
@keyframes ui-pulse {
  0% { transform: scale(1); color: inherit; }
  50% { transform: scale(1.18); color: #ffd166; }
  100% { transform: scale(1); color: inherit; }
}

.game-content {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 0;
  overflow: hidden;
  height: 100%;
}

@media (max-width: 1200px) {
  .game-content {
    grid-template-columns: 1fr 320px;
  }
}

@media (max-width: 900px) {
  .game-content {
    grid-template-columns: 1fr;
    gap: 10px;
    overflow: auto;
  }
  
  .sidebar {
    order: -1;
  }
}

.game-area {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
  padding: 20px;
}

@media (max-width: 900px) {
  .game-area {
    padding: 10px;
  }
}

#gameCanvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 90%;
  max-height: 90%;
  background: #000;
  border: 3px solid rgba(124,92,255,0.4);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6), inset 0 0 60px rgba(124,92,255,0.1);
  cursor: crosshair;
}

@media (max-width: 900px) {
  #gameCanvas {
    max-width: 95%;
    max-height: 95%;
  }
}

@media (max-width: 650px) {
  #gameCanvas {
    border-radius: 8px;
    max-width: 100%;
    max-height: 100%;
  }
}

.game-message {
  position: relative;
  margin: 12px auto;
  display: block;
  background: rgba(0,0,0,0.9);
  padding: 14px 22px;
  border-radius: 12px;
  border: 2px solid var(--accent);
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 8px 30px rgba(124,92,255,0.35);
  max-width: 90%;
  z-index: 50;
}

.game-message.hidden {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 15px;
  background: rgba(0,0,0,0.3);
  border-left: 1px solid rgba(255,255,255,0.1);
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
}

/* Achievements panel */
.achievements-panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,255,255,0.04);
  padding: 12px;
  border-radius: 8px;
  position: relative;
}

@keyframes achieveIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.achievements-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 160px;
  overflow-y: auto;
}
.achievement-item {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 6px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.03);
}
.achievement-item .badge {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: rgba(124,92,255,0.9);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.achievement-item .meta {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
}

.achievement-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}

/* Tooltip for achievement descriptions */
.tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  z-index: 9999;
  max-width: 260px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
}

/* Slight badge color variations */
.achievement-item .badge.rare { background: linear-gradient(135deg,#ffd166,#ffb86b);} 
.achievement-item .badge.common { background: linear-gradient(135deg,#7c5cff,#00d4ff);} 
.achievement-item .badge.epic { background: linear-gradient(135deg,#ff58c8,#ff9500);} 

/* Top-right HUD adjustments */
.top-hud {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 12px;
  z-index: 110;
}
.top-hud .stat {
  background: rgba(0,0,0,0.45);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.04);
}

/* Muzzle flash subtle overlay */
.muzzle-flash {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
}

.tower-shop, .tower-upgrade, .controls, .game-info {
  background: rgba(255,255,255,0.05);
  padding: 15px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .tower-shop, .tower-upgrade, .controls, .game-info {
    padding: 12px;
  }
}

/* Small screens: show tower cards in two columns to fit more at a glance */
@media (max-width: 600px) {
  .tower-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .tower-card {
    padding: 6px;
    border-radius: 6px;
    font-size: 0.92rem;
  }

  .tower-info { font-size: 0.88rem; }
}

.tower-shop h3, .tower-upgrade h3, .game-info h4 {
  margin-bottom: 10px;
  color: var(--accent-2);
  font-size: 1.1rem;
}

.game-info p {
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 6px;
  color: var(--muted);
}

.game-info p strong {
  color: var(--text);
}

.tower-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tower-card {
  display: flex;
  gap: 8px;
  padding: 8px;
  background: rgba(0,0,0,0.3);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

@media (max-width: 900px) {
  .tower-card {
    gap: 8px;
    padding: 6px;
  }
}

.tower-card:hover {
  border-color: var(--accent);
  background: rgba(124,92,255,0.1);
  transform: translateX(5px);
}

.tower-card.selected {
  border-color: var(--accent-2);
  background: rgba(0,212,255,0.2);
  box-shadow: 0 0 20px rgba(0,212,255,0.3);
}

.tower-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.tower-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.tower-info {
  flex: 1;
}

.tower-name {
  font-weight: bold;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 0.95rem;
}

.tower-stats {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.tower-stats div {
  margin-bottom: 2px;
}

.tower-specials {
  margin-top: 8px;
}

.tower-specials .action-btn {
  width: auto;
  padding: 6px 10px;
  font-size: 0.9rem;
}

.bomb-special-btn {
  position: relative;
  overflow: hidden;
  padding-right: 10px;
}
.bomb-special-btn .btn-label {
  position: relative;
  z-index: 2;
}
.bomb-special-btn .cooldown-overlay {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  width: 0%;
  background: linear-gradient(90deg, #ffcc00, #ff6600);
  z-index: 1;
  transition: width 0.2s linear;
}


.bomb-special-btn .cooldown-seconds {
  position: absolute;
  top: 4px;
  right: 6px;
  z-index: 3;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.95);
  background: rgba(0,0,0,0.25);
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
}

/* Bomb HUD when it's a dedicated card (no inner button) */
.bomb-hud {
  position: relative;
  margin-top: 8px;
  height: 18px;
}
.bomb-hud .cooldown-overlay {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  width: 0%;
  background: linear-gradient(90deg, #ffcc00, #ff6600);
  z-index: 1;
  transition: width 0.2s linear;
}
.bomb-hud .cooldown-seconds {
  position: absolute;
  top: -4px;
  right: 0;
  z-index: 2;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.95);
  background: rgba(0,0,0,0.25);
  padding: 2px 6px;
  border-radius: 6px;
}

/* Placement overlay covering canvas (blur effect) */
.placement-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  backdrop-filter: blur(4px) saturate(110%);
  background: rgba(0,0,0,0.18);
  transition: opacity 0.12s ease;
}
.placement-overlay.hidden { display: none; }

.action-btn {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  margin-bottom: 8px;
}

.action-btn.bomb-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.start-btn {
  background: linear-gradient(135deg, var(--success), #00cc70);
  color: white;
}

.start-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(0,255,136,0.4);
}

.next-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}

.next-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(124,92,255,0.4);
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.game-info p {
  margin-bottom: 6px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
}

#upgradeContent {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upgrade-info {
  background: rgba(0,0,0,0.3);
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.upgrade-btn {
  padding: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s;
}

.upgrade-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(124,92,255,0.4);
}

.upgrade-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sell-btn {
  background: linear-gradient(135deg, var(--danger), #cc0000);
  margin-top: 10px;
}

.sell-btn:hover {
  box-shadow: 0 8px 25px rgba(255,68,68,0.4);
}

@media (max-width: 1024px) {
  .game-content {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }

  .game-area {
    order: 1;
  }

  #gameCanvas {
    max-width: 100%;
  }
}

@media (max-width: 600px) {
  .game-header h1 {
    font-size: 1.8rem;
  }

  .stats {
    gap: 10px;
  }

  .stat {
    padding: 8px 15px;
    font-size: 0.9rem;
  }

  .home-btn {
    padding: 8px 15px;
    font-size: 0.9rem;
  }
}

/* Footer Styles - Unified Design */
.game-footer {
  display: none; /* Verstecke Footer für Vollbild-Spielerlebnis */
}

.site-footer {
  padding: 0.6rem 0;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.28), rgba(2, 6, 23, 0.18));
  backdrop-filter: blur(6px) saturate(120%);
  color: rgba(234, 246, 255, 0.86);
  margin-top: auto;
}
.site-footer a {
  color: rgba(0, 212, 255, 1);
  text-decoration: none;
  font-weight: 600;
}
.footer-inner {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 0.5rem;
}
.footer-left {
  flex: 0 0 auto;
  color: #99b8d1;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.footer-left > a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.footer-left .powered-logo {
  height: 20px;
  width: auto;
  max-height: 20px;
  max-width: 120px;
  display: inline-block;
  margin-left: 0;
  vertical-align: middle;
  filter: drop-shadow(0 6px 12px rgba(124, 92, 255, 0.06));
  object-fit: contain;
  flex-shrink: 0;
}
.footer-center {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  gap: 12px;
}
.footer-center a {
  color: #99b8d1;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color 0.18s, border-color 0.18s;
  font-size: 0.95rem;
}
.footer-center a:hover {
  color: rgba(0, 212, 255, 1);
  border-color: rgba(0, 212, 255, 0.25);
}
.footer-right {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
.social-icon {
  height: 28px;
  width: 28px;
  display: inline-block;
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(124, 92, 255, 0.1));
}
.logo-footer {
  height: 40px;
  margin-right: 12px;
  filter: drop-shadow(0 8px 22px rgba(124, 92, 255, 0.08));
}
@media (max-width:720px){
  .footer-inner {
    flex-direction: column;
    gap: 8px;
    align-items: center;
    text-align: center;
    padding: 0;
  }
  .footer-center {
    order: 3;
  }
  .footer-left {
    justify-content: center;
  }
  .site-footer {
    padding: 1rem 0;
  }
}
