* {
  margin: 0;
  padding: 0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

li {
  list-style-type: none;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  touch-action: none;
  background: #000;
}

#box {
  position: relative;
  width: 512px;
  height: 768px;
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  margin: 20px auto;
  overflow: hidden;
  touch-action: none;
}

#map {
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url("../img/bg_1.png") repeat-y;
  background-size: 100% auto;
  touch-action: none;
}

#level {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 24px 16px;
}

#level h1 {
  font-size: 40px;
  padding: 0 12px 48px;
  line-height: 1.3;
  text-align: center;
  color: #fff;
}

#level p {
  margin: 0;
  width: 200px;
  max-width: 70%;
  height: 50px;
  line-height: 50px;
  text-align: center;
  background: #fff;
  font-weight: bolder;
  cursor: pointer;
  border-radius: 4px;
}

#level p:hover,
#level p:active {
  background: #ffa80c;
  color: #fff;
}

#map .plane,
#map .biu,
#map .enemy,
#map .boom,
#map .boom2 {
  position: absolute;
  pointer-events: none;
}

#map .plane {
  z-index: 8;
}

#map .biu {
  z-index: 10;
}

#map .boom2 {
  z-index: 11;
  animation: bling 2s 1;
  animation-fill-mode: forwards;
}

#map .enemy {
  z-index: 9;
}

#map .boom {
  z-index: 7;
  animation: fade 0.8s 1;
  animation-fill-mode: forwards;
}

@keyframes fade {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes bling {
  0% {
    opacity: 1;
  }
  20% {
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
  60% {
    opacity: 0;
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

#score {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  color: #fff;
  line-height: 20px;
  font-size: 14px;
  font-weight: bold;
  z-index: 20;
  pointer-events: none;
}

#restart {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 30;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 24px 16px;
  background: rgba(0, 0, 0, 0.35);
}

#restart p {
  width: 300px;
  max-width: 90%;
  height: auto;
  line-height: 1.4;
  margin: 16px auto;
  color: #fff;
  text-align: center;
}

#restart p span {
  font-weight: bolder;
  font-size: 22px;
  text-align: center;
}

#restart .p1 span {
  color: red;
  font-size: 30px;
}

#restart .p2 span {
  color: #ffa80c;
}

#restart .p3 {
  font-size: 20px;
  width: 140px;
  height: 44px;
  background: rgba(255, 255, 255, 0.8);
  color: #000;
  font-weight: bolder;
  line-height: 44px;
  text-align: center;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 28px;
}

#restart .p3:hover,
#restart .p3:active {
  background: white;
}

/* 手机端全屏适配 */
@media (max-width: 768px), (max-height: 820px) {
  body {
    margin: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
  }

  #box {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    border-radius: 0;
  }

  #level h1 {
    font-size: clamp(28px, 8vw, 40px);
    padding-bottom: 36px;
  }

  #level p {
    width: min(220px, 72vw);
    height: 52px;
    line-height: 52px;
    font-size: 18px;
  }

  #score {
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    font-size: 16px;
  }

  #restart .p1 {
    font-size: 18px;
  }

  #restart .p1 span {
    font-size: 36px;
  }

  #restart .p3 {
    width: min(160px, 50vw);
    height: 48px;
    line-height: 48px;
    font-size: 18px;
  }
}

/* 横屏提示区域优化：尽量铺满，按钮更易点 */
@media (max-width: 768px) and (orientation: landscape) {
  #level h1 {
    font-size: 24px;
    padding-bottom: 16px;
  }

  #level p {
    height: 40px;
    line-height: 40px;
    font-size: 16px;
  }

  #restart .p3 {
    height: 40px;
    line-height: 40px;
    margin-top: 12px;
  }
}
