/* ミニゲーム（#play の中）と、ドット絵の動き・実績の通知。サイト全体の見た目は site.css */

.countdown-done {
	display: none;
	font-family: var(--font-game);
	font-size: 20px;
	color: var(--orange);
}

.launched .countdown-done {
	display: block;
}

.launched [data-clock-time] {
	display: none;
}

.play-inner {
	display: grid;
	gap: 32px;
	align-items: center;
}

.game {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--line-dark);
	background: #101011;
}

.game > .world {
	order: -3;
}

.game > .game-hint {
	order: -2;
}

.game > .game-complete {
	order: -1;
}

.world {
	--block: calc(100cqw / 12);
	position: relative;
	container-type: inline-size;
	aspect-ratio: 5 / 4;
	overflow: hidden;
	background: var(--black) url("/assets/game/stars.svg") 0 0 / 192px 192px;
}

.hud {
	position: absolute;
	inset: 10px 12px auto;
	z-index: 2;
	display: flex;
	justify-content: space-between;
	font-family: var(--font-game);
	font-size: 12px;
	color: var(--smoke-1);
	text-shadow: 1px 1px 0 var(--black), -1px -1px 0 var(--black);
}

.launchpad {
	position: absolute;
	left: 50%;
	bottom: calc(var(--block) * 2);
	width: 36%;
	transform: translateX(-50%);
}

.launchpad svg {
	width: 100%;
	height: auto;
}

.ship-button {
	position: absolute;
	inset: 0 22% 30%;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
}

.ground {
	position: absolute;
	inset: auto 0 0;
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	height: calc(var(--block) * 2);
	background:
		url("/assets/game/block-top.svg") 0 0 / var(--block) var(--block) repeat-x,
		url("/assets/game/block.svg") 0 100% / var(--block) var(--block) repeat-x;
}

.ground.playable {
	background: none;
}

.block {
	position: relative;
	padding: 0;
	border: 0;
	background: url("/assets/game/block.svg") 0 0 / 100% 100%;
	cursor: pointer;
}

.block.top {
	background-image: url("/assets/game/block-top.svg");
}

.block::after {
	content: "";
	position: absolute;
	inset: 0;
	background: 0 0 / 100% 100% no-repeat;
}

.block[data-hits="1"] {
	filter: brightness(0.8);
	transform: translateY(4%) scale(0.94);
}

.block[data-hits="2"] {
	filter: brightness(0.62);
	transform: translateY(8%) scale(0.88);
}

.block[data-hits="3"] {
	filter: brightness(0.45);
	transform: translateY(12%) scale(0.8);
}

.block:hover,
.block:focus-visible {
	outline: 2px solid rgb(245 245 243 / 70%);
	outline-offset: -2px;
}

.block.air {
	background: none;
}

.hotbar {
	display: grid;
	grid-template-columns: repeat(9, minmax(0, 1fr));
	gap: 4px;
	max-width: 400px;
	margin: 0 auto;
	padding: 10px 12px;
}

.hotbar-slot {
	position: relative;
	display: grid;
	place-items: center;
	aspect-ratio: 1;
	background: #19191a;
	box-shadow: inset 2px 2px 0 var(--black), inset -2px -2px 0 var(--smoke-4);
}

.hotbar-slot img {
	width: 72%;
	height: 72%;
	object-fit: contain;
}

.hotbar-slot .count {
	position: absolute;
	right: 3px;
	bottom: 0;
	font-family: var(--font-game);
	font-size: 12px;
	text-shadow: 1px 1px 0 var(--black);
}

.chat {
	max-height: 10.5em;
	overflow-y: auto;
	padding: 10px 12px;
	border-top: 1px solid var(--line-dark);
	font-family: var(--font-game);
	font-size: 14px;
	line-height: 1.7;
	overflow-wrap: anywhere;
}

.chat-line.cmd {
	color: var(--smoke-1);
}

.chat-line.error {
	color: var(--orange);
}

.typing {
	width: max-content;
	max-width: 100%;
}

.typing::after {
	content: "";
	display: inline-block;
	width: 0.55em;
	height: 1em;
	margin-left: 4px;
	vertical-align: -0.15em;
	background: var(--orange);
}

.console {
	display: flex;
	border-top: 1px solid var(--line-dark);
}

.console input {
	flex: 1;
	min-width: 0;
	padding: 12px;
	border: 0;
	border-radius: 0;
	background: var(--black);
	color: var(--white);
	font-family: var(--font-game);
	font-size: 16px;
}

.console input:focus-visible {
	outline-offset: -2px;
}

.console button {
	padding: 0 20px;
	border: 0;
	border-radius: 0;
	background: var(--orange);
	color: var(--black);
	font-family: var(--font-jp);
	font-weight: 700;
	font-size: 15px;
	cursor: pointer;
}

.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 12px;
}

