.dungeon-gate-launch {
  position: absolute;
  z-index: 14;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #a58e78;
  background: rgba(9, 6, 6, .72);
  border: 3px solid #4f3d36;
  box-shadow: 3px 3px 0 #000;
  opacity: .58;
  cursor: pointer;
  transition: opacity .12s linear, color .12s linear, border-color .12s linear, transform .12s steps(2, jump-none);
}

.dungeon-gate-launch::after {
  content: "Secret quest";
  position: absolute;
  top: 45px;
  right: -3px;
  width: max-content;
  padding: 5px 7px;
  color: var(--molten-light);
  background: #0b0808;
  border: 2px solid #5c4940;
  box-shadow: 2px 2px 0 #000;
  font-family: var(--pixel);
  font-size: .52rem;
  font-weight: 900;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity .12s linear, transform .12s steps(2, jump-none);
}

.dungeon-gate-launch:hover,
.dungeon-gate-launch:focus-visible {
  color: var(--molten-light);
  border-color: var(--molten);
  opacity: 1;
  outline: 3px solid var(--parchment);
  outline-offset: 3px;
  transform: translate(-1px, -1px);
}

.dungeon-gate-launch:hover::after,
.dungeon-gate-launch:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.dungeon-gate-icon {
  position: relative;
  width: 21px;
  height: 25px;
  display: block;
  overflow: hidden;
  border: 3px solid currentColor;
  border-bottom-width: 4px;
  border-radius: 10px 10px 1px 1px;
}

.dungeon-gate-icon::before {
  content: "";
  position: absolute;
  inset: 4px 3px 0;
  background: repeating-linear-gradient(90deg, currentColor 0 2px, transparent 2px 5px);
  opacity: .78;
}

.dungeon-gate-icon::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 4px;
  height: 3px;
  background: currentColor;
}

.dungeon-dialog {
  width: min(1220px, calc(100% - 24px));
  height: min(900px, calc(100dvh - 24px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  color: var(--parchment);
  background: #0d0909;
  border: 5px solid #080606;
  box-shadow: 0 0 0 4px var(--steel), 16px 16px 0 rgba(0, 0, 0, .72);
}

.dungeon-dialog:not([open]) { display: none; }

.dungeon-dialog::backdrop {
  background: rgba(4, 3, 3, .9);
  backdrop-filter: blur(5px);
}

body:has(.dungeon-dialog[open]) { overflow: hidden; }

.dungeon-frame-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #0d0909;
}

.dungeon-frame-bar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 10px 7px 14px;
  color: var(--molten-light);
  background: #251b1a;
  border-bottom: 4px solid #080606;
  font-family: var(--pixel);
  font-size: .68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.dungeon-frame-bar > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dungeon-frame-rune {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: #24130d;
  background: var(--molten);
  border: 2px solid var(--molten-light);
  box-shadow: 2px 2px 0 #000;
}

.dungeon-frame-bar button,
.dungeon-frame-error button {
  min-height: 34px;
  padding: 5px 12px;
  color: var(--parchment);
  background: #15100f;
  border: 2px solid var(--steel-light);
  box-shadow: 2px 2px 0 #000;
  font-family: var(--pixel);
  font-size: .62rem;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.dungeon-frame-bar button:focus-visible,
.dungeon-frame-error button:focus-visible {
  outline: 3px solid var(--molten-light);
  outline-offset: 2px;
}

.dungeon-frame-stage {
  position: relative;
  min-height: 0;
  background: #0d0909;
}

.dungeon-frame-stage iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  background: #0d0909;
  opacity: 0;
}

.dungeon-frame-stage[data-ready="true"] iframe { opacity: 1; }

.dungeon-frame-loading,
.dungeon-frame-error {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 28px;
  color: var(--ash);
  background:
    radial-gradient(circle at 50% 40%, rgba(168, 46, 27, .22), transparent 42%),
    #0d0909;
  font-family: var(--pixel);
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.dungeon-frame-loading::before {
  content: "";
  width: 36px;
  height: 42px;
  margin: 0 auto 12px;
  border: 5px solid var(--steel-light);
  border-bottom-width: 8px;
  border-radius: 18px 18px 2px 2px;
  box-shadow: inset 0 0 0 5px #171111, 5px 5px 0 #000;
  animation: dungeon-gate-pulse .8s steps(2, jump-none) infinite;
}

.dungeon-frame-stage[data-ready="true"] .dungeon-frame-loading { display: none; }
.dungeon-frame-error[hidden] { display: none; }
.dungeon-frame-error strong { color: var(--molten-light); }
.dungeon-frame-error p { max-width: 520px; margin: 0; text-transform: none; }
.dungeon-frame-error button { width: fit-content; margin-inline: auto; }

@keyframes dungeon-gate-pulse {
  50% { border-color: var(--molten); box-shadow: inset 0 0 0 5px #171111, 5px 5px 0 #000, 0 0 18px rgba(255, 181, 46, .42); }
}

@media (max-width: 660px) {
  .dungeon-dialog {
    width: 100%;
    height: 100dvh;
    border: 0;
    box-shadow: none;
  }

  .dungeon-frame-bar { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .dungeon-gate-launch,
  .dungeon-gate-launch::after { transition: none; }
  .dungeon-frame-loading::before { animation: none; }
}
