* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background: #0a0a1a;
  font-family: 'Press Start 2P', monospace;
  overflow: hidden;
  color: #e0e0e0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  height: 100dvh;
}

#game-wrapper {
  position: relative;
  width: 100%;
  height: calc(100% - 24px);
  max-width: 800px;
  overflow: hidden;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #1a1a2e;
  touch-action: none;
}

#hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: linear-gradient(180deg, rgba(10,10,26,0.95) 0%, rgba(10,10,26,0) 100%);
  z-index: 10;
  gap: 8px;
}

#wave-display {
  font-size: 9px;
  color: #4ade80;
  white-space: nowrap;
  text-shadow: 0 0 8px #22c55e;
  min-width: 90px;
}

#health-bar-container {
  flex: 1;
  height: 18px;
  background: #2a0a0a;
  border: 2px solid #ef4444;
  border-radius: 3px;
  position: relative;
  max-width: 300px;
  box-shadow: 0 0 6px rgba(239,68,68,0.3);
}

#health-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ef4444, #22c55e);
  border-radius: 1px;
  transition: width 0.3s;
}

#health-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 6px;
  color: #fff;
  text-shadow: 1px 1px 2px #000;
}

#money-display {
  font-size: 9px;
  color: #fbbf24;
  white-space: nowrap;
  text-shadow: 0 0 8px rgba(251,191,36,0.5);
  min-width: 80px;
  text-align: right;
}

#money-display.flash {
  animation: moneyFlash 0.3s;
}

@keyframes moneyFlash {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); color: #fff; }
}

#boss-bar-container {
  position: absolute;
  top: 32px;
  left: 10%;
  right: 10%;
  z-index: 10;
  text-align: center;
}

#boss-name {
  font-size: 8px;
  color: #ef4444;
  margin-bottom: 3px;
  text-shadow: 0 0 10px #ef4444;
  animation: bossGlow 1s infinite alternate;
}

@keyframes bossGlow {
  from { text-shadow: 0 0 5px #ef4444; }
  to { text-shadow: 0 0 20px #ef4444, 0 0 40px #ff0000; }
}

#boss-hp-bar-outer {
  height: 12px;
  background: #1a0a0a;
  border: 2px solid #ff4444;
  border-radius: 3px;
}

#boss-hp-bar {
  height: 100%;
  background: linear-gradient(90deg, #ff0000, #ff4444);
  border-radius: 1px;
  transition: width 0.2s;
}

#combo-display {
  position: absolute;
  top: 50px;
  right: 10px;
  font-size: 11px;
  color: #fbbf24;
  text-shadow: 0 0 12px #fbbf24;
  z-index: 10;
  animation: comboPulse 0.5s infinite alternate;
}

@keyframes comboPulse {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

#wave-announce {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  color: #ef4444;
  text-shadow: 0 0 20px #ef4444, 0 0 40px #ff0000;
  z-index: 20;
  animation: announceIn 0.5s ease-out;
  text-align: center;
}

@keyframes announceIn {
  from { transform: translate(-50%, -50%) scale(3); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

#penalty-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: #ff0000;
  text-shadow: 0 0 20px #ff0000;
  z-index: 25;
  background: rgba(255,0,0,0.15);
  padding: 15px 20px;
  border: 2px solid #ff0000;
  text-align: center;
  animation: penaltyShake 0.1s infinite alternate;
}

@keyframes penaltyShake {
  from { transform: translate(-50%, -50%) rotate(-1deg); }
  to { transform: translate(-50%, -50%) rotate(1deg); }
}

#fairplay-indicator {
  position: absolute;
  bottom: 60px;
  right: 8px;
  font-size: 6px;
  color: #22c55e;
  opacity: 0.5;
  z-index: 10;
}

#hud-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: linear-gradient(0deg, rgba(10,10,26,0.95) 0%, rgba(10,10,26,0) 100%);
  z-index: 10;
  gap: 6px;
}

#gun-display {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 7px;
  color: #8b5cf6;
  min-width: 70px;
}

#gun-icon {
  font-size: 16px;
}

#gun-name {
  white-space: nowrap;
}

#cooldown-ring {
  width: 20px;
  height: 20px;
}

#cooldown-canvas {
  width: 20px;
  height: 20px;
}

#upgrade-btn {
  flex: 1;
  max-width: 240px;
  padding: 6px 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  background: #1a1a3e;
  color: #8b5cf6;
  border: 2px solid #8b5cf6;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

