:root {
  --gold: #ffd166;
  --btn-bg: rgba(255, 255, 255, 0.08);
  --btn-active: rgba(255, 255, 255, 0.22);
  --modal-bg: #111;
  --modal-border: #333;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #000;
  color: #f5f5f5;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI",
        "Microsoft YaHei", sans-serif;
  user-select: none;
}

.stage {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
}

/* 木鱼容器与图片 */
.muyu-wrapper {
  position: relative;
  width: min(70vmin, 560px);
  max-width: 90vw;
}
.muyu-wrapper img {
  width: 100%;
  display: block;
  cursor: pointer;
  transform-origin: center;
  transition: transform 120ms ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* 点击缩放动画 */
.tap { animation: tap-scale 150ms ease; }
@keyframes tap-scale {
  0% { transform: scale(1); }
  50% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* 飘字层与动画 */
.float-layer {
  pointer-events: none;
  position: absolute;
  inset: 0;
  overflow: visible;
}
.float-text {
  position: absolute;
  transform: translate(-50%, 0);
  color: var(--gold);
  font-weight: 700;
  text-shadow: 0 2px 12px rgba(255, 209, 102, 0.35);
  white-space: nowrap;
  animation: rise 1.1s ease-out forwards;
  will-change: transform, opacity;
}
@keyframes rise {
  0% { transform: translate(-50%, 0); opacity: 1; }
  100% { transform: translate(-50%, -70px); opacity: 0; }
}

/* 左上角工具栏 */
.toolbar {
  position: fixed;
  left: 14px;
  top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}
.tool-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--btn-bg);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.2s, transform 0.05s, border-color 0.2s;
}
.tool-btn:hover { background: rgba(255, 255, 255, 0.12); }
.tool-btn:active { transform: scale(0.95); }
.tool-btn.active {
  background: var(--btn-active);
  border-color: rgba(255, 255, 255, 0.3);
}

/* 弹窗 */
.modal.hidden { display: none; }
.modal { position: fixed; inset: 0; z-index: 20; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.modal-body {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 460px);
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.modal-body h2 { margin: 4px 0 12px; font-size: 18px; }
.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.preset {
  display: flex;
  gap: 8px;
  align-items: center;
  background: #0e0e0e;
  border: 1px solid #2a2a2a;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.preset input { accent-color: #ffd166; }

.custom-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}
.custom-label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
#customInput {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #2a2a2a;
  background: #0e0e0e;
  color: #fff;
  outline: none;
}
#customInput:focus { border-color: #3a3a3a; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.btn {
  min-width: 88px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid #2a2a2a;
  background: #111;
  color: #fff;
  cursor: pointer;
}
.btn.primary {
  background: #ffd166;
  color: #000;
  border-color: #ffd166;
  font-weight: 700;
}
.btn.secondary:hover { background: #191919; }

@media (prefers-reduced-motion: reduce) {
  .tap { animation-duration: 1ms; }
  .float-text { animation-duration: 1ms; }
}