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

html, body {
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: 'Arial Black', Arial, sans-serif;
  touch-action: none;
}

#wrap {
  position: relative;
  width: 960px;
  height: 540px;
  margin: 0 auto;
  top: 50%;
  transform: translateY(-50%);
  box-shadow: 0 0 60px #000, 0 0 0 4px #1a1a1a, 0 0 0 6px #444;
  cursor: crosshair;
  background: #000;
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#gl {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

#muteBtn {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  z-index: 6;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(10, 14, 20, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
}
#muteBtn:hover { background: rgba(20, 26, 36, 0.85); }

#hud {
  pointer-events: none;
}

.hidden { display: none !important; }

#startScreen, #endScreen, #levelCompleteScreen {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, #06213a 0%, #000 80%);
  color: #eee;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  z-index: 10;
  padding: 20px;
}

#startScreen h1, #endScreen h1, #levelCompleteScreen h1 {
  font-size: 48px;
  letter-spacing: 3px;
  color: #ffcc00;
  text-shadow: 3px 3px 0 #003a6b, 0 0 20px #0af;
}

#startScreen h1 span, #endScreen h1 span {
  color: #4fd1ff;
}

#levelCompleteScreen h1 {
  color: #5fff7a;
}

#levelCompleteScreen p {
  font-size: 18px;
  color: #ffcf6a;
  max-width: 560px;
}

#startScreen p {
  color: #aac4dd;
  margin-bottom: 6px;
  max-width: 560px;
}

#startScreen ul {
  list-style: none;
  color: #ccc;
  font-size: 14px;
  line-height: 1.8;
}

#startBtn, #restartBtn, #nextLevelBtn {
  margin-top: 16px;
  padding: 14px 32px;
  font-size: 18px;
  letter-spacing: 2px;
  font-weight: bold;
  background: linear-gradient(#ffcc33, #ff9900);
  border: 2px solid #ffe680;
  color: #1a2a05;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(255, 200, 0, 0.6);
}

#startBtn:hover, #restartBtn:hover, #nextLevelBtn:hover {
  filter: brightness(1.15);
}

#endText {
  font-size: 18px;
  color: #ffcf6a;
  max-width: 560px;
}

/* ---------------- touch controls ---------------- */
#touchUI {
  position: absolute;
  inset: 0;
  z-index: 5;
}

#joyBase {
  position: absolute;
  left: calc(26px + env(safe-area-inset-left));
  bottom: calc(110px + env(safe-area-inset-bottom));
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.25);
  pointer-events: auto;
}

#joyThumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(255,204,0,0.55);
  border: 2px solid rgba(255,230,150,0.8);
}

/* Look joystick — same footprint as the movement stick, mirrored on the
   right. Horizontal turning is punchy, vertical is deliberately calmer
   (see LOOK_SENS_X/LOOK_SENS_Y in joueur.js). */
#lookBase {
  position: absolute;
  right: calc(26px + env(safe-area-inset-right));
  bottom: calc(110px + env(safe-area-inset-bottom));
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,120,90,0.35);
  pointer-events: auto;
}

#lookThumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(255,90,60,0.55);
  border: 2px solid rgba(255,180,150,0.8);
}

#fireBtn {
  position: absolute;
  right: calc(35px + env(safe-area-inset-right));
  bottom: calc(235px + env(safe-area-inset-bottom));
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a80, #b3241a 70%);
  border: 3px solid #ffb3ab;
  color: #2a0a05;
  font-weight: bold;
  font-size: 13px;
  letter-spacing: 1px;
  pointer-events: auto;
  box-shadow: 0 0 16px rgba(255,60,40,0.55);
}

/* ---------------- responsive / phone layout ---------------- */
@media (max-width: 760px), (max-height: 620px) {
  #wrap {
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* dynamic viewport height — accounts for mobile browser chrome resizing */
    top: 0;
    transform: none;
    box-shadow: none;
  }
  #startScreen h1, #endScreen h1, #levelCompleteScreen h1 { font-size: 34px; }
  #startScreen p { font-size: 14px; }
  #startScreen ul { font-size: 12px; }
}
