* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #0a0a12;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #fff;
  overflow: hidden;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

body {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 20px;
  pointer-events: none;
}

#hud-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 0 0 8px rgba(0,0,0,0.8);
}

#timer { color: #fff; font-size: 24px; }
#kills { color: #ccc; font-size: 14px; }

#hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 240px;
}

#hp-bar-container, #xp-bar-container {
  position: relative;
  width: 100%;
  height: 18px;
  background: rgba(0,0,0,0.6);
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
}

#hp-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(to right, #e53e3e, #f56565);
  border-radius: 9px;
  transition: width 0.2s;
}

#xp-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, #3182ce, #63b3ed);
  border-radius: 9px;
  transition: width 0.15s;
}

#hp-text, #xp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

#hud-right {
  display: flex;
  gap: 6px;
}

#weapons-display {
  display: flex;
  gap: 6px;
}

.weapon-icon {
  width: 36px;
  height: 36px;
  background: rgba(0,0,0,0.6);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  position: relative;
}

.weapon-icon .weapon-level {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: #3182ce;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

#pause-btn {
  pointer-events: auto;
  padding: 6px 10px;
  font-size: 18px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  cursor: pointer;
  color: #fff;
  line-height: 1;
  margin: 0;
}

#pause-btn:hover {
  background: rgba(255,255,255,0.15);
  transform: none;
  box-shadow: none;
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 10, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
  backdrop-filter: blur(4px);
}

.overlay.hidden { display: none; }

.overlay h1 {
  font-size: 52px;
  color: #f6ad55;
  text-shadow: 0 0 30px rgba(246, 173, 85, 0.4);
}

.overlay h2 {
  font-size: 36px;
  color: #f6ad55;
}

.overlay p {
  color: #a0aec0;
  font-size: 16px;
  max-width: 400px;
  text-align: center;
  line-height: 1.6;
}

.controls-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #718096;
  font-size: 14px;
  margin: 8px 0;
}

.mobile-hint { display: none; }

@media (pointer: coarse) {
  .desktop-hint { display: none; }
  .mobile-hint { display: inline; }
}

button {
  padding: 14px 40px;
  font-size: 18px;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #e53e3e, #c53030);
  transition: transform 0.1s, box-shadow 0.1s;
  margin-top: 8px;
  pointer-events: auto;
}

button:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(229, 62, 62, 0.4);
}

/* Level up choices */
#level-up-choices {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  pointer-events: auto;
}

.choice-card {
  width: 200px;
  padding: 20px;
  background: rgba(26, 32, 44, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s, border-color 0.15s;
}

.choice-card:hover {
  transform: translateY(-4px);
  border-color: #f6ad55;
}

.choice-card .choice-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.choice-card .choice-name {
  font-size: 16px;
  font-weight: bold;
  color: #f6ad55;
  margin-bottom: 6px;
}

.choice-card .choice-desc {
  font-size: 12px;
  color: #a0aec0;
  line-height: 1.4;
}

.choice-card .choice-level {
  font-size: 11px;
  color: #63b3ed;
  margin-top: 6px;
}

/* Pause Stats */
#pause-stats, #death-stats, #victory-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  max-width: 820px;
  max-height: 65vh;
  overflow-y: auto;
  padding: 4px;
}