.chip {
	padding: 6px 10px;
	border: 1px solid var(--smoke-4);
	border-radius: 0;
	background: #19191a;
	color: var(--white);
	font-family: var(--font-mono);
	font-size: 13px;
	cursor: pointer;
}

.chip:hover {
	border-color: var(--orange);
}

.game-hint {
	padding: 0 12px 12px;
	font-size: 12px;
	color: var(--smoke-1);
}

.toasts {
	position: fixed;
	top: 16px;
	right: 16px;
	z-index: 20;
	display: grid;
	gap: 8px;
	width: min(280px, calc(100vw - 32px));
	pointer-events: none;
}

.toast {
	padding: 10px 14px;
	background: var(--black);
	box-shadow: inset 0 0 0 2px var(--smoke-3), 4px 4px 0 rgb(0 0 0 / 40%);
	font-family: var(--font-game);
	line-height: 1.5;
}

.toast-title {
	font-size: 13px;
	color: var(--orange);
}

.toast-name {
	font-size: 16px;
}

@media (min-width: 1024px) {
	.play-inner {
			grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
			gap: 56px;
		}
}

.px {
	overflow: visible;
}

.frame {
	opacity: 0;
}

.frame.still {
	opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
	.px * {
			animation-timing-function: steps(1, end);
			animation-iteration-count: infinite;
		}

	.flame-1,
	.flame-2,
	.flame-3 {
			animation-name: frame-3;
			animation-duration: 0.45s;
		}

	.flame-2 {
			animation-delay: -0.3s;
		}

	.flame-3 {
			animation-delay: -0.15s;
		}

	.hop .flame-1,
	.hop .flame-2 {
			animation-name: frame-2;
			animation-duration: 0.5s;
			animation-delay: 0s;
		}

	.hop .flame-2 {
			animation-delay: -0.25s;
		}

	.smoke-left {
			animation-name: nudge-left;
			animation-duration: 1.2s;
		}

	.smoke-right {
			animation-name: nudge-right;
			animation-duration: 1.2s;
			animation-delay: -0.6s;
		}

	.hop {
			animation-name: rise;
			animation-duration: 1.6s;
		}

	.float {
			animation-name: float;
			animation-duration: 3.2s;
		}

	.launching .smoke-left {
			animation: nudge-left-big 0.24s steps(1, end) infinite;
		}

	.launching .smoke-right {
			animation: nudge-right-big 0.24s steps(1, end) infinite;
		}

	.launching .flame-1,
	.launching .flame-2,
	.launching .flame-3 {
			animation-duration: 0.2s;
		}

	.launching .ground {
			animation: rumble 0.08s steps(2, end) 12;
		}

	.in-space .ship {
			animation-name: float;
			animation-duration: 3.2s;
		}

	.world.in-space {
			animation: stars-fall 6s steps(48, end) infinite;
		}

	.world.launching .ship {
			animation: launch 4.4s both;
		}

	.world.warping {
			animation: warp 0.9s steps(18, end);
		}

	.ground,
	.launchpad {
			transition: transform 0.6s steps(6, end), bottom 0.6s steps(6, end);
		}

	.typing {
			animation: typing 1.6s steps(17, end) 0.6s both;
		}

	.typing::after {
			animation: cursor 1s steps(1, end) infinite;
		}

	.chip:active,
	.console button:active {
			transform: translate(0, 2px);
			box-shadow: none;
		}

	.toast {
			animation: toast-in 0.3s steps(6, end) both;
		}

}

@keyframes frame-2 {
	0% {
		opacity: 1;
	}

	50%,
	100% {
		opacity: 0;
	}
}

@keyframes frame-3 {
	0% {
		opacity: 1;
	}

	33.333%,
	100% {
		opacity: 0;
	}
}

@keyframes nudge-left {
	0% {
		transform: none;
	}

	50%,
	100% {
		transform: translateX(-1px);
	}
}

@keyframes nudge-right {
	0% {
		transform: none;
	}

	50%,
	100% {
		transform: translateX(1px);
	}
}

@keyframes rise {
	0% {
		transform: none;
	}

	50%,
	100% {
		transform: translateY(-1px);
	}
}

@keyframes float {
	0% {
		transform: none;
	}

	25% {
		transform: translateY(-1px);
	}

	50% {
		transform: none;
	}

	75%,
	100% {
		transform: translateY(1px);
	}
}

/* 点火 → 上昇（だんだん速く）→ 画面の外で待つ → 降下（だんだん遅く）→ パッドに着陸。1px = ドット1マス */
@keyframes launch {
	0% {
		transform: none;
	}

	8% {
		transform: translateY(0.5px);
	}

	14% {
		transform: none;
		animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45);
	}

	44% {
		transform: translateY(-46px);
	}

	56% {
		transform: translateY(-46px);
		animation-timing-function: cubic-bezier(0, 0.55, 0.45, 1);
	}

	90% {
		transform: translateY(-0.5px);
	}

	95% {
		transform: translateY(0.5px);
	}

	100% {
		transform: none;
	}
}

