:host {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	max-width: 100%;
}

div {
	/* Size the button's containing block to the sprite, even in a larger host. */
	position: relative;
	flex: none;
	align-self: center;
	width: var(--rpg-actor-size, 144px);
	max-width: 100%;
}

div:has(> span[hidden]) {
	display: none;
}

span {
	display: block;
	position: relative;
	overflow: hidden;
	width: 100%;
	aspect-ratio: 1;
	image-rendering: pixelated;
}

img {
	position: absolute;
	inset: 0 auto auto 0;
	max-width: none;
	display: block;
}

button {
	position: absolute;
	right: 4px;
	bottom: 4px;
	display: grid;
	place-items: center;
	box-sizing: border-box;
	width: 28px;
	height: 28px;
	padding: 0;
	color: white;
	background: #171717;
	border: 1px solid currentColor;
	border-radius: .4rem;
	cursor: pointer;
}

button::before {
	content: '';
	box-sizing: border-box;
	width: 10px;
	height: 12px;
	border-inline: 3px solid currentColor;
}

:host([paused]) button::before {
	width: 0;
	border: solid transparent;
	border-width: 6px 0 6px 10px;
	border-left-color: currentColor;
}

@media (hover: hover) {
	/* Opacity keeps the control in the tab order so focus can reveal it. */
	:host(:not(:hover)) button:not(:focus-visible) {
		opacity: 0;
		pointer-events: none;
	}
}

@media (hover: none) {
	button {
		width: 44px;
		height: 44px;
	}
}

button:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -4px;
}

[hidden] {
	display: none !important;
}
