:root {
  --bg: #12151e;
  --grid: rgba(255, 255, 255, 0.045);
  --surface: #1b202e;
  --surface-2: #242b3d;
  --ink: #f4f6fb;
  --muted: #98a3bc;
  --border: #0a0c12;
  --line: rgba(255, 255, 255, 0.14);
  --yellow: #f6cf59;
  --yellow-ink: #151515;
  --cyan: #4deeea;
  --red: #ff4d6d;
  --green: #38e59d;
  --shadow: 4px 4px 0 #090b10;
}

html[data-theme="light"] {
  --bg: #f6f4ee;
  --grid: rgba(20, 22, 30, 0.045);
  --surface: #ffffff;
  --surface-2: #f3f0e8;
  --ink: #161822;
  --muted: #616778;
  --border: #181b24;
  --line: #181b24;
  --yellow: #ffd659;
  --shadow: 4px 4px 0 #181b24;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 36px 36px;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 90;
}

.wrap {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 18px;
}

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  gap: 10px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}
.brand-dot {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--yellow-ink);
  border: 2.5px solid var(--border);
  box-shadow: 2px 2px 0 var(--border);
  display: grid;
  place-items: center;
  font-family: "Baloo 2", sans-serif;
  font-size: 21px;
  font-weight: 800;
}
.brand strong {
  display: block;
  font-family: "Baloo 2", sans-serif;
  font-size: 19px;
  line-height: 1.05;
}
.brand small {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--muted);
}

.top-controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.lang-bar {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}
.lang-pill {
  background: transparent;
  color: var(--muted);
  border: none;
  border-right: 1px solid var(--line);
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.12s, color 0.12s;
}
.lang-pill:last-child { border-right: none; }
.lang-pill:hover { color: var(--ink); }
.lang-pill.is-on {
  background: var(--yellow);
  color: var(--yellow-ink);
}
.ctrl-btn {
  background: var(--surface-2);
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
}
.ctrl-btn.is-on {
  background: var(--yellow);
  color: var(--yellow-ink);
  border-color: var(--border);
}

/* 主体单列栈 */
.main-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-top: 20px;
  padding-bottom: 28px;
}

.card {
  background: var(--surface);
  border: 2.5px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
}

/* 1. 精简状态卡片 */
.status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.status-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.status-title h1 {
  margin: 0;
  font-family: "Baloo 2", sans-serif;
  font-size: 21px;
}
.live-badge {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 800;
  background: var(--green);
  color: #0b1913;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
}
.tz-switch {
  display: inline-flex;
  border: 2px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.tz-btn {
  background: var(--surface-2);
  color: var(--ink);
  border: none;
  border-right: 1px solid var(--line);
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.tz-btn:last-child { border-right: none; }
.tz-btn.is-on { background: var(--yellow); color: var(--yellow-ink); }

.status-metrics {
  display: grid;
  grid-template-columns: 0.72fr 1.18fr 1.1fr;
  gap: 12px;
}
@media (max-width: 600px) {
  .status-metrics { grid-template-columns: 1fr; }
}
.metric {
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.metric-highlight {
  background: var(--yellow);
  color: var(--yellow-ink);
  border-color: var(--border);
}
.metric .label {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 800;
  opacity: 0.8;
}
.big-val {
  font-family: "Baloo 2", sans-serif;
  font-size: 40px;
  line-height: 1.05;
}
.clock-val, .merit-val {
  font-family: "JetBrains Mono", monospace;
  font-size: 22px;
  line-height: 1.25;
}
.merit-val { color: var(--yellow); }
html[data-theme="light"] .merit-val { color: #b56800; }
.metric small { font-size: 11.5px; color: var(--muted); }
.metric-highlight small { color: var(--yellow-ink); }

.latest-post {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
  border-left: 3px solid var(--yellow);
  padding-left: 10px;
}
.latest-post a { color: var(--cyan); font-weight: 700; text-decoration: none; }
html[data-theme="light"] .latest-post a { color: #1654c4; }

/* 2. 祈愿游乐台（双 Tab） */
.playground-card { padding: 16px 18px 22px; }
.game-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.game-tab {
  background: var(--surface-2);
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
  font-weight: 800;
  font-size: 14.5px;
  cursor: pointer;
  transition: transform 0.08s;
}
.game-tab.is-active {
  background: var(--yellow);
  color: var(--yellow-ink);
  border-color: var(--border);
  box-shadow: 3px 3px 0 var(--border);
}
.game-panel { display: none; }
.game-panel.is-active { display: block; }

/* 玩法 1：写实红木电子木鱼 */
.muyu-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 4px;
  min-height: 330px;
  user-select: none;
}
.muyu-float-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 6;
}
.merit-float {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translateX(-50%);
  font-weight: 800;
  font-size: 17px;
  color: var(--yellow);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.65);
  white-space: nowrap;
  animation: floatUp 0.92s ease-out forwards;
}
html[data-theme="light"] .merit-float {
  color: #a65700;
  text-shadow: none;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(0.92); }
  16% { opacity: 1; transform: translate(-50%, -12px) scale(1.06); }
  100% { opacity: 0; transform: translate(-50%, -88px) scale(0.98); }
}

/* 熊猫头敲木鱼拆解舞台（无边框直接融入卡片背景） */
.panda-scene {
  position: relative;
  width: min(100%, 300px);
  aspect-ratio: 505 / 508;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
  user-select: none;
}
html[data-theme="dark"] .panda-scene {
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.65));
}
.panda-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}
.panda-mallet {
  transform-origin: 61.5% 60%;
  transform: rotate(0deg);
  transition: transform 0.06s cubic-bezier(0.22, 0.9, 0.3, 1);
}
.panda-scene.is-hit .panda-mallet {
  transform: rotate(56deg);
}
.panda-fish {
  transform: none;
}
.panda-body {
  transform-origin: 35% 85%;
  transition: transform 0.08s ease-out;
}
.panda-scene.is-hit .panda-body {
  transform: rotate(1.5deg);
}

