body {
	margin: 0;
	font-family: "Droid Sans", Tahoma, "Lucida Grande", sans-serif;
	background-color: #202020;
	color: #e0e0e0;
}

body:has(#screen canvas) {
	overflow: hidden;
}

/*
 * Centre the engine canvas in the available viewport.
 *
 * `scaleMethod: "fit"` on the Application scales the canvas to the
 * largest dimension that preserves aspect ratio; the unused dimension
 * leaves margin. Without centring rules the canvas hugs the top-left,
 * which reads as "broken layout" on portrait examples whose aspect
 * ratio differs from the browser window (e.g. the 720×900 plinko
 * example in a typical landscape window).
 *
 * Flex with absolute positioning under the 41px example topbar keeps
 * the centre while leaving room for the controls. When no example is
 * mounted (`#screen` is empty), the flex container is a no-op.
 */
#screen {
	position: fixed;
	top: 41px;
	right: 0;
	bottom: 0;
	left: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	/*
	 * #screen is a `position: fixed` overlay covering everything
	 * below the 41 px topbar. Without `pointer-events: none`, the
	 * empty `#screen` div (after an example unmounts) still sits on
	 * top of the index-page cards and silently swallows every click.
	 * Direct children opt back in with `pointer-events: auto` —
	 * not just the canvas, since examples may also append HTML
	 * controls (dropdowns, HUDs) to `#screen`. After unmount, no
	 * children remain → nothing blocks clicks.
	 */
	pointer-events: none;
}

#screen > * {
	pointer-events: auto;
}

#screen canvas {
	display: block;
}

/* Example top bar */
.example-topbar {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 8px 16px;
	background: #1a1a1a;
	border-bottom: 1px solid #333;
	position: relative;
	z-index: 999;
}

.example-back {
	color: #82c743;
	text-decoration: none;
	font-size: 14px;
	padding: 4px 8px;
	border-radius: 4px;
	transition: background-color 0.2s;
}

.example-back:hover {
	background: #333;
}

.example-topbar-title {
	font-size: 14px;
	color: #aaa;
}

.example-source {
	color: #888;
	text-decoration: none;
	font-size: 13px;
	padding: 4px 8px;
	border-radius: 4px;
	border: 1px solid #444;
	margin-left: 4px;
	transition:
		border-color 0.2s,
		color 0.2s;
}

.example-source:hover {
	border-color: #82c743;
	color: #82c743;
}

/* Index page layout */
.index-page {
	max-width: 1200px;
	margin: 0 auto;
	padding: 40px 24px;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

.index-header {
	text-align: center;
	margin-bottom: 48px;
}

.index-logo {
	max-width: 360px;
	width: 100%;
	height: auto;
	margin-bottom: 16px;
}

.index-subtitle {
	color: #8de48d;
	font-size: 16px;
	margin: 0;
}

/* Example card grid — responsive columns based on viewport width */
.index-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 16px;
	flex: 1;
}

.example-card {
	display: block;
	background: #2a2a2a;
	border: 1px solid #3a3a3a;
	border-radius: 8px;
	padding: 20px;
	text-decoration: none;
	color: inherit;
	transition:
		border-color 0.2s,
		background-color 0.2s;
}

.example-card:hover {
	border-color: #82c743;
	background: #333;
}

.example-card-title {
	margin: 0 0 8px 0;
	font-size: 18px;
	color: #82c743;
}

.example-card-desc {
	margin: 0;
	font-size: 14px;
	color: #aaa;
	line-height: 1.5;
}

/* Footer */
.index-footer {
	margin-top: 48px;
	padding-top: 24px;
	border-top: 1px solid #3a3a3a;
	text-align: center;
	font-size: 14px;
	color: #888;
}

.index-footer a {
	color: #82c743;
	text-decoration: none;
}

.index-footer a:hover {
	text-decoration: underline;
}

.index-footer .separator {
	margin: 0 12px;
	color: #555;
}

/* Code toggle button */
.example-code-toggle {
	color: #888;
	font-size: 13px;
	padding: 4px 8px;
	border-radius: 4px;
	border: 1px solid #444;
	background: transparent;
	cursor: pointer;
	transition:
		border-color 0.2s,
		color 0.2s;
}

.example-code-toggle:hover {
	border-color: #82c743;
	color: #82c743;
}

/* Code editor panel — fixed right side overlay */
.example-editor {
	position: fixed;
	top: 41px;
	right: 0;
	width: min(500px, 100vw);
	height: calc(100vh - 41px);
	display: flex;
	flex-direction: column;
	border-left: 1px solid #333;
	background: #282c34;
	z-index: 998;
}

/* Editor file tabs */
.editor-tabs {
	display: flex;
	flex-wrap: wrap;
	background: #21252b;
	border-bottom: 1px solid #333;
}

.editor-tab {
	padding: 6px 14px;
	font-size: 12px;
	color: #888;
	background: transparent;
	border: none;
	border-bottom: 2px solid transparent;
	cursor: pointer;
	white-space: nowrap;
}

.editor-tab:hover {
	color: #ccc;
}

.editor-tab.active {
	color: #e0e0e0;
	border-bottom-color: #82c743;
}

/* Ace editor fills remaining space */
.example-editor .ace_editor {
	flex: 1;
}
