* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%;
  background: #0a0010;
  font-family: 'Courier New', monospace;
  overflow: hidden;
}
#gameContainer {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  /* Extend into safe area so game fills screen; UI will use safe-area for padding */
}
canvas {
  display: block;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#ui { position: absolute; top: 0; left: 0; right: 0; pointer-events: none; }
#hud {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
}
.hud-left, .hud-right { display: flex; flex-direction: column; gap: 6px; }
.hud-label { color: #ff69b4; font-size: 11px; font-weight: bold; text-transform: uppercase; letter-spacing: 2px; }
#loveLabel, #ammoLabel { margin-top: 2px; }
#healthBar {
  width: 180px; height: 16px; background: #1a0020;
  border: 1px solid #ff69b4; border-radius: 2px; overflow: hidden;
}
#healthFill { width: 100%; height: 100%; background: linear-gradient(90deg, #ff1493, #ff69b4); transition: width 0.15s; }
#timerDisplay {
  color: #ff69b4;
  font-size: 16px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 2px;
}
#loveBar {
  width: 180px; height: 14px; background: #1a0020;
  border: 1px solid #c084fc; border-radius: 2px; overflow: hidden; position: relative;
}
#loveFill { height: 100%; background: linear-gradient(90deg, #c084fc, #ff69b4, #ff1493); transition: width 0.1s; width: 0%; }
#scoreDisplay { color: #ff69b4; font-size: 24px; font-weight: bold; text-shadow: 0 0 8px #ff69b4; }
#levelDisplay {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  background: #000; border-radius: 12px;
  color: #fff; font-size: 26px; font-weight: bold; letter-spacing: 2px;
  text-align: center; padding: 8px 20px;
}
#wantedStars { color: #ff69b4; font-size: 16px; letter-spacing: 2px; }
#minimap {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  right: max(16px, env(safe-area-inset-right));
  border: 1px solid #ff69b4;
  border-radius: 12px;
  background: rgba(0,0,0,0.6);
  overflow: hidden;
}
#ammoLabel { display: none; }
#ammoDisplay { color: #ff69b4; font-size: 13px; font-weight: bold; }
#overlay {
  position: absolute; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: rgba(0,0,0,0.85); color: white;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12vh, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  pointer-events: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.menu-frame {
  border: 1px solid #c084fc;
  border-radius: 24px;
  padding: clamp(32px, 8vw, 56px) clamp(24px, 6vw, 64px) clamp(40px, 8vw, 64px);
  width: min(95vw, 960px);
  max-width: min(95vw, 960px);
  box-shadow:
    0 0 0 1px rgba(192,132,252,0.4),
    0 0 24px rgba(192,132,252,0.5),
    0 0 48px rgba(139,92,246,0.25),
    inset 0 0 80px rgba(192,132,252,0.06);
  background: rgba(30,0,50,0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.menu-frame h1 {
  white-space: nowrap;
  font-size: clamp(32px, 6vw, 64px);
}
@media (max-width: 400px) {
  .menu-frame h1 { white-space: normal; }
}
.menu-frame .subtitle,
.menu-frame .controls,
.menu-frame #startBtn { margin-left: 0; margin-right: 0; max-width: 100%; overflow-wrap: break-word; }
#overlay:has(.win-video-link) {
  padding-bottom: 100px;
}
#overlay:has(.win-video-link) .subtitle { margin-bottom: 24px; }
#overlay:has(.win-video-link) .leaderboard { margin-bottom: 16px; }
#overlay:has(.win-video-link) .win-save-row { margin-bottom: 24px; }
.win-video-link {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 1;
}
.win-youtube-link {
  display: inline-block; padding: 12px 24px;
  background: rgba(200, 0, 0, 0.9); color: #fff;
  font-size: 14px; font-weight: bold; font-family: 'Courier New', monospace;
  letter-spacing: 2px; text-decoration: none; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.3);
  transition: background 0.2s, transform 0.1s;
}
.win-youtube-link:hover { background: rgba(220, 20, 20, 1); color: #fff; transform: scale(1.05); }
#overlay h1 {
  font-size: clamp(42px, 10vw, 90px); color: #ff69b4;
  text-shadow: 0 0 20px #ff69b4, 0 0 40px #ff1493;
  margin-top: -24px; margin-bottom: 8px; letter-spacing: 4px;
  text-align: center; line-height: 1.15;
  max-width: min(95vw, 800); word-break: break-word;
}
#overlay.death-screen h1 { font-size: clamp(36px, 8vw, 72px); }
#overlay .subtitle { color: #c6aae2; font-size: 26px; font-weight: bold; letter-spacing: 4px; margin-bottom: 40px; text-align: center; }
#overlay.death-screen .subtitle { font-size: 20px; }
#overlay .controls {
  color: #ccc;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 2;
  text-align: center;
  margin-bottom: 30px;
  border: 1px solid #ff69b4;
  padding: 16px 32px;
  border-radius: 12px;
}
#overlay .controls span { color: #ff69b4; font-weight: 700; }
#startBtn {
  background: linear-gradient(135deg, #ff1493, #c084fc); border: none; color: white;
  padding: clamp(14px, 4vw, 18px) clamp(32px, 8vw, 48px);
  font-size: clamp(16px, 4vw, 18px); font-weight: bold; font-family: 'Courier New', monospace;
  letter-spacing: 3px; cursor: pointer; text-transform: uppercase; border-radius: 12px;
  box-shadow: 0 0 20px rgba(255,20,147,0.5); transition: transform 0.1s, box-shadow 0.1s; pointer-events: all;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#startBtn:hover { transform: scale(1.05); box-shadow: 0 0 30px rgba(255,20,147,0.8); }
.leaderboard { margin-bottom: 20px; min-height: 60px; }
.leaderboard-title { color: #ff69b4; font-size: 14px; font-weight: bold; letter-spacing: 3px; margin-bottom: 8px; }
.leaderboard-list { list-style: none; counter-reset: lb; color: #c084fc; font-size: 14px; font-weight: bold; }
.leaderboard-list li { counter-increment: lb; padding: 2px 0; display: flex; justify-content: space-between; gap: 24px; max-width: 280px; margin: 0 auto; }
.leaderboard-list li::before { content: counter(lb) ". "; color: #ff69b4; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: bold; }
.lb-score { color: #ff69b4; flex-shrink: 0; font-weight: bold; }

.win-save-row {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin-bottom: 16px; width: 100%; max-width: 520px;
}
.win-save-row .win-save-buttons-row {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
}
.win-end-buttons {
  display: flex; align-items: stretch; gap: 12px; flex-wrap: nowrap; flex-shrink: 0;
}
.win-save-row input#saveScoreName {
  padding: 12px 18px; font-size: 16px; font-family: 'Courier New', monospace;
  background: rgba(26,0,40,0.95); border: 2px solid #ff69b4; color: #fff;
  border-radius: 10px; width: 160px; min-width: 120px; max-width: 100%;
  letter-spacing: 1px; flex-shrink: 0;
}
.win-save-row input#saveScoreName::placeholder { color: rgba(255,255,255,0.5); }
.win-save-row input#saveScoreName:focus { outline: none; border-color: #c084fc; box-shadow: 0 0 14px rgba(255,105,180,0.5); }
.win-save-row .overlay-btn { flex-shrink: 0; }
.save-score-feedback { min-height: 22px; font-size: 14px; margin-top: 2px; text-align: center; }
.save-score-feedback.success { color: #86efac; }
.save-score-feedback.error { color: #fca5a5; }
#overlay .overlay-btn:hover { transform: scale(1.05); box-shadow: 0 0 28px rgba(255,20,147,0.7); }
#overlay .overlay-btn:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
#overlay .overlay-btn,
#overlay .overlay-btn-link { -webkit-tap-highlight-color: transparent; touch-action: manipulation; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; }
#overlay .overlay-btn-link {
  text-decoration: none; white-space: nowrap;
  padding: 14px 48px; font-size: 18px; line-height: 1.2;
}
.win-end-buttons .overlay-btn,
.win-end-buttons .overlay-btn-link { flex: 1 1 0; min-width: 0; min-height: 52px; }
#pauseBtn {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  background: rgba(26,0,40,0.9); border: 1px solid #ff69b4; color: #ff69b4;
  padding: clamp(10px, 2.5vw, 14px) clamp(16px, 4vw, 20px);
  font-size: clamp(12px, 3vw, 14px); font-weight: bold; font-family: 'Courier New', monospace;
  letter-spacing: 2px; cursor: pointer; text-transform: uppercase; border-radius: 12px;
  pointer-events: all; transition: background 0.15s, color 0.15s;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#pauseBtn:hover { background: rgba(255,105,180,0.25); color: #ff69b4; }

/* Mobile: on-screen Boom button (touch devices) */
#boomBtn {
  display: none;
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  margin-bottom: 100px;
  background: rgba(26,0,40,0.9); border: 1px solid #c084fc; color: #c084fc;
  padding: 12px 20px; font-size: 14px; font-weight: bold; font-family: 'Courier New', monospace;
  letter-spacing: 2px; text-transform: uppercase; border-radius: 12px;
  pointer-events: all; cursor: pointer; z-index: 20;
  transition: background 0.15s, color 0.15s;
  min-height: 48px; min-width: 80px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#boomBtn.visible { display: block; }
#boomBtn:hover,
#boomBtn:active { background: rgba(192,132,252,0.25); color: #c084fc; }

/* Mobile: scale HUD and level display on small screens */
@media (max-width: 480px) {
  #healthBar { width: 140px; height: 14px; }
  #loveBar { width: 140px; height: 12px; }
  #timerDisplay { font-size: 14px; }
  #levelDisplay { font-size: 18px; padding: 6px 14px; top: max(8px, env(safe-area-inset-top)); }
  #scoreDisplay { font-size: 20px; }
  #wantedStars { font-size: 14px; }
  .hud-label { font-size: 10px; }
  #overlay .controls { font-size: 12px; padding: 12px 20px; }
  /* Win/death overlay: smaller buttons and text so they fit */
  #overlay .overlay-score-line { font-size: 16px; margin-bottom: 14px; }
  #overlay .subtitle { font-size: clamp(16px, 4.5vw, 22px); letter-spacing: 2px; margin-bottom: 24px; }
  #overlay .overlay-btn,
  #overlay .overlay-btn-link {
    padding: 12px 24px; font-size: 14px; letter-spacing: 2px;
    min-height: 44px;
  }
  .win-end-buttons .overlay-btn,
  .win-end-buttons .overlay-btn-link { min-height: 44px; }
  #overlay .overlay-btn-link { padding: 12px 24px; font-size: 14px; }
  .win-save-row .win-save-buttons-row { gap: 10px; }
  .win-save-row input#saveScoreName { padding: 10px 14px; font-size: 16px; width: 140px; }
  .leaderboard-title { font-size: 13px; }
  .leaderboard-list { font-size: 13px; }
  .leaderboard-list li { max-width: 260px; }
  /* Minimap: scale down so it doesn’t dominate on small screens */
  #minimap { transform: scale(0.8); transform-origin: bottom right; }
}
/* Very narrow: stack Play again + Support my work vertically so both stay tappable */
@media (max-width: 360px) {
  .win-end-buttons { flex-direction: column; width: 100%; max-width: 280px; }
  #overlay .overlay-btn,
  #overlay .overlay-btn-link { width: 100%; }
  #overlay h1 { font-size: clamp(28px, 10vw, 48px); letter-spacing: 2px; }
  #overlay .subtitle { font-size: 14px; margin-bottom: 18px; }
  .menu-frame h1 { font-size: clamp(26px, 8vw, 48px); }
}
@media (max-height: 500px) {
  .menu-frame { padding: 24px 20px 28px; }
  #overlay h1 { margin-top: -12px; font-size: clamp(32px, 8vw, 64px); }
  #overlay .subtitle { margin-bottom: 20px; font-size: 18px; }
  #overlay .controls { margin-bottom: 16px; }
  /* Boom button: sit closer to bottom so it doesn’t overlap HUD on short screens */
  #boomBtn { margin-bottom: 60px; }
}
@media (max-height: 400px) {
  #boomBtn { margin-bottom: 48px; }
  #minimap { transform: scale(0.7); transform-origin: bottom right; }
}

/* Win screen floaters canvas (created by JS) */
.win-floaters-canvas {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: block;
}

/* 404 page */
.page-404 {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.page-404 .menu-frame {
  margin: 0 auto;
}
.page-404 .back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  background: linear-gradient(135deg, #ff1493, #c084fc);
  border: none;
  color: white;
  padding: 16px 40px;
  font-size: clamp(16px, 4vw, 18px);
  font-weight: bold;
  font-family: 'Courier New', monospace;
  letter-spacing: 3px;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(255,20,147,0.5);
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
  line-height: 1.25;
}
.page-404 .back-link:hover,
.page-404 .back-link:focus {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(255,20,147,0.8);
  color: white;
}
.page-404 h1 {
  color: #ff69b4;
  text-shadow: 0 0 20px #ff69b4, 0 0 40px #ff1493;
  margin-bottom: 12px;
  letter-spacing: 4px;
}
.page-404 .subtitle {
  color: #c084fc;
  font-size: clamp(18px, 4vw, 26px);
  font-weight: bold;
  letter-spacing: 2px;
  margin-bottom: 32px;
}
