/* ============ 主题变量 ============ */
:root {
  --bg: #0e0f1a;
  --bg-2: #16182a;
  --text: #ece8ff;
  --text-dim: #a9a6c4;
  --glass: rgba(255, 255, 255, 0.07);
  --glass-hover: rgba(255, 255, 255, 0.14);
  --glass-brd: rgba(255, 255, 255, 0.14);
  --accent: #e7b078;
  --accent-2: #8b6cf0;
  --shadow: rgba(0, 0, 0, 0.45);
  --blob-1: #6d4bff;
  --blob-2: #ff7a9c;
  --blob-3: #38d9c8;
}

:root[data-theme="light"] {
  --bg: #f4efe6;
  --bg-2: #fffdf8;
  --text: #2a2418;
  --text-dim: #6f6753;
  --glass: rgba(255, 255, 255, 0.55);
  --glass-hover: rgba(255, 255, 255, 0.78);
  --glass-brd: rgba(120, 90, 40, 0.18);
  --accent: #b9763e;
  --accent-2: #6b53d6;
  --shadow: rgba(120, 90, 40, 0.18);
  --blob-1: #b9a6ff;
  --blob-2: #ffc2d2;
  --blob-3: #aef3e8;
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  transition: background 0.4s ease, color 0.4s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ============ 极光背景 ============ */
.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  filter: blur(60px);
  opacity: 0.55;
}
.blob {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  mix-blend-mode: screen;
  animation: drift 22s ease-in-out infinite;
}
:root[data-theme="light"] .blob { mix-blend-mode: multiply; opacity: 0.7; }
.b1 { background: var(--blob-1); top: -12vmax; left: -8vmax; }
.b2 { background: var(--blob-2); bottom: -16vmax; right: -10vmax; animation-delay: -7s; }
.b3 { background: var(--blob-3); top: 30vmax; left: 40vmax; animation-delay: -13s; }
@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(6vmax, 4vmax) scale(1.12); }
  66% { transform: translate(-5vmax, -3vmax) scale(0.92); }
}

/* ============ 布局 ============ */
.app {
  position: relative;
  z-index: 1;
  width: min(440px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.glass {
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid var(--glass-brd);
  border-radius: 20px;
  box-shadow: 0 10px 30px var(--shadow);
}

/* 统计栏 */
.stats {
  display: flex;
  justify-content: space-around;
  padding: 16px 8px;
}
.stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.label { font-size: 12px; color: var(--text-dim); letter-spacing: 0.05em; }
.value {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* 作者卡片 */
.author {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}
.author .avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--glass-brd);
  box-shadow: 0 2px 8px var(--shadow);
  flex: none;
}
.author .who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.author .name { font-size: 15px; font-weight: 700; color: var(--text); }
.author .desc { font-size: 12px; color: var(--text-dim); }
.author .blog-link {
  margin-left: auto;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: #2a1c0a;
  background: var(--accent);
  border: 1px solid var(--accent);
  padding: 8px 12px;
  border-radius: 12px;
  white-space: nowrap;
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
}
.author .blog-link:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 18px rgba(231, 176, 120, 0.45);
  transform: translateY(-2px);
}
.author .blog-link:active { transform: translateY(0) scale(0.97); }

/* 木鱼舞台 */
.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 0 4px;
  min-height: 46vh;
}
.merit-readout { text-align: center; margin-bottom: 6px; }
.merit-readout .big {
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 16px rgba(231, 176, 120, 0.35);
}
.merit-readout .sub { font-size: 13px; color: var(--text-dim); margin-top: 2px; letter-spacing: 0.3em; }

.fish-btn {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  width: min(280px, 72vw);
  filter: drop-shadow(0 14px 24px var(--shadow));
  transition: transform 0.18s ease, filter 0.18s ease;
}
.fish-btn:hover { transform: scale(1.03); filter: drop-shadow(0 20px 34px var(--shadow)); }
.fish-btn:active { transform: scale(0.98); }
.fish-svg { width: 100%; height: auto; display: block; overflow: visible; }

/* 待机轻微呼吸 */
.fish-body { transform-box: fill-box; transform-origin: 50% 60%; animation: breathe 3.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* 敲击：木鱼下压 + 木槌落下 */
.fish-body.knock { animation: knock 0.16s ease; }
@keyframes knock {
  0% { transform: scale(1); }
  45% { transform: scale(0.955) translateY(3px); }
  100% { transform: scale(1); }
}
.mallet { transform-box: fill-box; transform-origin: 184px 42px; transition: transform 0.12s ease; }
.mallet.strike { transform: rotate(14deg); }

/* 飘字 +1 */
.floaters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  animation: floatUp 0.9s ease-out forwards;
  white-space: nowrap;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(10px) scale(0.8); }
  20% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-90px) scale(1.05); }
}

/* 连击徽章 */
.combo-badge {
  position: absolute;
  top: 6px;
  right: 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-2);
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  padding: 4px 10px;
  border-radius: 999px;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.2s, transform 0.2s;
  backdrop-filter: blur(8px);
}
.combo-badge.show { opacity: 1; transform: scale(1); }

.hint { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

/* 控制栏 */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  flex-wrap: wrap;
}
.ctrl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--glass-brd);
  background: var(--glass);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.12s ease, box-shadow 0.2s ease;
}
.ctrl:hover {
  background: var(--glass-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--shadow);
}
.ctrl:active { transform: translateY(0) scale(0.96); }
.ctrl:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ctrl.ghost { background: transparent; color: var(--text-dim); }
.ctrl.ghost:hover { background: transparent; border-color: var(--accent); color: var(--text); }
.ctrl.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #2a1c0a;
}
.ctrl.active:hover { filter: brightness(1.06); box-shadow: 0 6px 16px rgba(231, 176, 120, 0.4); }
.ctrl .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim);
}
.ctrl.active .dot { background: #2a1c0a; box-shadow: 0 0 0 3px rgba(42, 28, 10, 0.25); }

.bpm { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 120px; }
.bpm label { font-size: 12px; color: var(--text-dim); }
.bpm input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  outline: none;
}
.bpm input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  cursor: pointer; box-shadow: 0 2px 6px var(--shadow);
}
.bpm input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); cursor: pointer;
}

@media (max-width: 380px) {
  .merit-readout .big { font-size: 34px; }
  .value { font-size: 22px; }
}
