:root {
  --bg-color: #0b0b10;
  --text-color: #fff;
  --accent: #ffd64a;
  --combo-low: #ffffff;
  --combo-mid: #ffd64a;
  --combo-high: #ff5d6c;

  /* 调整气球缩小的原点（视觉上从哪里被"吸进去"） */
  --balloon-origin-x: 54.5%;
  --balloon-origin-y: 42.1%;

  /* 调整脸部膨胀的原点 */
  --face-origin-x: 50%;
  --face-origin-y: 50%;

  /* 脸部最大膨胀比例 */
  --face-inflate: 1.12;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-color);
  color: var(--text-color);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  height: 100vh;
  height: 100dvh;
}

img {
  -webkit-user-drag: none;
  pointer-events: none;
}

/* ===== 舞台 ===== */
.stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}

.frame {
  position: relative;
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  /* frame 的尺寸由 .layer-bg 的天然比例决定 */
  display: inline-block;
  line-height: 0;
}

/* ===== 三层图层 ===== */
.layer {
  display: block;
  user-select: none;
}

.layer-bg {
  /* 底图决定 frame 尺寸 */
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  width: auto;
  height: auto;
  position: relative;
  z-index: 1;
}

.layer-face,
.layer-balloon {
  /* 与底图完全重合（要求素材按相同画布尺寸导出） */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.layer-face {
  z-index: 2;
  transform-origin: var(--face-origin-x) var(--face-origin-y);
  transition: transform 0.7s cubic-bezier(.34, 1.56, .64, 1);
  will-change: transform;
}

.layer-balloon {
  z-index: 3;
  transform-origin: var(--balloon-origin-x) var(--balloon-origin-y);
  transition: transform 0.18s cubic-bezier(.34, 1.56, .64, 1), opacity 0.3s ease-out;
  will-change: transform;
}

/* 终局状态 */
.is-ended .layer-face {
  transform: scale(var(--face-inflate));
}

.is-ended .layer-balloon {
  opacity: 0;
  pointer-events: none;
}

/* 点击瞬间的"啵"反馈 */
.layer-balloon.is-pulsed {
  animation: balloonPulse 0.12s ease-out;
}

@keyframes balloonPulse {
  0%   { filter: brightness(1.0); }
  40%  { filter: brightness(1.3); }
  100% { filter: brightness(1.0); }
}

/* ===== 提示文字（气球上方浮动） ===== */
.hint {
  position: absolute;
  left: 50%;
  top: 8%;
  transform: translateX(-50%);
  z-index: 5;
  pointer-events: none;
  text-align: center;
  animation: hintFloat 2.4s ease-in-out infinite;
}

.hint span {
  display: inline-block;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  white-space: nowrap;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

@keyframes hintFloat {
  0%, 100% { transform: translate(-50%, 0); }
  50%      { transform: translate(-50%, -6px); }
}

.is-clicked .hint,
.is-ended .hint {
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

/* ===== Combo 数字 ===== */
.combo {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translate(-50%, 0);
  z-index: 6;
  pointer-events: none;
  font-size: 64px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.02em;
  color: var(--combo-low);
  text-shadow:
    0 0 12px rgba(255, 255, 255, 0.6),
    0 4px 18px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(0, 0, 0, 0.8);
  opacity: 0;
}

.combo.is-mid  { color: var(--combo-mid); }
.combo.is-high { color: var(--combo-high); }

.combo.is-pop {
  animation: comboPop 0.42s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes comboPop {
  0%   { opacity: 0; transform: translate(-50%, 10px) scale(0.6); }
  35%  { opacity: 1; transform: translate(-50%, -4px) scale(1.2); }
  60%  { transform: translate(-50%, 0) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -20px) scale(0.95); }
}

/* ===== 终局文案 ===== */
.result {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%) scale(0.6);
  z-index: 8;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease-out, transform 0.6s cubic-bezier(.34, 1.56, .64, 1);
}

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

.result-text {
  padding: 14px 28px;
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #ff8a3d, #ff3d6e 70%, #b13dff);
  border-radius: 18px;
  white-space: nowrap;
  box-shadow:
    0 8px 32px rgba(255, 80, 120, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* ===== 重来按钮 ===== */
.restart {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%) scale(0.8);
  z-index: 9;
  opacity: 0;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  padding: 14px 32px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  color: #1a1a1a;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: opacity 0.4s ease-out, transform 0.4s cubic-bezier(.34, 1.56, .64, 1);
  cursor: pointer;
  white-space: nowrap;
}

.restart.is-show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}

.restart:active {
  transform: translateX(-50%) scale(0.94);
}

/* ===== 纸屑 canvas ===== */
.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

/* ===== 横屏提示 ===== */
.orientation-warn {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--bg-color);
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

@media (orientation: landscape) and (max-height: 500px) {
  .orientation-warn {
    display: flex;
  }
  .frame, .confetti {
    visibility: hidden;
  }
}

/* ===== 小屏幕字号微调 ===== */
@media (max-width: 380px) {
  .combo { font-size: 54px; }
  .result-text { font-size: 26px; padding: 12px 22px; }
  .hint span { font-size: 14px; padding: 7px 14px; }
}