@keyframes nudge-left-big {
	0% {
		transform: translateX(-1px);
	}

	50%,
	100% {
		transform: translateX(-3px);
	}
}

@keyframes nudge-right-big {
	0% {
		transform: translateX(1px);
	}

	50%,
	100% {
		transform: translateX(3px);
	}
}

@keyframes rumble {
	0% {
		transform: translateX(-2px);
	}

	50%,
	100% {
		transform: translateX(2px);
	}
}

@keyframes warp {
	from {
		background-position: 0 0;
	}

	to {
		background-position: 0 576px;
	}
}

@keyframes stars-fall {
	to {
		background-position: 0 192px;
	}
}

@keyframes typing {
	from {
		clip-path: inset(0 100% 0 0);
	}

	to {
		clip-path: inset(0);
	}
}

@keyframes cursor {
	50% {
		opacity: 0;
	}
}

@keyframes toast-in {
	from {
		transform: translateX(110%);
	}

	to {
		transform: none;
	}
}

.in-space .ground {
	transform: translateY(100%);
}

.in-space .launchpad {
	bottom: 18%;
}

.in-space .launchpad svg > path,
.in-space .smoke-left,
.in-space .smoke-right {
	visibility: hidden;
}

.game-progress {
	width: fit-content;
	margin-top: 20px;
	padding: 6px 12px;
	background: #19191a;
	box-shadow: inset 0 0 0 2px var(--smoke-4);
	font-family: var(--font-game);
	font-size: 16px;
}

.game-progress b {
	font-weight: 400;
	color: var(--orange);
}

.game.complete {
	box-shadow: inset 0 0 0 2px var(--orange);
}

.chip {
	display: inline-grid;
	gap: 2px;
	min-height: 44px;
	padding: 6px 12px;
	text-align: left;
}

.chip-label {
	font-family: var(--font-game);
	font-size: 16px;
	line-height: 1.3;
}

.chip-command {
	font-family: var(--font-mono);
	font-size: 11px;
	color: var(--smoke-1);
}

.chat-line.hint {
	color: #ffc29e;
}

.chat-line.complete {
	color: var(--orange);
}

.world::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	background: rgb(4 6 24 / 0%);
	pointer-events: none;
	transition: background-color 0.6s steps(4, end);
}

.world.night::after {
	background: rgb(4 6 24 / 55%);
}

.hotbar {
	grid-template-columns: repeat(6, minmax(0, 1fr));
	max-width: 300px;
}

.hotbar-slot {
	background: #19191a;
	box-shadow: inset 0 0 0 1px var(--smoke-4);
}

@media (min-width: 768px) {
	.toasts {
			top: 80px;
		}
}

.game > .game-hint {
	padding: 10px 12px;
	font-family: var(--font-game);
	font-size: 15px;
	color: var(--white);
	border-top: 1px solid var(--line-dark);
}

.game-complete {
	display: grid;
	justify-items: center;
	gap: 10px;
	padding: 16px 12px;
	background: var(--orange);
	color: var(--black);
	text-align: center;
}

.game-complete[hidden] {
	display: none;
}

.game-complete p {
	font-family: var(--font-game);
	font-size: 22px;
}

.game-complete .button.solid {
	border-color: var(--black);
	background: var(--black);
	color: var(--white);
}

.chip[aria-disabled="true"] {
	opacity: 0.45;
	cursor: not-allowed;
}

.hotbar-button {
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
}

.hotbar-slot.locked img {
	width: 72%;
	height: 72%;
	object-fit: contain;
	filter: grayscale(1) brightness(0.35);
	opacity: 0.8;
}

.chip-label,
.chat-line,
.game-hint,
.toast {
	word-break: keep-all;
	overflow-wrap: anywhere;
}

@media (max-width: 767px) {
	.toasts {
			top: auto;
			bottom: 16px;
		}
}

@media print {
	.toasts {
			display: none !important;
		}
}

.bridge .countdown-done {
	font-family: var(--font-jp);
	font-weight: 700;
	color: var(--black);
}

.game {
	overflow: hidden;
	border: 0;
	border-radius: var(--radius);
	color: var(--white);
	box-shadow: var(--shadow);
}

.game-progress {
	border-radius: 999px;
	padding-inline: 16px;
	background: var(--black);
	color: var(--white);
	box-shadow: none;
}

.game-progress b {
	color: var(--orange);
}

/* スマホでは、実績の通知を画面の上に出し、ゲームのボタンや申し込みのボタンに重ねない */
@media (max-width: 767px) {
	.toasts {
		top: calc(12px + env(safe-area-inset-top));
		right: 16px;
		bottom: auto;
		left: 16px;
		width: auto;
	}
}
