/*
 * Shared page chrome for every game. The games themselves draw into a canvas; this is only the frame
 * around it.
 */

* {
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

html,
body {
	margin: 0;
	padding: 0;
	height: 100%;
	overflow: hidden;
	background: #0a1220;
	font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
	/* A child playing a catcher game will drag on the screen constantly; without this the page scrolls,
	   rubber-bands, and fires the pull-to-refresh instead of moving the catcher. */
	overscroll-behavior: none;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
}

canvas {
	position: absolute;
	display: block;
	/* Crisp edges when the canvas is scaled up on a small screen. */
	image-rendering: auto;
}

/*
 * The back link.
 *
 * A real anchor rather than something drawn on the canvas, so it is reachable by a screen reader and by
 * keyboard, and so it keeps working even if a game's own loop has stopped.
 */
/*
 * Top RIGHT, not top left.
 *
 * Every one of these games puts its title and score in the top-left corner - that is where the eye goes
 * first - and a fixed-size button sitting over the top of it looked like a mistake. The top right is
 * consistently the quietest corner across all of them.
 */
.home {
	position: fixed;
	right: max(10px, env(safe-area-inset-right));
	top: max(10px, env(safe-area-inset-top));
	z-index: 10;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	font-size: 22px;
	font-weight: 800;
	text-decoration: none;
	backdrop-filter: blur(4px);
}

.home:hover {
	background: rgba(255, 255, 255, 0.26);
}

/*
 * The rotate prompt.
 *
 * Only on a touch device held upright - `pointer: coarse` keeps it away from a narrow desktop window,
 * where the person can simply resize and does not want to be told to rotate a monitor.
 */
.rotate-hint {
	display: none;
}

@media (orientation: portrait) and (pointer: coarse) {
	.rotate-hint {
		position: fixed;
		inset: 0;
		z-index: 25;
		display: flex;
		flex-direction: column;
		gap: 14px;
		align-items: center;
		justify-content: center;
		padding: 30px;
		text-align: center;
		background: #0a1220;
		color: #fff;
		font-size: clamp(20px, 5.5vw, 30px);
		font-weight: 900;
		line-height: 1.3;
	}

	.rotate-hint span {
		font-size: clamp(56px, 18vw, 90px);
		/* A slow quarter-turn, so what to DO is shown rather than only described. */
		animation: turn 2.4s ease-in-out infinite;
	}

	.rotate-hint small {
		font-size: clamp(13px, 3.6vw, 17px);
		font-weight: 700;
		opacity: 0.55;
	}

	@keyframes turn {
		0%,
		35% {
			transform: rotate(0deg);
		}
		65%,
		100% {
			transform: rotate(90deg);
		}
	}
}

/* Shown before the first tap, because audio and fullscreen both need a gesture to begin. */
.tap-to-start {
	position: fixed;
	inset: 0;
	z-index: 20;
	display: flex;
	flex-direction: column;
	gap: 10px;
	align-items: center;
	justify-content: center;
	background: rgba(10, 18, 32, 0.92);
	color: #fff;
	font-size: clamp(22px, 5vw, 34px);
	font-weight: 900;
	cursor: pointer;
	text-align: center;
	padding: 24px;
}

.tap-to-start small {
	font-size: clamp(13px, 3vw, 17px);
	font-weight: 700;
	opacity: 0.6;
}

/*
 * The motion-permission button. A real element, deliberately - see arcade.js for why a canvas-drawn one
 * cannot work on iOS.
 */
.permission-button {
	position: fixed;
	left: 50%;
	top: 58%;
	transform: translate(-50%, -50%);
	z-index: 30;
	display: flex;
	flex-direction: column;
	gap: 6px;
	align-items: center;
	padding: 20px 34px;
	border: none;
	border-radius: 18px;
	background: #63d68a;
	color: #08331a;
	font: inherit;
	font-size: clamp(19px, 5vw, 27px);
	font-weight: 900;
	box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
	cursor: pointer;
}

.permission-button small {
	font-size: clamp(11px, 3vw, 14px);
	font-weight: 700;
	opacity: 0.65;
}
