/* Bazooka Man — styling matches thudinest.com's dark space-gradient theme:
   Orbitron for headers, Space Grotesk/Inter for body text, gold/purple/lime
   accents, glass-panel cards (rgba white on a dark radial gradient). */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #1a1a3e 0%, #0a0a1a 60%);
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

.back-link {
  position: fixed; top: 12px; left: 14px; z-index: 500;
  font-size: 0.8rem; color: rgba(255,255,255,0.55); text-decoration: none;
  padding: 6px 10px; border-radius: 8px;
}
.back-link:hover, .back-link:focus-visible { color: #fff; background: rgba(255,255,255,0.08); }
/* The in-game HUD occupies the same top-left corner (pause button, level
   name) — hide the fixed back-link there instead of overlapping it. Pause
   → Level Select is the way back to the hub while playing. */
body.in-game .back-link { display: none; }

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* ===== Menu ===== */
#screen-menu.active {
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  padding: 60px 20px 30px; text-align: center;
}
.menu-wrap { max-width: 420px; width: 100%; display: flex; flex-direction: column; align-items: center; }
.menu-icon { font-size: 3.4rem; margin-bottom: 6px; filter: drop-shadow(0 4px 18px rgba(255,140,0,0.35)); }
.game-title {
  font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: clamp(2.1rem, 8vw, 2.8rem);
  letter-spacing: 2px; text-transform: uppercase;
  background: linear-gradient(135deg, #ffd23f 0%, #ff5722 55%, #a855f7 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 8px;
}
.game-sub { color: rgba(255,255,255,0.5); font-size: 0.95rem; margin-bottom: 18px; letter-spacing: 0.5px; }
.menu-stars {
  font-size: 0.9rem; font-weight: 700; color: #ffd23f;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px; padding: 6px 16px; margin-bottom: 28px;
}
.menu-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 280px; }
.icon-toggle {
  margin-top: 22px; width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  color: #fff; font-size: 1.2rem; cursor: pointer;
}

/* ===== Buttons ===== */
.btn {
  min-height: 50px; padding: 12px 22px; border: none; border-radius: 14px;
  font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1rem;
  cursor: pointer; touch-action: manipulation;
  transition: transform 0.12s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: translateY(1px) scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, #ffd23f, #ff8a3d);
  color: #1a0f00; box-shadow: 0 10px 26px rgba(255,140,0,0.28);
}
.btn-primary:hover { box-shadow: 0 12px 32px rgba(255,140,0,0.4); }
.btn-ghost {
  background: rgba(255,255,255,0.06); color: #fff; border: 1px solid rgba(255,255,255,0.14);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); }

/* ===== Level select ===== */
.sub-header {
  display: flex; align-items: center; gap: 12px; padding: 16px 18px;
  position: sticky; top: 0; background: rgba(8,8,17,0.85); backdrop-filter: blur(10px);
  z-index: 20; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sub-header h2 { font-family: 'Space Grotesk', sans-serif; font-size: 1.15rem; letter-spacing: 1px; }
.header-spacer { flex: 1; }
.back-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06); color: #fff; font-size: 1.1rem; cursor: pointer;
}
.level-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px; padding: 20px; max-width: 780px; margin: 0 auto;
}
.level-card {
  min-height: 96px; border-radius: 16px; padding: 14px 10px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12);
  color: #fff; display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; font-family: 'Space Grotesk', sans-serif;
}
.level-card:not(.locked):active { transform: scale(0.97); }
.level-card.locked { opacity: 0.4; cursor: not-allowed; }
.level-num {
  width: 26px; height: 26px; border-radius: 50%; background: rgba(255,210,63,0.15);
  color: #ffd23f; font-size: 0.8rem; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.level-name { font-size: 0.82rem; font-weight: 600; text-align: center; }
.level-stars { font-size: 0.9rem; letter-spacing: 2px; color: #ffd23f; }

/* ===== Game screen ===== */
#screen-game.active { display: flex; flex-direction: column; min-height: 100vh; padding-top: 4px; }
.hud {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: rgba(8,8,17,0.7);
}
.hud-btn {
  width: 42px; height: 42px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06); color: #fff; font-size: 1rem; cursor: pointer; flex: none;
}
.hud-mid { flex: 1; display: flex; flex-direction: column; align-items: center; line-height: 1.3; }
.hud-level-name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 0.95rem; }
.hud-shots { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; color: rgba(255,255,255,0.55); }

.canvas-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 6px; min-height: 0;
}
/* Shrink-wraps to the canvas's actual rendered size (set in px by
   Engine.fitCanvas), so the ammo bar and overlays anchored to this frame
   always sit on top of the canvas — never off in the flex gutter around it. */
.canvas-frame { position: relative; line-height: 0; }
#game-canvas {
  display: block; background: #0a0a1a; border-radius: 14px; touch-action: none;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5); max-width: 100%;
}

.ammo-bar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; gap: 10px; z-index: 30;
}
.ammo-btn {
  min-width: 58px; min-height: 58px; border-radius: 16px; padding: 6px;
  background: rgba(10,10,20,0.72); border: 2px solid rgba(255,255,255,0.15);
  color: #fff; display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer; backdrop-filter: blur(6px);
}
.ammo-btn.active { border-color: #ffd23f; box-shadow: 0 0 0 3px rgba(255,210,63,0.2); }
.ammo-icon { font-size: 1.2rem; }
.ammo-count { font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; font-weight: 700; }

/* ===== Overlays ===== */
.overlay {
  position: absolute; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,4,10,0.72); backdrop-filter: blur(6px);
  border-radius: 14px; padding: 20px;
}
/* The [hidden] attribute and the class rule above have equal specificity,
   so without this the author rule's `display: flex` would always win and
   the overlay would stay visible even while `hidden` is set from JS. */
.overlay[hidden] { display: none; }
.overlay-fixed { position: fixed; border-radius: 0; }
.overlay-box {
  background: rgba(20,20,34,0.9); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px; padding: 30px 26px; max-width: 340px; width: 100%;
  text-align: center; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}
.overlay-box h2 { font-family: 'Orbitron', sans-serif; font-size: 1.3rem; letter-spacing: 1px; margin-bottom: 4px; }
.overlay-box p { color: rgba(255,255,255,0.6); font-size: 0.88rem; }
.win-stars { font-size: 2.2rem; color: #ffd23f; letter-spacing: 6px; }
.win-shots { font-family: 'JetBrains Mono', monospace; }

.howto-box { max-width: 420px; text-align: left; }
.howto-list { list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 6px 0 4px; }
.howto-list li { font-size: 0.86rem; line-height: 1.5; color: rgba(255,255,255,0.75); }
.howto-list strong { color: #ffd23f; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.9); color: #fff; padding: 10px 22px; border-radius: 10px;
  font-size: 0.85rem; opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 9000;
}
.toast.show { opacity: 1; }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .menu-actions { max-width: 100%; }
  .level-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; padding: 14px; }
  .ammo-btn { min-width: 52px; min-height: 52px; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .hud { padding: 6px 10px; }
  .hud-btn { width: 36px; height: 36px; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .btn, .level-card, .icon-toggle { transition: none; }
}
