* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  height: 100vh;
  overflow: hidden;
  position: relative;
  background: transparent;
  touch-action: manipulation; /* 提升触控性能 */
}

/* 背景图 */
#bg-image {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 0;
}

/* 磨砂遮罩 */
#frosted-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  z-index: 1;
}

/* UI 层 */
#ui-layer {
  position: relative;
  height: 100vh;
  z-index: 2;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
            env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* 功德计数 */
#merit-count {
  position: absolute;
  top: 16px;
  left: 16px;
  font-size: 1.5rem; /* 移动端稍小 */
  font-weight: bold;
  color: #222;
  text-shadow: 0 1px 2px rgba(255,255,255,0.7);
  z-index: 10;
}

/* 木鱼容器：响应式缩放 */
#woodfish-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 10;
  overflow: visible;
  /* 防止点击时高亮（移动端） */
  -webkit-tap-highlight-color: transparent;
}

#woodfish {
  width: min(200px, 60vw); /* 最大 200px，小屏按视口宽度比例 */
  height: auto;
  user-select: none;
  overflow: visible;
}

/* 动画 */
@keyframes tapAnimation {
  0% { transform: scale(1); }
  50% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.tapped {
  animation: tapAnimation 0.25s ease-out;
}

/* 飘字 */
#floating-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 11;
}

.floating-text {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: min(24px, 6vw);
  font-weight: bold;
  color: #d4af37;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
  opacity: 1;
  animation: floatUp 1.5s forwards;
}

@keyframes floatUp {
  to {
    transform: translate(-50%, -150%);
    opacity: 0;
  }
}

/* 控制按钮 */
#controls {
  position: absolute;
  top: 16px;        /* 距离顶部 16px */
  right: 16px;      /* 距离右侧 16px */
  display: flex;
  gap: 14px;
  z-index: 10;
  /* 确保在小屏上不会被状态栏遮挡 */
  padding-top: env(safe-area-inset-top);
}

@media (max-width: 375px) {
  #controls {
    gap: 10px;
  }
  #github-icon,
  #settings-btn {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
}

#github-icon,
#settings-btn {
  width: 44px;
  height: 44px; /* 符合触控最小 44x44px 建议 */
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #222;
  text-decoration: none;
  font-size: 18px;
  border: none;
  cursor: pointer;
  backdrop-filter: blur(6px);
  /* 防止 iOS 缩放 */
  -webkit-tap-highlight-color: transparent;
}

/* 模态框 */
.modal {
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  position: relative;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 24px;
  cursor: pointer;
}

#config-select {
  width: 100%;
  padding: 10px;
  margin: 12px 0;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 16px; /* 防止 iOS 自动缩放 */
}

/* 移动端优化：防止双击缩放 */
@media (max-width: 768px) {
  body {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  #merit-count {
    font-size: 1.3rem;
  }

  #github-icon,
  #settings-btn {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
}