/* Reset & body */
html, body {
  margin: 0; 
  padding: 0; 
  overflow: hidden; 
  height: 100vh;
  width: 100vw;
  height: 100%;
  font-family: 'Orbitron', sans-serif;
  /* Khôi phục background ngoài container */
  background: url("../img/bg.png") no-repeat center center fixed;
  background-size: cover;
  color: #fff;
}

/* Logo */
#title-img {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 360px;
  z-index: 20;
  user-select: none;
}

/* Game container */
#game-container {
  width: 100%;
  max-width: 1100px;
  aspect-ratio: 11 / 6.5;
  height: auto;
  margin: 20px auto;
  position: relative;
  background: url("../img/background.png") center/cover no-repeat;
  overflow: hidden;
  border: 4px solid #0ff;
  border-radius: 8px;
  box-shadow: 0 0 12px #0ff, 0 0 24px #0f0;
}

/* HUD */
.hud-container {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 25;
  text-align: right;
  color: #0ff;
  text-shadow: 0 0 4px #0f0, 0 0 8px #0f0;
}

.hud-container .hud-block {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
  user-select: none;
}

.hud-container .hud-block .label {
  font-weight: bold;
}

/* Restart button */
#restart-btn {
  display: block;
  position: absolute;
  top: calc(2 * 1em + 20px);
  right: 0;
  padding: 4px 8px;
  background: transparent;
  color: #0ff;
  border: 2px solid #0ff;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

#restart-btn:hover {
  background: rgba(0,255,255,0.2);
  color: #fff;
}

#sound-btn {
  display: block;
  position: absolute;
  top: calc(2 * 1em + 60px);
  right: 0;
  padding: 4px 8px;
  background: transparent;
  color: #0ff;
  border: 2px solid #0ff;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
#sound-btn:hover {
  background: rgba(0,255,255,0.2);
  color: #fff;
}

/* Footers */
.footer-left, .footer-right {
  position: absolute;
  bottom: 4px;
  font-size: 14px;
  color: #888;
  user-select: none;
}
.footer-left { left: 28px; }
.footer-right { right: 8px; }

/* Common entity styles */
.enemy, .exp, .boss, .bullet, .player-unit, .wall-segment, #gate {
  position: absolute;
  background-size: cover;
}
.enemy { width: 64px; height: 64px; background-image: url("../img/enemy.png"); }
.exp   { width: 64px; height: 64px; background-image: url("../img/exp.png"); }
.boss  { /* size set dynamically */ }
.player-unit { width: 64px; height: 64px; z-index: 5; }
.wall-segment { width: 24px; height: 64px; background-image: url("../img/wall.png"); z-index: 3; }
.bullet { width: 32px; height: 24px; z-index: 6; }

/* Level tag */
.level-tag {
  position: absolute;
  top: -22px; left: 50%;
  transform: translateX(-50%);
  background: #222; color: cyan;
  padding: 2px 6px; border-radius: 6px;
  box-shadow: 0 0 5px cyan; font-size: 14px;
  user-select: none;
}

/* EXP bar */
.exp-bar-container {
  position: absolute;
  right: 100%; top: 0;
  width: 8px; height: 64px;
  background: linear-gradient(to top, #222, #444);
  border: 1px solid #666; border-radius: 4px;
  margin-right: 4px; z-index: 4;
}
.exp-bar-fill {
  position: absolute; bottom: 0; width: 100%;
  background: linear-gradient(to top, #0f0, #6f6);
  box-shadow: 0 0 6px #0f0;
  transition: height 0.3s ease;
}

/* ảnh kết quả */
#result-img {
  display: none;
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%,-50%);
  width: 360px; z-index: 30;
}

/* hiệu ứng nổ */
@keyframes explode {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}


@media screen and (orientation: portrait) {
  #game-container,
  .hud-container,
  #title-img,
  #result-img {
    display: none !important;
  }

  body::before {
    content: "Please rotate your device to landscape mode to play.";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    color: #0ff;
    font-family: 'Orbitron', sans-serif;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    z-index: 9999;
  }
}

/* Tối ưu full màn hình */
html, body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#game-container {
  width: 1100px;
  height: 650px;
  margin: 20px auto;
  max-width: none;
  max-height: none;
}

@media (max-width: 768px) and (orientation: landscape) {
  #game-container.mobile-height {
    width: 100vw;
    height: 100vh;
    max-height: none;
    max-width: none;
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
  }
}

#wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
}

@media (max-width: 768px) and (orientation: landscape) {
  #game-container.mobile-height {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    margin: 0;
    border: none;
    border-radius: 0;
  }
}

#btn-fire {
  position: fixed;
  bottom: 30px;
  right: 40px;
  width: 92px;
  height: 92px;
  font-size: 35px;
  font-weight: bold;
  background: none;
  border: 3px solid #0ff;
  border-radius: 50%;
  color: #0ff;
  box-shadow: 0 0 10px #0ff;
  z-index: 1000;
}

html.not-touch #btn-fire {
  display: none;
}

/* Joystick ảo */
#joystick-zone {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 120px;
  height: 120px;
  z-index: 999;
  touch-action: none;
}

#joystick-base {
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.05);
  border: 2px solid #0ff;
  border-radius: 50%;
  position: relative;
}

#joystick-knob {
  width: 50px;
  height: 50px;
  background: #0ff;
  border-radius: 50%;
  position: absolute;
  top: 35px;
  left: 35px;
  transition: 0.1s;
  touch-action: none;
}

/* Container cho thanh HP của địch */
.enemy-hp-container {
  background: #333;
  border: 1px solid #000;
  border-radius: 4px;
  overflow: hidden;
}

.enemy-hp-container .enemy-hp-bar {
  background: linear-gradient(to right, #ff5555, #ff0000);
  transition: width 0.3s ease;
}
