[data-dungeon-theme="treasure"] .stage1-wall {
  background:
    radial-gradient(ellipse at 29% 68%, #f3a75035, transparent 25%),
    radial-gradient(ellipse at 74% 68%, #f3a75035, transparent 25%),
    linear-gradient(90deg, #17100f9c, transparent 42% 64%, #17100f9c),
    repeating-linear-gradient(90deg, transparent 0 104px, #322521 104px 108px),
    repeating-linear-gradient(#504039 0 38px, #42322b 38px 43px, #302521 43px 47px);
  border-bottom-color: #2d211d;
}

[data-dungeon-theme="treasure"] .stage1-wall::after {
  position: absolute;
  inset: 13% 0 auto;
  width: clamp(42px, 7vw, 110px);
  height: 62%;
  margin-inline: auto;
  border: 3px solid #8d6944;
  background:
    linear-gradient(45deg, transparent 28%, #cda469 28% 72%, transparent 72%) center 42% / 15px 15px no-repeat,
    linear-gradient(135deg, transparent 28%, #cda469 28% 72%, transparent 72%) center 42% / 15px 15px no-repeat,
    linear-gradient(90deg, #361e22, #6b3831 22% 78%, #361e22);
  clip-path: polygon(0 0, 100% 0, 100% 83%, 50% 100%, 0 83%);
  content: "";
}

[data-dungeon-theme="treasure"] .stage1-floor {
  background:
    radial-gradient(ellipse at 50% 29%, #bf88483d, transparent 49%),
    linear-gradient(90deg, #1b1310a6, transparent 43% 65%, #1b1310a6),
    repeating-linear-gradient(90deg, transparent 0 72px, #302521 72px 77px),
    repeating-linear-gradient(#524238 0 21px, #43342c 21px 24px, #31261f 24px 28px);
}

[data-dungeon-theme="treasure"] .dungeon-dialogue { border-color: #82664f; }

[data-chest] .intro { border-inline-start-color: var(--accent); }


.chest-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--inset);
  color: var(--muted);
  font-family: var(--mono);
}

.chest-hud strong { color: var(--accent); }
.chest-case-failure { color: var(--red); }

#dungeon-chest-hud {
  position: absolute;
  inset: 10px 12px auto auto;
  z-index: 10;
  align-items: center;
  border: 1px solid #ad8767;
  font-size: .82rem;
}

.scarecrow-sprite {
  width: 44px;
  height: 58px;
  transform-origin: bottom;
  background:
    linear-gradient(90deg, #583b25 2px, #90613d 2px 5px, #583b25 5px) center bottom / 7px 42px no-repeat,
    linear-gradient(#ab8150 2px, #6e4e33 2px) center 28px / 100% 5px no-repeat;
}

.scarecrow-sprite > span { position: absolute; }

.scarecrow-coat {
  inset: 25px 4px 11px;
  background:
    linear-gradient(#d6a567, #d6a567) 64% 72% / 5px 4px no-repeat,
    linear-gradient(90deg, #724234 25%, #b56b42 25% 73%, #834936 73%);
  clip-path: polygon(5% 0, 95% 0, 100% 31%, 75% 37%, 79% 94%, 64% 94%, 64% 100%, 28% 100%, 22% 87%, 25% 37%, 0 31%);
}

.scarecrow-head {
  inset: 11px 11px auto;
  height: 15px;
  background:
    linear-gradient(#382b23, #382b23) 5px 5px / 3px 3px no-repeat,
    linear-gradient(#382b23, #382b23) 14px 5px / 3px 3px no-repeat,
    linear-gradient(#78583c, #78583c) center 11px / 7px 2px no-repeat,
    #d8b078;
  clip-path: polygon(0 0, 100% 0, 100% 75%, 83% 75%, 83% 100%, 17% 100%, 17% 75%, 0 75%);
}

.scarecrow-hat {
  inset: 0 5px auto;
  height: 14px;
  background: linear-gradient(#deb36a 55%, #754a34 55% 72%, #ba894a 72%);
  clip-path: polygon(24% 8%, 73% 0, 78% 61%, 100% 69%, 100% 100%, 0 100%, 0 69%, 22% 61%);
}

#dungeon-chest {
  width: 44px;
  height: 30px;
  transform-origin: bottom;
}

#dungeon-chest .chest-art {
  position: absolute;
  inset: auto auto 0 50%;
  transform: translateX(-50%) scale(.38);
  transform-origin: bottom;
}

#dungeon-chest .chest-gain { inset: -27px 0 auto; font-size: .85rem; }

#dungeon-elder { transform-origin: bottom; }
.elder-sprite { position: relative; width: 40px; height: 56px; }
.elder-sprite > span { position: absolute; }

#elder-reaction {
  position: absolute;
  inset: auto -3px calc(100% + 12px) auto;
  width: max-content;
  max-width: min(36vw, 10rem);
  padding: 6px 8px;
  border: 2px solid #785437;
  background: #f5e6c9;
  color: #302017;
  font: 700 .85rem/1.45 system-ui, sans-serif;
  overflow-wrap: anywhere;
  box-shadow: 3px 3px #20150fa6;
}

#elder-reaction::after {
  position: absolute;
  inset: calc(100% - 1px) 14px auto auto;
  width: 8px;
  height: 8px;
  border-inline-end: 2px solid #785437;
  border-block-end: 2px solid #785437;
  background: #f5e6c9;
  rotate: 45deg;
  content: "";
}

#elder-reaction-announcement {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.elder-robe {
  inset: 22px 7px 0 4px;
  background: linear-gradient(90deg, #303221 22%, #82835b 22% 68%, #545438 68%);
  clip-path: polygon(24% 0, 76% 0, 76% 12%, 90% 12%, 90% 30%, 100% 30%, 100% 88%, 86% 88%, 86% 100%, 14% 100%, 14% 88%, 0 88%, 0 30%, 12% 30%, 12% 12%, 24% 12%);
}

.elder-head {
  inset: 3px 12px 24px 5px;
  background:
    linear-gradient(#352829, #352829) 5px 10px / 3px 3px no-repeat,
    linear-gradient(#352829, #352829) 14px 10px / 3px 3px no-repeat,
    linear-gradient(#b7b0a1 23%, #e0b491 23% 54%, #d7d2bc 54% 78%, #b6ad9a 78%);
  clip-path: polygon(20% 0, 80% 0, 80% 12%, 100% 12%, 100% 62%, 82% 62%, 82% 79%, 66% 79%, 66% 100%, 35% 100%, 35% 90%, 18% 90%, 18% 69%, 0 69%, 0 20%, 20% 20%);
}

.elder-staff {
  inset: 16px 3px 1px auto;
  width: 5px;
  border-inline-end: 2px solid #583923;
  background: #bd9562;
  rotate: 7deg;
}

.chest-art {
  position: relative;
  width: 112px;
  height: 46px;
  border: 5px solid #22131a;
  background: repeating-linear-gradient(90deg, #8e522e 0 24px, #603421 24px 29px);
  box-shadow: inset 0 -6px #503020, 0 9px #08060a80;
}

.chest-art::before {
  position: absolute;
  inset: -40px -5px auto;
  height: 38px;
  border: 5px solid #22131a;
  border-radius: 18px 18px 0 0;
  background: linear-gradient(#b9743b 56%, #704126 56%);
  content: "";
}

.chest-art span {
  position: absolute;
  inset: -10px 0 auto;
  width: 20px;
  height: 20px;
  margin-inline: auto;
  border: 4px solid #593817;
  background: #efbb54;
}

[data-chest-state="reward"] .chest-art::before { transform: translateY(-16px) skewX(-6deg); }
[data-chest-state="reward"] .chest-art span { background: #ffda7e; }
.chest-gain {
  position: absolute;
  inset: 14px 0 auto;
  visibility: hidden;
  color: var(--accent);
  font: 700 1.25rem var(--mono);
  text-align: center;
}

[data-chest-state="reward"] .chest-gain { visibility: visible; }
