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

.hidden {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Arial, sans-serif;
  background: #0d2e5b;
  color: #f2f7ff;
  touch-action: manipulation;
}

#gameRoot {
  position: relative;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#gameRoot,
#gameRoot * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#gameRoot input,
#gameRoot textarea,
#gameRoot select {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(#67b9f2, #5a8fd9);
}

#hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(6, 19, 43, 0.55);
}

#effectBanner {
  position: absolute;
  top: 124px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 215, 120, 0.45);
  background: rgba(9, 22, 44, 0.66);
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

#effectBannerTitle {
  font-size: 1.06rem;
  letter-spacing: 1.4px;
  font-weight: 800;
  color: #ffe586;
  text-shadow: 0 0 8px rgba(255, 227, 133, 0.55);
  text-transform: uppercase;
}

#effectBannerSub {
  margin-top: 2px;
  font-size: 0.85rem;
  color: #a9deff;
}

#mobileControls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
}

#mobileControls.hidden {
  display: none;
}

.mobilePad {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  pointer-events: auto;
  align-items: flex-end;
}

.mobilePadLeft {
  left: max(12px, env(safe-area-inset-left));
}

.mobilePadRight {
  right: max(12px, env(safe-area-inset-right));
}

.mobilePad button {
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  min-width: 68px;
  height: 54px;
  padding: 0 12px;
  background: rgba(8, 18, 38, 0.7);
  color: #f2f7ff;
  font-weight: 800;
  letter-spacing: 0.6px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#touchStick {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: radial-gradient(circle, rgba(140, 185, 245, 0.16), rgba(8, 18, 38, 0.62));
  position: relative;
  touch-action: none;
}

#touchStickKnob {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(25, 40, 70, 0.4);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

#touchStick.active #touchStickKnob {
  background: rgba(255, 222, 138, 0.94);
}

.mobilePad button:active,
.mobilePad button.pressed {
  background: rgba(255, 217, 113, 0.86);
  color: #18263d;
}

#touchFire {
  min-width: 92px;
  height: 64px;
  background: rgba(180, 52, 52, 0.76);
}

#touchFire:active,
#touchFire.pressed {
  background: rgba(255, 111, 89, 0.92);
}

#statusLabel {
  min-height: 1em;
  color: #ffd87a;
  font-size: 0.95rem;
}

#radarCanvas {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 180px;
  height: 180px;
  border: 2px solid rgba(230, 244, 255, 0.8);
  border-radius: 10px;
  background: rgba(4, 14, 30, 0.65);
}

#instructionsOverlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 11, 24, 0.82);
  padding: 22px;
  z-index: 12;
}

#instructionsOverlay.hidden {
  display: none;
}

#instructionsCard {
  width: min(760px, 94vw);
  max-height: 90vh;
  overflow: auto;
  touch-action: pan-y;
  border-radius: 14px;
  border: 1px solid rgba(255, 220, 120, 0.42);
  background: rgba(8, 18, 38, 0.92);
  box-shadow: 0 0 28px rgba(0, 0, 0, 0.45);
  padding: 20px 22px;
}

#instructionsCard h1 {
  color: #ffe184;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  margin-bottom: 6px;
}

.instructionsLead {
  color: #a9deff;
  margin-bottom: 12px;
}

.instructionsBlock + .instructionsBlock {
  margin-top: 12px;
}

.instructionsBlock h2 {
  color: #ffd87a;
  font-size: 1.02rem;
  margin-bottom: 6px;
}

.instructionsBlock ul {
  list-style: none;
  display: grid;
  gap: 7px;
}

#powerupLegend li,
.instructionsBlock li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f2f7ff;
}

.legendIcon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #0a1f3f;
  border: 1px solid rgba(255, 255, 255, 0.35);
  flex: 0 0 auto;
}

.legendIcon.wingmen {
  background: rgba(122, 255, 164, 0.9);
}

.legendIcon.invincible {
  background: rgba(255, 236, 112, 0.92);
}

.legendIcon.heatseek {
  background: rgba(255, 120, 120, 0.92);
}

.legendIcon.cloak {
  background: rgba(132, 210, 255, 0.92);
}

