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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #87ceeb;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#gameWrap {
  position: fixed;
  inset: 0;
}

/* 手机强制横屏：竖屏时把整个游戏旋转 90°，宽高互换 */
#gameWrap.forced {
  width: 100vh;
  height: 100vw;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(90deg);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------------- HUD ---------------- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 10;
  background: linear-gradient(rgba(15, 35, 60, 0.42), rgba(15, 35, 60, 0));
}

#hudLeft {
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

#levelTag {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
}

#scoreTag {
  font-size: 19px;
  font-weight: 800;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

#birdsTag {
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 30px;
}

.birdIcon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a75, #e63a24 58%, #8f1306);
  position: relative;
  box-shadow: inset -3px -3px 6px rgba(0, 0, 0, 0.28), 0 2px 4px rgba(0, 0, 0, 0.4);
  animation: birdIn 0.3s ease-out;
}

.birdIcon::before,
.birdIcon::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  top: 9px;
}

.birdIcon::before { left: 5px; }
.birdIcon::after { right: 5px; }

@keyframes birdIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

#hudRight {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.hudBtn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  font-size: 19px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.1s;
}

.hudBtn:active { transform: scale(0.9); }

/* ---------------- 提示 ---------------- */
#msg {
  position: absolute;
  left: 50%;
  bottom: 16%;
  transform: translateX(-50%);
  color: #fff;
  font-size: clamp(17px, 4vw, 24px);
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.35s;
  pointer-events: none;
  z-index: 12;
  text-align: center;
  white-space: nowrap;
}

#msg.show { opacity: 1; }

/* ---------------- 难度升级横幅 ---------------- */
#diffBanner {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translateX(-50%) scale(0.4);
  color: #fff;
  font-size: clamp(28px, 8vw, 56px);
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 0 18px rgba(255, 120, 20, 0.9), 0 4px 0 #a12b00, 0 10px 30px rgba(0, 0, 0, 0.55);
  background: linear-gradient(135deg, rgba(255, 90, 10, 0.92), rgba(200, 30, 0, 0.92));
  padding: 12px 34px;
  border-radius: 18px;
  border: 3px solid rgba(255, 220, 130, 0.8);
  z-index: 14;
  pointer-events: none;
  animation: diffIn 0.45s ease-out forwards, diffShake 0.35s 0.5s ease-in-out 3;
}

@keyframes diffIn {
  0% { transform: translateX(-50%) scale(0.2); opacity: 0; }
  70% { transform: translateX(-50%) scale(1.15); opacity: 1; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes diffShake {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  25% { transform: translateX(calc(-50% - 8px)) rotate(-2deg); }
  75% { transform: translateX(calc(-50% + 8px)) rotate(2deg); }
}

/* ---------------- 操作引导 ---------------- */
#guideWrap {
  position: absolute;
  z-index: 13;
  pointer-events: none;
  transform: translate(-50%, -130%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#guideArrow {
  font-size: clamp(34px, 8vw, 52px);
  animation: guideBounce 0.7s ease-in-out infinite;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45));
}

#guideLabel {
  background: rgba(20, 40, 70, 0.92);
  color: #fff;
  font-size: clamp(14px, 3.6vw, 18px);
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 12px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

@keyframes guideBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(10px); }
}

/* ---------------- 全屏界面 ---------------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse at 50% 35%, rgba(52, 100, 168, 0.75), rgba(12, 28, 52, 0.88));
  z-index: 20;
  text-align: center;
  padding: 20px;
}

.hidden { display: none !important; }

.screen h1 {
  color: #fff;
  font-size: clamp(30px, 7vw, 52px);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.5);
}

.screen h2 {
  color: #fff;
  font-size: clamp(34px, 8vw, 58px);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.5);
}

.screen .sub {
  color: #eaf4ff;
  font-size: clamp(15px, 3.4vw, 20px);
  line-height: 1.7;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.screen .hint {
  color: rgba(255, 255, 255, 0.75);
  font-size: 14px;
}

.levelBtns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.levelBtn {
  min-width: 92px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s, transform 0.1s;
}

.levelBtn:active { transform: scale(0.95); background: rgba(255, 255, 255, 0.3); }

.levelBtn.locked,
.levelBtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
}

.bigBtn {
  min-width: 150px;
  min-height: 50px;
  padding: 12px 26px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(#ffb347, #ff7a18);
  color: #fff;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 5px 0 #c95b08, 0 10px 20px rgba(0, 0, 0, 0.35);
  transition: transform 0.1s, box-shadow 0.1s;
}

.bigBtn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #c95b08, 0 5px 12px rgba(0, 0, 0, 0.3);
}

.helpBtn {
  min-width: 150px;
  padding: 10px 22px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s, transform 0.1s;
}

.helpBtn:active { transform: scale(0.95); background: rgba(255, 255, 255, 0.28); }

/* ---------------- 新手指引 ---------------- */
#tutorial {
  position: absolute;
  inset: 0;
  z-index: 26;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 18, 34, 0.78);
  backdrop-filter: blur(5px);
  padding: 16px;
}

.tutCard {
  width: min(92vw, 640px);
  max-height: 88vh;
  overflow-y: auto;
  background: linear-gradient(#fdf6e8, #f5e7c8);
  color: #4a3218;
  border-radius: 22px;
  padding: 22px 26px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.tutCard h2 {
  font-size: clamp(22px, 5vw, 30px);
  margin-bottom: 14px;
  color: #c0392b;
}

.tutSteps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  margin: 4px 0 10px;
}

.tutStep {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 12px;
  padding: 10px 12px;
}

.tutNum {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e67e22;
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.tutStep p {
  font-size: clamp(14px, 3.4vw, 16px);
  line-height: 1.55;
}

.tutTip {
  font-size: 13px;
  color: #8a6a3c;
  margin: 4px 0 12px;
}

.tutBtns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.ghostBtn {
  background: rgba(120, 90, 40, 0.14);
  color: #4a3218;
  box-shadow: 0 4px 0 rgba(120, 90, 40, 0.3);
}

.ghostBtn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(120, 90, 40, 0.3);
}

#endBtns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

#endScore {
  color: #ffe27a;
  font-size: clamp(20px, 5vw, 30px);
  font-weight: 800;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* ---------------- 竖屏提示 ---------------- */
#rotateHint {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(10, 22, 40, 0.92);
  color: #fff;
}

#rotateHint p {
  font-size: 20px;
  font-weight: 700;
}

.phone {
  width: 74px;
  height: 120px;
  border: 4px solid #fff;
  border-radius: 14px;
  position: relative;
  animation: rotate 1.6s ease-in-out infinite;
}

.phone::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}

@keyframes rotate {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

/* ---------------- 加载 / 错误 ---------------- */
#loading {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #7fb9e8;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#err {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  background: #fff;
  color: #c0392b;
  padding: 16px 22px;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  font-size: 15px;
  max-width: 86%;
  text-align: center;
}
