:root {
	--gbc-purple: #5b2a86;
	--gbc-purple-dark: #3d1c5c;
	--gbc-teal: #2fb8a8;
	--bg: #16121f;
	--panel: #241a33;
	--text: #f2eefc;
	--muted: #b6a9cf;
	--danger: #e74c3c;
}

* {
	box-sizing: border-box;
}

html, body {
	margin: 0;
	padding: 0;
	background: var(--bg);
	color: var(--text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	overscroll-behavior: none;
	touch-action: manipulation;
}

#app {
	display: flex;
	flex-direction: column;
	min-height: 100dvh;
	max-width: 640px;
	margin: 0 auto;
	padding: 12px 16px 24px;
}

.topbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.topbar h1 {
	font-size: 1.25rem;
	margin: 0;
	color: var(--teal, #7fe0d4);
	letter-spacing: 0.5px;
}

.topbar-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.btn {
	background: var(--gbc-purple);
	color: var(--text);
	border: 1px solid var(--gbc-purple-dark);
	border-radius: 8px;
	padding: 8px 12px;
	font-size: 0.85rem;
	cursor: pointer;
	position: relative;
	touch-action: manipulation;
}

.btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.btn:active:not(:disabled) {
	background: var(--gbc-teal);
}

.file-btn {
	display: inline-flex;
	align-items: center;
}

.file-btn input[type="file"] {
	position: absolute;
	inset: 0;
	opacity: 0;
	width: 100%;
	cursor: pointer;
}

.rom-notice {
	font-size: 0.72rem;
	color: var(--muted);
	margin: 8px 0 0;
}

.status {
	min-height: 1.2em;
	font-size: 0.8rem;
	color: var(--gbc-teal);
	margin: 6px 0;
}

.screen-wrap {
	position: relative;
	background: #000;
	border: 4px solid var(--gbc-purple-dark);
	border-radius: 10px;
	margin: 12px 0;
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 160 / 144;
	width: 100%;
	overflow: hidden;
}

#screen {
	width: 100%;
	height: 100%;
	image-rendering: pixelated;
	image-rendering: -moz-crisp-edges;
	image-rendering: crisp-edges;
	display: block;
}

.placeholder {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--muted);
	font-size: 0.85rem;
	text-align: center;
	padding: 0 16px;
	background: #000;
}

.placeholder.hidden {
	display: none;
}

.controls {
	display: grid;
	grid-template-columns: 1fr 1fr;
	align-items: center;
	gap: 16px;
	margin-top: 8px;
	user-select: none;
	-webkit-user-select: none;
}

.dpad {
	position: relative;
	display: grid;
	grid-template-columns: repeat(3, 44px);
	grid-template-rows: repeat(3, 44px);
	justify-self: start;
}

.dpad-btn {
	background: var(--panel);
	border: 1px solid var(--gbc-purple-dark);
	touch-action: none;
}

.dpad-up { grid-column: 2; grid-row: 1; border-radius: 8px 8px 0 0; }
.dpad-left { grid-column: 1; grid-row: 2; border-radius: 8px 0 0 8px; }
.dpad-center { grid-column: 2; grid-row: 2; background: var(--panel); pointer-events: none; }
.dpad-right { grid-column: 3; grid-row: 2; border-radius: 0 8px 8px 0; }
.dpad-down { grid-column: 2; grid-row: 3; border-radius: 0 0 8px 8px; }

.dpad-btn:active {
	background: var(--gbc-teal);
}

.ab-buttons {
	display: flex;
	gap: 14px;
	justify-self: end;
	align-items: center;
}

.round-btn {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--gbc-purple);
	border: 1px solid var(--gbc-purple-dark);
	color: var(--text);
	font-weight: 700;
	font-size: 1.1rem;
	touch-action: none;
}

.btn-b { margin-top: 22px; }

.round-btn:active {
	background: var(--gbc-teal);
}

.select-start {
	grid-column: 1 / -1;
	display: flex;
	justify-content: center;
	gap: 12px;
}

.pill-btn {
	background: var(--panel);
	border: 1px solid var(--gbc-purple-dark);
	color: var(--muted);
	border-radius: 999px;
	padding: 6px 18px;
	font-size: 0.75rem;
	touch-action: none;
}

.pill-btn:active {
	background: var(--gbc-teal);
	color: var(--text);
}

.keyboard-hint {
	margin-top: 16px;
	font-size: 0.7rem;
	color: var(--muted);
	text-align: center;
}

@media (min-width: 720px) {
	#app {
		max-width: 480px;
	}
}

#screenWrap:fullscreen {
	max-width: 100vw;
	max-height: 100vh;
	border-radius: 0;
	border-width: 0;
}