#startGameButton {
  margin-top: 16px;
  border: none;
  padding: 11px 18px;
  border-radius: 9px;
  background: #ffd35d;
  color: #1f2a3f;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

#startGameButton:hover {
  background: #ffe38d;
}

#gameOverOverlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  background: rgba(3, 10, 20, 0.78);
  text-align: center;
  padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#gameOverOverlay.hidden {
  display: none;
}

#levelCompleteOverlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  background: rgba(3, 10, 20, 0.8);
  text-align: center;
  padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#levelCompleteOverlay.hidden {
  display: none;
}

#restartButton {
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  background: #ffd35d;
  color: #1f2a3f;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}

#restartButton:hover {
  background: #ffe38d;
}

#nextLevelButton {
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  background: #7ce6a0;
  color: #1f2a3f;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}

#nextLevelButton:hover {
  background: #a5f3bf;
}

#jetUnlockPanel {
  margin-top: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 226, 132, 0.48);
  background: rgba(13, 26, 48, 0.74);
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.35);
}

#jetUnlockTitle {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #ffe184;
  text-shadow: 0 0 10px rgba(255, 220, 132, 0.58);
}

#unlockedJetImage {
  width: 190px;
  height: 190px;
  object-fit: contain;
  margin-top: 8px;
  filter: drop-shadow(0 0 14px rgba(120, 200, 255, 0.32));
}

#unlockedJetName {
  margin-top: 6px;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 1.2px;
  color: #9ce7ff;
  text-shadow: 0 0 10px rgba(140, 225, 255, 0.5);
  text-transform: uppercase;
}

.pulseTitle {
  color: #ffe184;
  text-shadow: 0 0 12px rgba(255, 222, 128, 0.58);
  animation: pulseGlow 1.1s ease-in-out infinite;
}

@keyframes pulseGlow {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

#leaderboardPanel {
  width: min(520px, 90vw);
  max-height: 58vh;
  overflow: auto;
  touch-action: pan-y;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 220, 120, 0.4);
  background: rgba(6, 14, 31, 0.75);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.35);
}

#leaderboardPanel h2 {
  margin-bottom: 8px;
  color: #ffd87a;
  letter-spacing: 1px;
  text-transform: uppercase;
}

#leaderboardList {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: left;
  font-family: "Courier New", monospace;
  font-size: 0.92rem;
  line-height: 1.55;
}

.leaderboardRow {
  display: grid;
  grid-template-columns: 38px 1fr 72px;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 3px 0;
}

.leaderboardRow.topRank {
  color: #ffe38d;
}

#leaderboardPrompt {
  margin-top: 10px;
}

#leaderboardPrompt.hidden {
  display: none;
}

#leaderboardPromptText {
  margin-bottom: 8px;
  color: #9ce7ff;
}

#leaderboardForm {
  display: flex;
  justify-content: center;
  gap: 8px;
}

#leaderboardNameInput {
  width: 180px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #f2f7ff;
  padding: 8px 10px;
  font-weight: bold;
  text-transform: uppercase;
}

#leaderboardNameInput:focus {
  outline: 2px solid rgba(153, 225, 255, 0.7);
}

#leaderboardSubmitButton {
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  background: #67d5ff;
  color: #12314d;
  font-weight: bold;
  cursor: pointer;
}

@media (max-width: 700px) {
  #hud {
    top: 8px;
    left: 8px;
    font-size: 0.9rem;
    padding: 8px 10px;
  }

  #radarCanvas {
    top: 8px;
    right: 8px;
    width: 132px;
    height: 132px;
  }

  .mobilePad {
    bottom: max(10px, env(safe-area-inset-bottom));
    gap: 6px;
  }

  .mobilePad button {
    min-width: 60px;
    height: 50px;
    border-radius: 10px;
    font-size: 0.78rem;
  }

  #touchStick {
    width: 116px;
    height: 116px;
  }

  #touchStickKnob {
    width: 50px;
    height: 50px;
  }

  #gameOverOverlay,
  #levelCompleteOverlay {
    gap: 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  #leaderboardPanel {
    width: 96vw;
    max-height: 52vh;
    padding: 10px 12px;
  }

  #leaderboardForm {
    flex-direction: column;
    align-items: center;
  }

  #leaderboardNameInput {
    width: min(220px, 86vw);
  }
}
