/* All selectors are scoped under .dino-game-root and prefixed with dino- to
   avoid leaking styles into the surrounding theme, and vice versa. */

.dino-game-root {
	all: initial;
	display: block;
	box-sizing: border-box;
	max-width: 100%;
	margin: 0 auto;
	font-family: var(--dino-font, inherit);
	position: relative;
}
.dino-game-root *,
.dino-game-root *::before,
.dino-game-root *::after {
	box-sizing: border-box;
}

.dino-game-frame {
	position: relative !important;
	width: 100%;
	max-width: var(--dino-width, 900px);
	margin: 0 auto;
	background: var(--dino-bg, #f7f7f7);
	border: var(--dino-border-width, 1px) solid var(--dino-border-color, #ddd);
	border-radius: var(--dino-border-radius, 8px);
	overflow: hidden !important; /* structural, not cosmetic: the overlay/hud/controls rely on this to stay within the game box regardless of theme CSS */
	touch-action: none; /* prevent page scroll while playing on touch devices */
	-webkit-user-select: none;
	user-select: none;
}

.dino-game-canvas {
	display: block !important;
	width: 100% !important;
	height: auto !important;
	aspect-ratio: var(--dino-aspect, 3 / 1) !important;
	background: transparent;
}

/* The visible score is drawn directly on the canvas (see drawHud() in
   dinosaur-game.js) so it scales exactly like the dino/obstacles. This
   element exists only so screen readers can announce the score -- it's
   visually hidden via the .dino-game-sr-only class applied alongside it. */
.dino-game-hud {
	position: absolute !important;
}

.dino-game-overlay {
	position: absolute !important;
	inset: 0 !important;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	background: rgba(255, 255, 255, 0.92);
	text-align: center;
	padding: 12px;
	color: var(--dino-text-color, #333);
	box-sizing: border-box;
	/* Contain everything within the game's own box even if the page's
	   theme overrides .dino-game-frame's overflow:hidden, or if content
	   simply doesn't fit a short configured game height -- a scrollbar
	   here beats content spilling out over the rest of the page. */
	overflow-y: auto;
	overflow-x: hidden;
}
.dino-game-overlay[hidden] {
	display: none;
}

/*
 * Themes frequently apply global typography/border/shadow styles to bare
 * tags (h1-h6, p, table, button, input...). Those rules can be more
 * specific or load after this stylesheet, which is exactly what produces
 * giant headings, boxy shadowed buttons, etc. bleeding into the game.
 * `all: revert !important` strips any such theme styling back to the
 * browser default for elements inside the overlay, and the properties
 * re-declared afterward (still !important, and later in the cascade) are
 * what actually render -- making the overlay's look independent of theme.
 */
.dino-game-overlay h3,
.dino-game-overlay p {
	all: revert !important;
	box-sizing: border-box !important;
	font-family: inherit !important;
	color: inherit !important;
}

.dino-game-overlay h3 {
	display: block !important;
	margin: 0 !important;
	font-size: 1.15em !important;
	line-height: 1.25 !important;
	font-weight: 700 !important;
}

.dino-game-overlay p {
	display: block !important;
	margin: 0 !important;
	font-size: 0.92em !important;
	line-height: 1.3 !important;
}

.dino-game-btn {
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	padding: 10px 20px;
	border: none;
	border-radius: 6px;
	background: var(--dino-btn-bg, #4c8bf5);
	color: var(--dino-btn-text, #fff);
	cursor: pointer;
	line-height: 1.2;
}
.dino-game-btn:hover {
	filter: brightness(0.95);
}
.dino-game-btn:focus-visible {
	outline: 3px solid #2271b1;
	outline-offset: 2px;
}

.dino-game-name-form {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
}
.dino-game-name-input {
	all: revert !important;
	box-sizing: border-box !important;
	font-family: inherit !important;
	font-size: 14px !important;
	padding: 7px 10px !important;
	border: 1px solid #ccc !important;
	border-radius: 6px !important;
	box-shadow: none !important;
	max-width: 160px !important;
}
.dino-game-name-input:focus-visible {
	outline: 3px solid #2271b1;
	outline-offset: 1px;
}

.dino-game-msg {
	font-size: 12px;
	min-height: 1.2em;
}
.dino-game-msg.is-error { color: #c0392b; }
.dino-game-msg.is-success { color: #1a7f37; }

.dino-game-leaderboard {
	all: revert !important;
	width: 100% !important;
	max-width: 300px !important;
	font-size: 12px !important;
	border-collapse: collapse !important;
	box-sizing: border-box !important;
}
.dino-game-leaderboard caption {
	all: revert !important;
	box-sizing: border-box !important;
	font-family: inherit !important;
	color: inherit !important;
	font-weight: 700 !important;
	margin-bottom: 4px !important;
}
.dino-game-leaderboard th,
.dino-game-leaderboard td {
	all: revert !important;
	box-sizing: border-box !important;
	font-family: inherit !important;
	color: inherit !important;
	padding: 2px 8px !important;
	text-align: left !important;
	border: none !important;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
	background: transparent !important;
}

.dino-game-controls {
	position: absolute !important;
	bottom: 10px;
	left: 0;
	right: 0;
	display: flex;
	justify-content: space-between;
	padding: 0 14px;
	pointer-events: none;
}
.dino-game-controls .dino-game-btn {
	pointer-events: auto;
	opacity: 0.85;
	min-width: 64px;
}

.dino-game-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

@media (max-width: 480px) {
	.dino-game-overlay h3 {
		font-size: 1em !important;
	}
}