#upgrade-btn:not(:disabled):hover {
  background: #8b5cf6;
  color: #fff;
  box-shadow: 0 0 15px rgba(139,92,246,0.5);
}

#upgrade-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #444;
  color: #666;
}

#upgrade-btn.affordable {
  animation: upgradePulse 1s infinite alternate;
  border-color: #4ade80;
  color: #4ade80;
}

@keyframes upgradePulse {
  from { box-shadow: 0 0 5px rgba(74,222,128,0.3); }
  to { box-shadow: 0 0 20px rgba(74,222,128,0.7); }
}

#shop-btn {
  padding: 6px 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  background: #fbbf24;
  color: #1a1a2e;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

#shop-btn:hover {
  background: #f59e0b;
  transform: scale(1.05);
}

#shop-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70%;
  background: rgba(16,16,40,0.97);
  border-top: 3px solid #8b5cf6;
  z-index: 30;
  overflow-y: auto;
  padding: 10px;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

#shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: #fbbf24;
  margin-bottom: 10px;
}

#shop-close {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  background: none;
  border: 1px solid #666;
  color: #ef4444;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 3px;
}

#gun-evolution-path {
  display: flex;
  gap: 2px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.gun-node {
  padding: 4px 6px;
  font-size: 5px;
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 3px;
  color: #666;
  white-space: nowrap;
}

.gun-node.current {
  border-color: #4ade80;
  color: #4ade80;
  box-shadow: 0 0 10px rgba(74,222,128,0.4);
}

.gun-node.owned {
  border-color: #8b5cf6;
  color: #8b5cf6;
}

.gun-arrow {
  color: #444;
  font-size: 7px;
}

#shop-upgrades {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 4px;
  gap: 8px;
}

.shop-item-info {
  flex: 1;
  font-size: 6px;
  line-height: 1.6;
}

.shop-item-name {
  color: #e0e0e0;
}

.shop-item-desc {
  color: #888;
  font-size: 5px;
}

.shop-buy-btn {
  padding: 5px 8px;
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  background: #1a1a3e;
  color: #fbbf24;
  border: 1px solid #fbbf24;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}

.shop-buy-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.shop-buy-btn:not(:disabled):hover {
  background: #fbbf24;
  color: #1a1a2e;
}

#title-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a1a 100%);
  cursor: pointer;
}

#title-text {
  font-size: 18px;
  color: #4ade80;
  text-shadow: 0 0 30px #22c55e, 0 0 60px #16a34a;
  text-align: center;
  line-height: 1.6;
  animation: titleGlow 2s infinite alternate;
}

@keyframes titleGlow {
  from { text-shadow: 0 0 20px #22c55e; }
  to { text-shadow: 0 0 40px #22c55e, 0 0 80px #16a34a, 0 0 120px #15803d; }
}

#title-sub {
  font-size: 10px;
  color: #888;
  margin-top: 30px;
  animation: blink 1.2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

#lifetime-stats-title {
  margin-top: 20px;
  font-size: 6px;
  color: #666;
  text-align: center;
  line-height: 2;
}

#countdown-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: rgba(10,10,26,0.9);
}

#countdown-num {
  font-size: 60px;
  color: #ef4444;
  text-shadow: 0 0 40px #ef4444;
  animation: countPulse 1s infinite;
}

@keyframes countPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

#gameover-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: rgba(10,0,0,0.92);
}

#gameover-title {
  font-size: 20px;
  color: #ef4444;
  text-shadow: 0 0 30px #ef4444;
  margin-bottom: 20px;
  animation: penaltyShake 0.15s infinite alternate;
}

#gameover-stats {
  font-size: 7px;
  color: #ccc;
  line-height: 2.2;
  text-align: center;
  margin-bottom: 20px;
}

#restart-btn {
  padding: 10px 24px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  background: #22c55e;
  color: #0a0a1a;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s;
}

#restart-btn:hover {
  background: #4ade80;
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(74,222,128,0.5);
}

.hidden {
  display: none !important;
}

footer {
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

footer a {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: #444;
  text-decoration: none;
}

footer a:hover {
  color: #4ade80;
}

@media (max-width: 480px) {
  #title-text { font-size: 13px; }
  #wave-display { font-size: 7px; min-width: 70px; }
  #money-display { font-size: 7px; min-width: 60px; }
  #upgrade-btn { font-size: 5px; }
}