/* 云端跳跳乐 · 卡通云端主题（主色 #FF8A3D） */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, #313A70 0%, #171C3E 52%, #0C1027 100%);
  color: #4A3128;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

.game {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: #1B2550;
  box-shadow: 0 0 80px rgba(6, 9, 26, 0.55);
  touch-action: none;
}

#game-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ---------- HUD ---------- */
.safe {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  padding:
    calc(12px + env(safe-area-inset-top, 0px))
    calc(16px + env(safe-area-inset-right, 0px))
    calc(16px + env(safe-area-inset-bottom, 0px))
    calc(16px + env(safe-area-inset-left, 0px));
}

.hud {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 14px 0 7px;
  border-radius: 20px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.score-pill {
  background: linear-gradient(180deg, #FFFBF5 0%, #FFE8CD 100%);
  border: 1px solid rgba(255, 255, 255, 0.85);
  color: #54372A;
  box-shadow:
    0 8px 20px rgba(20, 22, 54, 0.22),
    inset 0 1px 0 #FFFFFF;
}

.pill-ico {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: linear-gradient(145deg, #FFB463 0%, #FF7A2F 100%);
  color: #FFFFFF;
  box-shadow: 0 3px 9px rgba(255, 112, 40, 0.42);
}

.pill-ico .mp-icon {
  width: 16px;
  height: 16px;
}

.score-pill .pill-num {
  font-size: 21px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
}

.score-pill .pill-num.pop {
  animation: num-pop 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.5);
}

.best-pill {
  height: 36px;
  padding: 0 13px 0 11px;
  gap: 6px;
  background: rgba(20, 26, 58, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFF3E0;
  box-shadow: 0 6px 16px rgba(12, 16, 40, 0.18);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  backdrop-filter: blur(12px) saturate(1.2);
}

.best-pill .pill-ico {
  width: 18px;
  height: 18px;
  background: none;
  box-shadow: none;
  color: #FFD28A;
}

.best-pill .pill-ico .mp-icon {
  width: 17px;
  height: 17px;
}

.best-pill .pill-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0.72;
}

.best-pill .pill-num {
  font-size: 16px;
  font-weight: 800;
}

.combo {
  position: absolute;
  top: calc(70px + env(safe-area-inset-top, 0px));
  left: 50%;
  padding: 7px 15px;
  border-radius: 999px;
  background: linear-gradient(135deg, #FFA253 0%, #FF6B2C 100%);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow:
    0 9px 22px rgba(255, 100, 36, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  opacity: 0;
  transform: translate(-50%, -6px) scale(0.82);
  transition: opacity 0.2s ease, transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.5);
}

.combo.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

/* ---------- Bottom controls ---------- */
.bottom-ui {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.power {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 22px;
  opacity: 0;
  transform: translateY(7px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.power.on {
  opacity: 1;
  transform: translateY(0);
}

.power-cap {
  color: #FFE2C1;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-shadow: 0 1px 6px rgba(30, 22, 52, 0.6);
}

.power-track {
  position: relative;
  width: 158px;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(18, 24, 54, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 2px 5px rgba(6, 10, 28, 0.28);
}

/* 绿色安全区：让玩家知道蓄到哪一段松手能落到下一朵云 */
.power-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(156, 255, 208, 0.5), rgba(55, 215, 143, 0.36));
  box-shadow: inset 0 0 0 1px rgba(208, 255, 230, 0.45);
  opacity: 0;
  transition: opacity 0.16s ease;
  pointer-events: none;
}

.power.on .power-zone {
  opacity: 1;
}

.power-needle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  width: 2px;
  margin-left: -1px;
  border-radius: 2px;
  background: rgba(255, 250, 238, 0.92);
  box-shadow: 0 0 6px rgba(255, 250, 238, 0.7);
  opacity: 0;
  transition: left 0.12s ease, opacity 0.16s ease;
  pointer-events: none;
}

.power.on .power-needle {
  opacity: 1;
}

.power-fill {
  position: relative;
  z-index: 1;
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #FFD08A 0%, #FF9A4A 55%, #FF6B2C 100%);
  box-shadow: 0 0 12px rgba(255, 138, 61, 0.75);
  transition: width 0.05s linear, background 0.12s ease, box-shadow 0.12s ease;
}

.power.inzone .power-fill {
  background: linear-gradient(90deg, #D6FFE8 0%, #7BF0B9 52%, #35CE8B 100%);
  box-shadow: 0 0 14px rgba(88, 235, 167, 0.85);
}

.power.inzone .power-cap {
  color: #C4FFE0;
  text-shadow: 0 0 10px rgba(77, 228, 158, 0.55);
}

.power.inzone .power-track {
  border-color: rgba(196, 255, 224, 0.55);
  box-shadow:
    inset 0 2px 5px rgba(6, 10, 28, 0.28),
    0 0 12px rgba(76, 226, 156, 0.28);
}

/* 蓄过头：变红提醒，下一次早点松手 */
.power.over .power-fill {
  background: linear-gradient(90deg, #FFC46B 0%, #FF7A4E 55%, #F0473F 100%);
  box-shadow: 0 0 14px rgba(255, 82, 66, 0.85);
}

.power.over .power-cap {
  color: #FFC7B6;
  text-shadow: 0 0 10px rgba(255, 82, 66, 0.5);
}

.power.over .power-track {
  border-color: rgba(255, 171, 151, 0.55);
  box-shadow:
    inset 0 2px 5px rgba(6, 10, 28, 0.28),
    0 0 12px rgba(255, 82, 66, 0.24);
}

.hint {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 17px 10px 14px;
  border-radius: 999px;
  background: rgba(20, 26, 58, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFF4E5;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: 0 8px 22px rgba(10, 14, 38, 0.18);
  -webkit-backdrop-filter: blur(10px) saturate(1.15);
  backdrop-filter: blur(10px) saturate(1.15);
  animation: hint-float 2.6s ease-in-out infinite;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.hint .mp-icon {
  width: 18px;
  height: 18px;
  color: #FFB05C;
}

.hint.gone {
  opacity: 0;
  transform: translateY(10px);
  animation: none;
}

/* ---------- Game over ---------- */
.over {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(120% 90% at 50% 108%, rgba(255, 138, 61, 0.26), transparent 62%),
    rgba(14, 18, 42, 0.62);
  -webkit-backdrop-filter: blur(7px) saturate(0.92);
  backdrop-filter: blur(7px) saturate(0.92);
}

.over.hidden {
  display: none;
}

.over-card {
  position: relative;
  width: min(340px, 86vw);
  padding: 52px 24px 24px;
  border-radius: 30px;
  text-align: center;
  background: linear-gradient(180deg, #FFFBF4 0%, #FFEFD8 100%);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow:
    0 30px 70px rgba(8, 12, 32, 0.5),
    0 2px 0 rgba(255, 255, 255, 0.7) inset;
}

.over:not(.hidden) .over-card {
  animation: card-in 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.18) both;
}

.over-badge {
  position: absolute;
  top: -30px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(145deg, #FFB463 0%, #FF7A2F 100%);
  border: 4px solid #FFF8EE;
  color: #FFFFFF;
  box-shadow:
    0 10px 26px rgba(255, 110, 44, 0.42),
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
  transform: translateX(-50%);
}

.over-badge .mp-icon {
  width: 30px;
  height: 30px;
}

.over-badge::before,
.over-badge::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #FFD08A;
}

.over-badge::before {
  top: 5px;
  left: -14px;
  box-shadow: 0 0 10px rgba(255, 208, 138, 0.9);
}

.over-badge::after {
  right: -12px;
  bottom: 6px;
  width: 5px;
  height: 5px;
}

.over-kicker {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #A47A5E;
}

.over-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  color: #FF7A2F;
}

.over-score span {
  font-size: 64px;
  font-weight: 900;
  line-height: 1.04;
  letter-spacing: -0.05em;
  text-shadow:
    0 3px 0 #FFE0BF,
    0 12px 26px rgba(255, 122, 47, 0.24);
}

.over-score small {
  font-size: 14px;
  font-weight: 700;
  color: #B08362;
}

.over-line {
  min-height: 21px;
  margin: 12px 0 17px;
  color: #8A6650;
  font-size: 14px;
  line-height: 1.5;
}

.over-best {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  padding: 7px 14px;
  border-radius: 999px;
  background: #FFF3E2;
  border: 1px solid #FFE0BE;
  color: #A06A49;
  font-size: 12px;
  font-weight: 600;
}

.over-best .mp-icon {
  width: 16px;
  height: 16px;
  color: #FF9A4A;
}

.over-best b {
  color: #FF7A2F;
  font-weight: 900;
}

.btn-again {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 54px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, #FFA75A 0%, #FF7A2F 100%);
  color: #FFFFFF;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.06em;
  box-shadow:
    0 12px 24px rgba(255, 110, 44, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.42);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-again .mp-icon {
  width: 21px;
  height: 21px;
}

.btn-again:active {
  transform: translateY(2px) scale(0.985);
  box-shadow:
    0 6px 14px rgba(255, 110, 44, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.btn-again:focus-visible {
  outline: 3px solid rgba(255, 138, 61, 0.45);
  outline-offset: 3px;
}

.flash {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(80% 60% at 50% 78%, rgba(255, 190, 130, 0.75), transparent 70%);
}

.flash.hit {
  animation: flash-out 0.55s ease-out both;
}

@keyframes num-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.32); }
  100% { transform: scale(1); }
}

@keyframes hint-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes card-in {
  0% { opacity: 0; transform: translateY(26px) scale(0.92); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes flash-out {
  0% { opacity: 0.85; }
  100% { opacity: 0; }
}

@media (max-width: 480px) {
  .game { box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hint,
  .over:not(.hidden) .over-card,
  .score-pill .pill-num.pop,
  .flash.hit {
    animation: none;
  }
}
