* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #6ba7d6;
  color: #1d2d35;
  font-family: "Trebuchet MS", "Microsoft YaHei", sans-serif;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  user-select: none;
}

.game-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #6ba7d6;
}

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

.hud {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(70px, calc(env(safe-area-inset-right) + 70px));
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.badge,
.score {
  min-width: 92px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 2px solid rgba(29, 45, 53, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 4px 0 rgba(29, 45, 53, 0.16);
  font-size: 14px;
}

.badge strong,
.score strong {
  font-size: 18px;
}

.meter {
  width: min(36vw, 230px);
  height: 19px;
  overflow: hidden;
  border: 2px solid rgba(29, 45, 53, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
}

.meter i {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff6d7d, #ffc14d);
  transition: width 160ms ease;
}

.fullscreen-button {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 6;
  width: 48px;
  height: 48px;
  border: 2px solid rgba(29, 45, 53, 0.34);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 4px 0 rgba(29, 45, 53, 0.2);
  font-size: 22px;
  font-weight: 900;
}

.start-panel,
.game-over {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 5;
  width: min(420px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  padding: 22px;
  border: 3px solid rgba(29, 45, 53, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 9px 0 rgba(29, 45, 53, 0.16);
  text-align: center;
}

.start-panel h1,
.game-over h2 {
  margin: 0 0 8px;
  font-size: clamp(30px, 8vw, 48px);
  line-height: 1;
}

.start-panel p,
.game-over p {
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 1.55;
}

.start-panel button,
.game-over button {
  min-width: 150px;
  min-height: 46px;
  border-radius: 8px;
  background: #ffcf5a;
  box-shadow: inset 0 -4px 0 rgba(29, 45, 53, 0.15), 0 4px 0 rgba(29, 45, 53, 0.2);
  font-weight: 800;
}

.controls {
  position: fixed;
  inset: auto max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  z-index: 4;
  height: min(42vh, 230px);
  pointer-events: none;
}

.joystick {
  position: absolute;
  left: 8px;
  bottom: 10px;
  width: clamp(116px, 22vw, 150px);
  height: clamp(116px, 22vw, 150px);
  border: 2px solid rgba(29, 45, 53, 0.26);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.08));
  box-shadow: inset 0 0 22px rgba(255, 255, 255, 0.28), 0 5px 0 rgba(29, 45, 53, 0.15);
  pointer-events: auto;
}

.joystick-stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54%;
  height: 54%;
  border: 2px solid rgba(29, 45, 53, 0.3);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 4px 0 rgba(29, 45, 53, 0.2);
  transform: translate(-50%, -50%);
}

.controls button {
  position: absolute;
  display: grid;
  place-items: center;
  border: 2px solid rgba(29, 45, 53, 0.34);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 4px 0 rgba(29, 45, 53, 0.2);
  font-weight: 900;
  pointer-events: auto;
}

.controls button:active,
.controls button.active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(29, 45, 53, 0.2);
}

.action-main {
  right: clamp(30px, 6vw, 54px);
  bottom: 10px;
  width: clamp(76px, 12vw, 88px);
  height: clamp(76px, 12vw, 88px);
  background: rgba(255, 161, 90, 0.86) !important;
  font-size: 24px;
}

.action-jump {
  right: clamp(10px, 2vw, 22px);
  bottom: clamp(94px, 24vh, 118px);
  width: clamp(58px, 9vw, 66px);
  height: clamp(58px, 9vw, 66px);
  background: rgba(142, 218, 130, 0.86) !important;
  font-size: 20px;
}

.action-small {
  left: clamp(132px, 24vw, 172px);
  bottom: 16px;
  width: 54px;
  height: 54px;
  background: rgba(255, 220, 115, 0.82) !important;
}

.skill {
  width: clamp(50px, 8vw, 58px);
  height: clamp(50px, 8vw, 58px);
  font-size: 18px;
  background: rgba(255, 255, 255, 0.78) !important;
}

.skill-1 {
  right: clamp(116px, 16vw, 138px);
  bottom: 20px;
}

.skill-2 {
  right: clamp(122px, 16vw, 146px);
  bottom: clamp(86px, 21vh, 104px);
}

.skill-3 {
  right: clamp(58px, 9vw, 78px);
  bottom: clamp(144px, 34vh, 166px);
}

.skill-4 {
  right: clamp(180px, 24vw, 210px);
  bottom: clamp(66px, 16vh, 84px);
}

.hidden {
  display: none;
}

@media (orientation: portrait) {
  .controls {
    height: 260px;
  }

  .joystick {
    width: 118px;
    height: 118px;
  }

  .action-main {
    right: 36px;
    width: 78px;
    height: 78px;
  }

  .action-jump {
    right: 10px;
    bottom: 104px;
    width: 58px;
    height: 58px;
  }

  .skill {
    width: 52px;
    height: 52px;
  }

  .skill-1 {
    right: 118px;
    bottom: 20px;
  }

  .skill-2 {
    right: 124px;
    bottom: 92px;
  }

  .skill-3 {
    right: 74px;
    bottom: 156px;
  }

  .skill-4 {
    right: 184px;
    bottom: 72px;
  }
}
