.lot-envelope {
  --paper: #efc7d2;
  --fold: #e6aabd;
  --crease: #f7dbe3;
  margin: 18px auto 0;
  max-width: 540px;
}
.lot-envelope[data-lot="1"], .lot-envelope[data-lot="3"] {
  --paper: #dce990;
  --fold: #cad876;
  --crease: #eef4c9;
}
.envelope-button {
  position: relative;
  display: grid;
  justify-items: center;
  width: min(82%, 320px);
  margin: 0 auto;
  padding: 0 0 5px;
  background: transparent;
  color: var(--leaf);
  border-radius: 12px;
  touch-action: manipulation;
}
.envelope-button:not(:disabled):active .envelope-art { transform: scale(.97); }
.envelope-art {
  position: relative;
  width: 100%;
  aspect-ratio: 1.58;
  margin-top: 0;
  perspective: 700px;
  isolation: isolate;
  transition: transform .16s ease-out;
}
.envelope-back, .envelope-pocket, .envelope-flap {
  position: absolute;
  inset: 0;
  border-radius: 9px;
}
.envelope-back {
  background: var(--fold);
  box-shadow: 0 8px 24px #39273322;
}
.envelope-pocket {
  z-index: 2;
  background: var(--paper);
  clip-path: polygon(0 0,50% 48%,100% 0,100% 100%,0 100%);
}
.envelope-pocket::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--crease);
  clip-path: polygon(0 100%,50% 39%,100% 100%);
}
.envelope-flap {
  z-index: 3;
  height: 66%;
  background: var(--fold);
  clip-path: polygon(0 0,100% 0,53% 86%,50% 90%,47% 86%);
  transform-origin: top center;
}
.envelope-seal {
  position: absolute;
  z-index: 4;
  top: 43%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 46px;
  aspect-ratio: 1;
  transform: translate(-50%,-50%);
  border-radius: 50%;
  background: var(--berry);
  color: white;
  font-size: 1.3rem;
  box-shadow: 0 2px 4px #3927334d;
}
.envelope-insert {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  inset: 12% 12% 10%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fffcf6;
  color: var(--berry);
  font-size: clamp(1.8rem,9vw,3rem);
  opacity: 0;
}
.envelope-label { margin-top: 12px; font-size: 1.05rem; }
/* The open state swaps the folding artwork for an in-flow, fixed-size icon.
   Its button must not inherit the large footprint of the closed envelope. */
.lot-envelope .opened-envelope { display: none; }
.lot-envelope.is-open .envelope-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  min-height: 44px;
  height: auto;
  padding: 0;
  margin: 0 auto;
  background: transparent;
  border: 0;
}
.lot-envelope.is-open .envelope-art { display: none; }
.lot-envelope.is-open .opened-envelope { display: block; width: 48px; height: 38px; flex: none; }
.lot-envelope.is-open .envelope-label { margin: 0; color: var(--muted); font-size: .9rem; }
.lot-envelope.is-opening .envelope-card { animation: envelope-reveal .24s ease-out both; }
@keyframes envelope-reveal {
  from { opacity: 0; }
  to { opacity: 1; }
}
.envelope-card {
  margin-top: 12px;
  padding: clamp(12px,4vw,24px);
  border: 1px solid var(--fold);
  border-radius: 16px;
  background: #fffcf6;
}
.envelope-card h3 { margin: 0; text-align: center; }
.envelope-card .envelope-copy { margin: 14px auto; text-align: center; white-space: pre-line; overflow-wrap: anywhere; }
.lot-done { color: var(--leaf); font-weight: 650; text-align: center; }
.lot-confirm { min-height: 48px; }
@media (prefers-reduced-motion: reduce) {
  .lot-envelope *, .envelope-button:not(:disabled):active .envelope-art {
    animation: none !important;
    transition: none;
  }
}

#completed-lots { margin-top: 16px; }
#completed-lots summary { min-height: 44px; cursor: pointer; font-weight: 650; }

.visual-clue { display:block; width:min(100%, 440px); height:auto; margin-inline:auto; border-radius:8px; }
