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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(#aee3f5, #e8f7ff 60%, #d9f0d3);
  touch-action: none;
  user-select: none;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
}

#hud {
  position: fixed;
  top: 12px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
}

.home-btn {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  color: #5d544a;
  text-decoration: none;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
}

.score-box {
  background: rgba(60, 50, 40, 0.75);
  color: #fff;
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 12px;
  text-align: center;
}

.score-box span {
  display: block;
  font-size: 20px;
  font-weight: bold;
}

.score-box.gold { background: rgba(180, 130, 20, 0.85); }

.score-box.lives span { font-size: 16px; letter-spacing: 1px; }

.score-box.gold b { font-size: 15px; }

#overlay,
#level-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 35, 30, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #fff;
  z-index: 18;
}

#overlay.hidden,
#level-overlay.hidden { display: none; }

#overlay-title,
#level-title {
  font-size: 36px;
  font-weight: bold;
  text-align: center;
  padding: 0 24px;
}

#overlay-detail,
#level-detail {
  font-size: 16px;
  opacity: 0.9;
  text-align: center;
  line-height: 1.8;
  padding: 0 32px;
}

#restart,
#level-btn {
  background: #e8a020;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px 36px;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
}

.confetti {
  position: fixed;
  top: -16px;
  width: 10px;
  height: 14px;
  z-index: 30;
  pointer-events: none;
  animation: confetti-fall 3s ease-in forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0.5;
  }
}

.share-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 15px;
  cursor: pointer;
}

.share-btn.hidden { display: none; }

#share-modal {
  position: fixed;
  inset: 0;
  background: rgba(40, 35, 30, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

#share-modal.hidden { display: none; }

.share-card {
  width: min(84vw, 360px);
  text-align: center;
  color: #fff;
}

.share-card img {
  width: 100%;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.share-card p {
  font-size: 13px;
  opacity: 0.8;
  margin: 12px 0;
}

#share-download {
  display: inline-block;
  background: #e8a020;
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 15px;
  margin-bottom: 10px;
}

#share-close {
  display: block;
  margin: 0 auto;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  cursor: pointer;
}

#start-tip {
  position: fixed;
  bottom: 12vh;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(60, 50, 40, 0.7);
  font-size: 16px;
  pointer-events: none;
  transition: opacity 0.5s;
}

#tutorial {
  position: fixed;
  inset: 0;
  background: rgba(40, 35, 30, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

#tutorial.hidden { display: none; }

.tutorial-card {
  width: min(88vw, 400px);
  background: #fffdf8;
  border-radius: 16px;
  padding: 24px;
  color: #4a4238;
}

.tutorial-card h2 {
  text-align: center;
  margin-bottom: 16px;
}

.tutorial-card ul {
  list-style: none;
  margin-bottom: 20px;
}

.tutorial-card li {
  font-size: 14px;
  line-height: 1.6;
  padding: 8px 0;
  border-bottom: 1px dashed #e8e0d2;
}

.tutorial-card li:last-child { border-bottom: none; }

#start-game {
  display: block;
  width: 100%;
  background: #e8a020;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
}

#toast {
  position: fixed;
  bottom: 16vh;
  left: 50%;
  transform: translateX(-50%);
  max-width: 84vw;
  background: rgba(40, 35, 30, 0.85);
  color: #fff;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 15px;
  text-align: center;
  pointer-events: none;
  z-index: 15;
  transition: opacity 0.3s;
}

#toast.hidden {
  opacity: 0;
}

#help-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.6);
  color: #5d544a;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}

#bgm-btn {
  position: fixed;
  top: 12px;
  right: 54px;
  z-index: 10;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.6);
  font-size: 15px;
  cursor: pointer;
}

.tutorial-fig {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 12px;
}

/* 横屏提示：窄高度的横屏（手机横拿）时提示竖屏体验更佳 */
#rotate-tip {
  display: none;
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(40, 35, 30, 0.75);
  color: #fff;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  z-index: 12;
  pointer-events: none;
}

@media (orientation: landscape) and (max-height: 500px) {
  #rotate-tip { display: block; }
}
