.moon-blocks {
  --moon-ink: #37251c;
  --moon-red: #8a3529;
  color: var(--moon-ink);
  background: #f5eddf;
  scroll-margin-top: 84px;
}
.moon-blocks [hidden] { display: none !important; }
.moon-layout {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
  align-items: center;
  gap: clamp(24px, 5vw, 82px);
  box-sizing: border-box;
  max-width: 1400px;
  margin: auto;
  padding: clamp(28px, 5vw, 76px) 6%;
}
.moon-copy { min-width: 0; }
.moon-blocks .moon-title {
  font: 600 clamp(31px, 4vw, 55px)/1.22 'Songti TC', 'Noto Serif TC', Georgia, serif;
  margin: 0 0 18px;
  color: var(--moon-ink);
  letter-spacing: .03em;
  text-wrap: balance;
}
.moon-blocks .moon-intro {
  font-size: clamp(16px, 1.4vw, 18px);
  line-height: 1.8;
  letter-spacing: .015em;
  color: #5d5146;
  margin: 0;
  max-width: 32em;
}
.moon-progress, .moon-lamps, .moon-actions { display: flex; align-items: center; }
.moon-progress { gap: 12px; flex-wrap: wrap; margin: 23px 0 19px; }
.moon-count { font-size: 15px; color: #57483b; }
.moon-lamps { gap: 6px; height: 25px; }
.moon-lamp {
  position: relative;
  display: block;
  width: 13px;
  height: 15px;
  border-radius: 45% 45% 30% 30%;
  border: 1px solid #998974;
  background: #b5a798;
}
.moon-lamp::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 3px;
  border-radius: 1px;
  background: #786854;
}
.moon-lamp.is-lit {
  background: radial-gradient(ellipse at 50% 60%, #fff9b3 0%, #ffc14a 43%, #dc732b 75%);
  border-color: #bb7232;
  box-shadow: 0 0 8px #ffc76c;
}
.moon-actions { gap: 14px; flex-wrap: wrap; }
.moon-blocks .moon-cast, .moon-blocks .moon-fortune {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 48px;
  padding: 9px 25px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .04em;
  text-decoration: none;
  border-radius: 5px;
  cursor: pointer;
}
.moon-cast { color: #fff7e9; background: var(--moon-red); border: 1px solid var(--moon-red); }
.moon-cast[aria-disabled="true"] { cursor: wait; opacity: .8; }
.moon-fortune { color: var(--moon-red); background: transparent; border: 1px solid #ae8070; }
.moon-blocks :is(button, a):focus-visible { outline: 3px solid #cf8c36; outline-offset: 4px; }
.moon-stage {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  min-width: 0;
  width: 100%;
  display: grid;
  grid-template-rows: minmax(150px, 1fr) auto;
  min-height: 306px;
  border-radius: 9px;
  border: 1px solid #77523a;
  background: radial-gradient(ellipse at 45% 20%, #744a35, #3a231c 66%, #281a17);
  box-shadow: 0 12px 30px -20px #4a1a0b;
}
.moon-stage::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(to bottom, #24120e99, #321b18e8 47%, #261b16 100%),
              url('/assets/mazu-small.webp') center 39% / cover;
  opacity: .89;
}
.moon-pair {
  align-self: end;
  width: min(84%, 420px);
  height: 140px;
  margin: 26px auto 0;
  position: relative;
  background: radial-gradient(ellipse 51% 21% at 52% 76%, #bc856147, transparent);
}
.moon-position {
  position: absolute;
  width: 35%;
  height: 41%;
  top: 46%;
}
.moon-left { left: 12%; transform: rotate(-24deg); }
.moon-right { right: 11%; transform: rotate(158deg); }
.moon-position::before {
  content: '';
  position: absolute;
  inset: 22% 4% 0;
  border-radius: 50%;
  background: #130a08;
  filter: blur(5px);
  transform: translateY(8px);
  opacity: .7;
}
.moon-piece, .moon-body { position: absolute; inset: 0; display: block; }
.moon-piece { transform-origin: center; }
.moon-body {
  overflow: hidden;
  border-radius: 3% 5% 55% 49% / 15% 21% 96% 94%;
  mask-image: radial-gradient(ellipse 59% 57% at 50% -40%, transparent 98%, #000 100%);
  -webkit-mask-image: radial-gradient(ellipse 59% 57% at 50% -40%, transparent 98%, #000 100%);
}
.moon-piece[data-face="curved"] .moon-body {
  background: radial-gradient(ellipse 76% 65% at 45% 21%, #fb9871, transparent 58%),
              linear-gradient(168deg, #a83723 1%, #d45032 20%, #a83220 48%, #6f2015 70%, #390f0a 92%);
  box-shadow: inset 1px -5px 6px #44130c, inset 0 5px 3px #ffa37566;
}
.moon-piece[data-face="flat"] .moon-body {
  background: repeating-linear-gradient(8deg, transparent 0 6px, #67251630 6.5px 7px, transparent 8px 11px),
              linear-gradient(177deg, #fd9b70, #e57950 56%, #c15738 72%, #79291d 75%, #862f20 94%, #441912);
  box-shadow: inset 1px 1px 3px #f8aa84, inset 0 -3px 2px #592014;
}
.moon-stage.is-casting .moon-left .moon-piece { animation: moon-cast-left .8s both; }
.moon-stage.is-casting .moon-right .moon-piece { animation: moon-cast-right .8s .15s both; }
@keyframes moon-cast-left {
  0%, 100% { transform: translateY(0) rotate(0) rotateX(0); }
  40% { transform: translate(4px,-64px) rotate(-17deg) rotateX(220deg); }
  76% { transform: translateY(0) rotate(3deg) rotateX(358deg); }
  86% { transform: translateY(-7px) rotate(-2deg) rotateX(365deg); }
}
@keyframes moon-cast-right {
  0%, 100% { transform: translateY(0) rotate(0) rotateX(0); }
  40% { transform: translate(-7px,64px) rotate(18deg) rotateX(-212deg); }
  76% { transform: translateY(0) rotate(-4deg) rotateX(-357deg); }
  86% { transform: translateY(6px) rotate(2deg) rotateX(-364deg); }
}
.moon-blocks .moon-sound {
  position: absolute;
  top: 9px;
  right: 10px;
  min-height: 44px;
  padding: 7px 12px;
  color: #f3e5cd;
  background: #261b16db;
  border: 1px solid #c89e756e;
  border-radius: 5px;
  font-size: 14px;
  cursor: pointer;
}
.moon-outcome { padding: 4px 20px 24px; text-align: center; }
.moon-blocks .moon-result { display: block; color: #ffdfa2; font: 600 clamp(23px, 3vw, 34px)/1.3 'Songti TC', Georgia, serif; }
.moon-blocks .moon-detail { font-size: 16px; line-height: 1.55; color: #f2dfc8; margin: 7px auto 0; min-height: 2.8em; max-width: 35em; }
.moon-blessed .moon-stage { border-color: #bb8748; }
@media (max-width: 700px) {
  .moon-layout { grid-template-columns: 1fr; gap: 18px; padding: 32px 5.5%; }
  .moon-copy { display: contents; }
  .moon-blocks .moon-title { margin: 0; }
  .moon-blocks .moon-intro { margin: -8px 0 0; }
  .moon-stage { grid-row: 3; min-height: 265px; }
  .moon-progress { margin: 0; }
  .moon-actions { margin-top: -3px; }
  .moon-cast { flex: 1; }
  .moon-pair { width: min(88%, 360px); height: 116px; }
  .moon-outcome { padding-bottom: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .moon-stage.is-casting .moon-position .moon-piece { animation: none; }
}