/* 击打点扩散声波（对齐木槌与木鱼顶面接触点） */
.ripple-origin {
  position: absolute;
  left: 81%;
  top: 67%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 6;
}
.sound-wave {
  position: absolute;
  left: -24px;
  top: -24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid rgba(255, 77, 109, 0.9);
  animation: waveOut 0.52s ease-out forwards;
}
@keyframes waveOut {
  0% { transform: scale(0.35); opacity: 0.95; }
  100% { transform: scale(2.6); opacity: 0; }
}

.knock-action-btn {
  margin-top: 6px;
  background: var(--yellow);
  color: var(--yellow-ink);
  border: 2.5px solid var(--border);
  box-shadow: 0 5px 0 var(--border);
  border-radius: 12px;
  padding: 12px 28px;
  font-family: "Baloo 2", "Space Grotesk", sans-serif;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.06s, box-shadow 0.06s;
}
.knock-action-btn:hover { filter: brightness(1.04); }
.knock-action-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--border); }
.wish-total-pill strong {
  color: var(--yellow);
  font-family: "JetBrains Mono", monospace;
}
html[data-theme="light"] .wish-total-pill strong { color: #b56800; }

.muyu-controls {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.muyu-tip { font-size: 13px; color: var(--muted); }
.muyu-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.mini-pill {
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
}
.mini-btn {
  background: var(--surface-2);
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.mini-btn.is-on {
  background: var(--cyan);
  color: #10141c;
  border-color: var(--border);
}

/* 玩法 2：祈愿大转盘 */
.wheel-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.wheel-stage {
  position: relative;
  display: grid;
  place-items: center;
  padding-top: 14px;
  user-select: none;
}
.wheel-pointer {
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  transform-origin: 50% 12px;
  z-index: 6;
  transition: transform 0.06s;
}
#wheel-canvas {
  width: min(100%, 340px);
  height: auto;
  aspect-ratio: 1 / 1;
  cursor: grab;
  border-radius: 50%;
}
.spin-hub {
  position: absolute;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  border: 4px solid #11131a;
  box-shadow: 0 5px 0 #11131a;
  font-family: "Baloo 2", sans-serif;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  z-index: 5;
}
.spin-hub:active { transform: translateY(3px); box-shadow: 0 2px 0 #11131a; }
.wheel-result {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  text-align: center;
}

/* 3. 精简历史记录 */
.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.history-head h2 { margin: 0; font-family: "Baloo 2", sans-serif; font-size: 18px; }
.mono-dim { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--muted); }
.heatmap-scroll { overflow-x: auto; padding: 4px 0; }
.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 13px);
  grid-auto-flow: column;
  grid-auto-columns: 13px;
  gap: 4px;
  width: max-content;
}
.hm-cell {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: var(--surface-2);
}
.hm-cell.is-reset {
  background: var(--yellow);
  box-shadow: 0 0 6px rgba(246, 207, 89, 0.5);
  cursor: pointer;
}
.heatmap-tip {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.history-details {
  margin-top: 12px;
  border-top: 1.5px solid var(--line);
  padding-top: 10px;
}
.history-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--cyan);
}
html[data-theme="light"] .history-details summary { color: #1654c4; }
.timeline {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tl-item {
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--surface-2);
  font-size: 13px;
}
.tl-item strong {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--yellow);
}
html[data-theme="light"] .tl-item strong { color: #b56800; }

.footer {
  padding: 16px 18px 34px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.footer a { color: var(--muted); }

/* Production additions retain the reference three-section composition. */
.quiet-status { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.quiet-status:empty { display: none; }
.subscribe-form { display: flex; gap: 8px; margin-top: 12px; }
input, textarea, select { font: inherit; }
input, textarea { background: var(--surface-2); color: var(--ink); border: 1.5px solid var(--line); padding: 10px; border-radius: 8px; max-width: 100%; }
.subscribe-form input { flex: 1; min-width: 0; }
button:disabled { opacity: .55; cursor: wait; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--cyan); outline-offset: 4px; }
#wheel-canvas { touch-action: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.tl-item a { color: inherit; text-decoration: none; }
.tl-item small { display: block; color: var(--muted); }
.footer nav { margin-top: 8px; }
.admin-form { display: grid; gap: 12px; }
.admin-form label { display: grid; gap: 5px; }
.admin-form label.check { display: flex; align-items: center; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-output { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 340px; overflow: auto; font-size: 12px; }
[hidden] { display: none !important; }
@media (max-width: 420px) { .topbar-inner { flex-wrap: wrap; } .top-controls { margin-left: auto; } .muyu-btn { padding-left: 0; padding-right: 0; } .muyu-body { max-width: 100%; } .muyu-tip { text-align: center; } }
@media (prefers-reduced-motion: reduce) { .merit-float, .sound-wave { animation-duration: .01s; } }
#admin-panel { display: grid; gap: 18px; }