.stat-section {
  background: rgba(26, 32, 44, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 14px 18px;
  min-width: 230px;
  flex: 1;
}

.stat-section h3 {
  color: #f6ad55;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 13px;
}

.stat-row .stat-label {
  color: #a0aec0;
}

.stat-row .stat-value {
  color: #fff;
  font-weight: bold;
}

.stat-row .stat-value.green { color: #48bb78; }
.stat-row .stat-value.blue { color: #63b3ed; }
.stat-row .stat-value.gold { color: #f6ad55; }

.weapon-detail {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.weapon-detail:last-child { border-bottom: none; }

.weapon-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.weapon-detail-name {
  font-size: 13px;
  font-weight: bold;
}

.weapon-detail-level {
  font-size: 11px;
  color: #63b3ed;
}

.weapon-detail-level.maxed { color: #f6ad55; }

.weapon-detail-stats {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: #718096;
}

.weapon-detail-stats span { color: #a0aec0; }

/* Achievements */
.secondary-btn {
  background: rgba(26, 32, 44, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 30px;
  font-size: 14px;
}

.secondary-btn:hover {
  background: rgba(45, 55, 72, 0.9);
  box-shadow: none;
}

#achievements-count {
  color: #a0aec0;
  font-size: 14px;
}

#achievements-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 650px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 4px;
}

.achievement-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(26, 32, 44, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 14px;
  width: 280px;
}

.achievement-item.unlocked {
  border-color: rgba(246, 173, 85, 0.3);
}

.achievement-item.locked {
  opacity: 0.45;
}

.achievement-item .ach-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.achievement-item .ach-info {
  flex: 1;
  min-width: 0;
}

.achievement-item .ach-name {
  font-size: 13px;
  font-weight: bold;
  color: #f6ad55;
}

.achievement-item.locked .ach-name {
  color: #718096;
}

.achievement-item .ach-desc {
  font-size: 11px;
  color: #a0aec0;
}

.achievement-item.locked .ach-desc {
  color: #4a5568;
}

#pause-achievements .achievement-item {
  width: 100%;
  padding: 6px 10px;
}

#pause-achievements .ach-icon { font-size: 18px; width: 24px; }

#victory-screen h2 {
  color: #ffd700;
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
  font-size: 48px;
}

/* Gold HUD */
#gold { color: #ffd700; font-size: 14px; }

#start-gold-display {
  color: #ffd700;
  font-size: 18px;
  font-weight: bold;
}

/* Shop */
#shop-gold {
  color: #ffd700;
  font-size: 20px;
  font-weight: bold;
}

#shop-items {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 700px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 4px;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(26, 32, 44, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 12px 16px;
  width: 310px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
  pointer-events: auto;
}

.shop-item:hover {
  transform: translateY(-2px);
  border-color: #f6ad55;
}

.shop-item.cant-afford {
  opacity: 0.5;
  cursor: default;
}

.shop-item.cant-afford:hover {
  transform: none;
  border-color: rgba(255, 255, 255, 0.1);
}

.shop-item .shop-icon {
  font-size: 28px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

.shop-item .shop-info {
  flex: 1;
  min-width: 0;
}

.shop-item .shop-name {
  font-size: 14px;
  font-weight: bold;
  color: #fff;
}

.shop-item .shop-desc {
  font-size: 11px;
  color: #a0aec0;
}

.shop-item .shop-level {
  font-size: 11px;
  color: #63b3ed;
  margin-top: 2px;
}

.shop-item .shop-cost {
  font-size: 14px;
  font-weight: bold;
  color: #ffd700;
  flex-shrink: 0;
}

/* Save Slots */
#slot-list {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  pointer-events: auto;
}

.slot-card {
  position: relative;
  width: 220px;
  padding: 24px 20px;
  background: rgba(26, 32, 44, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s, border-color 0.15s;
}

.slot-card:hover {
  transform: translateY(-4px);
  border-color: #f6ad55;
}

.slot-card .slot-number {
  font-size: 16px;
  font-weight: bold;
  color: #f6ad55;
  margin-bottom: 12px;
}

.slot-card .slot-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #a0aec0;
}

.slot-card .slot-empty {
  font-size: 14px;
  color: #718096;
  padding: 12px 0;
}

.slot-card .slot-gold {
  color: #ffd700;
  font-weight: bold;
}

.slot-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  padding: 0;
  margin: 0;
  font-size: 12px;
  line-height: 1;
  background: rgba(229, 62, 62, 0.2);
  border: 1px solid rgba(229, 62, 62, 0.4);
  border-radius: 50%;
  color: #e53e3e;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-delete:hover {
  background: rgba(229, 62, 62, 0.5);
  transform: none;
  box-shadow: none;
}

/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 768px) {
  #hud {
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top));
  }

  #hud-left { font-size: 14px; }
  #timer { font-size: 18px; }
  #kills, #gold { font-size: 12px; }

  #hud-center { min-width: 160px; }
  #hp-bar-container, #xp-bar-container { height: 14px; }
  #hp-text, #xp-text { font-size: 9px; }

  .weapon-icon { width: 28px; height: 28px; font-size: 14px; }
  .weapon-icon .weapon-level { width: 12px; height: 12px; font-size: 8px; }

  #pause-btn { padding: 8px 12px; font-size: 20px; }

  .overlay h1 { font-size: 32px; }
  .overlay h2 { font-size: 24px; }
  .overlay p { font-size: 14px; max-width: 300px; }
  .controls-info { font-size: 12px; }

  button { padding: 12px 32px; font-size: 16px; }
  .secondary-btn { padding: 8px 24px; font-size: 13px; }

  /* Stack level-up cards vertically */
  #level-up-choices {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-height: 70vh;
    overflow-y: auto;
  }
  .choice-card { width: 260px; padding: 14px; }
  .choice-card .choice-icon { font-size: 28px; }
  .choice-card .choice-name { font-size: 14px; }

  /* Stack slot cards vertically */
  #slot-list { flex-direction: column; align-items: center; }
  .slot-card { width: 260px; padding: 16px; }

  /* Stat sections */
  #pause-stats, #death-stats, #victory-stats {
    max-height: 50vh;
    gap: 8px;
  }
  .stat-section { min-width: 180px; padding: 10px 12px; }

  /* Shop */
  .shop-item { width: 100%; max-width: 300px; }
  #shop-items { max-width: 320px; }
}
