/* ============================================================
   全局基础
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #ffffff;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  touch-action: none;
}

/* ============================================================
   页面容器
   ============================================================ */
.page {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  overflow: hidden;
}

.page.active {
  opacity: 1;
  pointer-events: all;
}

/* ============================================================
   圆点基础样式
   ============================================================ */
.dot {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
}

/* ============================================================
   Page 0 - 开始页
   ============================================================ */
.start-dot {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: #FF4757;
  cursor: pointer;
  animation: breathe 2.4s ease-in-out infinite;
  box-shadow: 0 8px 40px rgba(255, 71, 87, 0.45);
}

@keyframes breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 40px rgba(255, 71, 87, 0.4); }
  50%       { transform: scale(1.12); box-shadow: 0 14px 60px rgba(255, 71, 87, 0.6); }
}

/* ============================================================
   Page 1 - 变色音符
   ============================================================ */
.dots-container {
  display: flex;
  gap: clamp(16px, 4vw, 36px);
  align-items: center;
  justify-content: center;
  padding: 0 clamp(16px, 5vw, 40px);
  box-sizing: border-box;
  width: 100%;
}

.interactive-dot {
  width: clamp(70px, 22vw, 120px);
  height: clamp(70px, 22vw, 120px);
  flex-shrink: 0;
  background: #FF4757;
}

.interactive-dot:nth-child(2) { background: #FFA502; }
.interactive-dot:nth-child(3) { background: #2ED573; }

/* ============================================================
   提示
   ============================================================ */
.hint {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  color: #aaa;
  pointer-events: none;
  animation: hintFade 2s ease-in-out infinite;
}

.hint-icon { font-size: 28px; }
.hint-text { font-size: 20px; font-weight: 500; }

@keyframes hintFade {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

.next-hint {
  position: absolute;
  bottom: 60px;
  right: 40px;
  font-size: 48px;
  cursor: pointer;
  animation: none;
  color: #90A4AE;
}

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

/* ============================================================
   弹跳动画
   ============================================================ */
@keyframes bounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.35) rotate(-5deg); }
  55%  { transform: scale(0.88) rotate(3deg); }
  75%  { transform: scale(1.12) rotate(-2deg); }
  90%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}

.dot.bouncing {
  animation: bounce 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}

/* ============================================================
   Page 2 - 缩放变形
   ============================================================ */
.resize-area {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.resize-dot {
  width: 150px;
  height: 150px;
  background: #5352ED;
  transform-origin: center center;
  transition: border-radius 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: grab;
  touch-action: none;
}

/* ============================================================
   Page 3 - 爆炸
   ============================================================ */
.explode-area {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.explode-main-dot {
  width: 160px;
  height: 160px;
  background: #FF6B6B;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.explode-main-dot.charging {
  animation: charge 1.5s linear forwards;
}

@keyframes charge {
  0%   { transform: scale(1); }
  80%  { transform: scale(1.25); box-shadow: 0 0 40px 10px rgba(255,107,107,0.7); }
  100% { transform: scale(1.3); box-shadow: 0 0 60px 20px rgba(255,107,107,0.9); }
}

.mini-dot {
  position: absolute;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================
   Page 4 - 摇一摇
   ============================================================ */
.shake-area {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.shake-dot {
  position: absolute;
  border-radius: 50%;
  cursor: pointer;
  transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
              top  0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.shake-permission-btn {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  padding: 16px 36px;
  background: #FF4757;
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(255,71,87,0.4);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10;
}

.shake-permission-btn:active {
  transform: translateX(-50%) scale(0.93);
}

.shake-permission-btn.hidden { display: none; }

/* ============================================================
   Page 5 - 连线
   ============================================================ */
#connect-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.connect-dots-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

.connect-dot {
  position: absolute;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.3s ease;
}

.connect-dot.connected {
  box-shadow: 0 0 0 6px rgba(255,255,255,0.8), 0 0 0 10px currentColor;
}

.connect-dot.flash {
  animation: dotFlash 0.6s ease-in-out infinite;
}

@keyframes dotFlash {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%       { transform: translate(-50%, -50%) scale(1.25); }
}

/* ============================================================
   Page 6 - 自由画布
   ============================================================ */
#free-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

.free-dots-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.free-dot {
  position: absolute;
  border-radius: 50%;
  cursor: grab;
  transform: translate(-50%, -50%);
  pointer-events: all;
  transition: transform 0.1s;
}

.free-dot.deleting {
  animation: shrinkOut 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}

@keyframes shrinkOut {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
}

.save-btn,
.icon-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #eee;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.save-btn:active,
.icon-btn:active { transform: scale(0.9); }

/* 页5 刷新按钮：右上角，保存按钮左边 */
#retry-btn-5 {
  right: 84px; /* save-btn(20+56+8) */
}

/* ============================================================
   Page 7 - 结束页
   ============================================================ */
.end-confetti {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.confetti-dot {
  position: absolute;
  border-radius: 50%;
  top: -80px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg) scale(0.6); opacity: 0; }
}

.end-face-dot {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: #FFD700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 90px;
  cursor: pointer;
  animation: endBounce 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  box-shadow: 0 10px 40px rgba(255,215,0,0.5);
  z-index: 2;
}

@keyframes endBounce {
  0%   { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ============================================================
   导航箭头（前进 + 后退）
   ============================================================ */
.nav-arrow {
  position: absolute;
  bottom: 50px;
  right: 40px;
  font-size: 52px;
  color: #90A4AE;
  cursor: pointer;
  animation: none;
  z-index: 10;
  padding: 10px;
  line-height: 1;
  opacity: 0.85;
}

.nav-arrow.back-btn {
  right: auto;
  left: 40px;
  color: #aaa;
  font-size: 44px;
  animation: none;
  opacity: 0.7;
}

.nav-arrow.back-btn:active {
  opacity: 1;
  transform: scale(0.9);
}

/* ============================================================
   工具类
   ============================================================ */
.hidden { display: none !important; }

/* ============================================================
   长按进度圈
   ============================================================ */
.press-ring {
  position: absolute;
  border-radius: 50%;
  border: 5px solid #FF4757;
  animation: none;
  pointer-events: none;
  transform: scale(0);
  opacity: 0;
  transition: opacity 0.2s;
}

.press-ring.active {
  animation: ringGrow 1.5s linear forwards;
  opacity: 1;
}

@keyframes ringGrow {
  0%   { transform: scale(0.6); opacity: 0.8; }
  100% { transform: scale(1.5); opacity: 0; }
}
